IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ISelection selection = window.getSelectionService().getSelection("org.eclipse.jdt.ui.PackageExplorer");
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection(); Object firstElement = selection.getFirstElement(); if (firstElement instanceof IAdaptable) { IProject project = (IProject)((IAdaptable)firstElement).getAdapter(IProject.class); IPath path = project.getFullPath(); System.out.println(path); } }
/** * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow) */ @Override public void windowOpened(IWorkbenchWindow window) { if(fWindows.add(window)) { window.getSelectionService().addSelectionListener(this); } }
public class StartupHook implements IStartup { @Override public void earlyStartup() { IWorkbenchWindow window = PlatformUI.getWorkbench().getWorkbenchWindows()[0]; ISelectionListener projectListener = new ProjectSelectionListener(); window.getSelectionService().addSelectionListener(projectListener); } }
public ISelection getSelection() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null && window.getSelectionService() != null) { return window.getSelectionService().getSelection(); } return null; }
private IStructuredSelection evaluateCurrentSelection() { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { ISelection selection= window.getSelectionService().getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; } } return StructuredSelection.EMPTY; }
/** * Refresh the selection for the action. */ protected void refreshSelection() { ISelection selection = window.getSelectionService().getSelection(); selectionChanged(selection); }
/** * Returns the selection of the active workbench window. * * @return the current selection in the active workbench window or <code>null</code> */ protected final ISelection getSelection() { IWorkbenchWindow window= getWorkbenchWindow(); if (window != null) return window.getSelectionService().getSelection(); return null; }
public void dispose() { super.dispose(); if(window != null) { window.getSelectionService().removePostSelectionListener(selectionListener); } // Don't hold on to anything when we are disposed to prevent memory leaks (see bug 195521) selection = null; window = null; targetPart = null; shell = null; }
public void init(IWorkbenchWindow window) { this.window = window; this.shell = window.getShell(); window.getSelectionService().addPostSelectionListener(selectionListener); }
/** * Returns the selection of the active workbench window. * * @return the current selection in the active workbench window or <code>null</code> */ protected final ISelection getSelection() { IWorkbenchWindow window= getWorkbenchWindow(); if (window != null) return window.getSelectionService().getSelection(); return null; }
private IStructuredSelection evaluateCurrentSelection() { IWorkbenchWindow window= JavaPlugin.getActiveWorkbenchWindow(); if (window != null) { ISelection selection= window.getSelectionService().getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; } } return StructuredSelection.EMPTY; }
public static IStructuredSelection getCurrentSelection() { IWorkbenchWindow window = getActiveWorkbenchWindow(); if (window != null) { ISelection selection = window.getSelectionService().getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; } } return null; }
private void setSelectionListener() { this.getSite().getWorkbenchWindow().getSelectionService() .addPostSelectionListener(new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { DesignerTabbedPropertySheetPage.this.selectionChanged( part, selection); } }); }
@Override public void dispose() { if (workbenchWindow == null) { // action has already been disposed return; } workbenchWindow.getSelectionService().removeSelectionListener(this); workbenchWindow.getPartService().removePartListener(this); workbenchWindow = null; }
protected IStructuredSelection getCurrentSelection() { IWorkbenchWindow window = J2EEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); if (window != null) { ISelection selection = window.getSelectionService().getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; } } return null; }
@Override public void dispose() { if (lastWindow != null) lastWindow.getSelectionService().removeSelectionListener(this); workbench.removeWindowListener(windowListener); display.removeFilter(SWT.Activate, listener); hookListener(lastActiveWorkbenchWindow, null); lastActiveWorkbenchWindow = null; lastActiveWorkbenchWindowShell = null; lastActiveShell = null; lastWindow = null; }
@Override public void init(IWorkbenchWindow window) { this.window = window; this.shell = window.getShell(); window.getSelectionService().addPostSelectionListener(selectionListener); window.getActivePage().addPartListener(targetPartListener); }
public SearchDialog(IWorkbenchWindow window, String pageId) { super(window.getShell()); fWorkbenchWindow= window; fCurrentSelection= window.getSelectionService().getSelection(); fCurrentEnclosingProject= evaluateEnclosingProject(fCurrentSelection, getActiveEditor()); fDescriptors= filterByActivities(SearchPlugin.getDefault().getEnabledSearchPageDescriptors(pageId)); fInitialPageId= pageId; fPageChangeListeners= null; setUseEmbeddedProgressMonitorPart(false); }
@Override public Object execute(ExecutionEvent event) { IWorkbench workbench = PlatformUI.getWorkbench(); ISelection sel = workbench.getActiveWorkbenchWindow().getSelectionService().getSelection(); IStructuredSelection structuredSel = null; if (sel != null && sel instanceof IStructuredSelection) { structuredSel = (IStructuredSelection)sel; } SmartImportWizard wizard = new SmartImportWizard(); wizard.init(workbench, structuredSel); new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard).open(); return null; }