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:ext.org.eclipse.jdt.internal.ui.text.AbstractInformationControl.java

License:Open Source License

/**
 * Selects the first element in the tree which
 * matches the current filter pattern./*from  ww  w .  j a  v a2  s.  c o m*/
 */
protected void selectFirstMatch() {
    Object selectedElement = fTreeViewer.testFindItem(fInitiallySelectedType);
    TreeItem element;
    final Tree tree = fTreeViewer.getTree();
    if (selectedElement instanceof TreeItem)
        element = findElement(new TreeItem[] { (TreeItem) selectedElement });
    else
        element = findElement(tree.getItems());

    if (element != null) {
        tree.setSelection(element);
        tree.showItem(element);
    } else
        fTreeViewer.setSelection(StructuredSelection.EMPTY);
}

From source file:ext.org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyViewPart.java

License:Open Source License

private void internalSelectType(IMember elem, boolean reveal) {
    TypeHierarchyViewer viewer = getCurrentViewer();
    viewer.removePostSelectionChangedListener(fSelectionChangedListener);
    viewer.setSelection(elem != null ? new StructuredSelection(elem) : StructuredSelection.EMPTY, reveal);
    viewer.addPostSelectionChangedListener(fSelectionChangedListener);
}

From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.BuildpathModifierAction.java

License:Open Source License

/**
 * {@inheritDoc}// www.  j a  va  2  s .  c om
 */
public void selectionChanged(final SelectionChangedEvent event) {
    final ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection) {
        setEnabled(canHandle((IStructuredSelection) selection));
        fSelectedElements.clear();
        fSelectedElements.addAll(((IStructuredSelection) selection).toList());
    } else {
        setEnabled(canHandle(StructuredSelection.EMPTY));
        fSelectedElements.clear();
    }
}

From source file:ext.org.eclipse.jdt.internal.ui.wizards.buildpaths.newsourcepage.HintTextGroup.java

License:Open Source License

/**
  * {@inheritDoc}/*  w w  w.  ja  va2s  .c om*/
  */
public void selectionChanged(SelectionChangedEvent event) {
    if (event.getSelection() instanceof StructuredSelection) {
        handlePostSelectionChange((StructuredSelection) event.getSelection());
    } else {
        handlePostSelectionChange(StructuredSelection.EMPTY);
    }
}

From source file:fr.inria.atlanmod.neo4emf.ui.commands.CreateDynamicInstanceCommand.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    initializeEClass(event);/*ww  w  .j a  v a 2 s .  c  om*/

    URI uri = eClass.eResource().getURI();
    IStructuredSelection selection = StructuredSelection.EMPTY;
    if (uri != null && uri.isHierarchical()) {
        if (uri.isRelative() || (uri = uri.deresolve(PLATFORM_RESOURCE)).isRelative()) {
            IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toString()));
            if (file.exists()) {
                selection = new StructuredSelection(file);
            }
        }
    }

    // Register the EClass EPackage if  it is not registered yet
    if (EPackage.Registry.INSTANCE.getEPackage(eClass.getEPackage().getNsURI()) == null) {
        EPackage.Registry.INSTANCE.put(eClass.getEPackage().getNsURI(), eClass.getEPackage());
    }

    DynamicModelWizard dynamicModelWizard = new DynamicModelWizard(eClass);
    dynamicModelWizard.init(PlatformUI.getWorkbench(), selection);
    WizardDialog wizardDialog = new WizardDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dynamicModelWizard);

    wizardDialog.open();
    return null;
}

From source file:fr.inria.atlanmod.neoemf.eclipse.ui.command.CreateDynamicInstanceCommand.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    initializeEClass(event);//  w w  w.  j  a va 2  s  . c om

    URI uri = eClass.eResource().getURI();
    IStructuredSelection selection = StructuredSelection.EMPTY;
    if (nonNull(uri) && uri.isHierarchical()) {
        if (uri.isRelative() || (uri = uri.deresolve(PLATFORM_RESOURCE)).isRelative()) {
            IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toString()));
            if (file.exists()) {
                selection = new StructuredSelection(file);
            }
        }
    }

    // Register the EClass EPackage if it is not registered yet
    if (isNull(EPackage.Registry.INSTANCE.getEPackage(eClass.getEPackage().getNsURI()))) {
        EPackage.Registry.INSTANCE.put(eClass.getEPackage().getNsURI(), eClass.getEPackage());
    }

    DynamicModelWizard dynamicModelWizard = new DynamicModelWizard(eClass);
    dynamicModelWizard.init(PlatformUI.getWorkbench(), selection);

    WizardDialog wizardDialog = new WizardDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dynamicModelWizard);
    wizardDialog.open();

    return null;
}

From source file:fr.inria.linuxtools.internal.tmf.ui.project.handlers.BatchImportTraceHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    BatchImportTraceWizard w = new BatchImportTraceWizard();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    if (window == null) {
        return false;
    }//ww  w .j  a v a2s.c o m

    ISelection currentSelection = HandlerUtil.getCurrentSelection(event);

    IStructuredSelection sec = StructuredSelection.EMPTY;
    if (currentSelection instanceof IStructuredSelection) {
        sec = (IStructuredSelection) currentSelection;
    }

    w.init(PlatformUI.getWorkbench(), sec);
    WizardDialog dialog = new WizardDialog(window.getShell(), w);
    dialog.open();

    return null;
}

From source file:fr.inria.linuxtools.internal.tmf.ui.project.handlers.ImportTraceHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ImportTraceWizard w = new ImportTraceWizard();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

    if (window == null) {
        return false;
    }/*from w  ww  . j av  a2s  .c om*/

    ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
    // Menu Selection is only not null for context-sensitive menu
    ISelection menuSelection = HandlerUtil.getActiveMenuSelection(event);

    IStructuredSelection sec = StructuredSelection.EMPTY;

    // Only use the selection if handler is called from context-sensitive menu
    if ((menuSelection != null) && (currentSelection instanceof IStructuredSelection)) {
        sec = (IStructuredSelection) currentSelection;
    }

    w.init(PlatformUI.getWorkbench(), sec);
    WizardDialog dialog = new WizardDialog(window.getShell(), w);
    dialog.open();
    return null;
}

From source file:fr.inria.linuxtools.internal.tmf.ui.project.model.TmfEditorLinkHelper.java

License:Open Source License

@Override
public IStructuredSelection findSelection(IEditorInput anInput) {
    IFile file = ResourceUtil.getFile(anInput);
    if (file != null) {

        try {/*from   w  ww . ja v  a2 s.  co  m*/
            // Get the trace type ID
            String traceTypeId = file.getPersistentProperty(TmfCommonConstants.TRACETYPE);
            if (traceTypeId == null) {
                return StructuredSelection.EMPTY;
            }

            final TmfProjectElement project = TmfProjectRegistry.getProject(file.getProject(), true);

            // Check for experiments, traces which are folders or traces which are files
            if (traceTypeId.equals(TmfExperiment.class.getCanonicalName())) {
                // Case 1: Experiment
                for (final TmfExperimentElement experimentElement : project.getExperimentsFolder()
                        .getExperiments()) {
                    if (experimentElement.getResource().equals(file.getParent())) {
                        return new StructuredSelection(experimentElement);
                    }
                }
            } else if (traceTypeId.equals(TmfTrace.class.getCanonicalName())) {
                // Case 2: Trace that is a folder
                for (final TmfTraceElement traceElement : project.getTracesFolder().getTraces()) {
                    if (traceElement.getResource().equals(file.getParent())) {
                        return new StructuredSelection(traceElement);
                    }
                }
            } else {
                // Case 3: Trace that is a file
                for (final TmfTraceElement traceElement : project.getTracesFolder().getTraces()) {
                    if (traceElement.getResource().equals(file)) {
                        return new StructuredSelection(traceElement);
                    }
                }
            }
        } catch (CoreException e) {
            return StructuredSelection.EMPTY;
        }
    }
    return StructuredSelection.EMPTY;
}

From source file:fr.inria.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport.ExportTracePackageHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return Boolean.FALSE;
    }//from   w ww.java2 s.com

    ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
    IStructuredSelection sec = StructuredSelection.EMPTY;
    List<TmfTraceElement> selectedTraces = new ArrayList<>();
    if (currentSelection instanceof IStructuredSelection) {
        sec = (IStructuredSelection) currentSelection;
        Object[] selectedElements = sec.toArray();
        for (Object selectedElement : selectedElements) {
            if (selectedElement instanceof TmfTraceElement) {
                TmfTraceElement tmfTraceElement = (TmfTraceElement) selectedElement;
                selectedTraces.add(tmfTraceElement.getElementUnderTraceFolder());
            } else if (selectedElement instanceof TmfTraceFolder) {
                TmfTraceFolder tmfTraceFolder = (TmfTraceFolder) selectedElement;
                selectedTraces = tmfTraceFolder.getTraces();
            }
        }
    }

    ExportTracePackageWizard w = new ExportTracePackageWizard(selectedTraces);

    w.init(PlatformUI.getWorkbench(), sec);
    WizardDialog dialog = new WizardDialog(window.getShell(), w);
    dialog.open();
    return null;
}