use of org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand in project webtools.sourceediting by eclipse.
the class ExtensionsSchemasRegistry method getAllExtensionsSchemasContribution.
private List getAllExtensionsSchemasContribution(String id) {
IConfigurationElement[] asiPropertiesList = Platform.getExtensionRegistry().getConfigurationElementsFor(id);
boolean hasASIProperties = (asiPropertiesList != null) && (asiPropertiesList.length > 0);
if (hasASIProperties) {
for (int i = 0; i < asiPropertiesList.length; i++) {
IConfigurationElement asiPropertiesElement = asiPropertiesList[i];
String elementName = asiPropertiesElement.getName();
if ("category".equals(elementName)) {
String description = asiPropertiesElement.getAttribute(DESCRIPTION);
String displayName = asiPropertiesElement.getAttribute(DISPLAYNAME);
String namespaceURI = asiPropertiesElement.getAttribute(NAMESPACEURI);
String xsdFileURL = asiPropertiesElement.getAttribute(XSDFILEURL);
String labelProviderClass = asiPropertiesElement.getAttribute(LABELPROVIDER);
String addCommandClass = asiPropertiesElement.getAttribute(ADD_COMMAND_CLASS);
String deleteCommandClass = asiPropertiesElement.getAttribute(DELETE_COMMAND_CLASS);
if (displayName == null) {
// a display name.
continue;
}
if (xsdFileURL == null) {
xsdFileURL = locateFileUsingCatalog(namespaceURI);
}
SpecificationForExtensionsSchema extensionsSchemaSpec = createEntry();
extensionsSchemaSpec.setDescription(description);
extensionsSchemaSpec.setDisplayName(displayName);
extensionsSchemaSpec.setNamespaceURI(namespaceURI);
extensionsSchemaSpec.setDefautSchema();
String pluginId = asiPropertiesElement.getDeclaringExtension().getContributor().getName();
if (labelProviderClass != null) {
ILabelProvider labelProvider = null;
try {
Class theClass = Platform.getBundle(pluginId).loadClass(labelProviderClass);
if (theClass != null) {
labelProvider = (ILabelProvider) theClass.newInstance();
if (labelProvider != null) {
extensionsSchemaSpec.setLabelProvider(labelProvider);
}
}
} catch (Exception e) {
}
}
if (addCommandClass != null) {
try {
ExtensibleAddExtensionCommand addCommand = (ExtensibleAddExtensionCommand) asiPropertiesElement.createExecutableExtension(ADD_COMMAND_CLASS);
if (addCommand != null) {
extensionsSchemaSpec.setExtensibleAddExtensionCommand(addCommand);
}
} catch (Exception e) {
}
}
if (deleteCommandClass != null) {
try {
ExtensibleRemoveExtensionNodeCommand deleteCommand = (ExtensibleRemoveExtensionNodeCommand) asiPropertiesElement.createExecutableExtension(DELETE_COMMAND_CLASS);
if (deleteCommand != null) {
extensionsSchemaSpec.setExtensibleRemoveExtensionNodeCommand(deleteCommand);
}
} catch (Exception e) {
}
}
// $NON-NLS-1$
extensionsSchemaSpec.setLocation(LOCATION_PREFIX + pluginId + "/" + xsdFileURL);
nsURIProperties.add(extensionsSchemaSpec);
} else if ("categoryProvider".equals(elementName)) {
String categoryProviderClass = asiPropertiesElement.getAttribute(CATEGORY_PROVIDER_CLASS);
if (categoryProviderClass != null) {
try {
CategoryProvider categoryProvider = (CategoryProvider) asiPropertiesElement.createExecutableExtension(CATEGORY_PROVIDER_CLASS);
if (categoryProvider != null) {
categoryProviderList.add(categoryProvider);
}
} catch (Exception e) {
}
}
}
}
}
return nsURIProperties;
}
use of org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand in project webtools.sourceediting by eclipse.
the class ExtensionsSection method getRemoveExtensionCommand.
protected Command getRemoveExtensionCommand(Object o) {
Command command = null;
try {
if (o instanceof Node) {
Node node = (Node) o;
ExtensibleRemoveExtensionNodeCommand removeCommand = getExtensionsSchemasRegistry().getRemoveExtensionNodeCommand(node.getNamespaceURI());
if (removeCommand != null) {
removeCommand.setInput((XSDConcreteComponent) input);
removeCommand.setNode(node);
return removeCommand;
} else {
command = new RemoveExtensionNodeCommand(Messages._UI_ACTION_DELETE_APPINFO_ELEMENT, node);
// command.execute();
}
}
} catch (Exception e) {
}
return command;
}
Aggregations