Search in sources :

Example 1 with AddXSDAnyAttributeCommand

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

the class AddXSDAnyAttributeAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        selection = ((XSDBaseAdapter) selection).getTarget();
    }
    AddXSDAnyAttributeCommand command = null;
    if (selection instanceof XSDComplexTypeDefinition) {
        command = new AddXSDAnyAttributeCommand(Messages._UI_ACTION_ADD_ANY_ATTRIBUTE, (XSDComplexTypeDefinition) selection);
        getCommandStack().execute(command);
    } else if (selection instanceof XSDAttributeGroupDefinition) {
        command = new AddXSDAnyAttributeCommand(Messages._UI_ACTION_ADD_ANY_ATTRIBUTE, (XSDAttributeGroupDefinition) selection);
        getCommandStack().execute(command);
    }
    if (command != null) {
        addedComponent = command.getAddedComponent();
        Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
        selectAddedComponent(adapter);
    }
}
Also used : AddXSDAnyAttributeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAnyAttributeCommand) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) Adapter(org.eclipse.emf.common.notify.Adapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Aggregations

Adapter (org.eclipse.emf.common.notify.Adapter)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 AddXSDAnyAttributeCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAnyAttributeCommand)1 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1