Search in sources :

Example 1 with SelectionTracker

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;
    }
}
Also used : SelectionTracker(eu.esdihumboldt.hale.ui.util.selection.SelectionTracker) SelectionTrackerImpl(eu.esdihumboldt.hale.ui.util.selection.SelectionTrackerImpl)

Example 2 with SelectionTracker

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;
}
Also used : SelectionTracker(eu.esdihumboldt.hale.ui.util.selection.SelectionTracker) DefaultSchemaSelection(eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection) ISelection(org.eclipse.jface.viewers.ISelection) ISelectionService(org.eclipse.ui.ISelectionService) DefaultSchemaSelection(eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection)

Aggregations

SelectionTracker (eu.esdihumboldt.hale.ui.util.selection.SelectionTracker)2 DefaultSchemaSelection (eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection)1 SelectionTrackerImpl (eu.esdihumboldt.hale.ui.util.selection.SelectionTrackerImpl)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionService (org.eclipse.ui.ISelectionService)1