use of org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand 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.ExtensibleAddExtensionCommand in project webtools.sourceediting by eclipse.
the class ExtensionsSection method getAddExtensionCommand.
protected AddExtensionCommand getAddExtensionCommand(Object o) {
AddExtensionCommand addExtensionCommand = null;
if (o instanceof XSDElementDeclaration) {
XSDElementDeclaration element = (XSDElementDeclaration) o;
ExtensibleAddExtensionCommand extensibleAddExtensionCommand = getExtensionsSchemasRegistry().getAddExtensionCommand(element.getTargetNamespace());
if (extensibleAddExtensionCommand != null) {
extensibleAddExtensionCommand.setInputs((XSDConcreteComponent) input, element);
addExtensionCommand = extensibleAddExtensionCommand;
} else {
addExtensionCommand = new AddExtensionElementCommand(Messages._UI_ACTION_ADD_APPINFO_ELEMENT, (XSDConcreteComponent) input, element);
}
} else if (o instanceof XSDAttributeDeclaration) {
XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) o;
addExtensionCommand = new AddExtensionAttributeCommand(Messages._UI_ACTION_ADD_APPINFO_ATTRIBUTE, (XSDConcreteComponent) input, attribute);
}
return addExtensionCommand;
}
Aggregations