类org.eclipse.ui.internal.Workbench源码实例Demo

下面列出了怎么用org.eclipse.ui.internal.Workbench的API类实例代码及写法,或者点击链接到github查看源代码。

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();
        }

      });
}
 
源代码2 项目: gwt-eclipse-plugin   文件: GWTSettingsTab.java
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);
}
 
源代码3 项目: CppStyle   文件: CppStylePropertyPage.java
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;
}
 
源代码4 项目: birt   文件: DataSetParametersPage.java
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 ) );

		}
	}

}
 
源代码5 项目: bonita-studio   文件: CustomPopupMenuExtender.java
/**
 * 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);
            });
        }
    }
}
 
源代码6 项目: n4js   文件: EclipseUIUtils.java
/** 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;
}
 
源代码7 项目: gwt-eclipse-plugin   文件: BrowserUtilities.java
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;
}
 
源代码8 项目: gwt-eclipse-plugin   文件: GdtPlugin.java
/**
 * 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
  }
}
 
源代码9 项目: sarl   文件: AbstractFileBasedRenamingTest.java
/** 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);
}
 
源代码10 项目: translationstudio8   文件: CommonFunction.java
/**
 * 当删除一个文件时,刷新历史记录	--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();
	}
}
 
源代码11 项目: tmxeditor8   文件: CommonFunction.java
/**
 * 当删除一个文件时,刷新历史记录	--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();
	}
}
 
源代码12 项目: bonita-studio   文件: EditExpressionDialog.java
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"));
}
 
源代码13 项目: bonita-studio   文件: GroovyViewer.java
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;
}
 
源代码14 项目: bonita-studio   文件: GroovySourceViewerFactory.java
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);
}
 
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();
}
 
源代码16 项目: bonita-studio   文件: CommandExecutor.java
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;
}
 
源代码17 项目: bonita-studio   文件: CommandExecutor.java
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;
}
 
源代码18 项目: bonita-studio   文件: CustomPopupMenuExtender.java
private void runCleanUp(Workbench realWorkbench) {
    if (!cleanupNeeded) {
        return;
    }
    cleanupNeeded = false;
    realWorkbench.removeShowingMenus(getMenuIds(), null, null);
    cleanUpContributionCache();
}
 
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);
}
 
源代码20 项目: gama   文件: PerspectiveHelper.java
public static void activateAutoSave(final boolean activate) {
	// DEBUG.OUT("auto-save activated: " + activate);
	Workbench.getInstance().setEnableAutoSave(activate);
	// ApplicationWorkbenchAdvisor.CONFIGURER.setSaveAndRestore(activate);
}
 
源代码21 项目: birt   文件: DataSetParametersPage.java
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 );
			}
		}
			
	}
	
}
 
源代码22 项目: bonita-studio   文件: DeployBDMOperation.java
protected IEclipseContext e4Context() {
    Workbench workbench = (Workbench) PlatformUI.getWorkbench();
    return workbench.getContext();
}
 
源代码23 项目: bonita-studio   文件: DeployBDMOperation.java
protected EHandlerService handlerService() {
    Workbench workbench = (Workbench) PlatformUI.getWorkbench();
    return workbench.getService(EHandlerService.class);
}
 
源代码24 项目: bonita-studio   文件: DeployBDMOperation.java
protected ECommandService commandService() {
    Workbench workbench = (Workbench) PlatformUI.getWorkbench();
    return workbench.getService(ECommandService.class);
}
 
源代码25 项目: bonita-studio   文件: DummyEditorSite.java
@Override
public IWorkbenchWindow getWorkbenchWindow() {
    final IEclipseContext context = ((Workbench) PlatformUI.getWorkbench()).getContext();
    return (IWorkbenchWindow) context.get(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
}
 
源代码26 项目: bonita-studio   文件: EmbeddedEditorSite.java
protected static MWindow getMWindow() {
    Workbench workbench = (Workbench) PlatformUI.getWorkbench();
    WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) workbench.getActiveWorkbenchWindow();
    return activeWorkbenchWindow.getModel();
}
 
@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);
}
 
源代码28 项目: bonita-studio   文件: RecentFilesContentProvider.java
@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);
            }
        }
    }
}
 
 类所在包
 类方法
 同包方法