本文整理汇总了Java中org.eclipse.core.runtime.Platform类的典型用法代码示例。如果您正苦于以下问题:Java Platform类的具体用法?Java Platform怎么用?Java Platform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Platform类属于org.eclipse.core.runtime包,在下文中一共展示了Platform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCodeLensProviders
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
/**
* Load the SourceMap language supports.
*/
private synchronized void loadCodeLensProviders() {
if (codeLensProviderLoaded) {
return;
}
try {
IExtensionRegistry registry = Platform.getExtensionRegistry();
if (registry == null) {
return;
}
IConfigurationElement[] cf = registry.getConfigurationElementsFor(CodeLensPlugin.PLUGIN_ID,
EXTENSION_CODELENS_PROVIDERS);
loadCodeLensProvidersFromExtension(cf);
} finally {
codeLensProviderLoaded = true;
}
}
示例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());
}
}
示例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();
}
示例4: createFilesForTest
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
private void createFilesForTest() throws IOException{
File configDir = new File(Platform.getInstallLocation().getURL().getPath() + "/config");
if(!configDir.exists()){
configDir.mkdir();
}
File mavenDir = new File(configDir.getPath() + "/maven");
if(!mavenDir.exists()){
mavenDir.mkdir();
}
File destinationFile = new File(mavenDir + "/pom.xml");
if(destinationFile.exists()){
return;
}
else{
destinationFile.createNewFile();
}
}
示例5: getBundleDirectory
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
/**
* Return the bundle directory.
*
* @param bundle the bundle
* @return the bundle directory
*/
public String getBundleDirectory(Bundle bundle) {
if (bundle == null) return null;
// --- Get File URL of bundle ---------------------
URL pluginURL = null;
try {
pluginURL = FileLocator.resolve(bundle.getEntry("/"));
} catch (IOException e) {
throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName());
}
// --- Clean up the directory path ----------------
String pluginInstallDir = pluginURL.getFile().trim();
if (pluginInstallDir.length()==0) {
throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName());
}
// --- Corrections, if we are under windows -------
if (Platform.getOS().compareTo(Platform.OS_WIN32) == 0) {
//pluginInstallDir = pluginInstallDir.substring(1);
}
return pluginInstallDir;
}
示例6: retrieveLocators
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
/**
* Retrieve all the locators registered with the extension point, and additionally store them in a cache.
*
* @return All locators registered with the extension point.
*/
public List<ILocator> retrieveLocators() {
if (locators == null) {
IExtensionRegistry reg = Platform.getExtensionRegistry();
IExtensionPoint ep = reg.getExtensionPoint("org.eclipse.gemoc.dsl.debug.locator");
IExtension[] extensions = ep.getExtensions();
ArrayList<ILocator> contributors = new ArrayList<ILocator>();
for (int i = 0; i < extensions.length; i++) {
IExtension ext = extensions[i];
IConfigurationElement[] ce = ext.getConfigurationElements();
for (int j = 0; j < ce.length; j++) {
ILocator locator;
try {
locator = (ILocator)ce[j].createExecutableExtension("class");
contributors.add(locator);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
locators = contributors;
}
return locators;
}
示例7: getMelangeBundle
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
/**
* Return a bundle with a .melange declaring 'language'
*/
public static Bundle getMelangeBundle(String languageName){
IConfigurationElement[] melangeLanguages = Platform
.getExtensionRegistry().getConfigurationElementsFor(
"fr.inria.diverse.melange.language");
String melangeBundleName = "";
for (IConfigurationElement lang : melangeLanguages) {
if(lang.getAttribute("id").equals(languageName)){
melangeBundleName = lang.getContributor().getName();
return Platform.getBundle(melangeBundleName);
}
}
return null;
}
示例8: createImageDescriptor
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
public static ImageDescriptor createImageDescriptor(String path, String pluginId) {
if (path == null) {
/* fall back if path null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
if (pluginId == null) {
/* fall back if pluginId null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
Bundle bundle = Platform.getBundle(pluginId);
if (bundle == null) {
/*
* fall back if bundle not available, so avoid NPE in eclipse
* framework
*/
return ImageDescriptor.getMissingImageDescriptor();
}
URL url = FileLocator.find(bundle, new Path(path), null);
ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url);
return imageDesc;
}
示例9: createIcons
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
private void createIcons() {
icons = new HashMap<String, Image>(7);
final IConfigurationElement[] eles = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.scanning.api.generator");
for (IConfigurationElement e : eles) {
final String identity = e.getAttribute("id");
final String icon = e.getAttribute("icon");
if (icon !=null) {
final String cont = e.getContributor().getName();
final Bundle bundle= Platform.getBundle(cont);
final URL entry = bundle.getEntry(icon);
final ImageDescriptor des = ImageDescriptor.createFromURL(entry);
icons.put(identity, des.createImage());
}
}
}
示例10: 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...");
}
}
示例11: createConnection
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
public static ConnectionService createConnection ( final ConnectionInformation info, final Integer autoReconnectDelay, final boolean lazyActivation )
{
if ( info == null )
{
return null;
}
for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( Activator.EXTP_CONNECTON_CREATOR ) )
{
final String interfaceName = ele.getAttribute ( "interface" );
final String driverName = ele.getAttribute ( "driver" );
if ( interfaceName == null || driverName == null )
{
continue;
}
if ( interfaceName.equals ( info.getInterface () ) && driverName.equals ( info.getDriver () ) )
{
final ConnectionService service = createConnection ( info, ele, autoReconnectDelay, lazyActivation );
if ( service != null )
{
return service;
}
}
}
return null;
}
示例12: createBestPlatformMessagingSystem
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
/**
*
* @return a new MessagingSystem that is supposed to be the best implementation for the current platform
* @param baseMessageGroup id for the messaging system, if two instances of MessagingSystem use the same id, the platform may decide to group the messages in a single console
* @param userFriendlyName, name for the console, if several instances use the same baseMessageGroup, it will use one of the userFriendlyName (the first that is created)
*/
public MessagingSystem createBestPlatformMessagingSystem(String baseMessageGroup, String userFriendlyName ){
MessagingSystem result = null;
IConfigurationElement[] confElements = Platform.getExtensionRegistry()
.getConfigurationElementsFor(MESSAGINGSYSTEM_EXTENSION_POINT_NAME);
for (int i = 0; i < confElements.length; i++) {
// get first working contribution
// TODO find some criterion or properties allowing to have better selection in case of multiple definitions
//String name = confElements[i].getAttribute(MESSAGINGSYSTEM_EXTENSION_POINT_CONTRIB_NAME_ATT);
try {
result = (MessagingSystem) confElements[i].createExecutableExtension(MESSAGINGSYSTEM_EXTENSION_POINT_CONTRIB_MESSAGINGSYSTEM_ATT);
result.initialize(baseMessageGroup, userFriendlyName);
if(result != null) break;
} catch (Throwable e) {;
}
}
if (result == null){
// still not created, either due to exception or to missing extension contributor
// fallback to default constructor
result = new StdioSimpleMessagingSystem();
}
return result;
}
示例13: createFactories
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
public static Collection<KeyProviderFactory> createFactories ()
{
final Collection<KeyProviderFactory> result = new LinkedList<KeyProviderFactory> ();
for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_KEY_PROVIDER_FACTORY ) )
{
if ( !ELE_FACTORY.equals ( ele.getName () ) )
{
continue;
}
try
{
result.add ( (KeyProviderFactory)ele.createExecutableExtension ( ATTR_CLASS ) );
}
catch ( final CoreException e )
{
StatusManager.getManager ().handle ( e, Activator.PLUGIN_ID );
}
}
return result;
}
示例14: getExtensionDescriptors
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
public static List<ExtensionDescriptor> getExtensionDescriptors ()
{
final List<ExtensionDescriptor> result = new LinkedList<ExtensionDescriptor> ();
for ( final IConfigurationElement element : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_VIEWER ) )
{
if ( !"viewerExtension".equals ( element.getName () ) )
{
continue;
}
result.add ( new ExtensionDescriptor ( element ) );
}
return result;
}
示例15: loadDescriptors
import org.eclipse.core.runtime.Platform; //导入依赖的package包/类
protected static List<ViewInstanceDescriptor> loadDescriptors ()
{
final List<ViewInstanceDescriptor> result = new LinkedList<ViewInstanceDescriptor> ();
for ( final IConfigurationElement element : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_VIEW ) )
{
if ( !ELE_VIEW_INSTANCE.equals ( element.getName () ) )
{
continue;
}
final ViewInstanceDescriptor descriptor = convert ( element );
if ( descriptor != null )
{
result.add ( descriptor );
}
}
return result;
}