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

The following examples show how to use org.eclipse.core.runtime.IConfigurationElement#getName() . These examples are extracted from open source projects. 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 Project: tm4e   File: ThemeManager.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Load TextMate Themes from extension point.
 */
private void loadThemesFromExtensionPoints() {
	IConfigurationElement[] cf = Platform.getExtensionRegistry().getConfigurationElementsFor(TMUIPlugin.PLUGIN_ID,
			EXTENSION_THEMES);
	for (IConfigurationElement ce : cf) {
		String name = ce.getName();
		if (THEME_ELT.equals(name)) {
			// theme
			Theme theme = new Theme(ce);
			super.registerTheme(theme);
		} else if (THEME_ASSOCIATION_ELT.equals(name)) {
			// themeAssociation
			super.registerThemeAssociation(new ThemeAssociation(ce));
		}
	}
}
 
Example 2
private static List<Filter> getFilters(IConfigurationElement[] children) {
  List<Filter> filters = new ArrayList<>();
  for (IConfigurationElement childElement : children) {
    switch (childElement.getName()) {
      case ELEMENT_NAME_EXCLUSION_FILTER:
        filters.add(Filter.exclusionFilter(childElement.getAttribute(ATTRIBUTE_NAME_PATTERN)));
        break;
      case ELEMENT_NAME_INCLUSION_FILTER:
        filters.add(Filter.inclusionFilter(childElement.getAttribute(ATTRIBUTE_NAME_PATTERN)));
        break;
      default:
        // other child element of libraryFile, e.g.: mavenCoordinates
        break;
    }
  }
  return filters;
}
 
Example 3
/**
 * Return the analysis module outputs, wrapped as new module listeners,
 * advertised in the extension point, in iterable format.
 *
 * @return List of {@link ITmfNewAnalysisModuleListener}
 */
public static Iterable<@NonNull ITmfNewAnalysisModuleListener> getOutputListeners() {
    List<@NonNull ITmfNewAnalysisModuleListener> newModuleListeners = new ArrayList<>();
    // Get the sources element from the extension point
    IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID);
    for (IConfigurationElement ce : config) {
        String elementName = ce.getName();
        ITmfNewAnalysisModuleListener listener = null;
        if (elementName.equals(OUTPUT_ELEM)) {
            listener = getListenerFromOutputElement(ce);
        } else if (elementName.equals(LISTENER_ELEM)) {
            listener = getListenerFromListenerElement(ce);
        }
        if (listener != null) {
            newModuleListeners.add(listener);
        }
    }
    return newModuleListeners;
}
 
Example 4
private void loadChildren(String contentType, IConfigurationElement[] innerElements)
{

	for (IConfigurationElement innerElement : innerElements)
	{
		String name = innerElement.getName();

		if (name.equals(getContributionElementName()))
		{
			addContribution(contentType, innerElement);
		}
		else if (name.equals(SELECTOR_TAG))
		{
			addSelector(contentType, innerElement);
		}
	}
}
 
Example 5
private void readRegisteredImportPackages() {
    final IConfigurationElement[] configurationElements =
        Platform.getExtensionRegistry().getConfigurationElementsFor(IMPORT_PACKAGE_EXT);
    for (IConfigurationElement e : configurationElements) {
        final String name = e.getName();
        if (COMPONENT.equals(name)) {
            final String cmpName = e.getAttribute(COMPONENT_NAME);
            Collection<ExImportPackage> packageSet = componentImportPackages.get(cmpName);
            if (packageSet == null) {
                packageSet = new ArrayList<ExImportPackage>();
                componentImportPackages.put(cmpName, packageSet);
            }
            for (IConfigurationElement p : e.getChildren(IMPORT_PACKAGE)) {
                packageSet.add(createImportPackageFrom(p));
            }
        } else {
            importPackagesForAll.add(createImportPackageFrom(e));
        }
    }
}
 
Example 6
private void readRegisteredRequireBundles() {
    final IConfigurationElement[] configurationElements =
        Platform.getExtensionRegistry().getConfigurationElementsFor(REQUIRE_BUNDLE_EXT);
    for (IConfigurationElement e : configurationElements) {
        final String name = e.getName();
        if (COMPONENT.equals(name)) {
            final String cmpName = e.getAttribute(COMPONENT_NAME);
            Collection<ExRequireBundle> bundleSet = componentRequireBundles.get(cmpName);
            if (bundleSet == null) {
                bundleSet = new ArrayList<ExRequireBundle>();
                componentRequireBundles.put(cmpName, bundleSet);
            }
            for (IConfigurationElement b : e.getChildren(REQUIRE_BUNDLE)) {
                bundleSet.add(createRequireBundleFrom(b));
            }
        } else {
            requireBundlesForAll.add(createRequireBundleFrom(e));
        }
    }
}
 
Example 7
private Map<Integer, IConfigurationElement> collectNeededPages(String point,
	String[] userSettings, Map<Integer, IConfigurationElement> iceMap){
	List<IConfigurationElement> list = Extensions.getExtensions(point);
	for (IConfigurationElement ce : list) {
		try {
			if ("Artikel".equals(ce.getName())) { //$NON-NLS-1$
				continue;
			}
			IDetailDisplay d =
				(IDetailDisplay) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CDD);
			for (int i = 0; i < userSettings.length; i++) {
				if (userSettings[i].equals(d.getTitle().trim())) {
					iceMap.put(i, ce);
				}
			}
		} catch (Exception ex) {
			ElexisStatus status =
				new ElexisStatus(ElexisStatus.WARNING, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE,
					"Fehler beim Initialisieren von " + ce.getName(), ex,
					ElexisStatus.LOG_WARNINGS);
			StatusManager.getManager().handle(status, StatusManager.SHOW);
		}
	}
	return iceMap;
}
 
Example 8
private List<String> findPagesFor(String point, String ignore){
	List<String> pageNames = new ArrayList<String>();
	List<IConfigurationElement> list = Extensions.getExtensions(point);
	for (IConfigurationElement ce : list) {
		try {
			if (ignore != null && ignore.equals(ce.getName())) {
				continue;
			}
			IDetailDisplay d =
				(IDetailDisplay) ce.createExecutableExtension("CodeDetailDisplay"); //$NON-NLS-1$
			
			pageNames.add(d.getTitle().trim());
		} catch (Exception ex) {
			new ElexisStatus(ElexisStatus.WARNING, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE,
				"Fehler beim Laden von " + ce.getName(), ex, ElexisStatus.LOG_WARNINGS);
		}
	}
	return pageNames;
}
 
Example 9
/**
 * Read information from extensions defined in plugin.xml files
 */
protected synchronized void initialize() {
	if (isInitialized) {
		throw new IllegalStateException("may invoke method initialize() only once");
	}
	isInitialized = true;

	final IExtensionRegistry registry = RegistryFactory.getRegistry();
	if (registry != null) {
		final IExtension[] extensions = registry.getExtensionPoint(FILE_EXTENSIONS_POINT_ID).getExtensions();
		for (IExtension extension : extensions) {
			final IConfigurationElement[] configElems = extension.getConfigurationElements();
			for (IConfigurationElement elem : configElems) {
				try {
					List<String> fileExtensions = Splitter.on(',').trimResults().omitEmptyStrings()
							.splitToList(elem.getAttribute(ATT_FILE_EXTENSION));

					String elementName = elem.getName();
					if (ATT_TRANSPILABLE_FILE_EXTENSIONS.equals(elementName)) {
						transpilableFileExtensions.addAll(fileExtensions);
					} else if (ATT_TEST_FILE_EXTENSIONS.equals(elementName)) {
						testFileExtensions.addAll(fileExtensions);
					} else if (ATT_RUNNABLE_FILE_EXTENSIONS.equals(elementName)) {
						runnableFileExtensions.addAll(fileExtensions);
					} else if (ATT_TYPABLE_FILE_EXTENSIONS.equals(elementName)) {
						typableFileExtensions.addAll(fileExtensions);
					} else if (ATT_RAW_FILE_EXTENSIONS.equals(elementName)) {
						rawFileExtensions.addAll(fileExtensions);
					} else {
						LOGGER.error(new UnsupportedOperationException(
								"This file extension type " + elementName + " is not supported yet"));
					}
				} catch (Exception ex) {
					LOGGER.error("Error while reading extensions for extension point " + FILE_EXTENSIONS_POINT_ID,
							ex);
				}
			}
		}
	}
}
 
Example 10
Source Project: tm4e   File: SnippetManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Load snippets from extension point.
 */
private void loadGrammarsFromExtensionPoints() {
	IConfigurationElement[] cf = Platform.getExtensionRegistry().getConfigurationElementsFor(TMUIPlugin.PLUGIN_ID,
			EXTENSION_SNIPPETS);
	for (IConfigurationElement ce : cf) {
		String extensionName = ce.getName();
		if (SNIPPET_ELT.equals(extensionName)) {
			this.registerSnippet(new Snippet(ce));
		}
	}
}
 
Example 11
private void loadFromExtensionPoints() {
	IConfigurationElement[] cf = Platform.getExtensionRegistry()
			.getConfigurationElementsFor(LanguageConfigurationPlugin.PLUGIN_ID, EXTENSION_LANGUAGE_CONFIGURATIONS);
	for (IConfigurationElement ce : cf) {
		String name = ce.getName();
		if (LANGUAGE_CONFIGURATION_ELT.equals(name)) {
			LanguageConfigurationDefinition delegate = new LanguageConfigurationDefinition(ce);
			registerLanguageConfigurationDefinition(delegate);
		}
	}

}
 
Example 12
private List<ApplicableClass> fillApplicableClasses() {
    List<IConfigurationElement> ces = new ArrayList<>();
    /*
     * Get the module's applying tracetypes, first from the extension point itself
     */
    IConfigurationElement[] tracetypeCE = fCe.getChildren(TmfAnalysisModuleSourceConfigElement.TRACETYPE_ELEM);
    ces.addAll(Arrays.asList(tracetypeCE));
    /* Then those in their separate extension */
    tracetypeCE = Platform.getExtensionRegistry().getConfigurationElementsFor(TmfAnalysisModuleSourceConfigElement.TMF_ANALYSIS_TYPE_ID);
    String id = getId();
    for (IConfigurationElement element : tracetypeCE) {
        String elementName = element.getName();
        if (elementName.equals(TmfAnalysisModuleSourceConfigElement.TRACETYPE_ELEM)) {
            String analysisId = element.getAttribute(TmfAnalysisModuleSourceConfigElement.ID_ATTR);
            if (id.equals(analysisId)) {
                ces.add(element);
            }
        }
    }
    Map<Class<?>, ApplicableClass> classMap = new HashMap<>();
    /*
     * Convert the configuration element to applicable classes and keep only the
     * latest one for a class
     */
    ces.forEach(ce -> {
        ApplicableClass traceTypeApplies = parseTraceTypeElement(ce);
        if (traceTypeApplies != null) {
            classMap.put(traceTypeApplies.fClass, traceTypeApplies);
        }
    });
    List<ApplicableClass> applicableClasses = new ArrayList<>(classMap.values());
    return sortApplicableClasses(applicableClasses);
}
 
Example 13
/**
 * Return the analysis parameter providers advertised in the extension
 * point, and associated with an analysis ID.
 *
 * @param analysisId
 *            Get the parameter providers for an analysis identified by its
 *            ID
 * @return Map of analysis ID mapped to parameter provider classes
 */
public static Set<IAnalysisParameterProvider> getParameterProvidersFor(String analysisId) {
    Set<IAnalysisParameterProvider> providers = new HashSet<>();
    // Get the parameter provider elements from the extension point
    IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
    if (extensionRegistry == null) {
        return Collections.emptySet();
    }
    IConfigurationElement[] config = extensionRegistry.getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID);
    for (IConfigurationElement ce : config) {
        String elementName = ce.getName();
        if (elementName.equals(PARAMETER_PROVIDER_ELEM)) {
            try {
                IConfigurationElement[] children = ce.getChildren(ANALYSIS_ID_ELEM);
                if (children.length == 0) {
                    throw new IllegalStateException();
                }
                String id = children[0].getAttribute(ID_ATTR);
                String className = ce.getAttribute(CLASS_ATTR);
                if (id == null || className == null) {
                    continue;
                }
                if (analysisId.equals(id)) {
                    IAnalysisParameterProvider provider = fParamProviderInstances.get(className);
                    if (provider == null) {
                        provider = checkNotNull((IAnalysisParameterProvider) ce.createExecutableExtension(CLASS_ATTR));
                        fParamProviderInstances.put(className, provider);
                    }
                    providers.add(provider);
                }
            } catch (InvalidRegistryObjectException | CoreException e) {
                Activator.logError("Error creating module parameter provider", e); //$NON-NLS-1$
            }
        }
    }
    return providers;
}
 
Example 14
private void populateAnalysisList() {
    if (fAnalysisHelpers.isEmpty()) {
        // Populate the analysis module list
        IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(TMF_ANALYSIS_TYPE_ID);
        for (IConfigurationElement ce : config) {
            String elementName = ce.getName();
            if (elementName.equals(TmfAnalysisModuleSourceConfigElement.MODULE_ELEM)) {
                fAnalysisHelpers.add(new TmfAnalysisModuleHelperConfigElement(ce));
            }
        }
    }
}
 
Example 15
/**
 * 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
public void processElement(IConfigurationElement element)
{
	String name = element.getName();

	if (dispatchTable != null && dispatchTable.containsKey(name))
	{
		dispatchTable.get(name).processElement(element);
	}
}
 
Example 17
private void addPagesFor(String point){
	List<IConfigurationElement> list = Extensions.getExtensions(point);
	for (IConfigurationElement ce : list) {
		try {
			if ("Artikel".equals(ce.getName())) { //$NON-NLS-1$
				continue;
			}
			IDetailDisplay detailDisplay =
				(IDetailDisplay) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CDD);
			CodeSelectorFactory codeSelector =
				(CodeSelectorFactory) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CSF);
			String a = ce.getAttribute(ExtensionPointConstantsUi.VERRECHNUNGSCODE_IMPC);
			ImporterPage ip = null;
			if (a != null) {
				ip = (ImporterPage) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_IMPC);
				if (ip != null) {
					importers.put(detailDisplay.getTitle(), ip);
				}
			}
			MasterDetailsPage page = new MasterDetailsPage(ctab, codeSelector, detailDisplay);
			CTabItem ct = new CTabItem(ctab, SWT.NONE);
			ct.setText(detailDisplay.getTitle());
			ct.setControl(page);
			ct.setData(detailDisplay);
			
			CoreUiUtil.injectServicesWithContext(codeSelector);
			CoreUiUtil.injectServicesWithContext(detailDisplay);
		} catch (Exception ex) {
			LoggerFactory.getLogger(getClass()).error("Error creating pages", ex);
			ElexisStatus status =
				new ElexisStatus(ElexisStatus.WARNING, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE,
					"Fehler beim Initialisieren von " + ce.getName(), ex,
					ElexisStatus.LOG_WARNINGS);
			StatusManager.getManager().handle(status, StatusManager.SHOW);
		}
	}
}
 
Example 18
private void addUserSpecifiedPages(String settings){
	String[] userSettings = settings.split(",");
	Map<Integer, IConfigurationElement> iceMap = new TreeMap<Integer, IConfigurationElement>();
	
	iceMap = collectNeededPages(ExtensionPointConstantsUi.DIAGNOSECODE, userSettings, iceMap);
	iceMap =
		collectNeededPages(ExtensionPointConstantsUi.VERRECHNUNGSCODE, userSettings, iceMap);
	iceMap = collectNeededPages(ExtensionPointConstantsUi.GENERICCODE, userSettings, iceMap);
	
	// add favorites tab if settings desire it
	for (int i = 0; i < userSettings.length; i++) {
		if (userSettings[i].equals("Favoriten")) {
			iceMap.put(i, null);
		}
	}
	
	for (Integer key : iceMap.keySet()) {
		IConfigurationElement ce = iceMap.get(key);
		if (ce == null) {
			new FavoritenCTabItem(ctab, SWT.None);
			continue;
		}
		
		try {
			IDetailDisplay detailDisplay =
				(IDetailDisplay) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CDD);
			CodeSelectorFactory codeSelector =
				(CodeSelectorFactory) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_CSF);
			String a = ce.getAttribute(ExtensionPointConstantsUi.VERRECHNUNGSCODE_IMPC);
			ImporterPage ip = null;
			if (a != null) {
				ip = (ImporterPage) ce.createExecutableExtension(ExtensionPointConstantsUi.VERRECHNUNGSCODE_IMPC);
				if (ip != null) {
					importers.put(detailDisplay.getTitle(), ip);
				}
			}
			
			MasterDetailsPage page = new MasterDetailsPage(ctab, codeSelector, detailDisplay);
			CTabItem ct = new CTabItem(ctab, SWT.NONE);
			ct.setText(detailDisplay.getTitle());
			ct.setControl(page);
			ct.setData(detailDisplay);
			
			CoreUiUtil.injectServices(codeSelector);
			CoreUiUtil.injectServices(detailDisplay);
		} catch (Exception ex) {
			LoggerFactory.getLogger(getClass()).error("Error creating pages", ex);
			ElexisStatus status =
				new ElexisStatus(ElexisStatus.WARNING, Hub.PLUGIN_ID, ElexisStatus.CODE_NONE,
					"Fehler beim Initialisieren von " + ce.getName(), ex,
					ElexisStatus.LOG_WARNINGS);
			StatusManager.getManager().handle(status, StatusManager.SHOW);
		}
	}
}