use of eu.esdihumboldt.hale.ui.util.selection.SelectionTracker in project hale by halestudio.
the class ApplicationWorkbenchWindowAdvisor method postWindowOpen.
/**
* @see WorkbenchWindowAdvisor#postWindowOpen()
*/
@Override
public void postWindowOpen() {
// register selection tracker if none is defined yet
SelectionTracker tracker = SelectionTrackerUtil.getTracker();
if (tracker == null) {
// create tracker listening on window selection service
tracker = new SelectionTrackerImpl(getWindowConfigurer().getWindow().getSelectionService());
SelectionTrackerUtil.registerTracker(tracker);
}
// XXX do the following somewhere else:
// start instance validation service
PlatformUI.getWorkbench().getService(InstanceValidationService.class);
if (action != null) {
action.onOpenWorkbenchWindow();
// only do this once
action = null;
}
}
use of eu.esdihumboldt.hale.ui.util.selection.SelectionTracker in project hale by halestudio.
the class SchemaSelectionHelper method getSchemaSelection.
/**
* Get the current schema selection
*
* @return the current schema selection or an empty model selection if it
* can't be determined
*/
public static SchemaSelection getSchemaSelection() {
SchemaSelection result = null;
try {
ISelectionService ss = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
ISelection selection = ss.getSelection();
if (selection instanceof SchemaSelection) {
result = (SchemaSelection) selection;
}
} catch (Throwable e) {
log.warn("Could not get current selection", e);
}
if (result == null) {
SelectionTracker tracker = SelectionTrackerUtil.getTracker();
if (tracker != null) {
result = tracker.getSelection(SchemaSelection.class);
}
}
if (result == null) {
result = new DefaultSchemaSelection();
}
return result;
}
Aggregations