Add event handler on data

6 views
Skip to first unread message

Sebastien Gollion

unread,
Sep 24, 2009, 5:03:10 PM9/24/09
to JavaBuilders
We have bindings of data list to component like JTree, JList or
JTable, but the event handler onSelection is link to the view
component.

I propose a solution with an event handler link to data:
- Add an event handler: "onSelectionData"
For example: JList
(name=actionsJL,onSelection=onSelectionActionsJL,onSelectionData=onSelectionDataActionsJL)

- the AbstractPropertyHandler of this event handler:
"JListSelectionDataListenerHandler"
public void handle(BuilderConfig config, final BuildProcess process,
Node node, String key) throws BuildException {
final JList target = (JList) node.getMainObject();
final Values<String, ObjectMethod> values = (Values<String,
ObjectMethod>) node.getProperty(key);

if (values.size() > 0) {
target.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting() == false) {
ListSelectionDataEvent dataEvent = new
ListSelectionDataEvent(e.getSource(), target.getSelectedValues());
BuilderUtils.invokeCallerEventMethods
(process.getBuildResult(), target, values.values(), dataEvent);
}
}
});
}
}

- the EventObject used to store selected values:
"ListSelectionDataEvent"
private final Object[] selectedValues;
public Object[] getSelectedValues() {
return Arrays.copyOf(selectedValues, this.selectedValues.length);
}

Example of use:
private void onSelectionDataActionsJL(JList list, final
ListSelectionDataEvent aEvent) {
final List<?> lData = Arrays.asList(aEvent.getSelectedValues());
peopleDetails.clear();
for (final Object data : lData) {
peopleDetails.add((Person) data);
}
}
=> I have looking for a solution without cast of data, but I have a
problem with invocation in JListSelectionDataListenerHandler.

I have a complete implementation for JList, I can give these classes
as proposal and I can implement the same behaviour for JTable and
JTree.

I hope that you understand my point of view.
Give me your feed back about this enhancement.

Jacek Furmankiewicz

unread,
Sep 26, 2009, 10:44:52 AM9/26/09
to JavaBuilders
Sounds very useful. Pls log an enhancement request and submit your
work for all of them.

But pls also include unit tests for each of them, so we can integrate
them into the existing test suite out of the box.

Cheers, Jacek

Sebastien Gollion

unread,
Sep 28, 2009, 8:28:14 AM9/28/09
to JavaBuilders
That's fine.

I will open an enhancement issue with my devs and TU.

I've a question: I don't know how to open an enhancement issue, last
time my issue was a defect but the real type was an enhancement.

Best reagrds,
Seb.

Jacek Furmankiewicz

unread,
Sep 28, 2009, 8:43:10 AM9/28/09
to JavaBuilders
That's OK, I can change it afterwards

Sebastien Gollion

unread,
Oct 4, 2009, 5:03:27 PM10/4/09
to JavaBuilders
Hi Jacek,

I have two questions before sending my devs:
- where are your unit tests ? I didn't find them on GitHub, see wiki
page http://code.google.com/p/javabuilders/wiki/SourceCode?tm=4
- do you look for EventTreeModel of glazed list API ?

Thanks,
Seb.

Jacek Furmankiewicz

unread,
Oct 4, 2009, 5:21:46 PM10/4/09
to JavaBuilders
http://github.com/jacek99/javabuilders/tree/dev/org.javabuilders.swing/test/

I think it's the EventTableModel I use from GlazedLists, would need to
check the code...

Sebastien Gollion

unread,
Oct 5, 2009, 7:31:09 AM10/5/09
to JavaBuilders
Glazed list API defines at least three EventXXXModel: EventTableModel
for JTable, EventTreeModel for JTree and EventListModel for JList.

Nowadays, you have an implementation of EventTableModel that works for
JTable and a source binding for JList, but no solution for JTree.
I haven't see any working example for JTree in JavaBuilder samples. I
will please to see an example.

If you need help, I could do an implementation for EventTreeModel and
EventListModel like EventTableModel implementation.

On 4 oct, 23:21, Jacek Furmankiewicz <jace...@gmail.com> wrote:
> http://github.com/jacek99/javabuilders/tree/dev/org.javabuilders.swin...
Reply all
Reply to author
Forward
0 new messages