private void readExtentions() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint point = registry.getExtensionPoint(PDECore.PLUGIN_ID, TARGET_LOC_EXTPT); if (point == null) return; 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 type = elements[j].getAttribute(ATTR_TYPE); if (type != null) { fExtentionMap.put(type, elements[j]); } } } }
private Bundle getBundle() { String namespace= fElement.getDeclaringExtension().getContributor().getName(); Bundle bundle= Platform.getBundle(namespace); return bundle; }
private void loadDefinitions() { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS); IExtension[] types = point.getExtensions(); definitions = new HashMap<>(types.length); for (int i = 0; i < types.length; i++) { String markerId = types[i].getUniqueIdentifier(); if (markerId != null) definitions.put(markerId.intern(), new MarkerTypeDefinition(types[i])); else Policy.log(IStatus.WARNING, "Missing marker id from plugin: " + types[i].getContributor().getName(), null); //$NON-NLS-1$ } } }
/** * Obtains the ID of the specified extension, * or the defining plug-in ID if the extension has none. * * @param extension an extension * @return an identifier for the extension */ private String getExtensionID(IExtension extension) { String result = extension.getUniqueIdentifier(); if (result == null) { result = extension.getNamespaceIdentifier(); } return result; } }
/** * Logs the error in the desktop log using the provided * text and the information in the configuration element. */ protected void logError(IConfigurationElement element, String text) { IExtension extension = element.getDeclaringExtension(); System.err.println("Plugin " + extension.getContributor().getName() + ", extension " + extension.getExtensionPointUniqueIdentifier()); System.err.println(text); }
/** * @param extensionPointId * @param extensionId must not be null */ public IExtensionDelta getExtensionDelta(String extensionPointId, String extensionId) { for (Iterator<IExtensionDelta> extDeltasIter = extensionDeltas.iterator(); extDeltasIter.hasNext();) { IExtensionDelta extensionDelta = extDeltasIter.next(); IExtension extension = extensionDelta.getExtension(); if (extension.getExtensionPointUniqueIdentifier().equals(extensionPointId) && extension.getUniqueIdentifier() != null && extension.getUniqueIdentifier().equals(extensionId)) return extensionDelta; } return null; }
/** * Loads contributed value variables. This is done before loading persisted values. */ private void loadContributedValueVariables() { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(VariablesPlugin.PI_CORE_VARIABLES, EXTENSION_POINT_VALUE_VARIABLES); IConfigurationElement elements[]= point.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement element = elements[i]; String name= element.getAttribute(ATTR_NAME); if (name == null) { VariablesPlugin.logMessage(NLS.bind("Variable extension missing required 'name' attribute: {0}", new String[] {element.getDeclaringExtension().getLabel()}), null); //$NON-NLS-1$ continue; } String description= element.getAttribute(ATTR_DESCRIPTION); boolean isReadOnly = TRUE_VALUE.equals(element.getAttribute(ATTR_READ_ONLY)); IValueVariable variable = new ContributedValueVariable(name, description, isReadOnly, element); Object old = fValueVariables.put(name, variable); if (old != null) { StringVariable oldVariable = (StringVariable)old; VariablesPlugin.logMessage(NLS.bind("Contributed variable extension from bundle ''{0}'' overrides existing extension variable ''{1}'' from bundle ''{2}''", //$NON-NLS-1$ new String[] {element.getDeclaringExtension().getContributor().getName(),oldVariable.getName(), oldVariable.getConfigurationElement().getDeclaringExtension().getContributor().getName()}), null); } } }
/** * Instantiates and returns the builder with the given name. If the builder, its plugin, or its nature * is missing, returns null. */ private IncrementalProjectBuilder instantiateBuilder(String builderName) throws CoreException { IExtension extension = Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_BUILDERS, builderName); if (extension == null) return null; IConfigurationElement[] configs = extension.getConfigurationElements(); if (configs.length == 0) return null; String natureId = null; if (getBooleanAttribute(configs[0], "hasNature")) { //$NON-NLS-1$ //find the nature that owns this builder String builderId = extension.getUniqueIdentifier(); natureId = workspace.getNatureManager().findNatureForBuilder(builderId); if (natureId == null) return null; } //The nature exists, or this builder doesn't specify a nature InternalBuilder builder = (InternalBuilder) configs[0].createExecutableExtension("run"); //$NON-NLS-1$ builder.setPluginId(extension.getContributor().getName()); builder.setLabel(extension.getLabel()); builder.setNatureId(natureId); builder.setCallOnEmptyDelta(getBooleanAttribute(configs[0], "callOnEmptyDelta")); //$NON-NLS-1$ return (IncrementalProjectBuilder) builder; }
/** * Reads the MetaDataEnabledFeatures extensions into a registry */ protected void readRegistry() { try { IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(JSFCorePlugin.PLUGIN_ID, EXTPTID); IExtension[] extensions = point.getExtensions(); for (int i=0;i < extensions.length;i++){ IExtension ext = extensions[i]; for (int j=0;j < ext.getConfigurationElements().length;j++){ final String bundleId = ext.getConfigurationElements()[j].getContributor().getName(); final String id = ext.getConfigurationElements()[j].getAttribute("typeid"); final String klass = ext.getConfigurationElements()[j].getAttribute("class"); registerFeature(bundleId, id, klass); } } } catch (InvalidRegistryObjectException e) { JSFCorePlugin.log(e, "Unable to read " + JSFCorePlugin.PLUGIN_ID + EXTPTID + " registry"); } }
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint( ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS); if (point != null) { IExtension[] extensions = point.getExtensions(); for (int i = 0; i < extensions.length; ++i) { IExtension ext = extensions[i]; String id = ext.getUniqueIdentifier(); String label = ext.getLabel(); if (label.equals("")) {//$NON-NLS-1$ label = getWellKnownLabel(id); .getConfigurationElements(); for (int j = 0; j < configElements.length; ++j) { IConfigurationElement elt = configElements[j]; if (elt.getName().equalsIgnoreCase("super")) {//$NON-NLS-1$ String sup = elt.getAttribute("type");//$NON-NLS-1$ if (sup != null) { supersList.add(sup);
public boolean supportsConfigs() { if (!supportsConfigurationsCalculated) { IExtension extension = Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_BUILDERS, name); if (extension != null) { IConfigurationElement[] configs = extension.getConfigurationElements(); if (configs.length != 0) { String value = configs[0].getAttribute("supportsConfigurations"); //$NON-NLS-1$ supportsConfigurations = (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())); } } supportsConfigurationsCalculated = true; } return supportsConfigurations; }
private Map<String, String> createThemeAssociations() { Map<String, String> result = new HashMap<>(); IExtensionRegistry registry = RegistryFactory.getRegistry(); IExtensionPoint extPoint = registry.getExtensionPoint(E4_THEME_EXTENSION_POINT); for (IExtension e : extPoint.getExtensions()) { for (IConfigurationElement ce : e.getConfigurationElements()) { if (ce.getName().equals(ATT_THEME_ASSOCIATION)) { String themeId = ce.getAttribute(ATT_THEME_ID); String osVersion = ce.getAttribute(ATT_OS_VERSION); result.put(osVersion != null ? themeId + osVersion : themeId, ce.getAttribute(ATT_COLOR_AND_FONT_ID)); } } } return result; }
/** * Load extensions */ private void initialize() { fConfigurations = new HashMap<>(); IExtensionPoint point= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), EXTENSION_POINT_STRING_VARIABLE_PRESENTATIONS); IConfigurationElement elements[]= point.getConfigurationElements(); for (int i = 0; i < elements.length; i++) { IConfigurationElement element = elements[i]; String name= element.getAttribute(ATTR_NAME); if (name == null) { DebugUIPlugin.logErrorMessage(MessageFormat.format("String variable presentation extension missing required 'variableName' attribute: {0}", new Object[] { element.getDeclaringExtension().getLabel() })); //$NON-NLS-1$ continue; } fConfigurations.put(name, element); } }
private static Map<String, Object> collectAttributes(final IConfigurationElement config) { final Map<String, Object> map = new HashMap<String, Object>(); try { final IExtension extension = config.getDeclaringExtension(); // use @ to avoid conflicting with attributes in the XML safePut(map, "@id", extension.getUniqueIdentifier()); safePut(map, "@label", extension.getLabel()); safePut(map, "@contributor", config.getContributor()); safePut(map, "@namespace", config.getNamespaceIdentifier()); safePut(map, "@point", extension.getExtensionPointUniqueIdentifier()); // similarly use () to avoid conflicts safePut(map, "name()", config.getName()); safePut(map, "text()", config.getValue()); // now load the actual attributes from the XML for (final String key : config.getAttributeNames()) { safePut(map, key, config.getAttribute(key)); } } catch (final InvalidRegistryObjectException re) { map.clear(); // invalid, so wipe slate clean } return unmodifiableMap(map); }
protected IConfigurationElement[] getExtendedConfigurationElements() { IExtensionRegistry registry = Platform.getExtensionRegistry(); IExtensionPoint exampleWizardXP = registry.getExtensionPoint(EXAMPLE_WIZARD_XP_ID); if (exampleWizardXP == null) { return new IConfigurationElement[0]; } IExtension extension = exampleWizardXP.getExtension(getWizardExtensionId()); if (extension != null) { return extension.getConfigurationElements(); } IConfigurationElement[] exampleWizardCEs = exampleWizardXP.getConfigurationElements(); return exampleWizardCEs; }
private void remove(IExtension extension) { IConfigurationElement[] elements = extension.getConfigurationElements(); for (IConfigurationElement element : elements) { if (E_ENVIRONMENT_FACTORY.equals(element.getName())) { removeEnvironmentFactory(element); } } }
private void displayExtension(IExtension extention, CommandInterpreter ci, boolean full) { if (extention == null) return; if (full) { ci.print("Id: " + extention.getUniqueIdentifier()); //$NON-NLS-1$ ci.print(" PointId: " + extention.getExtensionPointUniqueIdentifier()); //$NON-NLS-1$ ci.println(" [from " + extention.getContributor().getName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } else { ci.println(extention.getUniqueIdentifier() + " [from " + extention.getContributor().getName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } }
private static IConfigurationElement[] getSequenceModifierElements(IConfigurationElement configurationElement) { IExtension extension = configurationElement.getDeclaringExtension(); List modifierElements = new ArrayList(); for (final IConfigurationElement configElement : extension.getConfigurationElements()) { if(TAG_SEQUENCE_MODIFIER.equals(configElement.getName())) modifierElements.add(configElement); } return (IConfigurationElement[]) modifierElements.toArray(new IConfigurationElement[modifierElements.size()]); }
private Extension createExtensionAdapter(IExtension extension) { Extension adapter = new Extension(); adapter.setNamespaceIdentifier(extension.getNamespaceIdentifier()); adapter.setLabel(extension.getLabel()); adapter.setExtensionPointUniqueIdentifier(extension.getExtensionPointUniqueIdentifier()); adapter.setContributor(getBundleId(extension.getContributor().getName())); IConfigurationElement[] elements = extension.getConfigurationElements(); if (elements.length > 0) { ConfigurationElement[] configurationElements = new ConfigurationElement[elements.length]; for (int i = 0; i < elements.length; i++) { configurationElements[i] = createConfigurationElement(elements[i]); } adapter.setConfigurationElements(configurationElements); } return adapter; }
public void fail(String message) throws CoreException { String id= findId(fElement); String extensionPointId= fElement.getDeclaringExtension().getExtensionPointUniqueIdentifier(); Object[] args= { fElement.getContributor().getName(), id, extensionPointId }; String blame= MessageFormat.format(RulerColumnMessages.ExtensionPointHelper_invalid_contribution_msg, args); IStatus status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, blame + message, null); throw new CoreException(status); }