Search in sources :

Example 21 with XSDConcreteComponent

use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.

the class ADTContentOutlinePage method createControl.

public void createControl(Composite parent) {
    super.createControl(parent);
    getTreeViewer().setContentProvider(contentProvider);
    getTreeViewer().setLabelProvider(labelProvider);
    getTreeViewer().setInput(model);
    getTreeViewer().addSelectionChangedListener(this);
    // $NON-NLS-1$
    MenuManager menuManager = new MenuManager("#popup");
    menuManager.setRemoveAllWhenShown(true);
    Menu menu = menuManager.createContextMenu(getTreeViewer().getControl());
    getTreeViewer().getControl().setMenu(menu);
    setSelectionManager(editor.getSelectionManager());
    // Create menu...for now reuse graph's.  Note edit part viewer = null
    DesignViewContextMenuProvider menuProvider = new DesignViewContextMenuProvider(editor, null, editor.getSelectionManager());
    menuManager.addMenuListener(menuProvider);
    // $NON-NLS-1$
    getSite().registerContextMenu("org.eclipse.wst.xsd.ui.popup.outline", menuManager, editor.getSelectionManager());
    // enable popupMenus extension
    // getSite().registerContextMenu("org.eclipse.wst.xsdeditor.ui.popup.outline",
    // menuManager, xsdEditor.getSelectionManager());
    // drill down from outline view
    getTreeViewer().getControl().addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent e) {
            ISelection iSelection = getTreeViewer().getSelection();
            if (iSelection instanceof StructuredSelection) {
                StructuredSelection selection = (StructuredSelection) iSelection;
                Object obj = selection.getFirstElement();
                if (obj instanceof XSDConcreteComponent) {
                    XSDConcreteComponent comp = (XSDConcreteComponent) obj;
                    if (comp.getContainer() instanceof XSDSchema) {
                    // getXSDEditor().getGraphViewer().setInput(obj);
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) MenuManager(org.eclipse.jface.action.MenuManager) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Menu(org.eclipse.swt.widgets.Menu) DesignViewContextMenuProvider(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewContextMenuProvider) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 22 with XSDConcreteComponent

use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.

the class AddXSDAttributeGroupDefinitionCommand method getNewName.

protected String getNewName(String description) {
    // $NON-NLS-1$
    String candidateName = "New" + description;
    XSDConcreteComponent parent = xsdComplexTypeDefinition;
    names = new ArrayList();
    int i = 1;
    if (parent instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) parent;
        walkUpInheritance(ct);
        boolean ready = false;
        while (!ready) {
            ready = true;
            for (Iterator iter = names.iterator(); iter.hasNext(); ) {
                String attrName = (String) iter.next();
                if (candidateName.equals(attrName)) {
                    ready = false;
                    // $NON-NLS-1$
                    candidateName = "New" + description + String.valueOf(i);
                    i++;
                }
            }
        }
    }
    return candidateName;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition)

Example 23 with XSDConcreteComponent

use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.

the class AddXSDElementCommand method createXSDElementDeclaration.

protected XSDParticle createXSDElementDeclaration() {
    // $NON-NLS-1$
    XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
    XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
    XSDConcreteComponent comp = xsdModelGroup.getContainer();
    ArrayList usedAttributeNames = new ArrayList();
    XSDCommonUIUtils.resetVisitedGroupsStack();
    usedAttributeNames.addAll(XSDCommonUIUtils.getChildElements(xsdModelGroup));
    while (comp != null) {
        if (comp instanceof XSDModelGroupDefinition) {
            usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDModelGroupDefinition) comp));
            break;
        } else if (comp instanceof XSDComplexTypeDefinition) {
            usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDComplexTypeDefinition) comp));
            usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes((XSDComplexTypeDefinition) comp));
            break;
        }
        comp = comp.getContainer();
    }
    element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
    usedAttributeNames));
    element.setTypeDefinition(type);
    XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
    particle.setContent(element);
    addedXSDConcreteComponent = element;
    return particle;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 24 with XSDConcreteComponent

use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.

the class DeleteXSDConcreteComponentAction method run.

public void run() {
    for (Iterator i = ((IStructuredSelection) getSelection()).iterator(); i.hasNext(); ) {
        Object selection = i.next();
        boolean doReselect = false;
        if (selection instanceof XSDBaseAdapter) {
            selection = ((XSDBaseAdapter) selection).getTarget();
        }
        if (selection instanceof XSDConcreteComponent) {
            XSDConcreteComponent xsdComponent = (XSDConcreteComponent) selection;
            XSDSchema model = xsdComponent.getSchema();
            doReselect = xsdComponent.eContainer() instanceof XSDSchema;
            DeleteCommand command = new DeleteCommand(getText(), xsdComponent);
            getCommandStack().execute(command);
            if (model != null && doReselect) {
                Adapter adapter = XSDAdapterFactory.getInstance().adapt(model);
                if (adapter != null)
                    provider.setSelection(new StructuredSelection(adapter));
            }
        }
    }
}
Also used : DeleteCommand(org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) 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) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 25 with XSDConcreteComponent

use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.

the class SetTypeAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        Object target = ((XSDBaseAdapter) selection).getTarget();
        if (target instanceof XSDConcreteComponent) {
            command = new SetTypeCommand(Messages._UI_ACTION_SET_TYPE, getId(), (XSDConcreteComponent) target);
            command.setAdapter((XSDBaseAdapter) selection);
            getCommandStack().execute(command);
        }
    }
}
Also used : SetTypeCommand(org.eclipse.wst.xsd.ui.internal.common.commands.SetTypeCommand) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)88 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)30 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)25 XSDSchema (org.eclipse.xsd.XSDSchema)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)18 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)17 Adapter (org.eclipse.emf.common.notify.Adapter)15 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)15 XSDParticle (org.eclipse.xsd.XSDParticle)13 Iterator (java.util.Iterator)12 ArrayList (java.util.ArrayList)11 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)11 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)11 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)11 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)11 List (java.util.List)10 Element (org.w3c.dom.Element)10 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)9 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)9