类org.eclipse.ui.IWorkbench源码实例Demo

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

@Override
public void run() {
	IWorkbench workbench= JavaPlugin.getDefault().getWorkbench();
	IWorkbenchWindow window= workbench.getActiveWorkbenchWindow();
	IWorkbenchPage page= window.getActivePage();
	IAdaptable input;
	if (page != null)
		input= page.getInput();
	else
		input= ResourcesPlugin.getWorkspace().getRoot();
	try {
		workbench.showPerspective(JavaUI.ID_PERSPECTIVE, window, input);
	} catch (WorkbenchException e) {
		ExceptionHandler.handle(e, window.getShell(),
			ActionMessages.OpenJavaPerspectiveAction_dialog_title,
			ActionMessages.OpenJavaPerspectiveAction_error_open_failed);
	}
}
 
源代码2 项目: tesb-studio-se   文件: RefactorRenameHandler.java
public boolean isEnabled() {
	if (!handler.isEnabled()) {
		return false;
	}
	// disable the command when editor is readonly.
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench == null) {
		return false;
	}
	IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
	if (window == null) {
		return false;
	}
	IWorkbenchPage activePage = window.getActivePage();
	if (activePage == null) {
		return false;
	}
	IEditorPart activeEditor = activePage.getActiveEditor();
	if (activeEditor != null && activeEditor instanceof LocalWSDLEditor) {
		LocalWSDLEditor wsdlEditor = (LocalWSDLEditor) activeEditor;
		return !wsdlEditor.isEditorInputReadOnly();
	}
	return false;
}
 
源代码3 项目: IndentGuide   文件: Starter.java
public void earlyStartup() {
	PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
		public void run() {
			IWorkbench workbench = PlatformUI.getWorkbench();
			IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
			if (window != null) {
				IWorkbenchPage page = window.getActivePage();
				if (page != null) {
					IEditorPart part = page.getActiveEditor();
					if (part != null) {
						addListener(part);
					}
				}
				window.getPartService().addPartListener(new PartListener());
			}
			workbench.addWindowListener(new WindowListener());
		}
	});
}
 
源代码4 项目: tlaplus   文件: UIHelper.java
/**
 * Opens the new window containing the new perspective
 * 
 * @param perspectiveId
 *            new perspective
 * @param input
 *            IAdaptable, or null if no input
 * @return IWorkbenchWindow instance
 * 
 */
public static IWorkbenchWindow openPerspectiveInNewWindow(String perspectiveId, IAdaptable input) {
	IWorkbench workbench = Activator.getDefault().getWorkbench();
	IWorkbenchWindow window = null;
	try {
		// avoids flicking, from implementation above
		window = workbench.openWorkbenchWindow(perspectiveId, input);

		// show intro
		if (InitialPerspective.ID.equals(perspectiveId) && workbench.getIntroManager().hasIntro()) {
			// IIntroPart intro =
			workbench.getIntroManager().showIntro(window, true);
		}

	} catch (WorkbenchException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return window;
}
 
源代码5 项目: n4js   文件: ADocSpecExportWizard.java
@Override
public void init(IWorkbench targetWorkbench, IStructuredSelection currentSelection) {
	this.selection = currentSelection;

	List<?> selectedResources = IDE.computeSelectedResources(currentSelection);
	if (!selectedResources.isEmpty()) {
		this.selection = new StructuredSelection(selectedResources);
	}

	setWindowTitle("AsciiDoc Specification Export");
	setNeedsProgressMonitor(true);

	configAdocPage = new SpecConfigAdocPage("Configuration Page");
	processAdocPage = new SpecProcessPage("Process Page");
	comparePage = new SpecComparePage("Compare Page", "Adoc");
	summaryPage = new SpecExportCodeSummaryPage("Summary Page");
	processOutputPage = new SpecProcessPage("Process Page");

	taskGenAdoc = new TaskGenerateAdoc(jsDoc2SpecProcessor, resourceSetProvider, n4JSCore, selection,
			configAdocPage, processAdocPage);
	taskWriteFiles = new TaskWriteFiles(processOutputPage, taskGenAdoc);

	addVisibilityListeners();
}
 
源代码6 项目: tracecompass   文件: TmfOpenTraceHelper.java
/**
 * Returns the editor with the specified input. Returns null if there is no
 * opened editor with that input. If restore is requested, the method finds and
 * returns the editor even if it is not restored yet after a restart.
 *
 * @param input
 *            the editor input
 * @param restore
 *            true if the editor should be restored
 * @return an editor with input equals to <code>input</code>
 */
private static IEditorPart findEditor(IEditorInput input, boolean restore) {
    final IWorkbench wb = PlatformUI.getWorkbench();
    final IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage();
    for (IEditorReference editorReference : activePage.getEditorReferences()) {
        try {
            IEditorInput editorInput = editorReference.getEditorInput();
            if (editorInput.equals(input)) {
                return editorReference.getEditor(restore);
            }
        } catch (PartInitException e) {
            // do nothing
        }
    }
    return null;
}
 
源代码7 项目: olca-app   文件: Navigator.java
/**
 * 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;
}
 
源代码8 项目: translationstudio8   文件: KeyAssistHandler.java
public Object execute(ExecutionEvent event) throws ExecutionException {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
	BindingService service = (BindingService) bindingService;
	ArrayList<Binding> lstBinding = new ArrayList<Binding>(Arrays.asList(bindingService.getBindings()));
	List<String> lstRemove = Constants.lstRemove;
	Iterator<Binding> it = lstBinding.iterator();
	while (it.hasNext()) {
		Binding binding = it.next();
		ParameterizedCommand pCommand = binding.getParameterizedCommand();
		if (pCommand == null || lstRemove.contains(pCommand.getCommand().getId())) {
			it.remove();
		}
	}
	service.getKeyboard().openKeyAssistShell(lstBinding);
	return null;
}
 
源代码9 项目: EasyShell   文件: Utils.java
private static void executeCommand(IWorkbench workbench, String commandName, Map<String, Object> params) {
    if (workbench == null) {
        workbench = PlatformUI.getWorkbench();
    }
    // get command
    ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class);
    Command command = commandService != null ? commandService.getCommand(commandName) : null;
    // get handler service
    //IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class);
    //TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open");
    IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class);
    if (command != null && handlerService != null) {
        ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params);
        try {
            handlerService.executeCommand(paramCommand, null);
        } catch (Exception e) {
            Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true);
        }
    }
}
 
源代码10 项目: APICloud-Studio   文件: UIUtils.java
/**
 * Opens the internal help in the Studio's internal browser.
 * 
 * @param url
 * @return A boolean value indicating a successful operations or not.
 */
public static boolean openHelpInBrowser(String url)
{
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench != null)
	{
		IWorkbenchHelpSystem helpSystem = workbench.getHelpSystem();
		URL resolvedURL = helpSystem.resolve(url, true);
		if (resolvedURL != null)
		{
			return openInBroswer(resolvedURL, true, IWorkbenchBrowserSupport.AS_EDITOR
					| IWorkbenchBrowserSupport.STATUS);
		}
		else
		{
			IdeLog.logError(UIPlugin.getDefault(), "Unable to resolve the Help URL for " + url); //$NON-NLS-1$
			return false;
		}
	}
	return false;
}
 
源代码11 项目: google-cloud-eclipse   文件: WorkbenchStartup.java
@Override
public void earlyStartup() {
  final IWorkbench workbench = PlatformUI.getWorkbench();
  GcpStatusMonitoringService service = workbench.getService(GcpStatusMonitoringService.class);
  if (service != null) {
    service.addStatusChangeListener(
        result -> {
          ICommandService commandService = workbench.getService(ICommandService.class);
          if (commandService != null) {
            commandService.refreshElements(
                "com.google.cloud.tools.eclipse.ui.status.showGcpStatus", null);
          }
        });
  }
}
 
源代码12 项目: elexis-3-core   文件: UserCasePreferences.java
public void init(IWorkbench workbench){
	getPreferenceStore().setValue(Preferences.USR_DEFCASELABEL, Fall.getDefaultCaseLabel());
	getPreferenceStore().setValue(Preferences.USR_DEFCASEREASON, Fall.getDefaultCaseReason());
	getPreferenceStore().setValue(Preferences.USR_DEFLAW, Fall.getDefaultCaseLaw());
	// read the sorting for this user form prefs, convert to LinkedList for editing
	String topItemsSortingStr = CoreHub.userCfg.get(Preferences.USR_TOPITEMSSORTING, "");
	String[] topItemsSorting = topItemsSortingStr.split(PREFSDELIMITER_REGEX);
	topItemsLinkedList = new LinkedList<String>(Arrays.asList(topItemsSorting));
}
 
源代码13 项目: APICloud-Studio   文件: CommonEditorPlugin.java
private void removePartListener()
{
	IWorkbench workbench = null;
	try
	{
		workbench = PlatformUI.getWorkbench();
	}
	catch (Exception e)
	{
		// ignore, may be running headless, like in tests
	}
	if (workbench != null)
	{
		IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
		IPartService partService;
		for (IWorkbenchWindow window : windows)
		{
			partService = window.getPartService();
			if (partService != null)
			{
				partService.removePartListener(fPartListener);
			}
			window.removePerspectiveListener(fPerspectiveListener);
		}
		PlatformUI.getWorkbench().removeWindowListener(fWindowListener);
	}
}
 
源代码14 项目: olca-app   文件: ExportWizard.java
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
	setWindowTitle(M.ILCDNetworkExport);
	setDefaultPageImageDescriptor(RcpActivator.imageDescriptorFromPlugin(
			RcpActivator.PLUGIN_ID, "/icons/network_wiz.png"));
	setNeedsProgressMonitor(true);
	selectionPage = new ExportWizardPage();
}
 
@Before
public void setUp() {
  evaluationService = mock( IEvaluationService.class );
  workbench = mock( IWorkbench.class );
  when( workbench.getService( IEvaluationService.class ) ).thenReturn( evaluationService );
  preferences = new WorkspaceScopePreferences( new PreferenceStore() );
  action = new CloseJUnitStatusAction( workbench, preferences );
}
 
源代码16 项目: neoscada   文件: SecurityModelWizard.java
/**
 * This just records the information.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void init ( IWorkbench workbench, IStructuredSelection selection )
{
    this.workbench = workbench;
    this.selection = selection;
    setWindowTitle ( SecurityEditorPlugin.INSTANCE.getString ( "_UI_Wizard_label" ) ); //$NON-NLS-1$
    setDefaultPageImageDescriptor ( ExtendedImageRegistry.INSTANCE.getImageDescriptor ( SecurityEditorPlugin.INSTANCE.getImage ( "full/wizban/NewSecurity" ) ) ); //$NON-NLS-1$
}
 
源代码17 项目: dawnsci   文件: TestUtils.java
/**
 * @return IWorkbenchPage
 */
public static IWorkbenchPage getDefaultPage() {
	final IWorkbench bench = PlatformUI.getWorkbench();
	if (bench==null) return null;
	final IWorkbenchWindow[] windows = bench.getWorkbenchWindows();
	if (windows==null) return null;
	
	return windows[0].getActivePage();
}
 
源代码18 项目: xtext-xtend   文件: AbstractSwtBotTest.java
@Before
public final void checkNotRunninginUiThread () {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench.getDisplay().getThread() == Thread.currentThread()) {
		Assert.fail("This test MUST NOT RUN in SWT's UI thread. Please check the 'Run in UI thread' option of your launch config or build configuration!");
	}
}
 
源代码19 项目: codeexamples-eclipse   文件: Application.java
@Override
public void stop() {
	if (!PlatformUI.isWorkbenchRunning())
		return;
	final IWorkbench workbench = PlatformUI.getWorkbench();
	final Display display = workbench.getDisplay();
	display.syncExec(new Runnable() {
		@Override
		public void run() {
			if (!display.isDisposed())
				workbench.close();
		}
	});
}
 
/**
 * This just records the information.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void init(IWorkbench workbench, IStructuredSelection selection) {
	this.workbench = workbench;
	this.selection = selection;
	setWindowTitle(BeansEditorPlugin.INSTANCE.getString("_UI_Wizard_label"));
	setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(BeansEditorPlugin.INSTANCE.getImage("full/wizban/NewBeans")));
}
 
源代码21 项目: neoscada   文件: GlobalizeModelWizard.java
/**
 * This just records the information.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void init ( IWorkbench workbench, IStructuredSelection selection )
{
    this.workbench = workbench;
    this.selection = selection;
    setWindowTitle ( GlobalizeEditorPlugin.INSTANCE.getString ( "_UI_Wizard_label" ) ); //$NON-NLS-1$
    setDefaultPageImageDescriptor ( ExtendedImageRegistry.INSTANCE.getImageDescriptor ( GlobalizeEditorPlugin.INSTANCE.getImage ( "full/wizban/NewGlobalize" ) ) ); //$NON-NLS-1$
}
 
源代码22 项目: gama   文件: Application.java
@Override
public void stop() {
	final IWorkbench workbench = PlatformUI.getWorkbench();
	if ( workbench == null ) { return; }
	final Display display = workbench.getDisplay();
	display.syncExec(() -> {
		if ( !display.isDisposed() ) {
			workbench.close();
		}
	});
}
 
源代码23 项目: Pydev   文件: DebuggerTestUtils.java
/**
 * Creates a run in debug mode for the debug editor
 */
public void launchEditorInDebug() {
    final IWorkbench workBench = PydevPlugin.getDefault().getWorkbench();
    Display display = workBench.getDisplay();

    // Make sure to run the UI thread.
    display.syncExec(new Runnable() {
        @Override
        public void run() {
            JythonLaunchShortcut launchShortcut = new JythonLaunchShortcut();
            launchShortcut.launch(debugEditor, "debug");
        }
    });
}
 
源代码24 项目: APICloud-Studio   文件: FilenameDifferentiator.java
public void dispose()
{
	IWorkbench workbench = null;
	try
	{
		workbench = PlatformUI.getWorkbench();
	}
	catch (Exception e)
	{
		// ignore
	}

	if (workbench != null)
	{
		IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
		if (window != null)
		{
			IWorkbenchPage page = window.getActivePage();
			if (page != null)
			{
				page.removePartListener(this);
			}
		}
	}
	if (baseNames != null)
	{
		baseNames.clear();
		baseNames = null;
	}
}
 
源代码25 项目: google-cloud-eclipse   文件: WorkbenchUtil.java
/**
 * Open the specified file in the editor.
 *
 * @param workbench the active workbench
 * @param file the file to open
 */
public static IEditorPart openInEditor(IWorkbench workbench, IFile file) {
  IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
  if (window != null && file != null) {
    IWorkbenchPage page = window.getActivePage();
    try {
      return IDE.openEditor(page, file, true);
    } catch (PartInitException ex) {
      // ignore; we don't have to open the file
    }
  }
  return null;
}
 
源代码26 项目: elexis-3-core   文件: FindingsSettings.java
@Override
public void init(IWorkbench workbench){
	setPreferenceStore(new SettingsPreferenceStore(CoreHub.globalCfg));
	setMessage("Globale Befunde Einstellungen");
	// initialize the model
	if (FindingsServiceComponent.getService() != null) {
		FindingsServiceComponent.getService().findById("", IObservation.class);
	} else {
		getLogger().warn("FindingsService is null - not found.");
		setErrorMessage("Befunde Service konnte nicht geladen werden.");
	}
}
 
源代码27 项目: tracecompass   文件: ImportTraceWizard.java
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
    fSelection = selection;

    setWindowTitle(Messages.ImportTraceWizard_DialogTitle);
    setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH));
    setNeedsProgressMonitor(true);
}
 
源代码28 项目: aCute   文件: DotnetExportWizard.java
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
	setWindowTitle(Messages.DotnetExportWizard_exportProject);

	Iterator<Object> selectionIterator = selection.iterator();
	IFile projectFile = null;

	while (selectionIterator.hasNext() && projectFile == null) {
		IResource resource = (IResource) selectionIterator.next();
		projectFile = getProjectFile(resource.getProject());
	}
	wizardPage = new DotnetExportWizardPage(projectFile);
}
 
源代码29 项目: APICloud-Studio   文件: TeamAction.java
/**
 * Convenience method for getting the current shell.
 * 
 * @return the shell
 */
public Shell getShell() {
	if (shell != null) {
		return shell;
	} else {
		IWorkbench workbench = SVNUIPlugin.getPlugin().getWorkbench();
		if (workbench == null) return null;
		IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
		if (window == null) return null;
		return window.getShell();
	}
}
 
源代码30 项目: translationstudio8   文件: KeyController2.java
@SuppressWarnings("restriction")
public void filterDupliteBind(){
	IWorkbench workbench = PlatformUI.getWorkbench();
	IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
	BindingService service =(BindingService)bindingService;
	BindingManager bindingManager = service.getBindingManager();
	//service.getBindingManager().
	Binding[] bindings = bindingManager.getBindings();
     List<Binding> bindTemp = new ArrayList<Binding>();
     List<String> ids = new ArrayList<String>();
     for(Binding bind : bindings){
		if(null ==bind){
			continue;
		}
		ParameterizedCommand command = bind.getParameterizedCommand();
		if(null == command){
			continue;
		}
		String id = command.getId();
		if(!ids.contains(id)){
			ids.add(id);
			bindTemp.add(bind);
		}
	}
   
     bindingManager.setBindings(bindTemp.toArray(new Binding[ids.size()]));
}
 
 类所在包
 同包方法