use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class ProviderFramework method getOrderedConfigElements.
/**
* Get launch providers for a given type and order them with regards to highest priority first.
*
* @param type Type of launch providers requested.
* @return Array of launch provider configuration elements in prioritized order
* @since 1.2
*/
public static ArrayList<IConfigurationElement> getOrderedConfigElements(String type) {
IConfigurationElement[] configs = getConfigurationElements();
ArrayList<IConfigurationElement> configList = new ArrayList<>();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) {
// $NON-NLS-1$
// $NON-NLS-1$
String currentType = config.getAttribute("type");
if (currentType != null && currentType.equals(type)) {
// $NON-NLS-1$
String priority = config.getAttribute("priority");
if (priority != null) {
try {
Integer.parseInt(priority);
configList.add(config);
} catch (NumberFormatException e) {
// continue
}
}
}
}
}
Collections.sort(configList, (c1, c2) -> {
int p1, p2;
// lowest priority.
try {
// $NON-NLS-1$
p1 = Integer.parseInt(c1.getAttribute("priority"));
if (p1 <= 0) {
return 1;
}
} catch (NumberFormatException e1) {
return 1;
}
try {
// $NON-NLS-1$
p2 = Integer.parseInt(c2.getAttribute("priority"));
if (p2 <= 0) {
return -1;
}
} catch (NumberFormatException e2) {
return -1;
}
return p1 < p2 ? -1 : 1;
});
return configList;
}
use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class ProviderFramework method getAllProviderNames.
/**
* Get map of all pairs of names and IDs of profiling providers. This
* looks through extensions of the extension point
* <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>.
*
* @return A <code>SortedMap<String, String></code> of all pairs of names and IDs
* of profiling providers.
* @since 2.0
*/
public static SortedMap<String, String> getAllProviderNames() {
SortedMap<String, String> ret = new TreeMap<>();
IConfigurationElement[] configs = getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) {
// $NON-NLS-1$
// $NON-NLS-1$
String currentId = config.getAttribute("id");
// $NON-NLS-1$
String currentName = config.getAttribute("name");
if (currentName != null && currentId != null) {
ret.put(currentName, currentId);
}
}
}
return ret;
}
use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class ProviderFramework method getProviderCategories.
/**
* Get all the profiling categories. This looks through extensions of
* the extension point <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code>
* and stores the different categories found.
*
* @return A <code>String []</code> of all profiling categories.
* @since 2.0
*/
public static String[] getProviderCategories() {
Set<String> ret = new TreeSet<>();
IConfigurationElement[] configs = getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) {
// $NON-NLS-1$
// $NON-NLS-1$
String currentType = config.getAttribute("type");
if (currentType != null) {
ret.add(currentType);
}
}
}
return ret.toArray(new String[] {});
}
use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class ProviderFramework method getTabGroupProviderFromId.
/**
* Get a profiling tab that is associated with the specified id.
* This looks through extensions of the extension point
* <code>org.eclipse.linuxtools.profiling.launch.launchProvider</code> that have a
* specific id.
*
* @param id A unique identifier
* @return a tab that implements <code>ProfileLaunchConfigurationTabGroup</code>
* and provides the necessary profiling type, or <code>null</code> if none could be found.
* @since 2.0
*/
public static ProfileLaunchConfigurationTabGroup getTabGroupProviderFromId(String id) {
IConfigurationElement[] configs = getConfigurationElements();
for (IConfigurationElement config : configs) {
if (config.getName().equals("provider")) {
// $NON-NLS-1$
// $NON-NLS-1$
String currentId = config.getAttribute("id");
// $NON-NLS-1$
String tabgroup = config.getAttribute("tabgroup");
if (currentId != null && tabgroup != null && currentId.equals(id)) {
try {
Object obj = config.createExecutableExtension(// $NON-NLS-1$
"tabgroup");
if (obj instanceof ProfileLaunchConfigurationTabGroup) {
return (ProfileLaunchConfigurationTabGroup) obj;
}
} catch (CoreException e) {
// continue, perhaps another configuration will succeed
}
}
}
}
return null;
}
use of org.eclipse.core.runtime.IConfigurationElement in project linuxtools by eclipse.
the class STBinutilsFactoryManager method getBinutilsFactoryImpl.
/**
* Try to find an extension point matching the given cpu; Then test availability of the tools. If no match, return
* default binutils factory
* @param cpu The cpu identifier.
* @return The factory.
*/
private static ISTBinutilsFactory getBinutilsFactoryImpl(String cpu) {
try {
IExtensionRegistry reg = Platform.getExtensionRegistry();
// $NON-NLS-1$
IExtensionPoint ep = reg.getExtensionPoint("org.eclipse.linuxtools.binutils.crossCompilerBinutils");
IExtension[] exts = ep.getExtensions();
for (IExtension extension : exts) {
IConfigurationElement[] elems = extension.getConfigurationElements();
for (IConfigurationElement configurationElement : elems) {
// $NON-NLS-1$
String s = configurationElement.getAttribute("CPU");
if (cpu.equals(s)) {
ISTBinutilsFactory factory = (ISTBinutilsFactory) configurationElement.createExecutableExtension(// $NON-NLS-1$
"binutilsFactory");
if (factory.testAvailability())
return factory;
}
}
}
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
if (defaultFactory == null) {
defaultFactory = new DefaultBinutilsFactory();
}
return defaultFactory;
}
Aggregations