Search in sources :

Example 1 with ExtensibleRemoveExtensionNodeCommand

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;
}
Also used : ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) ExtensibleAddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ExtensibleRemoveExtensionNodeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand)

Example 2 with ExtensibleRemoveExtensionNodeCommand

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;
}
Also used : ExtensibleRemoveExtensionNodeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand) RemoveExtensionNodeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.RemoveExtensionNodeCommand) ExtensibleAddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand) AddExtensionElementCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionElementCommand) AddExtensionAttributeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionAttributeCommand) Command(org.eclipse.gef.commands.Command) AddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand) Node(org.w3c.dom.Node) ExtensibleRemoveExtensionNodeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand) RemoveExtensionNodeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.RemoveExtensionNodeCommand) ExtensibleRemoveExtensionNodeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand)

Aggregations

ExtensibleAddExtensionCommand (org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand)2 ExtensibleRemoveExtensionNodeCommand (org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 Command (org.eclipse.gef.commands.Command)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 AddExtensionAttributeCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionAttributeCommand)1 AddExtensionCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand)1 AddExtensionElementCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionElementCommand)1 RemoveExtensionNodeCommand (org.eclipse.wst.xsd.ui.internal.common.commands.RemoveExtensionNodeCommand)1 Node (org.w3c.dom.Node)1