/** * 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; } }
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()); } }
/** * 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(); }
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(); } }
/** * 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; }
/** * 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; }
/** * 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; }
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; }
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()); } } }
/** * 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..."); } }
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; }
/** * * @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; }
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; }
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; }
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; }
private List<IResultHandler> getResultsHandlers() { if (resultsHandlers == null) { final IConfigurationElement[] configElements = Platform.getExtensionRegistry() .getConfigurationElementsFor(RESULTS_HANDLER_EXTENSION_POINT_ID); final List<IResultHandler> handlers = new ArrayList<>(configElements.length + 1); for (IConfigurationElement configElement : configElements) { try { final IResultHandler handler = (IResultHandler) configElement.createExecutableExtension("class"); handler.init(service, createConsumerConfiguration()); handlers.add(handler); } catch (Exception e) { ErrorDialog.openError(getSite().getShell(), "Internal Error", "Could not create results handler for class " + configElement.getAttribute("class") + ".\n\nPlease contact your support representative.", new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage())); } } handlers.add(new DefaultResultsHandler()); resultsHandlers = handlers; } return resultsHandlers; }
public static List<MonitorViewConfiguration> loadAllMonitorConfigurations () { final List<MonitorViewConfiguration> result = new ArrayList<MonitorViewConfiguration> (); for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_CFG_ID ) ) { if ( !"monitorView".equals ( ele.getName () ) ) //$NON-NLS-1$ { continue; } final MonitorViewConfiguration cfg = convertMonitor ( ele ); if ( cfg != null ) { result.add ( cfg ); } } return result; }
public static List<EventHistoryViewConfiguration> loadAllEventHistoryConfigurations () { final List<EventHistoryViewConfiguration> result = new ArrayList<EventHistoryViewConfiguration> (); for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_CFG_ID ) ) { if ( !"eventHistoryView".equals ( ele.getName () ) ) //$NON-NLS-1$ { continue; } final EventHistoryViewConfiguration cfg = convertEventHistory ( ele ); if ( cfg != null ) { result.add ( cfg ); } } return result; }
public static AlarmNotifierConfiguration findAlarmNotifierConfiguration () { for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_CFG_ID ) ) { if ( !"alarmNotifier".equals ( ele.getName () ) ) //$NON-NLS-1$ { continue; } final AlarmNotifierConfiguration cfg = convertAlarmNotifier ( ele ); if ( cfg != null ) { return cfg; } } return null; }
private static AlarmNotifierConfiguration convertAlarmNotifier ( final IConfigurationElement ele ) { try { final String connectionId = ele.getAttribute ( "connectionId" ); //$NON-NLS-1$ final String prefix = ele.getAttribute ( "prefix" ) == null ? "ae.server.info" : ele.getAttribute ( "prefix" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ $NON-NLS-2$ final URL soundFile = Platform.getBundle ( ele.getContributor ().getName () ).getEntry ( ele.getAttribute ( "soundFile" ) ); //$NON-NLS-1$ final ParameterizedCommand ackAlarmsAvailableCommand = convertCommand ( ele.getChildren ( "ackAlarmsAvailableCommand" )[0] ); //$NON-NLS-1$ final ParameterizedCommand alarmsAvailableCommand = convertCommand ( ele.getChildren ( "alarmsAvailableCommand" )[0] ); //$NON-NLS-1$ return new AlarmNotifierConfiguration ( connectionId, prefix, soundFile, ackAlarmsAvailableCommand, alarmsAvailableCommand ); } catch ( final Exception e ) { logger.warn ( "Failed to convert alarm notifier configuration: {}", ele ); //$NON-NLS-1$ return null; } }
public static List<ConfigurationFormInformation> findMatching ( final String factoryId ) { final List<ConfigurationFormInformation> result = new LinkedList<ConfigurationFormInformation> (); for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_FORM ) ) { if ( !"form".equals ( ele.getName () ) ) { continue; } final ConfigurationFormInformation info = new ConfigurationFormInformation ( ele ); if ( info.getFactoryIds () == null ) { continue; } if ( info.getFactoryIds ().contains ( "*" ) || info.getFactoryIds ().contains ( factoryId ) ) { result.add ( info ); } } return result; }
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); } }
private static void readExtensions(Map<Class<? extends IScanPathModel>, Class<? extends IPointGenerator<?>>> gens, Map<String, GeneratorInfo> tids) throws CoreException { if (Platform.getExtensionRegistry()!=null) { final IConfigurationElement[] eles = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.scanning.api.generator"); for (IConfigurationElement e : eles) { final IPointGenerator<?> generator = (IPointGenerator<?>)e.createExecutableExtension("class"); final IScanPathModel model = (IScanPathModel)e.createExecutableExtension("model"); final Class<? extends IScanPathModel> modelClass = model.getClass(); @SuppressWarnings("unchecked") final Class<? extends IPointGenerator<?>> generatorClass = (Class<? extends IPointGenerator<?>>) generator.getClass(); gens.put(modelClass, generatorClass); final GeneratorInfo info = new GeneratorInfo(); info.setModelClass(model.getClass()); info.setGeneratorClass(generator.getClass()); info.setLabel(e.getAttribute("label")); info.setDescription(e.getAttribute("description")); String id = e.getAttribute("id"); tids.put(id, info); } } }
@Override public Object start(IApplicationContext context) { try { return Main.main(Platform.getApplicationArgs()) ? EXIT_OK : EXIT_ERROR; } catch (Exception e) { e.printStackTrace(System.err); Status error = new Status(IStatus.ERROR, ApgdiffConsts.APGDIFF_PLUGIN_ID, "pgCodeKeeper error", e); Platform.getLog(Activator.getContext().getBundle()).log(error); return EXIT_ERROR; } finally { // only needed when org.apache.felix.gogo.shell bundle is present /*try { // see bug #514338 Thread.sleep(110); } catch (InterruptedException ex) { // no action }*/ } }
/** * Returns the bundle that launched the application that this class runs in. * * @return the defining bundle */ private Bundle getApplicationBundle() { IProduct product = Platform.getProduct(); if (product != null) { return product.getDefiningBundle(); } else { return Platform.getBundle(ECLIPSE_RUNTIME_BULDEID); } }
/** * 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); }
protected void createExample(IProject project) { Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); try (InputStream stream = FileLocator.openStream(bundle, new Path("examples/greeter.sol"), false)) { IFile file = project.getFile("greeter.sol"); file.create(stream, true, null); } catch (Exception e) { e.printStackTrace(); } }
@SuppressWarnings("restriction") @Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); ActionContributionItem pasteContribution = getPasteContribution(menu.getItems()); menu.remove(pasteContribution); IAction pasteAction = new Action(PASTE_ACTION_TEXT) { @Override public void run() { IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); try { JobCopyParticipant.setCopiedFileList(new ArrayList<>()); handlerService.executeCommand(PASTE_COMMAND_ID, null); } catch (Exception exception) { logger.warn("Error while pasting job files :: {}",exception.getMessage()); } } }; pasteAction.setAccelerator(SWT.MOD1 | 'v'); Bundle bundle = Platform.getBundle(MENU_PLUGIN_NAME); URL imagePath = BundleUtility.find(bundle,ImagePathConstant.PASTE_IMAGE_PATH.getValue()); ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(imagePath); pasteAction.setImageDescriptor(imageDescriptor); menu.insertAfter(COPY_ACTION_ID, pasteAction); }
private void launch(IResource file, int line, IType type, String agentArgs, IMethod mainMethod) throws CoreException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType confType = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy wc = confType.newInstance(null, file.getName() + " (PandionJ)"); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, file.getProject().getName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, false); // if(breakPoint != null) // breakPoint.delete(); // if(line != -1) // breakPoint = JDIDebugModel.createLineBreakpoint(file, firstType.getFullyQualifiedName(), line, -1, -1, 0, true, null); try { Bundle bundle = Platform.getBundle(LaunchCommand.class.getPackage().getName()); URL find = FileLocator.find(bundle, new Path("lib/agent.jar"), null); URL resolve = FileLocator.resolve(find); if(!mainMethod.exists()) { String path = resolve.getPath(); if(Platform.getOS().compareTo(Platform.OS_WIN32) == 0) path = path.substring(1); String args = "-javaagent:\"" + path + "=" + agentArgs + "\" -Djava.awt.headless=true"; wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, args); } } catch (IOException e1) { e1.printStackTrace(); } ILaunchConfiguration config = wc.doSave(); Activator.launch(config); }
/** * 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); } }
@SuppressWarnings("unchecked") @Override default <T> T getAdapter(final Class<T> adapter) { if (IWorkingSet.class == adapter || ResourceMapping.class == adapter) { return (T) new WorkingSetAdapter(this); } return Platform.getAdapterManager().getAdapter(this, adapter); }
private static File resolveFile(String pluginName, String path) { Bundle bundle = Platform.getBundle(pluginName); URL fileURL = bundle.getEntry(path); try { URL resolvedFileURL = FileLocator.toFileURL(fileURL); URI resolvedURI = new URI(resolvedFileURL.getProtocol(), resolvedFileURL.getPath(), null); return new File(resolvedURI); } catch (URISyntaxException | IOException e) { Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e)); } return null; }
/** * 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); } } }
private String getVersion() { IBundleGroupProvider[] providers = Platform.getBundleGroupProviders(); if (providers != null) { for (IBundleGroupProvider provider : providers) { IBundleGroup[] bundleGroups = provider.getBundleGroups(); for (IBundleGroup group : bundleGroups) { if (group.getIdentifier().equals("ru.taximaxim.codekeeper.feature")) { return group.getVersion(); } } } } return "version_unavalable"; }
private void readMetanodes() { // iterate over the meta node config elements and create meta node templates IExtension[] metanodeExtensions = getExtensions(ID_META_NODE); for (IExtension mnExt : metanodeExtensions) { IConfigurationElement[] mnConfigElems = mnExt.getConfigurationElements(); for (IConfigurationElement mnConfig : mnConfigElems) { try { MetaNodeTemplate metaNode = RepositoryFactory.createMetaNode(mnConfig); LOGGER.debug("Found meta node definition '" + metaNode.getID() + "': " + metaNode.getName()); IContainerObject parentContainer = m_root.findContainer(metaNode.getCategoryPath()); // If parent category is illegal, log an error and append the node to the // repository root. if (parentContainer == null) { LOGGER.warn("Invalid category-path for node contribution: '" + metaNode.getCategoryPath() + "' - adding to root instead"); m_root.addChild(metaNode); } else { // everything is fine, add the node to its parent category parentContainer.addChild(metaNode); } } catch (Throwable t) { String message = "MetaNode " + mnConfig.getAttribute("id") + "' from plugin '" + mnConfig.getNamespaceIdentifier() + "' could not be created: " + t.getMessage(); Bundle bundle = Platform.getBundle(mnConfig.getNamespaceIdentifier()); if (bundle == null || bundle.getState() != Bundle.ACTIVE) { // if the plugin is null, the plugin could not be activated maybe due to a not // activateable plugin (plugin class cannot be found) message = message + " The corresponding plugin bundle could not be activated!"; } LOGGER.error(message, t); } } } }
/** * 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)); }
/** * Creates a new job with the already ordered configurations to builder. * * @param configs * the configurations to build. * */ public RebuildWorkspaceProjectsJob(final IBuildConfiguration[] configs) { super("Building workspace"); checkState(Platform.isRunning(), "This job requires a running platform"); this.configs = checkNotNull(configs, "configs"); setSystem(false); setUser(true); setRule(BUILD_RULE); }
/** * 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(); } } }
/** * Installs the specified jar bundle and adds the Bundle instance to the local bundle vector {@link #getBundleVector()}. * @param bundleJarFile the bundle jar file */ public void installBundle(File bundleJarFile) { // --- Check the symbolic bundle name of the jar to load ---- String sbn = this.getBundleBuilder().getBundleJarsSymbolicBundleNames().get(bundleJarFile); if (sbn!=null && sbn.isEmpty()==false) { if (Platform.getBundle(sbn)!=null) { System.out.println("[" + this.getClass().getSimpleName() + "] Bundle '" + sbn + "' is already installed, skip installation of jar file!"); return; } } // --- INstall the local bundle ----------------------------- this.installBundle("reference:file:" + bundleJarFile.getAbsolutePath()); }
/** * Loads the version information to this instance. */ public Version getVersion() { if (version==null) { Bundle bundle = Platform.getBundle(this.plugInID); version = bundle.getVersion(); } return version; }