});
OpenStrategy os = new OpenStrategy(tree);
- os.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
- resetSelectionFromWidget();
- }));
os.addPostSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
//System.out.println("OPENSTRATEGY: post selection changed: " + e);
- resetSelectionFromWidgetAndFirePostSelection(true);
+ resetSelection();
+ selectionProvider.firePostSelection(selectionProvider.getSelection());
}));
// This listener takes care of updating the set of currently selected
});
}
- /**
- * @return the new selection if it was different from the old selection in
- * {@link #selectionProvider}
- */
- private ISelection resetSelectionFromWidget() {
- ISelection widgetSelection = getWidgetSelection();
+ private void resetSelection() {
+ final ISelection selection = getWidgetSelection();
// System.out.println("resetSelection()");
// System.out.println(" provider selection: " + selectionProvider.getSelection());
-// System.out.println(" widget selection: " + widgetSelection);
- boolean equals = selectionProvider.selectionEquals(widgetSelection);
- selectionProvider.setSelectionWithoutFiring(widgetSelection);
- return equals ? null : widgetSelection;
- }
-
- /**
- * @return the new selection if it was different from the old selection in
- * {@link #selectionProvider}
- */
- private boolean resetSelectionFromWidgetAndFirePostSelection(boolean force) {
- ISelection s = resetSelectionFromWidget();
- boolean fire = s != null || force;
- if (fire) {
- //System.out.println("FIRING POST-SELECTION: " + selectionProvider.getSelection());
- selectionProvider.firePostSelection(selectionProvider.getSelection());
- }
- return fire;
+// System.out.println(" widget selection: " + selection);
+ selectionProvider.setAndFireNonEqualSelection(selection);
}
protected void setDefaultProcessors() {
// System.out.println("MODCOUNT: " + modCount + " vs. " + count);
if (modCount != count)
return;
- resetSelectionFromWidgetAndFirePostSelection(false);
+ resetSelection();
}
});
}