Java Code Examples for org.eclipse.jface.viewers.StructuredSelection#EMPTY

The following examples show how to use org.eclipse.jface.viewers.StructuredSelection#EMPTY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NavigatorLinkHelper.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IStructuredSelection findSelection(IEditorInput input) {
  IFile file = ResourceUtil.getFile(input);

  if (file != null) {
    return new StructuredSelection(file);
  }

  IFileStore fileStore = (IFileStore) input.getAdapter(IFileStore.class);

  if (fileStore == null && input instanceof FileStoreEditorInput) {
    URI uri = ((FileStoreEditorInput)input).getURI();
    
    try {
      fileStore = EFS.getStore(uri);
    } catch (CoreException e) {

    }
  }
  
  if (fileStore != null) {
    return new StructuredSelection(fileStore);
  }

  return StructuredSelection.EMPTY;
}
 
Example 2
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
private ISelection getNavigatorSelection() {
	IDiagramDocument document = getDiagramDocument();
	if (document == null) {
		return StructuredSelection.EMPTY;
	}
	Diagram diagram = document.getDiagram();
	if (diagram == null || diagram.eResource() == null) {
		return StructuredSelection.EMPTY;
	}
	IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
	if (file != null) {
		ProcessNavigatorItem item = new ProcessNavigatorItem(diagram, file, false);
		return new StructuredSelection(item);
	}
	return StructuredSelection.EMPTY;
}
 
Example 3
Source File: JavaHistoryActionImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public final void runFromEditor(IAction uiProxy) {

		// this run is called from Editor
		IJavaElement element= null;
		try {
			element= SelectionConverter.getElementAtOffset(fEditor);
		} catch (JavaModelException e) {
			// ignored
		}

		fSelection= element != null
						? new StructuredSelection(element)
						: StructuredSelection.EMPTY;
		boolean isEnabled= isEnabled(fSelection);
		uiProxy.setEnabled(isEnabled);

		if (!isEnabled) {
			MessageDialog.openInformation(getShell(), fTitle, fMessage);
			return;
		}
		run(fSelection);
	}
 
Example 4
Source File: GridTableViewer.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ISelection getSelection() {
    if (grid == null || grid.isDisposed()) {
        return StructuredSelection.EMPTY;
    }
    if (!grid.isCellSelectionEnabled()) {
        IStructuredSelection selection = (IStructuredSelection) super.getSelection();
        Object el = null;
        if (grid.getFocusItem() != null && !grid.getFocusItem().isDisposed()) {
            el = grid.getFocusItem().getData();
        }
        return new SelectionWithFocusRow(selection.toList(), el, getComparer());
    } else {
        return createCellSelection();
    }
}
 
Example 5
Source File: AbstractLangStructureEditor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public StructuredSelection getSelectedElementAsStructureSelection() {
	StructureElement selectedElement = getSelectedElement();
	if(selectedElement == null) {
		return StructuredSelection.EMPTY;
	}
	return new StructuredSelection(selectedElement);
}
 
Example 6
Source File: AbstractOpenWizardAction.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private IStructuredSelection evaluateCurrentSelection() {
  IWorkbenchWindow window = JavaPlugin.getActiveWorkbenchWindow();
  if (window != null) {
    ISelection localSelection = window.getSelectionService().getSelection();
    if (localSelection instanceof IStructuredSelection) {
      return (IStructuredSelection) localSelection;
    }
  }
  return StructuredSelection.EMPTY;
}
 
Example 7
Source File: NonGEFSynchronizerWithTreeView.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public ISelection getSelection( )
{
	if ( getTreeViewer( ) == null )
	{
		return StructuredSelection.EMPTY;
	}
	return getTreeViewer( ).getSelection( );
}
 
Example 8
Source File: NavigatorLinkHelper.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public IStructuredSelection findSelection(IEditorInput anInput) {
	IEditorPart activeEditor = ActiveEditorTracker.getLastActiveEditor();
	if (activeEditor instanceof DiagramDocumentEditor) {
		Diagram diagram = ((DiagramDocumentEditor) activeEditor)
				.getDiagram();
		IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
		if (file != null) {
			DomainNavigatorItem item = new DomainNavigatorItem(diagram,
					file, myAdapterFactoryContentProvier);
			return new StructuredSelection(item);
		}
	}
	return StructuredSelection.EMPTY;
}
 
Example 9
Source File: TreeUtil.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Find new selected item
 *
 * @param selection
 *            the selected element
 * @param rootEntry
 *            the element to search through recursively
 * @return the new selected element
 */
public static ISelection getNewSelection(ISelection selection, @NonNull ITmfTreeViewerEntry rootEntry) {
    if (selection instanceof StructuredSelection && !selection.isEmpty()) {
        StructuredSelection structuredSelection = (StructuredSelection) selection;
        Object element = structuredSelection.getFirstElement();
        if (element instanceof ITmfTreeViewerEntry) {
            ITmfTreeViewerEntry newSelection = findEquivalent(rootEntry, (ITmfTreeViewerEntry) element);
            return newSelection != null ? new StructuredSelection(newSelection) : StructuredSelection.EMPTY;
        }
    }
    return selection;
}
 
Example 10
Source File: PluginUninstallAction.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private IStructuredSelection getSelection() {
	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window != null) {
		ISelection selection = window.getSelectionService().getSelection();
		if (selection instanceof IStructuredSelection)
			return (IStructuredSelection) selection;
	}
	return StructuredSelection.EMPTY;
}
 
Example 11
Source File: TmfEventsEditor.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ISelection getSelection() {
    if (fEventsTable == null) {
        return StructuredSelection.EMPTY;
    }
    return fEventsTable.getSelection();
}
 
Example 12
Source File: TimeGraphControl.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the selection object
 *
 * @return The selection
 */
public ISelection getSelectionTrace() {
    ITimeGraphEntry entry = getSelectedTrace();
    if (null != entry) {
        return new StructuredSelection(entry);
    }
    return StructuredSelection.EMPTY;
}
 
Example 13
Source File: TimeGraphViewer.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private void fireSelectionChanged(ITimeGraphEntry selection) {
    TimeGraphSelectionEvent event = new TimeGraphSelectionEvent(this, selection);

    for (ITimeGraphSelectionListener listener : fSelectionListeners) {
        listener.selectionChanged(event);
    }

    ISelection structuredSelection = (selection == null) ? StructuredSelection.EMPTY : new StructuredSelection(selection);
    fireSelectionChanged(new SelectionChangedEvent(this, structuredSelection));
}
 
Example 14
Source File: CommonQuickOutlinePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ISelection getSelection()
{
	if (getTreeViewer() == null)
	{
		return StructuredSelection.EMPTY;
	}
	return getTreeViewer().getSelection();
}
 
Example 15
Source File: ResourceLinkHelper.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public IStructuredSelection findSelection(IEditorInput anInput) {
	IFile file = ResourceUtil.getFile(anInput);
	if (file != null) {
		return new StructuredSelection(file);
	}
	return StructuredSelection.EMPTY;
}
 
Example 16
Source File: TypeScriptContentOutlinePage.java    From typescript.java with MIT License 4 votes vote down vote up
@Override
public ISelection getSelection() {
	if (fOutlineViewer == null)
		return StructuredSelection.EMPTY;
	return fOutlineViewer.getSelection();
}
 
Example 17
Source File: JarPackageActionDelegate.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void selectionChanged(IAction action, ISelection selection) {
	if (selection instanceof IStructuredSelection)
		fSelection= (IStructuredSelection)selection;
	else
		fSelection= StructuredSelection.EMPTY;
}
 
Example 18
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public ISelection getSelection() {
	if (fOutlineViewer == null)
		return StructuredSelection.EMPTY;
	return fOutlineViewer.getSelection();
}
 
Example 19
Source File: NavigatorLinkHelper.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IStructuredSelection findSelection(final IEditorInput anInput) {
	final IFile file = ResourceUtil.getFile(anInput);
	if (file != null) { return new StructuredSelection(ResourceManager.cache.getIfPresent(file)); }
	return StructuredSelection.EMPTY;
}
 
Example 20
Source File: SelectionConverter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Converts the selection provided by the given part into a structured selection. The following
 * conversion rules are used:
 * <ul>
 * <li><code>part instanceof JavaEditor</code>: returns a structured selection using code
 * resolve to convert the editor's text selection.</li>
 * <li><code>part instanceof IWorkbenchPart</code>: returns the part's selection if it is a
 * structured selection.</li>
 * <li><code>default</code>: returns an empty structured selection.</li>
 * </ul>
 * 
 * @param part the part
 * @return the selection
 * @throws JavaModelException thrown when the type root can not be accessed
 */
public static IStructuredSelection getStructuredSelection(IWorkbenchPart part) throws JavaModelException {
	if (part instanceof JavaEditor)
		return new StructuredSelection(codeResolve((JavaEditor)part));
	ISelectionProvider provider= part.getSite().getSelectionProvider();
	if (provider != null) {
		ISelection selection= provider.getSelection();
		if (selection instanceof IStructuredSelection)
			return (IStructuredSelection)selection;
	}
	return StructuredSelection.EMPTY;
}