org.eclipse.ui.IWorkbenchWindow Java Examples
The following examples show how to use
org.eclipse.ui.IWorkbenchWindow.
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 Project: tracecompass Author: tracecompass File: LamiChartViewerTest.java License: Eclipse Public License 2.0 | 6 votes |
/** * Reset the current perspective */ @After public void resetPerspective() { SWTBotView viewBot = fViewBot; if (viewBot != null) { viewBot.close(); } /* * UI Thread executes the reset perspective action, which opens a shell * to confirm the action. The current thread will click on the 'Yes' * button */ Runnable runnable = () -> SWTBotUtils.anyButtonOf(fBot, "Yes", "Reset Perspective").click(); UIThreadRunnable.asyncExec(() -> { IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getWorkbenchWindows()[0]; ActionFactory.RESET_PERSPECTIVE.create(activeWorkbenchWindow).run(); }); runnable.run(); }
Example #2
Source Project: Eclipse-Postfix-Code-Completion Author: trylimits File: OpenTypeHierarchyUtil.java License: Eclipse Public License 1.0 | 6 votes |
private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, IJavaElement[] input) { IWorkbenchPage page= window.getActivePage(); try { TypeHierarchyViewPart result= (TypeHierarchyViewPart) page.findView(JavaUI.ID_TYPE_HIERARCHY); if (result != null) { result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible' } result= (TypeHierarchyViewPart) page.showView(JavaUI.ID_TYPE_HIERARCHY); result.setInputElements(input); return result; } catch (CoreException e) { ExceptionHandler.handle(e, window.getShell(), JavaUIMessages.OpenTypeHierarchyUtil_error_open_view, e.getMessage()); } return null; }
Example #3
Source Project: olca-app Author: GreenDelta File: Navigator.java License: Mozilla Public License 2.0 | 6 votes |
/** * Returns the instance of the navigation view or NULL if there is# no such * instance available. */ public static Navigator getInstance() { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return null; IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window == null) return null; IWorkbenchPage page = window.getActivePage(); if (page == null) return null; IViewPart part = page.findView(ID); if (part instanceof Navigator) return (Navigator) part; return null; }
Example #4
Source Project: tmxeditor8 Author: heartsome File: ShowPreviousUntranslatedHandler.java License: GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int firstSelectedRow = selectedRows[0]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getPreviousUntranslatedSegmentIndex(firstSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在上一未翻译文本段。"); } return null; }
Example #5
Source Project: mat-calcite-plugin Author: vlsi File: CalcitePane.java License: Apache License 2.0 | 6 votes |
private void makeActions() { executeQueryAction = new ExecuteQueryAction(this, null, false); explainQueryAction = new ExecuteQueryAction(this, null, true); commentLineAction = new CommentLineAction(queryString); IWorkbenchWindow window = this.getEditorSite().getWorkbenchWindow(); ActionFactory.IWorkbenchAction globalAction = ActionFactory.COPY.create(window); this.copyQueryStringAction = new Action() { public void run() { CalcitePane.this.queryString.copy(); } }; this.copyQueryStringAction.setAccelerator(globalAction.getAccelerator()); this.contentAssistAction = new Action() { @Override public void run() { queryViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); } }; }
Example #6
Source Project: translationstudio8 Author: heartsome File: ShowNextUntranslatableHandler.java License: GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int lastSelectedRow = selectedRows[selectedRows.length - 1]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getNextUntranslatableSegmentIndex(lastSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在下一不可翻译文本段。"); } return null; }
Example #7
Source Project: saros Author: saros-project File: ViewUtils.java License: GNU General Public License v2.0 | 6 votes |
public static void openSarosView() { /* * TODO What to do if no WorkbenchWindows are are active? */ final IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return; final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window == null) return; try { window.getActivePage().showView(SarosView.ID, null, IWorkbenchPage.VIEW_CREATE); } catch (PartInitException e) { log.error("could not open Saros view (id: " + SarosView.ID + ")", e); // $NON-NLS-1$ } }
Example #8
Source Project: tlaplus Author: tlaplus File: ParseSpecHandler.java License: MIT License | 6 votes |
/** * @deprecated */ protected void saveDirtyEditors() { Display display = UIHelper.getCurrentDisplay(); display.syncExec(new Runnable() { public void run() { IWorkbenchWindow[] windows = Activator.getDefault().getWorkbench().getWorkbenchWindows(); for (int i = 0; i < windows.length; i++) { IWorkbenchPage[] pages = windows[i].getPages(); for (int j = 0; j < pages.length; j++) pages[j].saveAllEditors(false); } } }); }
Example #9
Source Project: tmxeditor8 Author: heartsome File: ShowPreviousUntranslatableHandler.java License: GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int firstSelectedRow = selectedRows[0]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getPreviousUntranslatableSegmentIndex(firstSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在上一不可翻译文本段。"); } return null; }
Example #10
Source Project: yang-design-studio Author: att File: YangSyntax.java License: Eclipse Public License 1.0 | 6 votes |
public MessageConsoleStream getMessageStream() { MessageConsole myConsole = findConsole("Yang Console"); //calls function to find/create the Yang console if (myConsole != null) { IWorkbench wb = PlatformUI.getWorkbench(); IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); IWorkbenchPage page = win.getActivePage(); String id = IConsoleConstants.ID_CONSOLE_VIEW; IConsoleView view; try { view = (IConsoleView) page.showView(id); view.display(myConsole); return myConsole.newMessageStream(); } catch (PartInitException e) { e.printStackTrace(); } } return null; }
Example #11
Source Project: tracecompass Author: tracecompass File: TmfAlignmentSynchronizer.java License: Eclipse Public License 2.0 | 6 votes |
/** * Get the narrowest view that corresponds to the given alignment information. */ private static TmfView getNarrowestView(TmfTimeViewAlignmentInfo alignmentInfo) { IWorkbenchWindow workbenchWindow = getWorkbenchWindow(alignmentInfo.getShell()); if (workbenchWindow == null || workbenchWindow.getActivePage() == null) { // Only time aligned views that are part of a workbench window are supported return null; } IWorkbenchPage page = workbenchWindow.getActivePage(); int narrowestWidth = Integer.MAX_VALUE; TmfView narrowestView = null; for (IViewReference ref : page.getViewReferences()) { IViewPart view = ref.getView(false); if (isTimeAlignedView(view)) { TmfView tmfView = (TmfView) view; if (isCandidateForNarrowestView(tmfView, alignmentInfo, narrowestWidth)) { narrowestWidth = ((ITmfTimeAligned) tmfView).getAvailableWidth(getClampedTimeAxisOffset(alignmentInfo)); narrowestWidth = getClampedTimeAxisWidth(alignmentInfo, narrowestWidth); narrowestView = tmfView; } } } return narrowestView; }
Example #12
Source Project: tracecompass Author: tracecompass File: PasteHandler.java License: Eclipse Public License 2.0 | 6 votes |
@Override public boolean isEnabled() { // Check if we are closing down IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) { return false; } // Get the selection IWorkbenchPage page = window.getActivePage(); IWorkbenchPart part = page.getActivePart(); if (!(part instanceof FilterView)) { return false; } FilterView v = (FilterView) part; ITmfFilterTreeNode sel = v.getSelection(); if (sel == null) { sel = v.getFilterRoot(); } ITmfFilterTreeNode objectToPaste = FilterEditUtils.getTransferredTreeNode(); return (v.isTreeInFocus() && objectToPaste != null && (sel.getValidChildren().contains(objectToPaste.getNodeName()) || TmfFilterNode.NODE_NAME.equals(objectToPaste.getNodeName()))); }
Example #13
Source Project: gama Author: gama-platform File: GamlReferenceSearch.java License: GNU General Public License v3.0 | 6 votes |
public static void install() { WorkbenchHelper.runInUI("Install GAML Search", 0, m -> { final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window instanceof WorkbenchWindow) { final MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim(); for (final MTrimElement element : topTrim.getChildren()) { if ("SearchField".equals(element.getElementId())) { final Composite parent = ((Control) element.getWidget()).getParent(); final Control old = (Control) element.getWidget(); WorkbenchHelper.runInUI("Disposing old search control", 500, m2 -> old.dispose()); element.setWidget(GamlSearchField.installOn(parent)); parent.layout(true, true); parent.update(); break; } } } }); }
Example #14
Source Project: tmxeditor8 Author: heartsome File: ShowPreviousNoteHandler.java License: GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int firstSelectedRow = selectedRows[0]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getPreviousNoteSegmentIndex(firstSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在上一个带批注的文本段。"); } return null; }
Example #15
Source Project: Eclipse-Postfix-Code-Completion Author: trylimits File: JavaReconciler.java License: Eclipse Public License 1.0 | 6 votes |
@Override public void uninstall() { IWorkbenchPartSite site= fTextEditor.getSite(); IWorkbenchWindow window= site.getWorkbenchWindow(); window.getPartService().removePartListener(fPartListener); fPartListener= null; Shell shell= window.getShell(); if (shell != null && !shell.isDisposed()) shell.removeShellListener(fActivationListener); fActivationListener= null; JavaCore.removeElementChangedListener(fJavaElementChangedListener); fJavaElementChangedListener= null; IWorkspace workspace= JavaPlugin.getWorkspace(); workspace.removeResourceChangeListener(fResourceChangeListener); fResourceChangeListener= null; JavaPlugin.getDefault().getCombinedPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); fPropertyChangeListener= null; super.uninstall(); }
Example #16
Source Project: tmxeditor8 Author: heartsome File: ShowHidenNonPrintingCharacterHandler.java License: GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { isSelected = !isSelected; try { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IEditorPart editor = page.getActiveEditor(); if (editor != null && editor instanceof IXliffEditor) { ((IXliffEditor) editor).refreshWithNonprinttingCharacter(isSelected); } } } } catch (NullPointerException e) { e.printStackTrace(); } return null; }
Example #17
Source Project: tlaplus Author: tlaplus File: UIHelper.java License: MIT License | 6 votes |
/** * Closes all windows with a perspective * * @param perspectiveId * a perspective Id pointing the perspective */ public static void closeWindow(String perspectiveId) { IWorkbench workbench = Activator.getDefault().getWorkbench(); // hide intro if (InitialPerspective.ID.equals(perspectiveId)) { workbench.getIntroManager().closeIntro(workbench.getIntroManager().getIntro()); } IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); // closing the perspective opened in a window for (int i = 0; i < windows.length; i++) { IWorkbenchPage page = windows[i].getActivePage(); if (page != null && page.getPerspective() != null && perspectiveId.equals(page.getPerspective().getId())) { windows[i].close(); } } }
Example #18
Source Project: tmxeditor8 Author: heartsome File: XLIFFEditorSelectionPropertyTester.java License: GNU General Public License v2.0 | 6 votes |
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { boolean enabled = false; IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IEditorPart editor = page.getActiveEditor(); if (editor != null && editor instanceof XLIFFEditorImplWithNatTable) { XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; if (xliffEditor != null && xliffEditor.getTable() != null) { List<String> selectedRowIds = xliffEditor.getSelectedRowIds(); enabled = (selectedRowIds != null && selectedRowIds.size() > 0); } } } } return enabled; }
Example #19
Source Project: eclipse-wakatime Author: wakatime File: WakaTime.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void promptForApiKey(IWorkbenchWindow window) { String apiKey = ConfigFile.get("settings", "api_key"); InputDialog dialog = new InputDialog(window.getShell(), "WakaTime API Key", "Please enter your api key from http://wakatime.com/settings#apikey", apiKey, null); if (dialog.open() == IStatus.OK) { apiKey = dialog.getValue(); ConfigFile.set("settings", "api_key", apiKey); } }
Example #20
Source Project: birt Author: eclipse File: SessionHandleAdapter.java License: Eclipse Public License 1.0 | 5 votes |
/** * @return Returns the active moudle in current session * * @deprecated It's better to find module from relevant context instead * here. */ public ModuleHandle getModule( ) { if ( model == null ) { IWorkbenchWindow activeWindow = PlatformUI.getWorkbench( ) .getActiveWorkbenchWindow( ); model = moduleHandleMap.get( activeWindow ); } return model; }
Example #21
Source Project: tesb-studio-se Author: Talend File: LocalWSDLEditor.java License: Apache License 2.0 | 5 votes |
@Override protected void createActions() { super.createActions(); ActionRegistry registry = getActionRegistry(); BaseSelectionAction action = new OpenInNewEditor(this) { @Override public void run() { if (getSelectedObjects().size() > 0) { Object o = getSelectedObjects().get(0); // should make this generic and be able to get the owner from a facade object if (o instanceof WSDLBaseAdapter) { WSDLBaseAdapter baseAdapter = (WSDLBaseAdapter) o; IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); Object object = editorPart.getAdapter(org.eclipse.wst.wsdl.Definition.class); if (object instanceof org.eclipse.wst.wsdl.Definition) { EObject eObject = (EObject) baseAdapter.getTarget(); OpenOnSelectionHelper openHelper = new OpenOnSelectionHelper( (org.eclipse.wst.wsdl.Definition) object); openHelper.openEditor(eObject); } } } } }; action.setSelectionProvider(getSelectionManager()); registry.registerAction(action); }
Example #22
Source Project: n4js Author: eclipse File: EclipseUIUtils.java License: Eclipse Public License 1.0 | 5 votes |
/** Obtains active workbench window. Can be null. */ public static IWorkbenchWindow getWorkbenchWindow() { if (!UIUtils.runsInUIThread()) LOGGER.warn("Eclipse UI utilities work correctly only when called from the UI thread."); IWorkbenchWindow window = null; if (Workbench.getInstance() != null) { IWorkbench wb = PlatformUI.getWorkbench(); window = wb.getActiveWorkbenchWindow(); } return window; }
Example #23
Source Project: XPagesExtensionLibrary Author: OpenNTF File: ExtLibPanelUtil.java License: Apache License 2.0 | 5 votes |
public static IWorkbenchPage getActiveWorkbenchPage(){ IWorkbenchWindow window = getActiveWorkbenchWindow(); if(null != window){ IWorkbenchPage page = window.getActivePage(); return page; } return null; }
Example #24
Source Project: xds-ide Author: excelsior-oss File: SwtUtils.java License: Eclipse Public License 1.0 | 5 votes |
public static Shell getDefaultShell() { IWorkbenchWindow window = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); if (window != null) { return window.getShell(); } return null; }
Example #25
Source Project: ice Author: eclipse File: ForkStorkWizard.java License: Eclipse Public License 1.0 | 5 votes |
/** * The default constructor. This is not normally called by the platform but * via handlers. * * @param window * The workbench window. */ public ForkStorkWizard(IWorkbenchWindow window) { // Initialize the default information. this(); // Store a reference to the workbench window. workbenchWindow = window; page = new ForkStorkWizardPage("Fork the Stork!"); }
Example #26
Source Project: eclipse-wakatime Author: wakatime File: CustomExecutionListener.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void postExecuteSuccess(String commandId, Object returnValue) { if (commandId.equals("org.eclipse.ui.file.save")) { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench == null) return; IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window == null) return; if (window.getPartService() == null) return; if (window.getPartService().getActivePart() == null) return; if (window.getPartService().getActivePart().getSite() == null) return; if (window.getPartService().getActivePart().getSite().getPage() == null) return; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput() == null) return; // log file save event IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor().getEditorInput(); if (input instanceof IURIEditorInput) { URI uri = ((IURIEditorInput)input).getURI(); if (uri != null && uri.getPath() != null) { String currentFile = uri.getPath(); long currentTime = System.currentTimeMillis() / 1000; // always log writes WakaTime.sendHeartbeat(currentFile, WakaTime.getActiveProject(), true); WakaTime.getDefault().lastFile = currentFile; WakaTime.getDefault().lastTime = currentTime; } } } }
Example #27
Source Project: Pydev Author: fabioz File: UIUtils.java License: Eclipse Public License 1.0 | 5 votes |
public static IWorkbenchPage getActivePage() { IWorkbenchWindow workbench = getActiveWorkbenchWindow(); if (workbench == null) { return null; } return workbench.getActivePage(); }
Example #28
Source Project: n4js Author: eclipse File: N4JSGracefulActivator.java License: Eclipse Public License 1.0 | 5 votes |
/** * Returns the active workbench shell or <code>null</code> if none * * @return the active workbench shell or <code>null</code> if none */ public static Shell getActiveWorkbenchShell() { IWorkbenchWindow window = getInstance().getWorkbench().getActiveWorkbenchWindow(); if (window != null) { return window.getShell(); } return null; }
Example #29
Source Project: gwt-eclipse-plugin Author: gwt-plugins File: WebAppLaunchViewActivator.java License: Eclipse Public License 1.0 | 5 votes |
@Override public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IViewPart webAppView = page.findView(WebAppLaunchView.ID); if (webAppView == null) { try { webAppView = page.showView(WebAppLaunchView.ID); } catch (PartInitException e) { return StatusUtilities.newErrorStatus(e, Activator.PLUGIN_ID); } } if (webAppView != null) { synchronized(boldingLock) { if (bolding) { if (webAppView.getSite() != null) { IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) webAppView.getSite().getAdapter( IWorkbenchSiteProgressService.class); if (service != null) { service.warnOfContentChange(); } } } else { page.bringToTop(webAppView); } } } } } return Status.OK_STATUS; }
Example #30
Source Project: CodeCheckerEclipsePlugin Author: Ericsson File: CodeCheckerContext.java License: Eclipse Public License 1.0 | 5 votes |
/** * Refresh change editor part. * * @param partRef the IEditorPart which the user has switched. */ public void refreshChangeEditorPart(IEditorPart partRef) { if (partRef.getEditorInput() instanceof IFileEditorInput){ //could be FileStoreEditorInput //for files which are not part of the //current workspace activeEditorPart = partRef; IFile file = ((IFileEditorInput) partRef.getEditorInput()).getFile(); IProject project = file.getProject(); CodeCheckerProject ccProj = projects.get(project); String filename = ""; if (ccProj != null) filename = ((FileEditorInput) partRef.getEditorInput()).getFile().getLocation().toFile().toPath() .toString(); IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (activeWindow == null) { Logger.log(IStatus.ERROR, NULL_WINDOW); return; } IWorkbenchPage[] pages = activeWindow.getPages(); this.refreshProject(pages, project, true); this.refreshCurrent(pages, project, filename, true); this.refreshCustom(pages, project, "", true); this.activeProject = project; } }