/** * Get a list of plot views from extension register * * @return list of views */ public static List<String> getRegisteredViews() { List<String> plotViews = new LinkedList<String>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); // Add the default point first, this is where the double click action will go IExtensionPoint point = registry.getExtensionPoint("uk.ac.diamond.scisoft.analysis.rcp.ExplorerViewDefault"); IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { IConfigurationElement[] elements = extensions[i].getConfigurationElements(); for (int i1 = 0; i1 < elements.length; i1++) { if (elements[i1].getName().equals("ViewDefaultRegister")) { if (!plotViews.contains(elements[i1].getAttribute("ViewName"))) plotViews.add(elements[i1].getAttribute("ViewName")); } } } // now add all the other contributions to the list point = registry.getExtensionPoint("uk.ac.diamond.scisoft.analysis.rcp.ExplorerViewRegister"); extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { IConfigurationElement[] elements = extensions[i].getConfigurationElements(); for (int i1 = 0; i1 < elements.length; i1++) { if (elements[i1].getName().equals("ViewRegister")) { if (!plotViews.contains(elements[i1].getAttribute("ViewName"))) plotViews.add(elements[i1].getAttribute("ViewName")); } } } return plotViews; }
public static List<ICheckNodesService> getCheckNodesService() { if (checkNodeServices == null) { checkNodeServices = new ArrayList<ICheckNodesService>(); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint( "org.talend.designer.core.check_nodes"); //$NON-NLS-1$ if (extensionPoint != null) { IExtension[] extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] configurationElements = extension.getConfigurationElements(); for (IConfigurationElement configurationElement : configurationElements) { try { Object service = configurationElement.createExecutableExtension("class"); // $NON-NLS-1$ if (service instanceof ICheckNodesService) { checkNodeServices.add((ICheckNodesService) service); } } catch (CoreException e) { ExceptionHandler.process(e); } } } } } return checkNodeServices; }
/** see if any extra right click handlers are defined */ private static void loadLoaderExtensions() { IExtensionRegistry registry = Platform.getExtensionRegistry(); if (registry != null) { final IExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID); final IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { final IExtension iExtension = extensions[i]; final IConfigurationElement[] confE = iExtension.getConfigurationElements(); for (int j = 0; j < confE.length; j++) { final IConfigurationElement iConfigurationElement = confE[j]; RightClickContextItemGenerator newInstance; try { newInstance = (RightClickContextItemGenerator) iConfigurationElement.createExecutableExtension("class"); addRightClickGenerator(newInstance); } catch (final CoreException e) { CorePlugin.logError( Status.ERROR, "Trouble whilst loading right-click handler extensions", e); } } } } }
void processingExtensionPointByHand() { String xpid = "net.refractions.udig.project.ui.tool"; IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = registry.getExtensionPoint(xpid); if (extensionPoint == null) { throw new NullPointerException("Could not find extensionPoint:" + xpid); } for (IExtension extension : extensionPoint.getExtensions()) { for (IConfigurationElement element : extension.getConfigurationElements()) { String name = element.getName(); System.out.println(name); if ("modalTool".equals(name)) { try { ModalTool tool = (ModalTool) element.createExecutableExtension("class"); System.out.println(tool); } catch (CoreException e) { // Perhaps an error in the constructor? String message = "Could not create Modal tool " + element.getAttribute("class"); Status status = new Status(IStatus.ERROR, extension.getContributor().getName(), message, e); Activator.getDefault().getLog().log(status); } } } } }
private static void initializeClientContextIDs() { registeredClientContextIds = new java.util.HashSet<String>(); IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(EP_UI_REGISTERED_CLIENT_CONTEXTS); for (IExtension extension : extPoint.getExtensions()) { for (IConfigurationElement next : extension.getConfigurationElements()) { registeredClientContextIds.add(next.getAttribute(A_ID)); } } IExtensionTracker extTracker = ValidationUIPlugin.getExtensionTracker(); if (extTracker != null) { IExtensionChangeHandler extensionHandler = new IExtensionChangeHandler() { public void addExtension(IExtensionTracker tracker, IExtension extension) { addClientContextIDs(extension.getConfigurationElements()); } public void removeExtension(IExtension extension, Object[] objects) { // client-context IDs cannot be undefined } }; extTracker.registerHandler( extensionHandler, ExtensionTracker.createExtensionPointFilter(extPoint)); } }
/** * Returns the {@link INamespaceLabelProvider} for the given {@link ISourceModelElement}'s * namespace. */ public static INamespaceLabelProvider getLabelProvider(ISourceModelElement element) { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(NAMESPACES_EXTENSION_POINT); if (point != null) { String namespaceURI = getNameSpaceURI(element); for (IExtension extension : point.getExtensions()) { for (IConfigurationElement config : extension.getConfigurationElements()) { if (namespaceURI.equals(config.getAttribute("uri"))) { if (config.getAttribute("labelProvider") != null) { try { Object provider = config.createExecutableExtension("labelProvider"); if (provider instanceof INamespaceLabelProvider) { return (INamespaceLabelProvider) provider; } } catch (CoreException e) { BeansUIPlugin.log(e); } } return null; } } } } return null; }
private List<OpenWizardDescr> loadDataProviders() { List<OpenWizardDescr> res = new LinkedList<>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); if (registry == null) { return res; } IExtensionPoint point = registry.getExtensionPoint(OPENWIZARD_EXTENSION_POINT); if (point == null) { return res; } for (IExtension extension : point.getExtensions()) { if (null != extension) { for (IConfigurationElement element : extension.getConfigurationElements()) { if (null != element) { try { res.add(createDescr(element)); } catch (CoreException e) { // just ignore } } } } } return res; }
private static QvtTransformationInterpreterFactory getInterpreterFactory() throws MdaException { if (implFactory != null) { return implFactory; } IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = pluginRegistry.getExtensionPoint( QvtTransformationInterpreterFactory.Descriptor.FACTORY_POINT_ID); if (extensionPoint != null) { IExtension[] allExtensions = extensionPoint.getExtensions(); // take only first suitable factory for (IExtension ext : allExtensions) { IConfigurationElement[] elements = ext.getConfigurationElements(); Object factoryObj = null; try { factoryObj = elements[0].createExecutableExtension( QvtTransformationInterpreterFactory.Descriptor.CLASS_ATTR); } catch (CoreException e) { throw new MdaException(e); } return implFactory = (QvtTransformationInterpreterFactory) factoryObj; } } throw new MdaException(Messages.NoQvtImplementorFactoryRegistered); }
static { IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(TYPE_EVALUATORS); IExtension[] ext = extensionPoint.getExtensions(); // ArrayList resolvers = new ArrayList(); for (int a = 0; a < ext.length; a++) { IConfigurationElement[] elements = ext[a].getConfigurationElements(); IConfigurationElement myElement = elements[0]; try { String nature = myElement.getAttribute(NATURE); List list = (List) evaluatorsByNatures.get(nature); if (list == null) { list = new ArrayList(); evaluatorsByNatures.put(nature, list); } // ITypeInferencer resolver = (ITypeInferencer) myElement // .createExecutableExtension("evaluator"); // resolvers.add(resolver); // list.add(resolver); list.add(myElement); } catch (Exception e) { e.printStackTrace(); } } }
/** Called by IncQueryBasePlugin. */ public static void initRegistry() { getContributedWellbehavingDerivedFeatures().clear(); getContributedWellbehavingDerivedClasses().clear(); getContributedWellbehavingDerivedPackages().clear(); IExtensionRegistry reg = Platform.getExtensionRegistry(); IExtensionPoint poi; poi = reg.getExtensionPoint(IncQueryBasePlugin.WELLBEHAVING_DERIVED_FEATURE_EXTENSION_POINT_ID); if (poi != null) { IExtension[] exts = poi.getExtensions(); for (IExtension ext : exts) { IConfigurationElement[] els = ext.getConfigurationElements(); for (IConfigurationElement el : els) { if (el.getName().equals("wellbehaving-derived-feature")) { processWellbehavingExtension(el); } else { throw new UnsupportedOperationException( "Unknown configuration element " + el.getName() + " in plugin.xml of " + el.getDeclaringExtension().getUniqueIdentifier()); } } } } }
public static List<ContextComputationStrategy> readContextComputationStrategies() { List<ContextComputationStrategy> strategies = new ArrayList<ContextComputationStrategy>(); IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(STRATEGIES_EXTENSION_POINT_ID); IExtension[] extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] configurationElements = extension.getConfigurationElements(); for (IConfigurationElement element : configurationElements) { if (element.getName().equals(CONTEXT_COMPUTATION_STRATEGY)) { try { ContextComputationStrategy strategy = (ContextComputationStrategy) element.createExecutableExtension(ATTRIBUTE_CLASS); strategies.add(strategy); } catch (Throwable t) { StatusHandler.log( new Status( IStatus.ERROR, ContextCorePlugin.ID_PLUGIN, NLS.bind( "Cannot instantiate {0} from bundle {1}: {2}", //$NON-NLS-1$ new Object[] { element.getAttribute(ATTRIBUTE_CLASS), extension.getContributor().getName(), t.getMessage() }), t)); } } } } return strategies; }
/** * Dump the whole extension registry up to the specified nesting depth. * * @param extensionPointPrefix considering only extension points that have this prefix or null for * all * @param depth nesting depth */ public static void dumpRegistry(final String extensionPointPrefix, final int depth) { final IExtensionRegistry extensionRegistry = RegistryFactory.getRegistry(); if (extensionRegistry == null) { System.out.println("No extension registry available."); // $NON-NLS-1$ return; } final Object strategy = ReflectionUtils.getHidden(extensionRegistry, "strategy"); // $NON-NLS-1$ final StringBuilder bob = new StringBuilder("<< Registry"); // $NON-NLS-1$ if (extensionPointPrefix != null) { bob.append(" for prefix ").append(extensionPointPrefix); // $NON-NLS-1$ } bob.append(" with strategy ") .append(strategy.getClass().getSimpleName()) .append(":"); // $NON-NLS-1$ //$NON-NLS-2$ System.out.println(bob); final IExtensionPoint[] extensionPoints = extensionRegistry.getExtensionPoints(); Arrays.sort( extensionPoints, new Comparator<IExtensionPoint>() { public int compare(final IExtensionPoint ep1, final IExtensionPoint ep2) { return ep1.getUniqueIdentifier().compareTo(ep2.getUniqueIdentifier()); } }); for (final IExtensionPoint extensionPoint : extensionPoints) { if (extensionPointPrefix != null && !extensionPoint.getUniqueIdentifier().startsWith(extensionPointPrefix)) { continue; } System.out.println(extensionPoint.getUniqueIdentifier() + ":"); // $NON-NLS-1$ dumpExtensions(extensionPoint.getExtensions(), depth); } System.out.println(">>"); // $NON-NLS-1$ }
/** @param viewer */ private void addDndSupport(GraphicalViewer viewer, String type) { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(UMLPlugin.PLUGIN_ID, "dnd"); IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { IExtension extension = extensions[i]; IConfigurationElement[] elements = extension.getConfigurationElements(); for (int j = 0; j < elements.length; j++) { IConfigurationElement element = elements[j]; try { Object object = element.createExecutableExtension("class"); if (object instanceof UMLDropTargetListenerFactory) { UMLDropTargetListenerFactory factory = (UMLDropTargetListenerFactory) object; if (factory.accept(type)) { TransferDropTargetListener targetListener = factory.getDropTargetListener(viewer); viewer.addDropTargetListener(targetListener); } } } catch (CoreException e) { e.printStackTrace(); } finally { } } } }
EngineExtensionManager() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = registry.getExtensionPoint("org.eclipse.birt.core.FactoryService"); IExtension[] extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { String type = element.getAttribute("type"); if ("org.eclipse.birt.report.engine.extension".equals(type)) { try { Object factoryObject = element.createExecutableExtension("class"); if (factoryObject instanceof IReportEngineExtensionFactory) { IReportEngineExtensionFactory factory = (IReportEngineExtensionFactory) factoryObject; IReportEngineExtension engineExtension = factory.createExtension(ReportEngine.this); exts.put(engineExtension.getExtensionName(), engineExtension); } } catch (CoreException ex) { logger.log(Level.WARNING, "can not load the engine extension factory", ex); } } } } }
/** Loads the extension for the source code view. */ public void loadExtensions() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint point = registry.getExtensionPoint(EXTENSION_POINT_ID); if (point == null) { return; } IExtension[] extensions = point.getExtensions(); if (extensions.length > 0) { IExtension ex = extensions[0]; IConfigurationElement[] elems = ex.getConfigurationElements(); for (IConfigurationElement h : elems) { Object obj = null; if (h.getName().compareTo("sourcecodeview") == 0) { try { obj = h.createExecutableExtension("class"); } catch (CoreException e) { e.printStackTrace(); } if (obj instanceof SourceCodeView) { sourceCodeView = (SourceCodeView) obj; } } } } }
private static void loadCheatSheetExtensions() { IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CHEAT_SHEET_PLUGIN_ID, EXT_PT); if (extensionPoint != null) { IExtension[] extensions = extensionPoint.getExtensions(); if (extensions.length != 0) { List temp = new ArrayList(); for (int i = 0; i < extensions.length; ++i) { IConfigurationElement[] elements = extensions[i].getConfigurationElements(); // only care about cheatsheet configuration elements. don't care about category elements. for (int j = 0; j < elements.length; ++j) { if (elements[j].getName().equals(CHEATSHEET_ELEMENT)) { temp.add(elements[j]); } } } if (!temp.isEmpty()) { temp.toArray(cheatsheets = new IConfigurationElement[temp.size()]); } else { cheatsheets = new IConfigurationElement[0]; } } } if (cheatsheets == null) { cheatsheets = new IConfigurationElement[0]; } }
/** @return true if some extensions were found */ protected boolean configure(String extensionPointId) { IExtensionPoint extPoint = registry.getExtensionPoint(extensionPointId); if (extPoint == null) { return false; } IExtension[] extensions = extPoint.getExtensions(); if (extensions.length == 0) { return false; } Map<String, Map<String, ICSSPropertyHandler>> handlersMap = new HashMap<String, Map<String, ICSSPropertyHandler>>(); for (IExtension e : extensions) { for (IConfigurationElement ce : e.getConfigurationElements()) { if (ce.getName().equals(ATTR_HANDLER)) { // a single handler may implement a number of properties String name = ce.getAttribute(ATTR_COMPOSITE); String adapter = ce.getAttribute(ATTR_ADAPTER); // if (className.equals(adapter)) { IConfigurationElement[] children = ce.getChildren(); String[] names = new String[children.length]; String[] deprecated = new String[children.length]; for (int i = 0; i < children.length; i++) { if (children[i].getName().equals(ATTR_PROPERTY_NAME)) { names[i] = children[i].getAttribute(ATTR_NAME); deprecated[i] = children[i].getAttribute(ATTR_DEPRECATED); if (deprecated[i] != null) { hasDeprecatedProperties = true; } } } try { Map<String, ICSSPropertyHandler> adaptersMap = handlersMap.get(adapter); if (adaptersMap == null) { handlersMap.put(adapter, adaptersMap = new HashMap<String, ICSSPropertyHandler>()); } if (!adaptersMap.containsKey(name)) { Object t = ce.createExecutableExtension(ATTR_HANDLER); if (t instanceof ICSSPropertyHandler) { for (int i = 0; i < names.length; i++) { adaptersMap.put( names[i], deprecated[i] == null ? (ICSSPropertyHandler) t : new DeprecatedPropertyHandlerWrapper( (ICSSPropertyHandler) t, deprecated[i])); } } else { logError("invalid property handler for " + name); } } } catch (CoreException e1) { logError("invalid property handler for " + name + ": " + e1); } } } } propertyHandlerMap.putAll(handlersMap); return true; }
/** Start the registry reading process using the supplied plugin ID and extension point. */ protected void readRegistry(IExtensionRegistry registry, String pluginId, String extensionPoint) { IExtensionPoint point = registry.getExtensionPoint(pluginId, extensionPoint); if (point != null) { IExtension[] extensions = point.getExtensions(); extensions = orderExtensions(extensions); for (int i = 0; i < extensions.length; i++) readExtension(extensions[i]); } }
public static void initExtensions() { if (!extensionsRead) { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = registry.getExtensionPoint(BridgesExtensionPointReader.EXTENSION_ID_CONTEXT); IExtension[] extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { if (element.getName().compareTo(BridgesExtensionPointReader.ELEMENT_STRUCTURE_BRIDGE) == 0) { readBridge(element); } } } // internal bridges extensionPoint = registry.getExtensionPoint(BridgesExtensionPointReader.EXTENSION_ID_INTERNAL_CONTEXT); extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { if (element.getName().compareTo(BridgesExtensionPointReader.ELEMENT_SHADOW) == 0) { readInternalBridge(element); } } } extensionPoint = registry.getExtensionPoint(BridgesExtensionPointReader.EXTENSION_ID_RELATION_PROVIDERS); extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { if (element.getName().compareTo(BridgesExtensionPointReader.ELEMENT_RELATION_PROVIDER) == 0) { readRelationProvider(element); } } } extensionsRead = true; } }
private void printExtensionPoints(String pointId) { System.out.println("Point [" + pointId + "] search results:"); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(pointId); if (point != null) { for (IExtension ex : point.getExtensions()) { System.out.println(" " + ex.getNamespaceIdentifier() + "/" + ex.getUniqueIdentifier()); } } }
/** key is the plugin id, value is the plugin library path */ public static synchronized SortedMap<String, String> getContributedDetectors() { if (contributedDetectors != null) { return contributedDetectors; } TreeMap<String, String> set = new TreeMap<String, String>(); IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint point = registry.getExtensionPoint(EXTENSION_POINT_ID); if (point == null) { return set; } IExtension[] extensions = point.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement configElt : elements) { String libPathAsString; String pluginId; IContributor contributor = null; try { contributor = configElt.getContributor(); if (contributor == null) { throw new IllegalArgumentException("Null contributor"); } pluginId = configElt.getAttribute(PLUGIN_ID); if (pluginId == null) { throw new IllegalArgumentException("Missing '" + PLUGIN_ID + "'"); } libPathAsString = configElt.getAttribute(LIBRARY_PATH); if (libPathAsString == null) { throw new IllegalArgumentException("Missing '" + LIBRARY_PATH + "'"); } libPathAsString = resolveRelativePath(contributor, libPathAsString); if (libPathAsString == null) { throw new IllegalArgumentException("Failed to resolve library path for: " + pluginId); } if (set.containsKey(pluginId)) { throw new IllegalArgumentException("Duplicated '" + pluginId + "' contribution."); } set.put(pluginId, libPathAsString); } catch (Throwable e) { String cName = contributor != null ? contributor.getName() : "unknown contributor"; String message = "Failed to read contribution for '" + EXTENSION_POINT_ID + "' extension point from " + cName; FindbugsPlugin.getDefault().logException(e, message); continue; } } } contributedDetectors = set; return contributedDetectors; }
/** * Though this listener reacts to the extension point changes, there could have been contributions * before it's been registered. This will parse these initial contributions. */ public void parseInitialContributions() { final IExtensionRegistry registry = Platform.getExtensionRegistry(); final IExtensionPoint extensionPoint = registry.getExtensionPoint(VIEW_LABELPROVIDER_EXTENSION_POINT); if (extensionPoint != null) { for (IExtension extension : extensionPoint.getExtensions()) { parseExtension(extension); } } }
public TriggerPointManager() { super(); triggerMap.put( ITriggerPointManager.UNKNOWN_TRIGGER_POINT_ID, new AbstractTriggerPoint() { /* * (non-Javadoc) * * @see org.eclipse.ui.activities.ITriggerPoint#getId() */ public String getId() { return ITriggerPointManager.UNKNOWN_TRIGGER_POINT_ID; } /* * (non-Javadoc) * * @see org.eclipse.ui.activities.ITriggerPoint#getStringHint(java.lang.String) */ public String getStringHint(String key) { if (ITriggerPoint.HINT_INTERACTIVE.equals(key)) { // TODO: change to false when we have mapped our // trigger points return Boolean.TRUE.toString(); } return null; } /* * (non-Javadoc) * * @see org.eclipse.ui.activities.ITriggerPoint#getBooleanHint(java.lang.String) */ public boolean getBooleanHint(String key) { if (ITriggerPoint.HINT_INTERACTIVE.equals(key)) { // TODO: change to false when we have mapped our // trigger points return true; } return false; } }); IExtensionTracker tracker = PlatformUI.getWorkbench().getExtensionTracker(); tracker.registerHandler( this, ExtensionTracker.createExtensionPointFilter(getExtensionPointFilter())); IExtensionPoint point = getExtensionPointFilter(); IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { addExtension(tracker, extensions[i]); } }
private static String[] readGlobalLoadingPluginNames() { IExtensionRegistry reg = Platform.getExtensionRegistry(); IExtensionPoint exPoint = reg.getExtensionPoint(PLUGIN_ID, "globalPluginResourceLoad"); // $NON-NLS-1$ IExtension[] extensions = exPoint.getExtensions(); String[] names = new String[extensions.length]; if (extensions.length > 0) { for (int i = 0; i < extensions.length; i++) names[i] = extensions[i].getContributor().getName(); } return names; }
private boolean getConverter(String convertToId) { String fromId = null; String toId = null; // Get the Converter Extension Point IExtensionPoint extensionPoint = Platform.getExtensionRegistry() .getExtensionPoint( "org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$ "projectConverter"); //$NON-NLS-1$ if (extensionPoint != null) { // Get the extensions IExtension[] extensions = extensionPoint.getExtensions(); for (int i = 0; i < extensions.length; i++) { // Get the configuration elements of each extension IConfigurationElement[] configElements = extensions[i].getConfigurationElements(); for (int j = 0; j < configElements.length; j++) { IConfigurationElement element = configElements[j]; if (element.getName().equals("converter")) { // $NON-NLS-1$ fromId = element.getAttribute("fromId"); // $NON-NLS-1$ toId = element.getAttribute("toId"); // $NON-NLS-1$ // Check whether the current converter can be used for // the selected project type if (fromId.equals(getId()) && toId.equals(convertToId)) { // If it matches String mbsVersion = element.getAttribute("mbsVersion"); // $NON-NLS-1$ Version currentMbsVersion = ManagedBuildManager.getBuildInfoVersion(); // set the converter element based on the MbsVersion if (currentMbsVersion.compareTo(new Version(mbsVersion)) > 0) { previousMbsVersionConversionElement = element; } else { currentMbsVersionConversionElement = element; } return true; } } } } } // If control comes here, it means 'Tool Integrator' specified // 'convertToId' attribute in toolchain definition file, but // has not provided any converter. So, make the project is invalid return false; }
public static void runStartupExtensions() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_ID_STARTUP); IExtension[] extensions = extensionPoint.getExtensions(); for (IExtension extension : extensions) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { if (element.getName().compareTo(ELEMENT_STARTUP) == 0) { runStartupExtension(element); } } } }
private void loadDriverExtensions() { if (driverExtensions != null) // Already loaded return; // First time: load all driverinfo extensions driverExtensions = new HashMap(); IExtensionRegistry extReg = Platform.getExtensionRegistry(); /* * getConfigurationElementsFor is not working for server Platform. * I have to work around this by walking the extension list IConfigurationElement[] configElems = extReg.getConfigurationElementsFor( OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION ); */ IExtensionPoint extPoint = extReg.getExtensionPoint(OdaJdbcDriver.Constants.DRIVER_INFO_EXTENSION); if (extPoint == null) return; IExtension[] exts = extPoint.getExtensions(); if (exts == null) return; for (int e = 0; e < exts.length; e++) { IConfigurationElement[] configElems = exts[e].getConfigurationElements(); if (configElems == null) continue; for (int i = 0; i < configElems.length; i++) { if (configElems[i].getName().equals(OdaJdbcDriver.Constants.DRIVER_INFO_ELEM_JDBCDRIVER)) { String driverClass = configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_DRIVERCLASS); String connectionFactory = configElems[i].getAttribute(OdaJdbcDriver.Constants.DRIVER_INFO_ATTR_CONNFACTORY); logger.info( "Found JDBC driverinfo extension: driverClass=" + driverClass + ", connectionFactory=" + connectionFactory); if (driverClass != null && driverClass.length() > 0 && connectionFactory != null && connectionFactory.length() > 0) { // This driver class has its own connection factory; cache it // Note that the instantiation of the connection factory can wait // until we actually need it driverExtensions.put(driverClass, configElems[i]); } } } } }
public IExtension[] getBreakpointActionPageExtensions() { if (breakpointActionPageExtensions == null) { IExtensionPoint point = Platform.getExtensionRegistry() .getExtensionPoint( CDebugUIPlugin.PLUGIN_ID, BREAKPOINT_ACTION_PAGE_EXTENSION_POINT_ID); if (point == null) breakpointActionPageExtensions = new IExtension[0]; else { breakpointActionPageExtensions = point.getExtensions(); } } return breakpointActionPageExtensions; }
static Class<?> getJDClassFileEditorClass() throws ClassNotFoundException { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint point = registry.getExtensionPoint("org.eclipse.ui.editors"); if (point == null) return null; IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; i++) { IConfigurationElement[] elements = extensions[i].getConfigurationElements(); for (int j = 0; j < elements.length; j++) { String id = elements[j].getAttribute("id"); if (id.indexOf("jd.ide.eclipse.editors.JDClassFileEditor") == 0) return Class.forName(elements[j].getAttribute("class")); } } return null; }
public static INamespaceDefinition getDefaultNamespaceDefinition() { INamespaceDefinitionResolver definitionResolver = BeansCorePlugin.getNamespaceDefinitionResolver(null); org.springframework.ide.eclipse.beans.core.model.INamespaceDefinition namespaceDefinition = definitionResolver.resolveNamespaceDefinition(DEFAULT_NAMESPACE_URI); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(NAMESPACES_EXTENSION_POINT); if (point != null) { String namespaceURI = DEFAULT_NAMESPACE_URI; for (IExtension extension : point.getExtensions()) { for (IConfigurationElement config : extension.getConfigurationElements()) { if (namespaceURI.equals(config.getAttribute("uri"))) { String prefix = config.getAttribute("prefix"); if (!StringUtils.hasText(prefix) && namespaceDefinition != null) { prefix = namespaceDefinition.getPrefix(); } String schemaLocation = config.getAttribute("defaultSchemaLocation"); if (!StringUtils.hasText(schemaLocation) && namespaceDefinition != null) { schemaLocation = namespaceDefinition.getDefaultSchemaLocation(); } String uri = config.getAttribute("uri"); IImageAccessor image = null; if (config.getAttribute("icon") != null) { String ns = config.getDeclaringExtension().getNamespaceIdentifier(); String icon = config.getAttribute("icon"); image = new DefaultImageAccessor(ns, icon); } else if (namespaceDefinition != null) { image = new NamespaceDefinitionImageAccessor(namespaceDefinition); } return new DefaultNamespaceDefinition( prefix, uri, schemaLocation, namespaceDefinition.getUriMapping(), image); } } } } if (namespaceDefinition != null) { return new DefaultNamespaceDefinition( namespaceDefinition.getPrefix(), namespaceDefinition.getNamespaceUri(), namespaceDefinition.getDefaultSchemaLocation(), namespaceDefinition.getUriMapping(), new NamespaceDefinitionImageAccessor(namespaceDefinition)); } return null; }