Java Code Examples for org.eclipse.ui.IWorkbenchPart#getSite()
The following examples show how to use
org.eclipse.ui.IWorkbenchPart#getSite() .
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: BaseYankHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * In the console context, use paste as * in some consoles (e.g. org.eclipse.debug.internal.ui.views.console.ProcessConsole), updateText * will not simulate keyboard input * * @param event the ExecutionEvent * @param widget The consoles StyledText widget */ protected void paste(ExecutionEvent event, StyledText widget) { IWorkbenchPart apart = HandlerUtil.getActivePart(event); if (apart != null) { try { IWorkbenchPartSite site = apart.getSite(); if (site != null) { IHandlerService service = (IHandlerService) site.getService(IHandlerService.class); if (service != null) { service.executeCommand(IEmacsPlusCommandDefinitionIds.EMP_PASTE, null); KillRing.getInstance().setYanked(true); } } } catch (CommandException e) { } } }
Example 2
Source File: JavaMergeViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IWorkbenchPartSite getSite() { if (fSite == null) { IWorkbenchPart workbenchPart= getCompareConfiguration().getContainer().getWorkbenchPart(); fSite= workbenchPart != null ? workbenchPart.getSite() : null; } return fSite; }
Example 3
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 4
Source File: WorkbenchUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static Shell getActivePartShell() { IWorkbenchPage activePage = WorkbenchUtils.getActivePage(); if (activePage == null) { return null; } IWorkbenchPart activePart = activePage.getActivePart(); if (activePart == null) { return null; } IWorkbenchPartSite site = activePart.getSite(); if (site == null) { return null; } return site.getShell(); }
Example 5
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 6
Source File: FindBugsAction.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
protected static IWorkbenchWindow getWindow(IWorkbenchPart part) { IWorkbenchWindow window; IWorkbenchPartSite currentSite = part != null ? part.getSite() : null; if (currentSite != null) { window = currentSite.getWorkbenchWindow(); } else { window = FindbugsPlugin.getActiveWorkbenchWindow(); } return window; }
Example 7
Source File: TypeScriptMergeViewer.java From typescript.java with MIT License | 5 votes |
private IWorkbenchPartSite getSite() { if (fSite == null) { IWorkbenchPart workbenchPart = getCompareConfiguration().getContainer().getWorkbenchPart(); fSite = workbenchPart != null ? workbenchPart.getSite() : null; } return fSite; }
Example 8
Source File: SWTBotUtils.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Maximize a part. Calling this a second time will "un-maximize" a part. * * @param part * the workbench part */ public static void maximize(@NonNull IWorkbenchPart part) { assertNotNull(part); IWorkbenchPartSite site = part.getSite(); assertNotNull(site); // The annotation is to make the compiler not complain. @Nullable Object handlerServiceObject = site.getService(IHandlerService.class); assertTrue(handlerServiceObject instanceof IHandlerService); IHandlerService handlerService = (IHandlerService) handlerServiceObject; try { handlerService.executeCommand(IWorkbenchCommandConstants.WINDOW_MAXIMIZE_ACTIVE_VIEW_OR_EDITOR, null); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { fail(e.getMessage()); } }
Example 9
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 10
Source File: CompareWithRouteAction.java From eip-designer with Apache License 2.0 | 4 votes |
@Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { serviceLocator = targetPart.getSite(); }
Example 11
Source File: JarPackageActionDelegate.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void setActivePart(IAction action, IWorkbenchPart targetPart) { IWorkbenchPartSite site= targetPart.getSite(); fShell= site != null ? site.getShell() : null; }
Example 12
Source File: FormatAllAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void setActivePart(IAction action, IWorkbenchPart targetPart) { fAction= new FormatAllAction(targetPart.getSite()); }
Example 13
Source File: OrganizeImportsAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public void setActivePart(IAction action, IWorkbenchPart targetPart) { fAction= new OrganizeImportsAction(targetPart.getSite()); }
Example 14
Source File: CompareWithRouteAction.java From eip-designer with Apache License 2.0 | 4 votes |
@Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { serviceLocator = targetPart.getSite(); }
Example 15
Source File: PersistToRouteModelAction.java From eip-designer with Apache License 2.0 | 4 votes |
@Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { serviceLocator = targetPart.getSite(); }
Example 16
Source File: WriteAttributesOperationAction.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public void setActivePart ( final IAction action, final IWorkbenchPart targetPart ) { this.site = targetPart.getSite (); }
Example 17
Source File: ShowInPackageExplorerAction.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { site = targetPart.getSite(); }
Example 18
Source File: WorkbenchUtils.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
public static IWorkbenchPartSite getActivePartSite() { IWorkbenchPart activePart = getActivePart(); return activePart != null ? activePart.getSite() : null; }
Example 19
Source File: DefaultMergeViewer.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected IWorkbenchPartSite getSite() { IWorkbenchPart workbenchPart = getCompareConfiguration().getContainer().getWorkbenchPart(); return workbenchPart != null ? workbenchPart.getSite() : null; }
Example 20
Source File: WriteOperationAction.java From neoscada with Eclipse Public License 1.0 | 4 votes |
@Override public void setActivePart ( final IAction action, final IWorkbenchPart targetPart ) { this.site = targetPart.getSite (); }