use of org.eclipse.core.runtime.IConfigurationElement in project che by eclipse.
the class ContributionContextTypeRegistry method createContextType.
/**
* Tries to create a context type given an id. Contributions to the
* <code>org.eclipse.ui.editors.templates</code> extension point are
* searched for the given identifier and the specified context type
* instantiated if it is found. Any contributed
* {@link org.eclipse.jface.text.templates.TemplateVariableResolver}s
* are also instantiated and added to the context type.
*
* @param id the id for the context type as specified in XML
* @return the instantiated and configured context type, or
* <code>null</code> if it is not found or cannot be instantiated
*/
public static TemplateContextType createContextType(String id) {
Assert.isNotNull(id);
IConfigurationElement[] extensions = getTemplateExtensions();
TemplateContextType type;
try {
type = createContextType(extensions, id);
if (type != null) {
TemplateVariableResolver[] resolvers = createResolvers(extensions, id);
for (int i = 0; i < resolvers.length; i++) type.addResolver(resolvers[i]);
}
} catch (CoreException e) {
JavaPlugin.log(e);
type = null;
}
return type;
}
use of org.eclipse.core.runtime.IConfigurationElement in project che by eclipse.
the class ExtensionsRegistry method doGetDocumentFactory.
/**
* Returns a sharable document factory for the given content types.
*
* @param contentTypes the content types used to find the factory
* @return the sharable document factory or <code>null</code>
* @deprecated As of 3.5
*/
protected org.eclipse.core.filebuffers.IDocumentFactory doGetDocumentFactory(IContentType[] contentTypes) {
Set set = null;
int i = 0;
while (i < contentTypes.length && set == null) {
set = (Set) fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
}
if (set != null) {
IConfigurationElement entry = selectConfigurationElement(set);
return (org.eclipse.core.filebuffers.IDocumentFactory) getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
}
return null;
}
use of org.eclipse.core.runtime.IConfigurationElement in project che by eclipse.
the class ExtensionsRegistry method doGetDocumentSetupParticipants.
/**
* Returns the set of setup participants for the given content types.
*
* @param contentTypes the contentTypes to be used for lookup
* @return the sharable set of document setup participants
*/
private List doGetDocumentSetupParticipants(IContentType[] contentTypes) {
Set resultSet = new HashSet();
int i = 0;
while (i < contentTypes.length) {
Set set = (Set) fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
if (set != null)
resultSet.addAll(set);
}
List participants = new ArrayList();
Iterator e = resultSet.iterator();
while (e.hasNext()) {
IConfigurationElement entry = (IConfigurationElement) e.next();
Object participant = getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
if (participant != null)
participants.add(participant);
}
return participants.isEmpty() ? null : participants;
}
use of org.eclipse.core.runtime.IConfigurationElement in project tdi-studio-se by Talend.
the class SchemaNode method addExtensionNodes.
/**
* Add Extension nodes.
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private void addExtensionNodes() {
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;
}
//$NON-NLS-1$
String imagePath = ces[j].getAttribute("icon");
//$NON-NLS-1$
String id = ces[j].getAttribute("id");
//$NON-NLS-1$
String type = ces[j].getAttribute("table-type").trim();
//$NON-NLS-1$
AbstractNode childNode = (AbstractNode) ces[j].createExecutableExtension("class");
childNode.setParent(this);
childNode.setSession(psessionNode);
childNode.setType(type);
String fragmentId = id.substring(0, id.indexOf('.', END_INDEX));
if (imagePath != null && imagePath.trim().length() != 0) {
childNode.setImage(ImageUtil.getFragmentImage(fragmentId, imagePath));
}
pchildNames.add(childNode.getLabelText());
if (!isExcludedByFilter(childNode.getLabelText())) {
addChildNode(childNode);
}
} catch (Throwable ex) {
//$NON-NLS-1$
SqlBuilderPlugin.log(Messages.getString("SchemaNode.logMessage1"), ex);
}
}
}
}
use of org.eclipse.core.runtime.IConfigurationElement in project tdi-studio-se by Talend.
the class JavaJobScriptsExportWSWizardPagePresenter method initExtraCheckersFromExtensionPoint.
/**
* Inits the extra checkers from plugin extension
* <code>org.talend.repository.ui.wizards.exportjob.extraBuildChecker</code>
*/
private void initExtraCheckersFromExtensionPoint() {
IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_EXTRA_BUILD_CHECKER).getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] eles = extension.getConfigurationElements();
for (IConfigurationElement ele : eles) {
try {
ExtraBuildChecker checker = (ExtraBuildChecker) ele.createExecutableExtension(EXTRA_BUILD_CHECKER);
addExtraChecker(checker);
} catch (CoreException e) {
ExceptionHandler.process(new RuntimeException("Can't load extra Job Build checker - " + ele, e));
}
}
}
}
Aggregations