当前位置: 首页>>代码示例>>Java>>正文


Java Platform.isRunning方法代码示例

本文整理汇总了Java中org.eclipse.core.runtime.Platform.isRunning方法的典型用法代码示例。如果您正苦于以下问题:Java Platform.isRunning方法的具体用法?Java Platform.isRunning怎么用?Java Platform.isRunning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.runtime.Platform的用法示例。


在下文中一共展示了Platform.isRunning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: collectRegisteredProviders

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private static Builder<DefaultQuickfixProvider> collectRegisteredProviders() {
	final Builder<DefaultQuickfixProvider> builder = ImmutableList.<DefaultQuickfixProvider> builder();
	if (Platform.isRunning()) {
		final IConfigurationElement[] elements = getQuickfixSupplierElements();
		for (final IConfigurationElement element : elements) {
			try {
				final Object extension = element.createExecutableExtension(CLAZZ_PROPERTY_NAME);
				if (extension instanceof QuickfixProviderSupplier) {
					builder.add(((QuickfixProviderSupplier) extension).get());
				}
			} catch (final CoreException e) {
				LOGGER.error("Error while instantiating quickfix provider supplier instance.", e);
			}
		}
	}
	return builder;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:DelegatingQuickfixProvider.java

示例2: iterator

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
public Iterator<URI> iterator(IN4JSSourceContainer sourceContainer) {
	if (sourceContainer.isLibrary()) {
		return workspace.getArchiveIterator(sourceContainer.getLibrary().getLocation(),
				sourceContainer.getRelativeLocation());
	} else {
		if (sourceContainer.getProject().isExternal() && Platform.isRunning()) {
			// The `Platform.isRunning()` is not valid check for the OSGI headless compiler
			// it may still be valid in some scenarios (maybe some test scenarios)
			if (externalLibraryWorkspace instanceof NoopExternalLibraryWorkspace
					&& workspace instanceof FileBasedWorkspace
					&& workspace.findProjectWith(sourceContainer.getLocation()) != null) {
				return workspace.getFolderIterator(sourceContainer.getLocation());
			}

			return externalLibraryWorkspace.getFolderIterator(sourceContainer.getLocation());
		}
		return workspace.getFolderIterator(sourceContainer.getLocation());
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:N4JSModel.java

示例3: collectExternalProjectDependents

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Sugar for collecting {@link IWorkspace Eclipse workspace} projects that have any direct dependency to any
 * external projects. Same as {@link #collectExternalProjectDependents()} but does not consider all the available
 * projects but only those that are given as the argument.
 *
 * @param externalProjects
 *            the external projects that has to be considered as a possible dependency of an Eclipse workspace based
 *            project.
 * @return a map where each entry maps an external project to the workspace projects that depend on it.
 */
public Map<IProject, Collection<IProject>> collectExternalProjectDependents(
		final Iterable<? extends IProject> externalProjects) {
	final Multimap<IProject, IProject> mapping = Multimaps2.newLinkedHashListMultimap();

	if (Platform.isRunning()) {

		final Map<String, IProject> externalsMapping = new HashMap<>();
		externalProjects.forEach(p -> externalsMapping.put(p.getName(), p));

		asList(getWorkspace().getRoot().getProjects()).forEach(p -> {
			getDirectExternalDependencyIds(p).forEach(eID -> {
				IProject externalDependency = externalsMapping.get(eID);
				if (externalDependency != null) {
					mapping.put(externalDependency, p);
				}
			});
		});

	}

	return mapping.asMap();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:33,代码来源:ExternalProjectsCollector.java

示例4: writeLogsOnFileAndConsole

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private void writeLogsOnFileAndConsole() {
loggers.debug("****Configuring Logger****");
      try {
      	if(Platform.isRunning()){
      	    System.setProperty(HYDROGRAPH_INSTALLATION_LOCATION, Platform.getInstallLocation().getURL().getPath());
           ClassLoader loader = new URLClassLoader(new URL[]
           		{new File(Platform.getInstallLocation().getURL().getPath() + LOG_DIR).toURI().toURL()});
           LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
           URL url = Loader.getResource(CLASSIC_FILE, loader);
           if (url != null) {
               JoranConfigurator configurator = new JoranConfigurator();
               configurator.setContext(lc);
               lc.reset();
               configurator.doConfigure(url);
               lc.start();
           }
           loggers.debug("****Logger Configured Successfully****");
      	}
      } catch(MalformedURLException|JoranException exception){
      	loggers.error("Failed to configure the logger {}", exception);
      } 
  }
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:23,代码来源:LogFactory.java

示例5: initialize

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Initializes the extensions map.
 * 
 * @throws CoreException
 *             if the registry cannot be initialized
 */
public void initialize() {
  try {
	if (Platform.isRunning()) {
		registry.clear();
		final IExtension[] extensions = Platform.getExtensionRegistry()
				.getExtensionPoint(OCCIE_EXTENSION_POINT).getExtensions();
		for (int i = 0; i < extensions.length; i++) {
			final IConfigurationElement[] configElements = extensions[i]
					.getConfigurationElements();
			for (int j = 0; j < configElements.length; j++) {
				String scheme = configElements[j].getAttribute("scheme"); //$NON-NLS-1$
				String uri = "platform:/plugin/" + extensions[i].getContributor().getName() + "/" + configElements[j].getAttribute("file"); //$NON-NLS-1$
				registerExtension(scheme, uri);
			}
		}
	}
  } catch(NoClassDefFoundError ncdfe) {
	  LOGGER.info("  Running out of an Eclipse Platform...");
  }
}
 
开发者ID:occiware,项目名称:OCCI-Studio,代码行数:27,代码来源:OcciRegistry.java

示例6: registerExtensions

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Register extensions manually. This method should become obsolete when extension point fully works in headless
 * case.
 */
public void registerExtensions() {
	// Wire registers related to the extension points
	// in non-OSGI mode extension points are not automatically populated
	if (!Platform.isRunning()) {
		runnerRegistry.register(nodeRunnerDescriptorProvider.get());
		testerRegistry.register(nodeTesterDescriptorProvider.get());
	}

	// Register file extensions
	registerTestableFiles(N4JSGlobals.N4JS_FILE_EXTENSION, N4JSGlobals.N4JSX_FILE_EXTENSION);
	registerRunnableFiles(N4JSGlobals.N4JS_FILE_EXTENSION, N4JSGlobals.JS_FILE_EXTENSION,
			N4JSGlobals.N4JSX_FILE_EXTENSION, N4JSGlobals.JSX_FILE_EXTENSION);
	registerTranspilableFiles(N4JSGlobals.N4JS_FILE_EXTENSION, N4JSGlobals.N4JSX_FILE_EXTENSION,
			N4JSGlobals.JS_FILE_EXTENSION, N4JSGlobals.JSX_FILE_EXTENSION);
	registerTypableFiles(N4JSGlobals.N4JSD_FILE_EXTENSION, N4JSGlobals.N4JS_FILE_EXTENSION,
			N4JSGlobals.N4JSX_FILE_EXTENSION, N4JSGlobals.JS_FILE_EXTENSION,
			N4JSGlobals.JSX_FILE_EXTENSION);
	registerRawFiles(N4JSGlobals.JS_FILE_EXTENSION, N4JSGlobals.JSX_FILE_EXTENSION);

	// Register ECMAScript subgenerator
	subGeneratorRegistry.register(ecmaScriptSubGenerator, N4JSGlobals.N4JS_FILE_EXTENSION);
	subGeneratorRegistry.register(ecmaScriptSubGenerator, N4JSGlobals.JS_FILE_EXTENSION);
	subGeneratorRegistry.register(ecmaScriptSubGenerator, N4JSGlobals.N4JSX_FILE_EXTENSION);
	subGeneratorRegistry.register(ecmaScriptSubGenerator, N4JSGlobals.JSX_FILE_EXTENSION);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:30,代码来源:HeadlessExtensionRegistrationHelper.java

示例7: loadXpectConfiguration

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Load Xpect configuration
 */
private void loadXpectConfiguration(
		org.eclipse.xpect.setup.ISetupInitializer<Object> init, FileSetupContext fileSetupContext) {
	if (Platform.isRunning()) {
		readOutConfiguration = new ReadOutWorkspaceConfiguration(fileSetupContext, core, fileExtensionProvider);
	} else {
		readOutConfiguration = new ReadOutResourceSetConfiguration(fileSetupContext, core);
	}
	init.initialize(readOutConfiguration);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:13,代码来源:XpectN4JSES5TranspilerHelper.java

示例8: ensureInitialized

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private synchronized void ensureInitialized() {
	if (!initialized) {
		if (!Platform.isRunning()) {
			LOGGER.warn(
					"You appear to be running outside Eclipse; you might want to remove the jar org.eclipse.xtext.logging*.jar from your classpath and supply your own log4j.properties.");
		} else {
			log = Platform.getLog(Platform.getBundle(LOG4J_BUNDLE_NAME));
		}
		initialized = true;
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:EclipseLogAppender.java

示例9: init

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Initializes the backing cache with the cache loader and registers a {@link ProjectStateChangeListener} into the
 * workspace.
 */
@Inject
public void init() {
	projectCache = CacheBuilder.newBuilder().build(cacheLoader);
	if (Platform.isRunning()) {
		getWorkspace().addResourceChangeListener(projectStateChangeListener);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:12,代码来源:EclipseExternalLibraryWorkspace.java

示例10: getAllEclipseWorkspaceProjectNames

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private Collection<String> getAllEclipseWorkspaceProjectNames() {
	if (Platform.isRunning()) {
		return from(Arrays.asList(getWorkspace().getRoot().getProjects()))
				.filter(p -> p.isAccessible())
				.transform(p -> p.getName())
				.toSet();
	}
	return emptyList();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:EclipseExternalLibraryWorkspace.java

示例11: log

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Logs the given status to the platform log. Has no effect if the platform is not running or the bundle cannot be
 * found.
 *
 * @param status
 *            the status to log.
 */
public static void log(final IStatus status) {
	if (null != status && Platform.isRunning() && null != context) {
		final Bundle bundle = context.getBundle();
		if (null != bundle) {
			Platform.getLog(bundle).log(status);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:ExternalLibrariesActivator.java

示例12: cleanBuildDependencies

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private void cleanBuildDependencies(final IProgressMonitor monitor, final MultiStatus status,
		final Iterable<java.net.URI> toBeDeleted, final Collection<File> adaptedPackages,
		boolean triggerCleanbuild) {

	logger.logInfo("Registering new projects... [step 4 of 4]");
	monitor.setTaskName("Registering new projects... [step 4 of 4]");
	// nothing to do in the headless case. TODO inject logic instead?
	if (Platform.isRunning()) {
		logger.logInfo("Platform is running.");
		final Iterable<java.net.URI> toBeUpdated = from(adaptedPackages).transform(file -> file.toURI());
		final NpmProjectAdaptionResult adaptionResult = NpmProjectAdaptionResult.newOkResult(toBeUpdated,
				toBeDeleted);
		logger.logInfo("Call " + externalLibraryWorkspace + " to register " + toBeUpdated + " and de-register "
				+ toBeDeleted);

		externalLibraryWorkspace.registerProjects(adaptionResult, monitor, triggerCleanbuild);
	} else {
		logger.logInfo("Platform is not running.");
	}
	logger.logInfo("Finished registering projects.");

	if (status.isOK())
		logger.logInfo("Successfully finished installing  packages.");
	else
		logger.logInfo("There were errors during installation, see logs for details.");

	logger.logInfo(LINE_DOUBLE);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:29,代码来源:NpmManager.java

示例13: runWithWorkspaceLock

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
private static <T> T runWithWorkspaceLock(Supplier<T> operation) {
	if (Platform.isRunning()) {
		final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot();
		try {
			Job.getJobManager().beginRule(rule, null);
			return operation.get();
		} finally {
			Job.getJobManager().endRule(rule);
		}
	} else {
		// locking not available/required in headless case
		return operation.get();
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:15,代码来源:NpmManager.java

示例14: collectProjectsWithDirectExternalDependencies

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Sugar for collecting {@link IWorkspace Eclipse workspace} projects that have any direct dependency to any
 * external projects. Same as {@link #collectProjectsWithDirectExternalDependencies()} but does not considers all
 * the available projects but only those that are given as the argument.
 *
 * @param externalProjects
 *            the external projects that has to be considered as a possible dependency of an Eclipse workspace based
 *            project.
 * @return an iterable of Eclipse workspace projects that has direct dependency to an external project given as the
 *         argument.
 */
public Iterable<IProject> collectProjectsWithDirectExternalDependencies(
		final Iterable<? extends IProject> externalProjects) {

	if (!Platform.isRunning()) {
		return emptyList();
	}

	final Collection<String> externalIds = from(externalProjects).transform(p -> p.getName()).toSet();
	final Predicate<String> externalIdsFilter = Predicates.in(externalIds);

	return from(asList(getWorkspace().getRoot().getProjects()))
			.filter(p -> Iterables.any(getDirectExternalDependencyIds(p), externalIdsFilter));

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:ExternalProjectsCollector.java

示例15: scheduleBuildIfNecessary

import org.eclipse.core.runtime.Platform; //导入方法依赖的package包/类
/**
 * Schedules a build with the given projects. Does nothing if the {@link Platform platform} is not running, or the
 * iterable of projects is empty.
 *
 * @param toUpdate
 *            an iterable of projects to build.
 */
public void scheduleBuildIfNecessary(final Iterable<IProject> toUpdate) {
	if (Platform.isRunning() && !Iterables.isEmpty(toUpdate)) {
		final Workspace workspace = (Workspace) ResourcesPlugin.getWorkspace();
		final IBuildConfiguration[] projectsToReBuild = from(asList(workspace.getBuildOrder()))
				.filter(config -> Iterables.contains(toUpdate, config.getProject()))
				.toArray(IBuildConfiguration.class);

		if (!Arrays2.isEmpty(projectsToReBuild)) {
			new RebuildWorkspaceProjectsJob(projectsToReBuild).schedule();
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:RebuildWorkspaceProjectsScheduler.java


注:本文中的org.eclipse.core.runtime.Platform.isRunning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。