SDL/Swing 1.2.0 is Released

20 views
Skip to first unread message

Dan Leuck

unread,
Jul 24, 2010, 1:15:29 AM7/24/10
to SDL/Swing
We just released SDL 1.2 with support for custom property handlers. An
example can be seen in the OoiPad sample application:

/*
* Example use of a custom property handler: This adds an
"invisible" property. Try using it
* in Ooi pad like so:
* button "Can't see me" x:invisible=true
*/
UI.registerPropertyHandler("x", new ComponentPropertyHandler() {
public void set(Component c, String key, Object value) {
if(key.equals("invisible")) {
c.setVisible(!((Boolean)value));
}
}
});

We also closed all open bugs.

Raul_Arabaolaza

unread,
Jul 24, 2010, 12:44:24 PM7/24/10
to SDL/Swing
Thanks a lot Dan :)

Raul_Arabaolaza

unread,
Jul 24, 2010, 6:11:16 PM7/24/10
to SDL/Swing
Just an example of what can be achieved with the new feature, with a
little coding i can atach generic listeners in a declarative way to
components in sdl, for example:

table ID="entityList" do="saludar" event:doubleClicked="extractRecord"

With this code i can make my jtable to invoque the extractrecord
method of the controller when one row is double clicked, and the best
thing is that i can attach any method like the do option for buttons
as listener and even specify the listener type :)

To do that i only need this java code:

UI.registerPropertyHandler("event", new ComponentPropertyHandler() {
@Override
public void set(final Component component, String key, final Object
value)
throws UIBindingException {
if (key.equalsIgnoreCase("doubleClicked")) {
component.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
FormController controller = UI
.getFormForComponent(component)
.getController();
try {
Method m = controller.getClass()
.getDeclaredMethod(value.toString(),
new Class[] {});
m.invoke(controller, new Object[] {});
} catch (Exception e1) {
throw new UIBindingException("Problem trying to execute
method "+value+"as double click listener for "+component.getName(),
e1);
}

}
}
});
}
}
});

Using the key value i can attach other type of listeners if needed,
the code may seem complicated but it´s not, it´s due to the use of
nested clases, i wonder if i could use Scala or Groovy to make it even
more readable. :)

Anyway, thanks a lot again for the new feature, Dan

Dan Leuck

unread,
Jul 24, 2010, 8:09:19 PM7/24/10
to sdls...@googlegroups.com
Very nice! Perhaps we should make your event component property
handler part of the core library.

Its great to find other people with an in-depth understanding of the
framework. I look forward to hearing more about your app and how you
are using SDL/Swing.

Reply all
Reply to author
Forward
0 new messages