Community
Participate
Working Groups
Created attachment 140874 [details] addSelectionListener It should be possible to register the SelectionListener on the following ridgets: TableRidget, ListRidget, TreeRidget, TreeTableRidget Example: ... tableRidget.addSelectionListener(new ISelectionListener() { public void ridgetSelected(SelectionEvent e) { System.out.println("SelectionEvent: " + e); }
Elias, can you please validate this patch.... thanks christian
Elias, I've noticed that the old selection of the multiple selection (in MultiSelectionObservable) contains exactly one item less than the new selection. If I select item1 and item2 together, I see that the new selection contains item1 and item2 and the old selection contains item1. I expected in this case the old selection containing no items. May you have a look at this and say if this is a problem or the expected behaviour? Thanks, Nataliya
Nataliya, thanks for your comment. I could reproduce the selection behavior and it does not seem right to me. I'll look at this in more detail. After modifying the TableSubModule{View/Controller} to accept multiple selection: - when having 1 item selected and selecting 4 items, the event contains: old:3, new:4 SelectionEvent[source=org.eclipse.riena.internal.ui.ridgets.swt.TableRidget@13cae7, oldSelection=[Adventure, Acclimatisation, Aardwark], newSelection=[Adventure, Acclimatisation, Aardwark, Binoculars]] - when having 4 items selected and selecting 1 item, the event contains: old:2, new:1 SelectionEvent[source=org.eclipse.riena.internal.ui.ridgets.swt.TableRidget@13cae7, oldSelection=[Adventure, Acclimatisation], newSelection=[Adventure]] Kind regards, Elias.
The problem is in the way the old selection is computed for multiple selection. Basically the JFace databinding will invoke MultiSelectionObservable.fireListChange() once for each added or removed element in the selection. The result is that oldSelectionList, as computed in the patch, contains the only the very last change. Nataliya, just curious: are you primarily interested in (a) the SWT selection event or (b) the change of the selection value? If it is (b) this could be done relatively easy by adding a property change listener: public void addSelectionListener(ISelectionListener selectionListener) { Assert.isNotNull(selectionListener, "selectionListener is null"); //$NON-NLS-1$ if (selectionListeners == null) { selectionListeners = new ListenerList<ISelectionListener>(ISelectionListener.class); addPropertyChangeListener(ISelectableRidget.PROPERTY_SELECTION, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { notifySelectionListeners((List<?>) evt.getOldValue(), (List<?>) evt.getNewValue()); } }); } selectionListeners.add(selectionListener); } The 'downside' of this is that it fires an event for each change, i.e. if 'a' is selected and now 'a,b,c,d' is selected it will fire: 'a' -> 'a,b', 'a,b' -> 'a,b,c', 'a,b,c,' -> 'a,b,c,d'. The 'upside' is that is also sends a notication when the selected item is deleted, and it avoids sending a notification when the same item is selected (I believe both of these cases are an issue with the attached patch). If it is (a) I have to think a bit more about how to do this.
Created attachment 140920 [details] Comment #4 - idea (b) Patch showing comment #4, idea b. Note that tests are broken at the moment (not updated).
Created attachment 141053 [details] the updated tests Elias, I've updated the tests. Thanks for the support. Kind regards, Nataliya
The patch is good to go; marking with iplog+ Christian, Nataliya, before I can commit I need confirmation that: - Compeople has a Member Committer Agreement - Nataliya is a compeople employee - Patch contains no cryptography - Patch was developed from scratch - Patch is 100% EPL Please leave a reply in bugzilla that all of the above is correct.
all of the items you mention are correct good to go
Committed -- Thanks Nataliya!