Sunday, March 28, 2010

Swinging Task Dialog (part 4)

It's my pleasure today to announce the availability of the new TaskDialog 0.5.0 library release, which is dedicated to Mac OS support. The last two weeks were spent researching the Apple standards and making task dialogs on Mac OS look as close as possible  to original ones. The list of specific Mac OS differences, supported by library includes:

  • Correct Resources (Fonts, icons, text) and component gaps
  • No separators between Message, Command and Footer areas
  • Expandable component is showing directly under "Details" check box ( disclosure triangle )
  • Expandable component is automatically wrapped in correct border
  • Correct Command button order

Media_httpmcojfileswo_pxhpp

Here are examples of the same dialog under windows 7 and Mac OS 10.6.2

Media_httpmcojfileswo_hdxgb

I cannot say I'm confident I caught all the details but with your help I'm sure I'm going to :)

The project is available at http://code.google.com/p/oxbow/ under BSD license. As always - comments and suggestions are welcome.

Saturday, March 13, 2010

Swinging Task Dialog (part 3)

Following user requests several new features were added to the library this week.

i18n support
The Task Dialog library now has i18n support.  So  common text in the dialog can be shown in any language by supplying locale specific resource bundle named `task-dialog_<locale_id>.properties` and switching default locale. Library has built-in default and Spanish(es) bundles, which can be found under 'src/main/resources'.

Customizable defaults
The defaults for resources (such as colors, fonts, icons) used by the library is stored in `UIDefaults`, same way as for any other Swing component.  This means the dialog can be customized by simply replacing these defaults with desired ones. Defaults are  set on the first use of `TaskDialog` class. List of keys can be found in `com.ezware.dialog.task.iDesign` interface.

New TaskDialogs.radioChoice methods
New`radioChoice` methods were added to `TaskDialogs` class. They provide almost a trivial way to request user selection based on a set of radio buttons. Here is an example [sourcecode language="java"] int choice = TaskDialogs.radioChoice("You've got selection to make", "Go ahead", 1, "Yes", "No", "May be" ); [/sourcecode]

Media_httpmcojfileswo_ujfmm

Partial support for OS specific look
This feature is not finished yet, but I made great inroads and can report on a status.
After doing research  into this topic I realized that there are significant differences not only in resources (fonts, icons, colors) used but actual layout of components in the dialog. This realization inspired internal design change which is based on concept of "dialog design" - a class responsible for all aspects of the dialog design. The appropriate design class is instantiated according to the underlying OS and is be used to create the dialog's resources and layouts.
While creation of the  dialog layout is still work in progress, setting OS specific resources is pretty much done for Windows and Mac OS. Here is how the same dialog currently looks on Windows  and Mac OS X.

Media_httpmcojfileswo_onxco


Media_httpmcojfileswo_hjwee

That is all I could accomplish this week. Further progress will be reported in the next installments of this series.
The project is available at http://code.google.com/p/oxbow/ under BSD license. As always - comments and suggestions are welcome.

Sunday, March 7, 2010

Swinging Task Dialog (part 2)

This week's focus was on adding more functionality.
The API was extended with an ability to set commands (buttons on the bottom of the dialog). TaskDialog features a set of standard commands ( currently only Ok and Cancel ). But it is very easy to add any arbitrary command. The only requirement is that the command has to implement TaskDialog.Command interface.
TaskDialog's getResult() method returns last executed command. A simpler way to use it is show() method which shows the dialog and returns last executed command. Here is a warning dialog:




Media_httpmcojfileswo_dkhfw

Sometimes custom command has to not just close the dialog but execute some additional logic.  To accomplish this PropertyChangeListener can be attached to the TaskDialog's "result" property. As soon as result changes (command button is pressed ) your code will be notified.
It is possible now to add any fixed component to the dialog ( in addition to expandable one ). Here is the example of the  dialog with the progress bar.




Media_httpmcojfileswo_tjdli


More work is required in the area as I want to to provide prebuilt components such as command links. To even further simplify usage I added TaskDialogs class. It makes creation of certain task dialogs a one liner.



The above code produces three task dialogs:

Media_httpmcojfileswo_gijcu
Media_httpmcojfileswo_lwldg
Media_httpmcojfileswo_xedvc

The project is available at http://code.google.com/p/oxbow/ under BSD license.
As always - comments and suggestions are welcome.