Search in sources :

Example 1 with AddXSDAnyElementCommand

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

the class AddXSDAnyElementAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        selection = ((XSDBaseAdapter) selection).getTarget();
    }
    XSDModelGroup modelGroup = getModelGroup(selection);
    AddXSDAnyElementCommand command = new AddXSDAnyElementCommand(getText(), modelGroup);
    if (selection instanceof XSDComplexTypeDefinition) {
        command.setComplexType((XSDComplexTypeDefinition) selection);
    }
    command.setDoCreateModelGroupForComplexType(modelGroup == null);
    getCommandStack().execute(command);
    addedComponent = command.getAddedComponent();
    Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
    selectAddedComponent(adapter);
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) AddXSDAnyElementCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAnyElementCommand) 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)

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 AddXSDAnyElementCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAnyElementCommand)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)1