org.eclipse.ui.internal.Workbench Java Examples
The following examples show how to use
org.eclipse.ui.internal.Workbench.
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: GWTCodeFormatterApplication.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private void startWorkbench() { PlatformUI.createAndRunWorkbench(PlatformUI.createDisplay(), new WorkbenchAdvisor() { @Override public String getInitialWindowPerspectiveId() { return null; } @Override public void postStartup() { // Kill it when it opens so that the thread is unstuck. Workbench.getInstance().close(); } }); }
Example #2
Source File: GWTSettingsTab.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
public void performApply(ILaunchConfigurationWorkingCopy configuration) { // super dev mode args GWTLaunchConfigurationWorkingCopy.setSuperDevModeEnabled(configuration, selectionBlock.isSuperDevModeSelected()); // Logic for determining Super Dev Mode is retrieved form working copy in // processors. So saving the Super Dev enabled here decouples processors. // TODO refer to updateArgumentProcessors todo about LaunchCOnfigurationUpdater. try { configuration.doSave(); } catch (CoreException e) { MessageDialog.openError(Workbench.getInstance().getActiveWorkbenchWindow().getShell(), "Error saving project", "Please try hitting apply agian."); } // When changing between selections update all the launch config args updateArgumentProcessors(configuration); }
Example #3
Source File: CustomPopupMenuExtender.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * Notifies the listener that the menu is about to be hidden. */ @Override public final void menuAboutToHide(final IMenuManager mgr) { gatherContributions(mgr); cleanupNeeded = true; // Remove this menu as a visible menu. final IWorkbenchPartSite site = part.getSite(); if (site != null) { final IWorkbench workbench = site.getWorkbenchWindow().getWorkbench(); if (workbench instanceof Workbench) { // try delaying this until after the selection event // has been fired. // This is less threatening if the popup: menu // contributions aren't tied to the evaluation service workbench.getDisplay().asyncExec(() -> { final Workbench realWorkbench = (Workbench) workbench; runCleanUp(realWorkbench); }); } } }
Example #4
Source File: CppStylePropertyPage.java From CppStyle with MIT License | 6 votes |
public static String getCurrentProject() { ISelectionService selectionService = Workbench.getInstance() .getActiveWorkbenchWindow().getSelectionService(); ISelection selection = selectionService.getSelection(); if (selection instanceof IStructuredSelection) { Object element = ((IStructuredSelection) selection).getFirstElement(); IProject project = null; if (element instanceof IResource) { project = ((IResource) element).getProject(); } else if (element instanceof ICElement) { project = ((ICElement) element).getResource().getProject(); } if (project != null) { return project.getLocation().toOSString(); } } return null; }
Example #5
Source File: DataSetParametersPage.java From birt with Eclipse Public License 1.0 | 6 votes |
private void handleLinkedMultipleValuesReportParam( OdaDataSetParameter dsParam ) { if ( dsParam.getParamName( ) == null ) return; ScalarParameterHandle paramHandle = ParameterPageUtil.getScalarParameter( dsParam.getParamName( ), true ); if ( paramHandle != null ) { if ( DesignChoiceConstants.SCALAR_PARAM_TYPE_MULTI_VALUE.equals( paramHandle.getParamType( ) ) ) { MessageDialog.openWarning( Workbench.getInstance( ) .getDisplay( ) .getActiveShell( ), Messages.getString( "DataSetParameterPage.warningLinkedMultipleValuesParams.title" ), getWarning( dsParam ) ); } } }
Example #6
Source File: BrowserUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public static IWebBrowser launchBrowser(String targetUrl) throws MalformedURLException, PartInitException { Workbench workbench = Workbench.getInstance(); if (workbench == null) { throw new PartInitException("No workbench is available"); } IWorkbenchBrowserSupport browserSupport = workbench.getBrowserSupport(); URL url = new URL(targetUrl); IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.AS_EXTERNAL, null, "GWT", "GWT"); browser.openURL(url); return browser; }
Example #7
Source File: ConstraintEditorWizardDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void configureContext() { final IEclipseContext e4Context = ((Workbench) PlatformUI.getWorkbench()).getContext(); while (!Objects.equals(e4Context.getActiveLeaf(), e4Context)) { e4Context.getActiveLeaf().deactivate(); } final IEclipseContext expressionDialogContext = e4Context.createChild("expressionDialogContext"); expressionDialogContext.activate(); getShell().setData("org.eclipse.e4.ui.shellContext", expressionDialogContext); }
Example #8
Source File: CustomPopupMenuExtender.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void runCleanUp(Workbench realWorkbench) { if (!cleanupNeeded) { return; } cleanupNeeded = false; realWorkbench.removeShowingMenus(getMenuIds(), null, null); cleanUpContributionCache(); }
Example #9
Source File: CommandExecutor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public boolean canExecute(String command, Map<String, Object> parameters) { if (Workbench.getInstance() != null) { initServices(); ParameterizedCommand parameterizedCommand = eCommandService.createCommand(command, parameters); return eHandlerService.canExecute(parameterizedCommand); } return false; }
Example #10
Source File: CommandExecutor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public Object executeCommand(String command, Map<String, Object> parameters) { if (Workbench.getInstance() != null) { initServices(); ParameterizedCommand parameterizedCommand = eCommandService.createCommand(command, parameters); if (eHandlerService.canExecute(parameterizedCommand)) { return eHandlerService.executeHandler(parameterizedCommand); } throw new RuntimeException(String.format("Can't execute command %s", parameterizedCommand.getId())); } return null; }
Example #11
Source File: ExtensionContextInjectionFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public static IEclipseContext workbenchContext() { if (PlatformUI.isWorkbenchRunning()) { final Workbench workbench = (Workbench) PlatformUI.getWorkbench(); if (workbench != null) { final IEclipseContext context = workbench.getContext(); checkNotNull(context, "Workbench eclipse context is null"); return context; } throw new IllegalStateException("No workbench available"); } return headlessContext(); }
Example #12
Source File: GroovySourceViewerFactory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void configureContext(Shell shell) { final IEclipseContext e4Context = ((Workbench) PlatformUI.getWorkbench()).getContext(); while (!Objects.equals(e4Context.getActiveLeaf(), e4Context)) { e4Context.getActiveLeaf().deactivate(); } final IEclipseContext expressionDialogContext = e4Context.createChild("expressionDialogContext"); expressionDialogContext.activate(); shell.setData("org.eclipse.e4.ui.shellContext", expressionDialogContext); }
Example #13
Source File: GroovyViewer.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private IEclipseContext createGroovyEditorContext() { final IEclipseContext context = ((Workbench) PlatformUI.getWorkbench()).getContext(); final IEclipseContext activeLeaf = context.getActiveLeaf(); IEclipseContext groovyEditorContext = activeLeaf.createChild("groovyEditorContext"); groovyEditorContext.set("localContexts", Lists.newLinkedList(Lists.newArrayList("org.eclipse.ui.contexts.window", "org.eclipse.ui.contexts.dialogAndWindow", "org.eclipse.ui.textEditorScope", "org.eclipse.jdt.ui.javaEditorScope", "org.codehaus.groovy.eclipse.editor.groovyEditorScope"))); return groovyEditorContext; }
Example #14
Source File: EditExpressionDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void configureContext() { final IEclipseContext e4Context = ((Workbench) PlatformUI.getWorkbench()).getContext(); while (!Objects.equals(e4Context.getActiveLeaf(), e4Context)) { e4Context.getActiveLeaf().deactivate(); } getShell().setData("org.eclipse.e4.ui.shellContext", e4Context.createChild("expressionDialogContext")); }
Example #15
Source File: CommonFunction.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 当删除一个文件时,刷新历史记录 --robert 2012-11-20 */ @SuppressWarnings("restriction") public static void refreshHistoryWhenDelete(IEditorInput input){ IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench instanceof Workbench) { EditorHistory history = ((Workbench) workbench).getEditorHistory(); for (EditorHistoryItem item : history.getItems()) { if (item.matches(input)) { history.remove(item); } } history.refresh(); } }
Example #16
Source File: CommonFunction.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 当删除一个文件时,刷新历史记录 --robert 2012-11-20 */ @SuppressWarnings("restriction") public static void refreshHistoryWhenDelete(IEditorInput input){ IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench instanceof Workbench) { EditorHistory history = ((Workbench) workbench).getEditorHistory(); for (EditorHistoryItem item : history.getItems()) { if (item.matches(input)) { history.remove(item); } } history.refresh(); } }
Example #17
Source File: AbstractFileBasedRenamingTest.java From sarl with Apache License 2.0 | 5 votes |
/** Validate the refactoring given by the support. * * @param support the support. * @throws Exception */ protected void validateRefactoring(RenameSupport support) throws Exception { IStatus status = support.preCheck(); assertTrue(status.isOK()); support.perform(helper().getShell(), Workbench.getInstance().getActiveWorkbenchWindow()); helper().awaitAutoBuild(); String newContent = helper().getContents(helper().getFile(this.newFilename)); assertEquals(this.expected, newContent); }
Example #18
Source File: GdtPlugin.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Adds the new wizards to the current perspective displayed in the workbench's active window, if they've not been * added already. Adds listeners on the workbench so that the same is done for any new workbench windows that are * created. * * Note: This method can only be called once the workbench has been started. */ private void maybeAddNewWizardActionsToWorkbench() { IWorkbench workbench = Workbench.getInstance(); if (workbench != null) { workbench.addWindowListener(windowListener); maybeAddNewWizardActionsToWindow(workbench.getActiveWorkbenchWindow()); } else { // This should never happen; the workbench must be started by the time // this code is executed } }
Example #19
Source File: EclipseUIUtils.java From n4js with 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 #20
Source File: DeployBDMOperation.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected IEclipseContext e4Context() { Workbench workbench = (Workbench) PlatformUI.getWorkbench(); return workbench.getContext(); }
Example #21
Source File: DeployBDMOperation.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected EHandlerService handlerService() { Workbench workbench = (Workbench) PlatformUI.getWorkbench(); return workbench.getService(EHandlerService.class); }
Example #22
Source File: DeployBDMOperation.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected ECommandService commandService() { Workbench workbench = (Workbench) PlatformUI.getWorkbench(); return workbench.getService(ECommandService.class); }
Example #23
Source File: DummyEditorSite.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public IWorkbenchWindow getWorkbenchWindow() { final IEclipseContext context = ((Workbench) PlatformUI.getWorkbench()).getContext(); return (IWorkbenchWindow) context.get(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); }
Example #24
Source File: EmbeddedEditorSite.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected static MWindow getMWindow() { Workbench workbench = (Workbench) PlatformUI.getWorkbench(); WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) workbench.getActiveWorkbenchWindow(); return activeWorkbenchWindow.getModel(); }
Example #25
Source File: DataSetParametersPage.java From birt with Eclipse Public License 1.0 | 4 votes |
public void updateLinkedReportParameter( String originalLink ) { ScalarParameterHandle orignalHandle = null; if ( !originalLink.equals( Messages.getString( "DataSetParametersPage.reportParam.None" ) ) ) { orignalHandle = ParameterPageUtil.getScalarParameter( originalLink, true ); } ParameterHandle currentHandle = null; if ( !linkToScalarParameter.getText( ) .equals( Messages.getString( "DataSetParametersPage.reportParam.None" ) ) ) { currentHandle = ParameterPageUtil.getScalarParameter( linkToScalarParameter.getText( ), true ); } OdaDataSetParameterHandle dataSetParameterHandle = (OdaDataSetParameterHandle) structureHandle; if ( currentHandle != null && orignalHandle != currentHandle ) { boolean setting = ReportPlugin.getDefault( ) .getPluginPreferences( ) .getBoolean( DateSetPreferencePage.PROMPT_PARAM_UPDATE ); String option = ReportPlugin.getDefault( ) .getPluginPreferences( ) .getString( DateSetPreferencePage.PROMPT_PARAM_UPDATE_OPTION ); if ( setting ) { if ( option != null && option.equals( DateSetPreferencePage.PROMPT_PARAM_UPDATE_OPTION_UPDATE ) ) { executeLinkedReportParameterUpdate( currentHandle, dataSetParameterHandle ); } return; } MessageDialogWithToggle dialog = new MessageDialogWithToggle( Workbench.getInstance( ) .getDisplay( ) .getActiveShell( ), Messages.getString( "DataSetParameterPage.updateReportParameter.title" ), null, Messages.getString( "DataSetParameterPage.updateReportParameter.message" ), MessageDialog.QUESTION, new String[]{ Messages.getString( "DataSetParameterPage.updateReportParameter.promptButtonYes" ), Messages.getString( "DataSetParameterPage.updateReportParameter.promptButtonNo" ) }, 1, Messages.getString( "DataSetParameterPage.updateReportParameter.propmtText" ), false ); dialog.open( ); if ( dialog.getReturnCode( ) == 256 ) { executeLinkedReportParameterUpdate( currentHandle,dataSetParameterHandle ); } if ( dialog.getToggleState( ) ) { ReportPlugin.getDefault( ) .getPluginPreferences( ) .setValue( DateSetPreferencePage.PROMPT_PARAM_UPDATE, true ); if ( dialog.getReturnCode( ) == 256 ) { ReportPlugin.getDefault( ) .getPluginPreferences( ) .setValue( DateSetPreferencePage.PROMPT_PARAM_UPDATE_OPTION, DateSetPreferencePage.PROMPT_PARAM_UPDATE_OPTION_UPDATE ); } else { ReportPlugin.getDefault( ) .getPluginPreferences( ) .setValue( DateSetPreferencePage.PROMPT_PARAM_UPDATE_OPTION, DateSetPreferencePage.PROMPT_PARAM_UPDATE_OPTION_IGNORE ); } } } }
Example #26
Source File: PerspectiveHelper.java From gama with GNU General Public License v3.0 | 4 votes |
public static void activateAutoSave(final boolean activate) { // DEBUG.OUT("auto-save activated: " + activate); Workbench.getInstance().setEnableAutoSave(activate); // ApplicationWorkbenchAdvisor.CONFIGURER.setSaveAndRestore(activate); }
Example #27
Source File: BonitaStudioWorkbenchAdvisor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void earlyStartup() { if (PlatformUtil.isHeadless()) { return;//Do not execute earlyStartup in headless mode } final IConfigurationElement[] elements = BonitaStudioExtensionRegistryManager.getInstance() .getConfigurationElements( "org.bonitasoft.studio.common.poststartup"); //$NON-NLS-1$ for (final IConfigurationElement elem : elements) { final Workbench workbench = (Workbench) PlatformUI.getWorkbench(); try { IPostStartupContribution contrib = (IPostStartupContribution) ContextInjectionFactory .make(Platform.getBundle(elem.getDeclaringExtension().getNamespaceIdentifier()) .loadClass(elem.getAttribute("class")), workbench.getContext()); Display.getDefault().asyncExec(contrib::execute); } catch (InjectionException | ClassNotFoundException | InvalidRegistryObjectException e) { BonitaStudioLog.error(e); } } preLoad(); // Fix issue with asciidoctor plugin overriding text content-type final EditorRegistry editorRegistry = (EditorRegistry) WorkbenchPlugin.getDefault().getEditorRegistry(); IFileEditorMapping[] fileEditorMappings = editorRegistry.getFileEditorMappings(); List<IFileEditorMapping> mappings = Stream.of(fileEditorMappings).collect(Collectors.toList()); FileEditorMapping mapping = new FileEditorMapping("*", "log"); mapping.setDefaultEditor(editorRegistry.findEditor("org.eclipse.ui.DefaultTextEditor")); mappings.add(mapping); Display.getDefault().asyncExec(()-> editorRegistry.setFileEditorMappings(mappings.toArray(new FileEditorMapping[] {}))); editorRegistry.setDefaultEditor("*.txt", "org.eclipse.ui.DefaultTextEditor"); final long startupDuration = System.currentTimeMillis() - BonitaStudioApplication.START_TIME; BonitaStudioLog.info("Startup duration : " + DateUtil.getDisplayDuration(startupDuration), ApplicationPlugin.PLUGIN_ID); ApplicationPlugin.getDefault().getPreferenceStore().setDefault(FIRST_STARTUP, true); if (isFirstStartup()) { new OpenReleaseNoteHandler().setFocus(false).asView().openBrowser(); } ApplicationPlugin.getDefault().getPreferenceStore().setValue(FIRST_STARTUP, false); }
Example #28
Source File: RecentFilesContentProvider.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void createContent(Document dom, Element parent) { if (!RepositoryManager.getInstance().hasActiveRepository() || !RepositoryManager.getInstance().getCurrentRepository().isLoaded()) { return; } Element ul = dom.createElement("ul"); parent.appendChild(ul); EditorHistory history = ((Workbench) PlatformUI.getWorkbench()).getEditorHistory(); EditorHistoryItem[] historyItems = history.getItems(); int maxElem = MAX_HISTORY_SIZE; for (int i = 0; i < historyItems.length; i++) { if (maxElem == 0) break; final EditorHistoryItem item = historyItems[i]; if (item.isRestored() || item.restoreState().isOK()) { IEditorInput input = item.getInput(); if(input == null) { break; } IResource resource = input.getAdapter(IResource.class); if (resource != null && resource.isAccessible()) { Element li = dom.createElement("li"); Element a = dom.createElement("a"); a.setAttribute("class", "hover:text-red-600"); a.setAttribute("title", item.getToolTipText()); try { a.setAttribute("href", String.format("http://org.eclipse.ui.intro/runAction?pluginId=%s&class=%s&file=%s", Activator.PLUGIN_ID, OpenEditorFromHistoryItemAction.class.getName(), URLEncoder.encode(item.getName(), "UTF-8"))); } catch (DOMException | UnsupportedEncodingException e) { BonitaStudioLog.error(e); } a.setTextContent(item.getName()); li.appendChild(a); maxElem--; ul.appendChild(li); } } } }