Example usage for org.eclipse.jface.viewers StructuredSelection EMPTY

List of usage examples for org.eclipse.jface.viewers StructuredSelection EMPTY

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StructuredSelection EMPTY.

Prototype

StructuredSelection EMPTY

To view the source code for org.eclipse.jface.viewers StructuredSelection EMPTY.

Click Source Link

Document

The canonical empty selection.

Usage

From source file:gov.nasa.arc.spife.ui.timeline.chart.ChartEditor.java

License:Open Source License

@Override
public void dispose() {
    UndoRedoUtils.disposeUndoRedo(getEditorSite().getActionBars());
    super.dispose();
    if (editingDomain != null) {
        editingDomain.removeResourceSetListener(pageExtentListener);
    }//ww w  .  j a v a2 s . c o  m
    if (listener != null) {
        listener.dispose();
        listener = null;
    }
    if (dirtyMonitor != null) {
        dirtyMonitor.dispose();
        dirtyMonitor = null;
    }
    if (synchronizer != null) {
        synchronizer.dispose();
        synchronizer = null;
    }
    if (editingDomain != null) {
        editingDomain.dispose();
        ResourceSet resourceSet = editingDomain.getResourceSet();
        editingDomain = null;
        for (Resource r : resourceSet.getResources()) {
            r.unload();
        }
    }
    if (timeline != null) {
        timeline.dispose();
        timeline = null;
    }
    if (timelineModel != null) {
        timelineModel = null;
    }
    if (profileSynchronizer != null) {
        profileSynchronizer.dispose();
        profileSynchronizer = null;
    }
    IWorkbenchPartSite site = getSite();
    if (site != null) {
        ISelectionProvider provider = site.getSelectionProvider();
        if (provider != null) {
            provider.setSelection(StructuredSelection.EMPTY);
        }
    }
    if (undoContext != null) {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        history.dispose(undoContext, true, true, true);
        undoContext = null;
    }
}

From source file:gov.nasa.ensemble.common.ui.editor.AbstractEnsembleEditorPart.java

License:Open Source License

/**
 * Get the current selection from the site for this editor
 * @return the current selection (guaranteed to be non-null)
 *//*w  ww.jav  a 2  s . c  om*/
protected final ISelection getCurrentSelection() {
    ISelectionProvider provider = selectionProvider;
    if (provider != null) {
        ISelection selection = provider.getSelection();
        if (selection != null) {
            return selection;
        }
    }
    return StructuredSelection.EMPTY;
}

From source file:gov.nasa.ensemble.common.ui.editor.EditorPartUtils.java

License:Open Source License

public static IStructuredSelection getCurrentSelection() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null || workbench.getActiveWorkbenchWindow() == null) {
        return StructuredSelection.EMPTY;
    }/*from   ww w .  j a  va 2s .c o  m*/
    IStructuredSelection structuredSelection = StructuredSelection.EMPTY;
    IViewReference[] viewReferences = workbench.getActiveWorkbenchWindow().getActivePage().getViewReferences();
    IViewPart viewPart = null;
    for (IViewReference viewReference : viewReferences) {
        IViewPart view = viewReference.getView(false);
        if (view instanceof CommonViewer) {
            viewPart = view;
        }
    }

    if (viewPart != null) {
        ISelectionProvider selectionProvider = viewPart.getSite().getSelectionProvider();
        ISelection selection = selectionProvider.getSelection();
        if (selection instanceof IStructuredSelection) {
            structuredSelection = (IStructuredSelection) selection;
        }
    }
    return structuredSelection;
}

From source file:gov.nasa.ensemble.common.ui.ide.navigator.NewResourceAction.java

License:Open Source License

protected static IStructuredSelection getCurrentSelection() {
    IStructuredSelection structuredSeleciton = StructuredSelection.EMPTY;
    IWorkbench workbench = PlatformUI.getWorkbench();
    IViewReference[] viewReferences = workbench.getActiveWorkbenchWindow().getActivePage().getViewReferences();
    IViewPart viewPart = null;//from   www  . j  a v a 2  s .  c o  m
    for (IViewReference viewReference : viewReferences) {
        IViewPart view = viewReference.getView(false);
        if (view instanceof CommonViewer) {
            viewPart = view;
        }
    }

    if (viewPart != null) {
        ISelectionProvider selectionProvider = viewPart.getSite().getSelectionProvider();
        ISelection selection = selectionProvider.getSelection();
        if (selection instanceof IStructuredSelection) {
            structuredSeleciton = (IStructuredSelection) selection;
        }
    }

    return structuredSeleciton;
}

From source file:gov.nasa.ensemble.common.ui.treetable.TreeTableViewer.java

License:Open Source License

private void handleMouseDown(MouseEvent e) {
    if (currentCellEditorHelper != null) {
        trace.debug("mouse down");
        // Occasionally we get a mouse down and no focus is lost from the editor.
        // This case ends up here and we accept the value (as in any other focus loss)
        currentCellEditorHelper.applyEditorValue();
    }/*from www .j ava 2 s  .c  o  m*/
    TreeItem item = getTree().getItem(new Point(e.x, e.y));
    if (item == null) {
        setSelection(StructuredSelection.EMPTY);
        selectedItem = null;
    }
    if (e.button == 1) {
        int columnIndex = getColumnIndex(item, e.x, e.y);
        if ((item != null) && (columnIndex != -1) && (selectedItem == item)) {
            ITreeTableColumn column = configuration.getColumns().get(columnIndex);
            if (!column.editOnDoubleClick()) {
                handleEditRequest(item, columnIndex);
            }
        }
    }
}

From source file:gov.nasa.ensemble.common.ui.view.page.TreeViewerPage.java

License:Open Source License

/**
 * To dispose of this page, remove references to the selection provider and the template
 * plan./*from w ww.  jav  a  2  s .  c o  m*/
 */
@Override
public void dispose() {
    if (selectionProvider != null) {
        getSite().setSelectionProvider(null);
        selectionProvider.setSelection(StructuredSelection.EMPTY);
        selectionProvider.detachSelectionProvider(treeViewer);
        selectionProvider = null;
    }
    super.dispose();
}

From source file:gov.nasa.ensemble.common.ui.wizard.OpenWizardDialogAction.java

License:Open Source License

@Override
public void run() {
    IWorkbenchWizard createWizard;//  w w  w  .  j a  v a2s.c om
    try {
        createWizard = descriptor.createWizard();
        IWorkbench workbench = workbenchWindow.getWorkbench();
        IStructuredSelection sselection = StructuredSelection.EMPTY;
        if (selection instanceof StructuredSelection) {
            sselection = (StructuredSelection) selection;
        } else {
            List<EnsembleCommonNavigator> navigators = EnsembleCommonNavigator
                    .getExistingInstances(EnsembleCommonNavigator.class);
            for (EnsembleCommonNavigator navigator : navigators) {
                IWorkbenchPartSite site = navigator.getSite();
                if (site != null) {
                    ISelectionProvider selectionProvider = site.getSelectionProvider();
                    ISelection potentialSelection = selectionProvider.getSelection();
                    if (potentialSelection instanceof IStructuredSelection) {
                        sselection = (IStructuredSelection) potentialSelection;
                        break;
                    }

                }
            }
        }
        createWizard.init(workbench, sselection);

    } catch (CoreException e) {
        MessageDialog.openError(null, "Error creating wizard", e.getMessage());
        return;
    }
    WizardDialog dialog = new WizardDialog(null, createWizard);
    dialog.open();
}

From source file:gov.nasa.ensemble.core.activityDictionary.view.DefinitionTreeView.java

License:Open Source License

@Override
public void dispose() {
    treeViewer.setSelection(StructuredSelection.EMPTY);
    super.dispose();
}

From source file:gov.nasa.ensemble.core.plan.editor.actions.AbstractPlanEditorHandler.java

License:Open Source License

protected ISelection getSelection() {
    if (activeSelectionProvider != null) {
        ISelection selection = activeSelectionProvider.getSelection();
        if (selection != null) {
            return selection;
        }/* www.  jav  a  2s .c  om*/
    }
    return StructuredSelection.EMPTY;
}

From source file:gov.nasa.ensemble.core.plan.editor.actions.NewPlanResourceAction.java

License:Open Source License

/**
 * Create the new-plan-resource wizard and open the dialog.
 * If the active part is an EnsembleCommonNavigator, get the StructuredSelection from it;
 * otherwise the selection is empty.//  w  w w  . ja  va 2s .  c  o  m
 * @param action ignored
 */
@Override
public void run(IAction action) {
    IStructuredSelection structuredSeleciton = StructuredSelection.EMPTY;
    IWorkbench workbench = PlatformUI.getWorkbench();
    INewWizard newResourceWizard = new NewPlanResourceWizard();
    IWorkbenchPart part = window.getPartService().getActivePart();
    if (part instanceof EnsembleCommonNavigator) {
        ISelection selection = ((EnsembleCommonNavigator) part).getCommonViewer().getSelection();
        if (selection instanceof IStructuredSelection) {
            structuredSeleciton = (IStructuredSelection) selection;
        }
    }
    newResourceWizard.init(workbench, structuredSeleciton);
    Shell parent = workbench.getActiveWorkbenchWindow().getShell();
    WizardDialog wizardDialog = new WizardDialog(parent, newResourceWizard);
    wizardDialog.create();
    wizardDialog.open();
}