org.eclipse.core.runtime.Platform Java Examples
The following examples show how to use
org.eclipse.core.runtime.Platform.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GdbTrace.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override public void initTrace(IResource resource, String path, Class<? extends ITmfEvent> type) throws TmfTraceException { try { String tracedExecutable = resource.getPersistentProperty(EXEC_KEY); if (tracedExecutable == null) { throw new TmfTraceException(Messages.GdbTrace_ExecutableNotSet); } String defaultGdbCommand = Platform.getPreferencesService().getString(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND, IGDBLaunchConfigurationConstants.DEBUGGER_DEBUG_NAME_DEFAULT, null); fGdbTpRef = new DsfGdbAdaptor(this, defaultGdbCommand, path, tracedExecutable); fNbFrames = getNbFrames(); } catch (CoreException e) { throw new TmfTraceException(Messages.GdbTrace_FailedToInitializeTrace, e); } super.initTrace(resource, path, type); }
Example #2
Source File: PubListener.java From dartboard with Eclipse Public License 2.0 | 6 votes |
/** * Retrieves all registered PubService extensions * * All services that have the priority attribute set to true, are at the * beginning of the resulting list. * * @return a List of all PubService extensions */ public static LinkedList<IPubService> getPubServices() { LinkedList<IPubService> pubServices = new LinkedList<IPubService>(); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); for (IConfigurationElement e : extensionRegistry.getExtensionPoint(GlobalConstants.PUB_SERVICE_EXTENSION_POINT) .getConfigurationElements()) { try { IPubService pubService = (IPubService) e.createExecutableExtension(EXTENSION_CLASS); boolean priority = Boolean.valueOf(e.getAttribute(EXTENSION_PRIORITY)); if (priority) { pubServices.add(0, pubService); } else { pubServices.add(pubService); } } catch (CoreException e1) { e1.printStackTrace(); } } return pubServices; }
Example #3
Source File: CustomPopupMenuExtender.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public CustomPopupMenuExtender(final String id, final MenuManager menu, final ISelectionProvider prov, final IWorkbenchPart part, IEclipseContext context, final boolean includeEditorInput) { super(); this.menu = menu; this.selProvider = prov; this.part = part; this.context = context; this.modelPart = part.getSite().getService(MPart.class); if (includeEditorInput) { bitSet |= INCLUDE_EDITOR_INPUT; } menu.addMenuListener(this); if (!menu.getRemoveAllWhenShown()) { menuWrapper = new SubMenuManager(menu); menuWrapper.setVisible(true); } createModelFor(id); addMenuId(id); Platform.getExtensionRegistry().addRegistryChangeListener(this); }
Example #4
Source File: ExtensionPointsReader.java From tesb-studio-se with Apache License 2.0 | 6 votes |
private void readRegisteredBundleClasspaths() { final IConfigurationElement[] configurationElements = Platform.getExtensionRegistry() .getConfigurationElementsFor(BUNDLE_CLASSPATH_EXT); for (IConfigurationElement e : configurationElements) { final String cmpName = e.getAttribute(NAME); final ExBundleClasspath bc = new ExBundleClasspath(e.getAttribute(PARAMETER), Boolean.parseBoolean(e.getAttribute(OPTIONAL))); parsePredicates(bc, e); Collection<ExBundleClasspath> attributeSet = componentBundleClasspaths.get(cmpName); if (attributeSet == null) { attributeSet = new ArrayList<ExBundleClasspath>(); componentBundleClasspaths.put(cmpName, attributeSet); } attributeSet.add(bc); } }
Example #5
Source File: OpenJavaSourceAction.java From birt with Eclipse Public License 1.0 | 6 votes |
private String getPath( String fileName ) { Bundle bundle = Platform.getBundle( ChartExamplesPlugin.ID ); Path relativePath = new Path( "/src/org/eclipse/birt/chart/examples/view/models/" + fileName + JAVA_EXTENSION ); //$NON-NLS-1$ URL relativeURL = FileLocator.find( bundle, relativePath, null ); String absolutePath = null; try { URL absoluteURL = FileLocator.toFileURL( relativeURL ); String tmp = absoluteURL.getPath( ); absolutePath = tmp.substring( 0, tmp.lastIndexOf( "/" ) ); //$NON-NLS-1$ } catch ( IOException io ) { io.printStackTrace( ); } return absolutePath; }
Example #6
Source File: LegacyJavadocCompletionProposalComputer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IJavadocCompletionProcessor[] getContributedProcessors() { if (fSubProcessors == null) { try { IExtensionRegistry registry= Platform.getExtensionRegistry(); IConfigurationElement[] elements= registry.getConfigurationElementsFor(JavaUI.ID_PLUGIN, PROCESSOR_CONTRIBUTION_ID); IJavadocCompletionProcessor[] result= new IJavadocCompletionProcessor[elements.length]; for (int i= 0; i < elements.length; i++) { result[i]= (IJavadocCompletionProcessor) elements[i].createExecutableExtension("class"); //$NON-NLS-1$ } fSubProcessors= result; } catch (CoreException e) { JavaPlugin.log(e); fSubProcessors= new IJavadocCompletionProcessor[0]; } } return fSubProcessors; }
Example #7
Source File: AbstractSelfHelpUI.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
private boolean useExternalBrowser(String url) { // On non Windows platforms, use external when modal window is displayed if (!Constants.OS_WIN32.equalsIgnoreCase(Platform.getOS())) { Display display = Display.getCurrent(); if (display != null) { if (insideModalParent(display)) return true; } } // Use external when no help frames are to be displayed, otherwise no // navigation buttons. if (url != null) { if (url.indexOf("?noframes=true") > 0 //$NON-NLS-1$ || url.indexOf("&noframes=true") > 0) { //$NON-NLS-1$ return true; } } return false; }
Example #8
Source File: TmImporter.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 加载记忆库匹配实现 ; */ private void runExtension() { IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( TMIMPORTER_EXTENSION_ID); try { for (IConfigurationElement e : config) { final Object o = e.createExecutableExtension("class"); if (o instanceof ITmImporter) { ISafeRunnable runnable = new ISafeRunnable() { public void handleException(Throwable exception) { logger.error(Messages.getString("importer.TmImporter.logger1"), exception); } public void run() throws Exception { tmImporter = (ITmImporter) o; } }; SafeRunner.run(runnable); } } } catch (CoreException ex) { logger.error(Messages.getString("importer.TmImporter.logger1"), ex); } }
Example #9
Source File: ExtendPopupMenu.java From erflute with Apache License 2.0 | 6 votes |
public static List<ExtendPopupMenu> loadExtensions(MainDiagramEditor editor) throws CoreException { final List<ExtendPopupMenu> extendPopupMenuList = new ArrayList<>(); final IExtensionRegistry registry = Platform.getExtensionRegistry(); final IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_ID); if (extensionPoint != null) { for (final IExtension extension : extensionPoint.getExtensions()) { for (final IConfigurationElement configurationElement : extension.getConfigurationElements()) { final ExtendPopupMenu extendPopupMenu = ExtendPopupMenu.createExtendPopupMenu(configurationElement, editor); if (extendPopupMenu != null) { extendPopupMenuList.add(extendPopupMenu); } } } } return extendPopupMenuList; }
Example #10
Source File: Resource.java From EasyShell with Eclipse Public License 2.0 | 6 votes |
public String getFullQualifiedName() { if (resource != null) { Bundle bundle = Platform.getBundle("org.eclipse.jdt.core"); if (bundle != null) { IJavaElement element = JavaCore.create(resource); if (element instanceof IPackageFragment) { return ((IPackageFragment)element).getElementName(); } else if (element instanceof ICompilationUnit) { IType type = ((ICompilationUnit)element).findPrimaryType(); if (type != null) { return type.getFullyQualifiedName(); } } } } return getFullQualifiedPathName(); }
Example #11
Source File: IsNodeProjectPropertyTester.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (IS_NODE_RESOURCE_PROPERTY.equals(property)) { IResource resource = Adapters.adapt(receiver, IResource.class); if (resource == null) { return false; } if (resource instanceof IFile) { IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); IContentType jsContentType = contentTypeManager.getContentType("org.eclipse.wildwebdeveloper.js"); IContentType tsContentType = contentTypeManager.getContentType("org.eclipse.wildwebdeveloper.ts"); try ( InputStream content = ((IFile) resource).getContents(); ) { List<IContentType> contentTypes = Arrays.asList(contentTypeManager.findContentTypesFor(content, resource.getName())); return contentTypes.contains(jsContentType) || contentTypes.contains(tsContentType); } catch (Exception e) { return false; } } } return false; }
Example #12
Source File: Utils.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
/** * Provisions a project that's part of the "testProjects" * @param folderName the folderName under "testProjects" to provision from * @return the provisioned project * @throws CoreException * @throws IOException */ public static IProject provisionTestProject(String folderName) throws CoreException, IOException { URL url = FileLocator.find(Platform.getBundle("org.eclipse.wildwebdeveloper.tests"), Path.fromPortableString("testProjects/" + folderName), null); url = FileLocator.toFileURL(url); File folder = new File(url.getFile()); if (folder.exists()) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("testProject" + System.nanoTime()); project.create(null); project.open(null); java.nio.file.Path sourceFolder = folder.toPath(); java.nio.file.Path destFolder = project.getLocation().toFile().toPath(); Files.walk(sourceFolder).forEach(source -> { try { Files.copy(source, destFolder.resolve(sourceFolder.relativize(source)), StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { e.printStackTrace(); } }); project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); return project; } return null; }
Example #13
Source File: EclipseUtil.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public boolean accept(File dir, String name) { IPath path = Path.fromOSString(dir.getAbsolutePath()).append(name); name = path.removeFileExtension().lastSegment(); String ext = path.getFileExtension(); if (Platform.OS_MACOSX.equals(Platform.getOS())) { if (!"app".equals(ext)) //$NON-NLS-1$ { return false; } } for (String launcherName : LAUNCHER_NAMES) { if (launcherName.equalsIgnoreCase(name)) { return true; } } return false; }
Example #14
Source File: ExternalContributions.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private static void instantiate(){ IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( Activator.PLUGIN_ID + ".ExternalMaintenance"); if (config.length == 0) return; for (IConfigurationElement e : config) { try { Object o = e.createExecutableExtension("MaintenanceCode"); if (o instanceof ExternalMaintenance) { ext.add((ExternalMaintenance) o); } } catch (CoreException e1) { Status status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, e1.getLocalizedMessage()); StatusManager.getManager().handle(status, StatusManager.SHOW); } } }
Example #15
Source File: DerbyClasspathContainer.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public DerbyClasspathContainer() { List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); Bundle bundle = Platform.getBundle(CommonNames.CORE_PATH); Enumeration en = bundle.findEntries("/", "*.jar", true); String rootPath = null; try { rootPath = FileLocator.resolve(FileLocator.find(bundle, new Path("/"), null)).getPath(); } catch(IOException e) { Logger.log(e.getMessage(), IStatus.ERROR); } while(en.hasMoreElements()) { IClasspathEntry cpe = JavaCore.newLibraryEntry(new Path(rootPath+'/'+((URL)en.nextElement()).getFile()), null, null); entries.add(cpe); } IClasspathEntry[] cpes = new IClasspathEntry[entries.size()]; _entries = (IClasspathEntry[])entries.toArray(cpes); }
Example #16
Source File: LogUtils.java From eclipsegraphviz with Eclipse Public License 1.0 | 6 votes |
public static void log(Supplier<IStatus> statusSupplier) { IStatus status = statusSupplier.get(); if (!Platform.isRunning()) { System.err.println(status.getMessage()); if (status.getException() != null) status.getException().printStackTrace(); if (status.isMultiStatus()) for (IStatus child : status.getChildren()) log(child); return; } Bundle bundle = Platform.getBundle(status.getPlugin()); if (bundle == null) { String thisPluginId = LogUtils.class.getPackage().getName(); bundle = Platform.getBundle(thisPluginId); Platform.getLog(bundle).log( new Status(IStatus.WARNING, thisPluginId, "Could not find a plugin " + status.getPlugin() + " for logging as")); } Platform.getLog(bundle).log(status); }
Example #17
Source File: UIPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void updateInitialPerspectiveVersion() { // updates the initial stored version so that user won't get a prompt on a new workspace boolean hasStartedBefore = Platform.getPreferencesService().getBoolean(PLUGIN_ID, IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, false, null); if (!hasStartedBefore) { IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(PLUGIN_ID); prefs.putInt(IPreferenceConstants.PERSPECTIVE_VERSION, WebPerspectiveFactory.VERSION); prefs.putBoolean(IPreferenceConstants.IDE_HAS_LAUNCHED_BEFORE, true); try { prefs.flush(); } catch (BackingStoreException e) { IdeLog.logError(getDefault(), Messages.UIPlugin_ERR_FailToSetPref, e); } } }
Example #18
Source File: AbstractSelfHelpUI.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
private boolean useExternalBrowser(String url) { // On non Windows platforms, use external when modal window is displayed if (!Constants.OS_WIN32.equalsIgnoreCase(Platform.getOS())) { Display display = Display.getCurrent(); if (display != null) { if (insideModalParent(display)) return true; } } // Use external when no help frames are to be displayed, otherwise no // navigation buttons. if (url != null) { if (url.indexOf("?noframes=true") > 0 //$NON-NLS-1$ || url.indexOf("&noframes=true") > 0) { //$NON-NLS-1$ return true; } } return false; }
Example #19
Source File: PreferenceUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @param direction * indicates if this is for upload or download permissions * @return true if the new files and folders should update their permissions to specific permissions after * transferring, false if they should maintain the source permissions */ public static boolean getSpecificPermissions(PermissionDirection direction) { switch (direction) { case UPLOAD: return Platform.getPreferencesService().getBoolean(CoreIOPlugin.PLUGIN_ID, IPreferenceConstants.UPLOAD_SPECIFIC_PERMISSIONS, true, null); case DOWNLOAD: return Platform.getPreferencesService().getBoolean(CoreIOPlugin.PLUGIN_ID, IPreferenceConstants.DOWNLOAD_SPECIFIC_PERMISSIONS, true, null); } return true; }
Example #20
Source File: ProjectContentsLocationArea.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Return the location for the project. If we are using defaults then return the workspace root so that core creates * it with default values. * * @return String */ public String getProjectLocation() { if (isDefault()) { return Platform.getLocation().toOSString(); } return locationPathField.getText(); }
Example #21
Source File: WSO2PluginSampleExt.java From developer-studio with Apache License 2.0 | 5 votes |
public Image getImage(String iconLocation, String id, String isFromGit) { ImageDescriptor imageDescriptor = null; if (!Boolean.parseBoolean(isFromGit)) { if (iconLocation != null && !iconLocation.isEmpty()) { imageDescriptor = ImageDescriptor.createFromURL(FileLocator.find(Platform.getBundle(bundleID), new Path(iconLocation), null)); } else { imageDescriptor = ImageDescriptor.createFromURL(FileLocator.find(Platform.getBundle(Activator.PLUGIN_ID), new Path("icons/plugin-icon.png"), null)); } return imageDescriptor.createImage(); } else { try { String gitIconLoc = WSO2PluginListSelectionPage.tempCloneDir + File.separator + id + File.separator + "icons" + File.separator + iconLocation; imageDescriptor = ImageDescriptor.createFromURL(new URL(WSO2PluginConstants.FILE_PROTOCOL + gitIconLoc)); return imageDescriptor.createImage(); } catch (MalformedURLException e) { // log image cannot be found at location return null; } } }
Example #22
Source File: ModelFeatureStructure.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { if (FeatureStructure.class.equals(adapter)) { return getStructre(); } else if (AnnotationFS.class.equals(adapter) && getStructre() instanceof AnnotationFS) { return getStructre(); } else { return Platform.getAdapterManager().getAdapter(this, adapter); } }
Example #23
Source File: ProjectSettingHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 加载扩展向导页 ; */ private void runWizardPageExtension() { IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( "net.heartsome.cat.ts.ui.extensionpoint.projectsetting"); try { // 修改术语库重复 extensionPages.clear(); for (IConfigurationElement e : config) { final Object o = e.createExecutableExtension("class"); if (o instanceof AbstractProjectSettingPage) { ISafeRunnable runnable = new ISafeRunnable() { public void handleException(Throwable exception) { logger.error(Messages.getString("handlers.ProjectSettingHandler.logger1"), exception); } public void run() throws Exception { extensionPages.add((AbstractProjectSettingPage) o); } }; SafeRunner.run(runnable); } } } catch (CoreException ex) { logger.error(Messages.getString("handlers.ProjectSettingHandler.logger1"), ex); } }
Example #24
Source File: ExtensionPointProxy.java From thym with Eclipse Public License 1.0 | 5 votes |
public static <T extends ExtensionPointProxy> List<T> getNativeExtensionPointProxy( String extensionPointID, Class<T> clazz){ IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointID); List<T> proxies = new ArrayList<T>(); for (int i = 0; i < configElements.length; i++) { T proxy; try { proxy = clazz.getDeclaredConstructor(IConfigurationElement.class).newInstance(configElements[i]); proxies.add(proxy); } catch (Exception e) { HybridCore.log(IStatus.ERROR, "Error instantiating ExtensionPointProxy object", e); } } return proxies; }
Example #25
Source File: PropertiesUtil.java From ganttproject with GNU General Public License v3.0 | 5 votes |
public static void loadProperties(Properties result, String resource) { URL url = PropertiesUtil.class.getResource(resource); if (url == null) { return; } URL resolvedUrl; try { resolvedUrl = Platform.resolve(url); result.load(resolvedUrl.openStream()); } catch (IOException e) { if (!GPLogger.log(e)) { e.printStackTrace(System.err); } } }
Example #26
Source File: ResourceUtils.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
/** * Fix uris by adding missing // to single file:/ prefix */ public static String fixURI(URI uri) { if (uri == null) { return null; } if (Platform.OS_WIN32.equals(Platform.getOS()) && URIUtil.isFileURI(uri)) { uri = URIUtil.toFile(uri).toURI(); } String uriString = uri.toString(); return uriString.replaceFirst("file:/([^/])", "file:///$1"); }
Example #27
Source File: WSDLPopulationUtilTest.java From tesb-studio-se with Apache License 2.0 | 5 votes |
/** * Test method for {@link org.talend.repository.services.utils.WSDLPopulationUtil#loadWSDL(java.lang.String)}. * * To validate an imported XSD/WSDL type files. TESB-19040 */ @Test public void testLoadWSDL() { Bundle b = Platform.getBundle("org.talend.esb.repository.services.test"); try { URL url = FileLocator.toFileURL(FileLocator.find(b, new Path("resources"), null)); //$NON-NLS-1$ WSDLPopulationUtil wsdlPopulationUtil = new WSDLPopulationUtil(); wsdlPopulationUtil.loadWSDL("file://" + url.getPath() + "/client_wsdl/cliente-v1_1.wsdl"); Assert.assertNotNull(wsdlPopulationUtil .getXSDSchemaFromNamespace("http://www.supervielle.com.ar/xsd/Integracion/common/commonTypes-v1")); } catch (IOException e) { e.printStackTrace(); fail("Test testGetTemplateURL() method failure."); } }
Example #28
Source File: PlottingFactory.java From dawnsci with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") private static final <T> IPlottingSystem<T> createPlottingSystem(final String plottingSystemId) throws CoreException { IConfigurationElement[] systems = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.dawnsci.plotting.api.plottingClass"); for (IConfigurationElement ia : systems) { if (ia.getAttribute("id").equals(plottingSystemId)) return (IPlottingSystem<T>)ia.createExecutableExtension("class"); } return null; }
Example #29
Source File: XpectN4JSES5TranspilerHelper.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * 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); }
Example #30
Source File: BuildPathManager.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void processElement(IConfigurationElement element) { // get extension pt's bundle IExtension extension = element.getDeclaringExtension(); String pluginId = extension.getNamespaceIdentifier(); Bundle bundle = Platform.getBundle(pluginId); // grab the item's display name String name = element.getAttribute(ATTR_NAME); // get the item's URI, resolved to a local file String resource = element.getAttribute(ATTR_PATH); URL url = FileLocator.find(bundle, new Path(resource), null); // add item to master list URI localFileURI = ResourceUtil.resourcePathToURI(url); if (localFileURI != null) { addBuildPath(name, localFileURI); } else { // @formatter:off String message = MessageFormat.format( Messages.BuildPathManager_UnableToConvertURLToURI, url.toString(), ELEMENT_BUILD_PATH, BUILD_PATHS_ID, pluginId ); // @formatter:on IdeLog.logError(BuildPathCorePlugin.getDefault(), message); } }