Search in sources :

Example 1 with AddExtensionCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand in project webtools.sourceediting by eclipse.

the class AbstractExtensionsSection method widgetSelected.

public void widgetSelected(SelectionEvent event) {
    if (event.widget == addButton) {
        ExtensionsSchemasRegistry registry = getExtensionsSchemasRegistry();
        AddExtensionsComponentDialog dialog = createAddExtensionsComponentDialog();
        List properties = registry.getAllExtensionsSchemasContribution();
        dialog.setInput(properties);
        dialog.setBlockOnOpen(true);
        dialog.setPrefStore(getPrefStore());
        if (prevCategory != null)
            dialog.setInitialCategorySelection(prevCategory);
        if (dialog.open() == Window.OK) {
            Object newSelection = null;
            Object[] result = dialog.getResult();
            if (result != null) {
                SpecificationForExtensionsSchema extensionsSchemaSpec = (SpecificationForExtensionsSchema) result[1];
                AddExtensionCommand addExtensionCommand = getAddExtensionCommand(result[0]);
                if (addExtensionCommand != null) {
                    addExtensionCommand.setSchemaProperties(extensionsSchemaSpec);
                    if (getCommandStack() != null) {
                        getCommandStack().execute(addExtensionCommand);
                        newSelection = addExtensionCommand.getNewObject();
                    }
                }
            }
            // refresh();
            if (newSelection != null) {
                extensionTreeViewer.setSelection(new StructuredSelection(newSelection));
            }
        }
        prevCategory = dialog.getSelectedCategory();
    } else if (event.widget == removeButton) {
        ISelection selection = extensionTreeViewer.getSelection();
        if (selection instanceof StructuredSelection) {
            Object o = ((StructuredSelection) selection).getFirstElement();
            Command command = getRemoveExtensionCommand(o);
            if (getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        }
    } else if (event.widget == extensionTreeViewer.getTree()) {
    }
}
Also used : SpecificationForExtensionsSchema(org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema) AddExtensionsComponentDialog(org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog) Command(org.eclipse.gef.commands.Command) AddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) ExtensionsSchemasRegistry(org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionsSchemasRegistry) List(java.util.List) AddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand)

Example 2 with AddExtensionCommand

use of org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand 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;
}
Also used : AddExtensionElementCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionElementCommand) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) AddExtensionAttributeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionAttributeCommand) ExtensibleAddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) ExtensibleAddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand) AddExtensionCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand)

Aggregations

AddExtensionCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand)2 List (java.util.List)1 Command (org.eclipse.gef.commands.Command)1 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 AddExtensionAttributeCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionAttributeCommand)1 AddExtensionElementCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionElementCommand)1 ExtensibleAddExtensionCommand (org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand)1 AddExtensionsComponentDialog (org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog)1 ExtensionsSchemasRegistry (org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionsSchemasRegistry)1 SpecificationForExtensionsSchema (org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema)1 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)1