Java Code Examples for org.eclipse.core.runtime.IConfigurationElement#getAttribute()

The following examples show how to use org.eclipse.core.runtime.IConfigurationElement#getAttribute() . 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: XMLExtensionRegistry.java    From wildwebdeveloper with Eclipse Public License 2.0 6 votes vote down vote up
private Map<IConfigurationElement, LemminxClasspathExtensionProvider> getRegisteredClassPathProviders() {
	Map<IConfigurationElement, LemminxClasspathExtensionProvider> extensionProviders = new HashMap<>();
	for (IConfigurationElement extension : Platform.getExtensionRegistry()
			.getConfigurationElementsFor(EXTENSION_POINT_ID)) {
		try {
			if (extension.getName().equals("classpathExtensionProvider") && extension.getAttribute("provider") != null) {
				final Object executableExtension = extension.createExecutableExtension("provider");
				if (executableExtension instanceof LemminxClasspathExtensionProvider) {
					extensionProviders.put(extension, (LemminxClasspathExtensionProvider) executableExtension);
				}
			}
		} catch (Exception ex) {
			Activator.getDefault().getLog()
					.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, ex.getMessage(), ex));

		}
	}
	return extensionProviders;
}
 
Example 2
Source File: ConfigurationHelper.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
private static MonitorViewConfiguration convertMonitor ( final IConfigurationElement ele )
{
    try
    {
        final String id = ele.getAttribute ( "id" ); //$NON-NLS-1$
        final String monitorQueryId = ele.getAttribute ( "monitorQueryId" ); //$NON-NLS-1$
        final String connectionString = ele.getAttribute ( "connectionString" ); //$NON-NLS-1$
        final ConnectionType connectionType = ConnectionType.valueOf ( ele.getAttribute ( "connectionType" ) ); //$NON-NLS-1$
        final String label = ele.getAttribute ( "label" ); //$NON-NLS-1$
        final List<ColumnProperties> columns = parseColumnSettings ( ele.getAttribute ( "columns" ) ); //$NON-NLS-1$

        return new MonitorViewConfiguration ( id, monitorQueryId, connectionString, connectionType, label, columns );
    }
    catch ( final Exception e )
    {
        logger.warn ( "Failed to convert monitor configuration: {}", ele ); //$NON-NLS-1$
        return null;
    }
}
 
Example 3
Source File: OutputLog.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public static IOutputter getOutputter(String outputterID){
	IOutputter ret = outputter_cache.get(outputterID);
	if (ret == null) {
		List<IConfigurationElement> eps =
			Extensions.getExtensions(ExtensionPointConstantsData.OUTPUT_LOG_DESCRIPTOR);
		for (IConfigurationElement ep : eps) {
			String id = ep.getAttribute("id");
			if (id != null && id.equals(outputterID)) {
				try {
					ret = (IOutputter) ep.createExecutableExtension("Outputter");
					outputter_cache.put(outputterID, ret);
					break;
				} catch (CoreException ex) {
					ExHandler.handle(ex);
				}
			}
		}
	}
	return ret;
}
 
Example 4
Source File: ExtensionPointManager.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @param newPoint
 *            the extension point instance
 * @param element
 *            the configuration element
 * @param className
 *            the name of the class attribute
 */
private void loadClass( ExtendedElementUIPoint newPoint,
		IConfigurationElement element, String className,
		String attributeName )
{
	String value = element.getAttribute( className );
	if ( value != null )
	{
		try
		{
			newPoint.setClass( attributeName,
					element.createExecutableExtension( className ) );
		}
		catch ( CoreException e )
		{
		}
	}

}
 
Example 5
Source File: IXtextSearchFilter.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static Collection<String> allNamespaceDelimiters() {
	IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
			.getConfigurationElementsFor(EXTENSION_POINT_ID);
	Set<String> delimiters = Sets.newHashSet();
	delimiters.add(DEFAULT_NAMESPACE_DELIMITER);
	for (IConfigurationElement configurationElement : configurationElements) {
		if (NAMESPACE_DELIMITER.equals(configurationElement.getName())) {
			String delimiter = configurationElement.getAttribute(VALUE);
			if(delimiter.contains("*") || delimiter.contains("?")) {
				LOG.error("Invalid namespace delimiter in " + configurationElement.getContributor().getName() + ": '*' and '?' not allowed.");
			}
			delimiters.add(delimiter);
		}
	}
	return delimiters;
}
 
Example 6
Source File: TmfAnalysisModuleOutputs.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static ITmfNewAnalysisModuleListener getListenerFromOutputElement(IConfigurationElement ce) {
    ITmfNewAnalysisModuleListener listener = null;
    try {
        IAnalysisOutput output = (IAnalysisOutput) ce.createExecutableExtension(CLASS_ATTR);
        if (output == null) {
            Activator.logWarning("An output could not be created"); //$NON-NLS-1$
            return listener;
        }
        for (IConfigurationElement childCe : ce.getChildren()) {
            if (childCe.getName().equals(ANALYSIS_ID_ELEM)) {
                listener = new TmfNewAnalysisOutputListener(output, childCe.getAttribute(ID_ATTR), null);
            } else if (childCe.getName().equals(MODULE_CLASS_ELEM)) {
                String contributorName = childCe.getContributor().getName();
                Class<?> moduleClass = Platform.getBundle(contributorName).loadClass(childCe.getAttribute(CLASS_ATTR));
                listener = new TmfNewAnalysisOutputListener(output, null, moduleClass.asSubclass(IAnalysisModule.class));
            }
        }
    } catch (InvalidRegistryObjectException | CoreException | ClassNotFoundException e) {
        Activator.logError("Error creating module output listener", e); //$NON-NLS-1$
    }
    return listener;
}
 
Example 7
Source File: ContributedJavadocWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static ContributedJavadocWizardPage[] getContributedPages(JavadocOptionsManager store) {
	ArrayList<ContributedJavadocWizardPage> pages= new ArrayList<ContributedJavadocWizardPage>();

	IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(JavaUI.ID_PLUGIN, ATT_EXTENSION);
	for (int i = 0; i < elements.length; i++) {
		IConfigurationElement curr= elements[i];
		String id= curr.getAttribute(ATT_ID);
		String description= curr.getAttribute(ATT_DESCRIPTION);
		String pageClassName= curr.getAttribute(ATT_PAGE_CLASS);

		if (id == null || description == null || pageClassName == null) {
			JavaPlugin.logErrorMessage("Invalid extension " + curr.toString()); //$NON-NLS-1$
			continue;
		}
		pages.add(new ContributedJavadocWizardPage(elements[i], store));
	}
	return pages.toArray(new ContributedJavadocWizardPage[pages.size()]);
}
 
Example 8
Source File: ExtendPopupMenu.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
public static ExtendPopupMenu createExtendPopupMenu(
		IConfigurationElement configurationElement, ERDiagramEditor editor)
		throws CoreException {
	ExtendPopupMenu menu = null;

	if (ExtendPopupMenu.EXTENSION_NAME.equals(configurationElement
			.getName())) {

	}
	String path = configurationElement.getAttribute(ATTRIBUTE_PATH);
	Object obj = configurationElement
			.createExecutableExtension(ATTRIBUTE_CLASS);

	if (obj instanceof IERDiagramActionFactory) {
		menu = new ExtendPopupMenu();
		IERDiagramActionFactory actionFactory = (IERDiagramActionFactory) obj;

		menu.action = actionFactory.createIAction(editor);
		menu.path = path;
	}

	return menu;
}
 
Example 9
Source File: ESBService.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
private void addExtensionRepositoryNodes(List<ERepositoryObjectType> arraysList) {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] configurationElements = registry
            .getConfigurationElementsFor("org.talend.core.repository.repository_node_provider");
    for (IConfigurationElement element : configurationElements) {
        String type = element.getAttribute("type");
        ERepositoryObjectType repositoryNodeType = ERepositoryObjectType.valueOf(ERepositoryObjectType.class, type);
        if (repositoryNodeType != null) {
            arraysList.add(repositoryNodeType);
        }
    }
}
 
Example 10
Source File: E4HandlerWrapper.java    From tlaplus with MIT License 5 votes vote down vote up
@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
		throws CoreException {
	final String defaultHandler = config.getAttribute("defaultHandler");
	if (defaultHandler.contains(":")) {
		clazz = defaultHandler.split(":")[1];
	}
}
 
Example 11
Source File: DetectorsExtensionHelper.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void addContribution(TreeMap<String, String> set, IConfigurationElement configElt) {
    IContributor contributor = configElt.getContributor();
    try {
        if (contributor == null) {
            throw new IllegalArgumentException("Null contributor");
        }
        String pluginId = configElt.getAttribute(PLUGIN_ID);
        if (pluginId == null) {
            throw new IllegalArgumentException("Missing '" + PLUGIN_ID + "'");
        }
        String 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);
    }
}
 
Example 12
Source File: ChartExtensionPointManager.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public Map<String, Chart> getRegisteredCharts() {
	if (chartMap == null) {
		chartMap = new HashMap<>();
	}
	
	IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId);

	if (extensionPoint != null) {
		for (IExtension element : extensionPoint.getExtensions()) {
			String name = element.getContributor().getName();
			Bundle bundle = Platform.getBundle(name);

			for (IConfigurationElement ice : element.getConfigurationElements()) {
				String path = ice.getAttribute("json");
				if (path!= null) {
					// TODO: More validation is needed here, as it's very susceptible
					// to error. Only load the chart if it passes validation.
					URL url = bundle.getResource(path);
					JsonNode json;
					try {
						json = loadJsonFile(url);
					} catch (Exception e) {
						e.printStackTrace(); // FIXME
						continue;
					}
					chartMap.put(json.path("name").textValue(), new Chart(json));
				}
			}
		}
	}
	return chartMap;
}
 
Example 13
Source File: LanguageCheckCatalogRegistryReader.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected boolean readElement(final IConfigurationElement element, final boolean add) {
  if (element.getAttribute(getAttribute()) == null) {
    return true; // the element is optional, no need to log an error
  }
  return super.readElement(element, add);
}
 
Example 14
Source File: DeclaredTemplatesListener.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * adds an extension to this.
 * 
 * @param extension
 *            the extension
 */
private void add(IExtension extension) {
    for (IConfigurationElement element : extension.getConfigurationElements()) {
        if (TEMPLATE_ELEMENT_NAME.equals(element.getName())) {
            final String templateName = element.getAttribute(NAME_ATTR_NAME);
            final String templateURIString = element.getAttribute(URI_ATTR_NAME);
            TemplateRegistry.INSTANCE.registerTemplate(templateName, URI.createURI(templateURIString));
        }
    }
}
 
Example 15
Source File: OsExecutionGraphProvider.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param trace
 *            The trace on which to build graph
 */
public OsExecutionGraphProvider(ITmfTrace trace) {
    super(trace, "LTTng Kernel"); //$NON-NLS-1$
    fSystem = new OsSystemModel();

    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_GRAPH_HANDLER_ID);
    for (IConfigurationElement ce : config) {
        String elementName = ce.getName();
        if (HANDLER.equals(elementName)) {
            IOsExecutionGraphHandlerBuilder builder;
            try {
                builder = (IOsExecutionGraphHandlerBuilder) ce.createExecutableExtension(ATTRIBUTE_CLASS);
            } catch (CoreException e1) {
                Activator.getDefault().logWarning("Error create execution graph handler builder", e1); //$NON-NLS-1$
                continue;
            }
            String priorityStr = ce.getAttribute(ATTRIBUTE_PRIORITY);
            int priority = DEFAULT_PRIORITY;
            try {
                priority = Integer.valueOf(priorityStr);
            } catch (NumberFormatException e) {
                // Nothing to do, use default value
            }
            ITraceEventHandler handler = builder.createHandler(this, priority);
            registerHandler(handler);
        }
    }
}
 
Example 16
Source File: PythonSourceFolderActionFilter.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Cache them after the 1st request for a given name.
 * 
 * Gets the property testers in org.python.pydev.customizations that match the passed name.
 */
private static synchronized List<PropertyTester> getPropertyTestersFromPydevCustomizations(String name) {
    List<PropertyTester> propertyTester = propertyTesters.get(name);
    if (propertyTester == null) {
        IExtension[] extensions = ExtensionHelper.getExtensions("org.eclipse.core.expressions.propertyTesters");
        // For each extension ...
        propertyTester = new ArrayList<PropertyTester>();
        propertyTesters.put(name, propertyTester);
        for (int i = 0; i < extensions.length; i++) {
            IExtension extension = extensions[i];
            IConfigurationElement[] elements = extension.getConfigurationElements();
            // For each member of the extension ...
            for (int j = 0; j < elements.length; j++) {
                IConfigurationElement element = elements[j];
                //Any property tester that's declared in "org.python.pydev.customizations"
                //is considered to be an object that provides the objectState for an IActionFilter.
                if ("org.python.pydev.customizations".equals(element.getAttribute("namespace"))) {
                    String attribute = element.getAttribute("properties");
                    if (name.equals(attribute)) {//i.e.: app_engine (and future references)
                        try {
                            PropertyTester executableExtension = (PropertyTester) element
                                    .createExecutableExtension("class");
                            propertyTester.add(executableExtension);
                        } catch (Exception e) {
                            Log.log(e);
                        }
                    }
                }
            }
        }
    }
    return propertyTester;
}
 
Example 17
Source File: FormPageDef.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private String loadStringAttribute( IConfigurationElement element,
		String attributeName )
{
	return element.getAttribute( attributeName );
}
 
Example 18
Source File: ContributionAction.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public ContributionAction(IConfigurationElement command){
	commandId = command.getAttribute("commandId");
	label = command.getAttribute("label");
}
 
Example 19
Source File: AbstractValidElementBase.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Reads the named attribute value from the configuration element. Throws IllegalArgumentException
 * if the name of the attribute is not known
 * 
 * @param configurationElement
 *          the container (configuration element)
 * @param name
 *          name of the attribute
 * @param optional
 *          if true, will return null if not found, otherwise IllegalArgumentException is raised
 * @return the value of the attribute of null if the attribute is optional and not supplied
 */
protected static String getAttribute(final IConfigurationElement configurationElement, final String name, final boolean optional) {
  String value = configurationElement.getAttribute(name);
  if (value != null) {
    return value;
  }
  if (optional) {
    return null;
  }
  throw new IllegalArgumentException(MessageFormat.format(MISSING_ATTRIBUTE_0, name));
}
 
Example 20
Source File: ValidModelTreeContentProvider.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a preference category object based on a configuration element.
 *
 * @param categoryProxy
 *          the configuration element
 * @return the preference category
 */
private PreferenceCategory createPreferenceCategory(final IConfigurationElement categoryProxy) {
  return new PreferenceCategory(categoryProxy.getAttribute(NAME), categoryProxy.getAttribute(LABEL), categoryProxy.getAttribute(DESCRIPTION));
}