use of org.eclipse.core.runtime.IExtensionRegistry in project knime-core by knime.
the class WebResourceController method getConfigurationFromID.
private static IConfigurationElement getConfigurationFromID(final String extensionPointId, final String configurationID, final String jsObjectID) {
if (jsObjectID != null) {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor(extensionPointId);
for (IConfigurationElement element : configurationElements) {
if (jsObjectID.equals(element.getAttribute(configurationID))) {
return element;
}
}
}
return null;
}
use of org.eclipse.core.runtime.IExtensionRegistry in project yamcs-studio by yamcs.
the class SimplePVLayer method createPVFactory.
private static AbstractPVFactory createPVFactory(String pvFactoryID) throws CoreException {
IExtensionRegistry extReg = Platform.getExtensionRegistry();
IConfigurationElement[] confElements = extReg.getConfigurationElementsFor(EXTPOINT_PVFACTORY);
for (IConfigurationElement element : confElements) {
String name = element.getAttribute("id");
if (name.equals(pvFactoryID)) {
Object object = element.createExecutableExtension("class");
if (object instanceof AbstractPVFactory) {
return (AbstractPVFactory) object;
}
}
}
return null;
}
use of org.eclipse.core.runtime.IExtensionRegistry in project yamcs-studio by yamcs.
the class WidgetsService method loadAllWidgets.
/**
* Load all widgets information from extensions.
*/
private void loadAllWidgets() {
IExtensionRegistry extReg = Platform.getExtensionRegistry();
IConfigurationElement[] confElements = extReg.getConfigurationElementsFor(OPIBuilderPlugin.EXTPOINT_WIDGET);
List<IConfigurationElement> boyElements = new LinkedList<IConfigurationElement>();
List<IConfigurationElement> otherElements = new LinkedList<IConfigurationElement>();
// Sort elements. opibuilder.widgets should always appear first.
for (IConfigurationElement element : confElements) {
if (element.getContributor().getName().equals(BOY_WIDGETS_PLUGIN_NAME))
boyElements.add(element);
else
otherElements.add(element);
}
boyElements.addAll(otherElements);
for (IConfigurationElement element : boyElements) {
// $NON-NLS-1$
String typeId = element.getAttribute("typeId");
// $NON-NLS-1$
String name = element.getAttribute("name");
// $NON-NLS-1$
String icon = element.getAttribute("icon");
// //$NON-NLS-1$
String onlineHelpHtml = element.getAttribute("onlineHelpHtml");
String pluginId = element.getDeclaringExtension().getNamespaceIdentifier();
String description = element.getAttribute("description");
if (description == null || description.trim().length() == 0) {
description = "";
}
String category = element.getAttribute("category");
if (category == null || category.trim().length() == 0) {
category = DEFAULT_CATEGORY;
}
if (typeId != null) {
List<String> list = allCategoriesMap.get(category);
if (list == null) {
list = new ArrayList<String>();
allCategoriesMap.put(category, list);
}
// ensure no duplicates in the widgets palette
if (!list.contains(typeId))
list.add(typeId);
allWidgetDescriptorsMap.put(typeId, new WidgetDescriptor(element, typeId, name, description, icon, category, pluginId, onlineHelpHtml));
}
}
// sort the widget in the categories
// for(List<String> list : allCategoriesMap.values())
// Collections.sort(list);
}
use of org.eclipse.core.runtime.IExtensionRegistry in project tdi-studio-se by Talend.
the class DBTreeActionGroup method getContextActions.
/**
* Loop through all extensions and add the appropriate actions.
*
* Actions are selected by database product name, node type and
* availability.
*
* @param nodes currently selected nodes
* @return array of actions
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private IAction[] getContextActions(INode[] nodes) {
String databaseProductName = nodes[0].getSession().getRoot().getDatabaseProductName().toLowerCase().trim();
String nodeType = nodes[0].getType().toLowerCase().trim();
List actions = new ArrayList();
IExtensionRegistry registry = Platform.getExtensionRegistry();
//$NON-NLS-1$ //$NON-NLS-2$
IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.sqlexplorer", "nodeContextAction");
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IExtension e = extensions[i];
IConfigurationElement[] ces = e.getConfigurationElements();
for (int j = 0; j < ces.length; j++) {
try {
boolean isValidProduct = false;
boolean isValidNodeType = false;
//$NON-NLS-1$
String id = ces[j].getAttribute("id");
//$NON-NLS-1$ //$NON-NLS-2$
String[] validProducts = ces[j].getAttribute("database-product-name").split(",");
//$NON-NLS-1$ //$NON-NLS-2$
String[] validNodeTypes = ces[j].getAttribute("node-type").split(",");
//$NON-NLS-1$
String imagePath = ces[j].getAttribute("icon");
// check if action is valid for current database product
for (int k = 0; k < validProducts.length; k++) {
String product = validProducts[k].toLowerCase().trim();
if (product.length() == 0) {
continue;
}
if (product.equals("*")) {
//$NON-NLS-1$
isValidProduct = true;
break;
}
//$NON-NLS-1$
String regex = TextUtil.replaceChar(product, '*', ".*");
if (databaseProductName.matches(regex)) {
isValidProduct = true;
break;
}
}
if (!isValidProduct) {
continue;
}
// check if action is valid for current node type
for (int k = 0; k < validNodeTypes.length; k++) {
String type = validNodeTypes[k].toLowerCase().trim();
if (type.length() == 0) {
continue;
}
if (type.equals("*")) {
//$NON-NLS-1$
isValidNodeType = true;
break;
}
//$NON-NLS-1$
String regex = TextUtil.replaceChar(type, '*', ".*");
if (nodeType.matches(regex)) {
isValidNodeType = true;
break;
}
}
if (!isValidNodeType) {
continue;
}
// check if the action thinks it is suitable..
//$NON-NLS-1$
AbstractDBTreeContextAction action = (AbstractDBTreeContextAction) ces[j].createExecutableExtension("class");
action.setSelectedNodes(nodes);
action.setTreeViewer(pTreeViewer);
action.setView(pView);
String fragmentId = id.substring(0, id.indexOf('.', END_INDEX));
if (imagePath != null && imagePath.trim().length() != 0) {
action.setImageDescriptor(ImageUtil.getFragmentDescriptor(fragmentId, imagePath));
}
if (action.isAvailable()) {
actions.add(action);
}
} catch (Throwable ex) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("DBTreeActionGroup.logMessage"), ex);
}
}
}
return (IAction[]) actions.toArray(new IAction[] {});
}
use of org.eclipse.core.runtime.IExtensionRegistry in project tdi-studio-se by Talend.
the class SchemaNode method findExtensionNode.
/**
* Location extenstion nodes for a given tableType.
*
* @param tableType for which to find extension node
* @return INode or null if no extensions found
*/
private INode findExtensionNode(String tableType) {
String databaseProductName = getSession().getRoot().getDatabaseProductName().toLowerCase().trim();
IExtensionRegistry registry = Platform.getExtensionRegistry();
//$NON-NLS-1$ //$NON-NLS-2$
IExtensionPoint point = registry.getExtensionPoint("net.sourceforge.sqlexplorer", "node");
IExtension[] extensions = point.getExtensions();
for (int i = 0; i < extensions.length; i++) {
IExtension e = extensions[i];
IConfigurationElement[] ces = e.getConfigurationElements();
for (int j = 0; j < ces.length; j++) {
try {
// include only nodes that are attachted to the schema
// node..
//$NON-NLS-1$
String parent = ces[j].getAttribute("parent-node");
if (parent.indexOf("schema") == -1) {
//$NON-NLS-1$
continue;
}
boolean isValidProduct = false;
//$NON-NLS-1$ //$NON-NLS-2$
String[] validProducts = ces[j].getAttribute("database-product-name").split(",");
// include only nodes valid for this database
for (int k = 0; k < validProducts.length; k++) {
String product = validProducts[k].toLowerCase().trim();
if (product.length() == 0) {
continue;
}
if (product.equals("*")) {
//$NON-NLS-1$
isValidProduct = true;
break;
}
//$NON-NLS-1$
String regex = TextUtil.replaceChar(product, '*', ".*");
if (databaseProductName.matches(regex)) {
isValidProduct = true;
break;
}
}
if (!isValidProduct) {
continue;
}
// check if it is the correct type
//$NON-NLS-1$
String type = ces[j].getAttribute("table-type").trim();
if (!type.equalsIgnoreCase(tableType)) {
continue;
}
//$NON-NLS-1$
AbstractNode childNode = (AbstractNode) ces[j].createExecutableExtension("class");
childNode.setParent(this);
childNode.setSession(psessionNode);
return childNode;
} catch (Throwable ex) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("SchemaNode.logMessage2"), ex);
}
}
}
return null;
}
Aggregations