org.eclipse.ui.PlatformUI#isWorkbenchRunning ( )源码实例Demo

下面列出了org.eclipse.ui.PlatformUI#isWorkbenchRunning ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: n4js   文件: TestedN4JSWorkspace.java
@Override
protected void starting(Description d) {
	name = d.getMethodName();

	assertEmptyIndex();

	IProject[] projects = IResourcesSetupUtil.root().getProjects();
	if (projects.length != 0) {
		Assert.assertEquals(1, projects.length);
		Assert.assertEquals("RemoteSystemsTempFiles", projects[0].getName());
	}

	if (PlatformUI.isWorkbenchRunning()) {
		final IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
		if (introManager.getIntro() != null) {
			Display.getDefault().asyncExec(() -> introManager.closeIntro(introManager.getIntro()));
		}
	}
}
 
源代码2 项目: tesb-studio-se   文件: BundleJavaProcessor.java
@Override
public void generatePom(int option) {
    super.generatePom(option);
    if (option == TalendProcessOptionConstants.GENERATE_IS_MAINJOB) {
        try {
            IRepositoryObject repositoryObject = new RepositoryObject(getProperty());

            // Fix TESB-22660: Avoide to operate repo viewer before it open
            if (PlatformUI.isWorkbenchRunning()) {
                RepositorySeekerManager.getInstance().searchRepoViewNode(getProperty().getId(), false);
            }

            IRunnableWithProgress action = new JavaCamelJobScriptsExportWSAction(repositoryObject, getProperty().getVersion(),
                    "", false);
            action.run(new NullProgressMonitor());
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
 
源代码3 项目: bonita-studio   文件: SourceFileStore.java
private void closeRelatedEditorIfOpened(final ICompilationUnit compilationUnit) throws PartInitException {
    Optional<IWorkbenchPage> activePage = Optional.ofNullable(PlatformUI.getWorkbench().getActiveWorkbenchWindow())
            .map(IWorkbenchWindow::getActivePage);
    if (activePage.isPresent()) {
        if (editorPart != null) {
            if (PlatformUI.isWorkbenchRunning()) {
                activePage.get().closeEditor(editorPart, false);
            }
        } else {
            if (PlatformUI.isWorkbenchRunning()) {
                for (final IEditorReference editorReference : activePage.get().getEditorReferences()) {
                    final IEditorInput editorInput = editorReference.getEditorInput();
                    if (compilationUnit.getResource()
                            .equals(EditorUtil.retrieveResourceFromEditorInput(editorInput))) {
                        activePage.get().closeEditors(new IEditorReference[] { editorReference }, false);
                        break;
                    }
                }
            }
        }
    }
}
 
源代码4 项目: KaiZen-OpenAPI-Editor   文件: Activator.java
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    if (Display.getCurrent() != null && PlatformUI.isWorkbenchRunning()) {
        Bundle bundle = Platform.getBundle(PLUGIN_ID);
        addImage(bundle, Icons.assist_item.name(), "icons/assist_item_16.png");
        addImage(bundle, Icons.template_item.name(), "icons/template_item_16.png");

        // for quick outline, add icons from YEdit
        bundle = Platform.getBundle(org.dadacoalition.yedit.Activator.PLUGIN_ID);
        addImage(bundle, Icons.outline_document.name(), "icons/outline_document.gif");
        addImage(bundle, Icons.outline_mapping.name(), "icons/outline_mapping.gif");
        addImage(bundle, Icons.outline_scalar.name(), "icons/outline_scalar.gif");
        addImage(bundle, Icons.outline_mapping_scalar.name(), "icons/outline_mappingscalar.gif");
        addImage(bundle, Icons.outline_sequence.name(), "icons/outline_sequence.png");
    }
}
 
源代码5 项目: workspacemechanic   文件: ShowViewScanner.java
public boolean evaluate() {
  if (!PlatformUI.isWorkbenchRunning()) {
    return true;
  }
  final IWorkbench workbench = PlatformUI.getWorkbench();
  if (workbench == null) {
    return true;
  }

  final Set<String> remaining = Sets.newHashSet(list);
  Display.getDefault().syncExec(new Runnable() {
    public void run() {
      for (IWorkbenchWindow workbenchWindow : workbench.getWorkbenchWindows()) {
        for (IWorkbenchPage workbenchPage : workbenchWindow.getPages()) {
          for (IViewReference viewReference : workbenchPage.getViewReferences()) {
            remaining.remove(viewReference.getId());
          }
        }
      }
    }
  });
  return remaining.isEmpty();
}
 
源代码6 项目: KaiZen-OpenAPI-Editor   文件: Activator.java
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    if (Display.getCurrent() != null && PlatformUI.isWorkbenchRunning()) {
        Bundle bundle = Platform.getBundle(PLUGIN_ID);
  
        // for quick outline, add icons from YEdit
        bundle = Platform.getBundle(org.dadacoalition.yedit.Activator.PLUGIN_ID);
        addImage(bundle, Icons.outline_document.name(), "icons/outline_document.gif");
        addImage(bundle, Icons.outline_mapping.name(), "icons/outline_mapping.gif");
        addImage(bundle, Icons.outline_scalar.name(), "icons/outline_scalar.gif");
        addImage(bundle, Icons.outline_mapping_scalar.name(), "icons/outline_mappingscalar.gif");
        addImage(bundle, Icons.outline_sequence.name(), "icons/outline_sequence.png");
    }
}
 
源代码7 项目: tesb-studio-se   文件: RunContainerProcessor.java
@Override
public void generatePom(int option) {
    super.generatePom(option);

    if (option == TalendProcessOptionConstants.GENERATE_IS_MAINJOB
            && ComponentCategory.CATEGORY_4_CAMEL.getName().equals(getProcess().getComponentsType())) {
        try {
            IRepositoryObject repositoryObject = new RepositoryObject(getProperty());

            // Fix TESB-22660: Avoide to operate repo viewer before it open
            if (PlatformUI.isWorkbenchRunning()) {
                RepositorySeekerManager.getInstance().searchRepoViewNode(getProperty().getId(), false);
            }

            IRunnableWithProgress action = new JavaCamelJobScriptsExportWSAction(repositoryObject, getProperty().getVersion(),
                    "", false);
            action.run(new NullProgressMonitor());
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
 
protected ImageRegistry createImageRegistry() {
    // If we are in the UI Thread use that
    if (Display.getDefault() != null) {
        return new ImageRegistry(Display.getDefault());
    }

    if (PlatformUI.isWorkbenchRunning()) {
        return new ImageRegistry(PlatformUI.getWorkbench().getDisplay());
    }

    // Invalid thread access if it is not the UI Thread
    // and the workbench is not created.
    throw new SWTError(SWT.ERROR_THREAD_INVALID_ACCESS);
}
 
源代码9 项目: nebula   文件: MyLib.java
public static void popup(final String title, final String message) {
   if (!PlatformUI.isWorkbenchRunning()) {
      MyLog.log(Activator.class, Level.SEVERE, message);
   } else {
ensureInDisplayThread(() -> {
	MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title,
			message);
});
    }
}
 
源代码10 项目: typescript.java   文件: TypeScriptUIPlugin.java
public ITypeScriptConsole getInstallTypesConsole() {
	if (!PlatformUI.isWorkbenchRunning()) {
		return null;
	}
	InstallTypesConsole console = InstallTypesConsole.getConsole();
	TypeScriptConsoleHelper.showConsole(console);
	return console;
}
 
源代码11 项目: typescript.java   文件: JSDTEditorTracker.java
private void init() {
	if (PlatformUI.isWorkbenchRunning()) {
		IWorkbench workbench = JSDTTypeScriptUIPlugin.getDefault().getWorkbench();
		if (workbench != null) {
			IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
			for (IWorkbenchWindow window : windows) {
				windowOpened(window);
			}
			JSDTTypeScriptUIPlugin.getDefault().getWorkbench().addWindowListener(this);
		}
	}
}
 
源代码12 项目: typescript.java   文件: TypeScriptUIPlugin.java
public ITypeScriptConsole getConsole(IIDETypeScriptProject project) {
	if (project.isServerDisposed()) {
		return null;
	}
	if (!PlatformUI.isWorkbenchRunning()) {
		return null;
	}
	TypeScriptConsole console = TypeScriptConsole.getOrCreateConsole(project);
	TypeScriptConsoleHelper.showConsole(console);
	return console;
}
 
源代码13 项目: bonita-studio   文件: EditorFinder.java
public static Optional<IEditorPart> findOpenedEditor(Function<IEditorPart, Boolean> editorInstanceValidator) {
    if (PlatformUI.isWorkbenchRunning()
            && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
            && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
        return Arrays.asList(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences())
                .stream()
                .map(ref -> ref.getEditor(false))
                .filter(editorInstanceValidator::apply)
                .findFirst();
    }
    return Optional.empty();
}
 
源代码14 项目: elexis-3-core   文件: Log.java
/**
 * Eine Log-Nachricht ausgeben.
 * 
 * @param message
 *            die Nachricht
 * @param level
 *            der level
 */
public void log(String message, int level){
	if (out == null)
		out = LoggerFactory.getLogger(Log.class);
	synchronized (out) {
		String type = "unknown"; //$NON-NLS-1$
		if (level > 0 && level < Levels.length)
			type = Levels[level];
		switch (level) {
		case NOTHING:
			break;
		case SYNCMARK:
			out.info("SYNC: " + message);
			break;
		case FATALS: // slf4j does not know fatal. Use error instead
		case ERRORS:
			out.error(message);
			break;
		case WARNINGS:
			out.error(message);
			break;
		case INFOS:
			out.trace(message);
			break;
		case DEBUGMSG:
			out.debug(message);
			break;
		default:
			out.debug(message);
			break;
		}
		if (level <= LogLevel) {
			if (level <= alertLevel && PlatformUI.isWorkbenchRunning()) {
				if (level != SYNCMARK) {
					if (doAlert == null) {
						doAlert = UiDesk.getTopShell();
					}
					lastError =
						new StringBuilder().append(" |").append(type).append("| - ")
							.append(prefix).append(": ").append(message).toString();
					if (doAlert != null) {
						UiDesk.asyncExec(new Runnable() {
							public void run(){
								MessageBox msg =
									new MessageBox(doAlert, SWT.ICON_ERROR | SWT.OK);
								msg.setMessage(lastError);
								msg.open();
							}
						});
						
					}
				}
			}
		}
	}
}
 
源代码15 项目: nebula   文件: XViewerDisplay.java
/**
 * @return true if this xviewer is embedded in Eclipse workbench and it's running
 */
public static boolean isWorkbenchRunning() {
   return PlatformUI.isWorkbenchRunning();
}
 
源代码16 项目: goclipse   文件: ToolsConsole.java
public boolean isIgnorinCommands() {
	return !PlatformUI.isWorkbenchRunning() && DevelopmentCodeMarkers.TESTS_MODE;
}
 
public void configureLanguageSpecificURIEditorOpener(Binder binder) {
	if (PlatformUI.isWorkbenchRunning()) {
		binder.bind(IURIEditorOpener.class).annotatedWith(LanguageSpecific.class).to(DerivedMemberAwareEditorOpener.class);
		binder.bind(IDerivedMemberAwareEditorOpener.class).to(DerivedMemberAwareEditorOpener.class);
	}
}
 
源代码18 项目: bonita-studio   文件: BonitaStudioApplication.java
protected boolean isWorkbenchRunning() {
    return PlatformUI.isWorkbenchRunning();
}
 
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  try {
    IProject project = getSelectedProject(event);

    if (PlatformUI.isWorkbenchRunning()) {
      if (!PlatformUI.getWorkbench().saveAllEditors(true)) {
        return null;
      }
      if (getWorkspace(event).isAutoBuilding()) {
        Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
      }
    }
    Shell shell = HandlerUtil.getActiveShell(event);
    if (project != null && !checkProjectErrors(project)) {
      MessageDialog.openInformation(
          shell,
          Messages.getString("build.error.dialog.title"),
          Messages.getString("build.error.dialog.message"));
      return null;
    }
    if (!checkProject(shell, project)) {
      return null;
    }

    IGoogleLoginService loginService = ServiceUtils.getService(event, IGoogleLoginService.class);
    IGoogleApiFactory googleApiFactory = ServiceUtils.getService(event, IGoogleApiFactory.class);
    DeployPreferencesDialog dialog =
        newDeployPreferencesDialog(shell, project, loginService, googleApiFactory);
    if (dialog.open() == Window.OK) {
      launchDeployJob(project, dialog.getCredential());
    }
    // return value must be null, reserved for future use
    return null;
  } catch (CoreException | IOException | InterruptedException exception) {
    throw new ExecutionException(
        Messages.getString("deploy.failed.error.message"), exception); //$NON-NLS-1$
  } catch (OperationCanceledException ex) {
    /* ignore */
    return null;
  }
}
 
源代码20 项目: bonita-studio   文件: UIDesignerServerManager.java
@Override
public void projectClosed(Repository repository, IProgressMonitor monitor) {
    if (PlatformUI.isWorkbenchRunning()) {
        stop();
    }
}