Java Code Examples for org.eclipse.ui.IWorkbenchPartSite#getSelectionProvider()
The following examples show how to use
org.eclipse.ui.IWorkbenchPartSite#getSelectionProvider() .
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: RenameElementHandler.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override public boolean isEnabled() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { return false; } IWorkbenchPartSite site = window.getActivePage().getActiveEditor().getSite(); if (site == null) { return false; } ISelectionProvider selectionProvider = site.getSelectionProvider(); if (selectionProvider == null) { return false; } ISelection currentSelection = selectionProvider.getSelection(); setContext(refactoring, currentSelection); return refactoring.isExecutable(); }
Example 2
Source File: GamlSearchField.java From gama with GNU General Public License v3.0 | 6 votes |
public void search() { final IWorkbenchPart part = WorkbenchHelper.getActivePart(); if (part instanceof IEditorPart) { final IEditorPart editor = (IEditorPart) part; final IWorkbenchPartSite site = editor.getSite(); if (site != null) { final ISelectionProvider provider = site.getSelectionProvider(); if (provider != null) { final ISelection viewSiteSelection = provider.getSelection(); if (viewSiteSelection instanceof TextSelection) { final TextSelection textSelection = (TextSelection) viewSiteSelection; text.setText(textSelection.getText()); } } } } activate(null); text.setFocus(); }
Example 3
Source File: NewTextSearchActionGroup.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public NewTextSearchActionGroup(IViewPart part) { Assert.isNotNull(part); IWorkbenchPartSite site = part.getSite(); fSelectionProvider = site.getSelectionProvider(); fPage = site.getPage(); fOpenPropertiesDialog = new PropertyDialogAction(site, fSelectionProvider); fOpenAction = new OpenFileAction(fPage); ISelection selection = fSelectionProvider.getSelection(); if (selection instanceof IStructuredSelection) { fOpenPropertiesDialog.selectionChanged((IStructuredSelection) selection); } else { fOpenPropertiesDialog.selectionChanged(selection); } }
Example 4
Source File: NewTextSearchActionGroup.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public NewTextSearchActionGroup(IViewPart part) { Assert.isNotNull(part); IWorkbenchPartSite site = part.getSite(); fSelectionProvider = site.getSelectionProvider(); fPage = site.getPage(); fOpenPropertiesDialog = new PropertyDialogAction(site, fSelectionProvider); fOpenAction = new OpenFileAction(fPage); ISelection selection = fSelectionProvider.getSelection(); if (selection instanceof IStructuredSelection) { fOpenPropertiesDialog.selectionChanged((IStructuredSelection) selection); } else { fOpenPropertiesDialog.selectionChanged(selection); } }
Example 5
Source File: SelectionUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * Underlying implementation of <code>getSelectedResources</code> * * @return the list of selected <code>IResource</code> objects, or empty list if none. */ protected static List<IResource> getSelectedResources0() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); List<IResource> resources = new ArrayList<IResource>(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IWorkbenchPart part = page.getActivePart(); if (part instanceof IEditorPart) { IEditorPart epart = (IEditorPart) part; IResource adaptee = (IResource) epart.getEditorInput().getAdapter(IResource.class); if (adaptee != null) { resources.add(adaptee); } } else if (part != null) { IWorkbenchPartSite site = part.getSite(); if(site != null) { ISelectionProvider provider = site.getSelectionProvider(); if (provider != null) { ISelection selection = provider.getSelection(); resources = getObjectsFromStructuredSelection(selection, IResource.class); } } } } } return resources; }
Example 6
Source File: JavadocView.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected Object computeInput(Object input) { if (getControl() == null || ! (input instanceof IJavaElement)) return null; IWorkbenchPart part= null; IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) { part= page.getActivePart(); } } ISelection selection= null; if (part != null) { IWorkbenchPartSite site= part.getSite(); if (site != null) { ISelectionProvider provider= site.getSelectionProvider(); if (provider != null) { selection= provider.getSelection(); } } } return computeInput(part, selection, (IJavaElement) input, new NullProgressMonitor()); }
Example 7
Source File: JavaBrowsingPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
void setSelectionFromEditor(IWorkbenchPart part) { if (!fProcessSelectionEvents || !linkBrowsingViewSelectionToEditor() || !(part instanceof IEditorPart)) return; IWorkbenchPartSite site= part.getSite(); if (site == null) return; ISelectionProvider provider= site.getSelectionProvider(); if (provider != null) setSelectionFromEditor(part, provider.getSelection()); }
Example 8
Source File: WorkbenchUtils.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
public static ISelectionProvider getActivePartSelectionProvider() { IWorkbenchPartSite site = getActivePartSite(); return site != null ? site.getSelectionProvider() : null; }