Search in sources :

Example 26 with XSDConcreteComponent

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

the class XSDAnyElementContentsSection method doWidgetSelected.

public void doWidgetSelected(SelectionEvent e) {
    XSDConcreteComponent concreteComponent = (XSDConcreteComponent) input;
    if (concreteComponent instanceof XSDWildcard) {
        XSDWildcard wildcard = (XSDWildcard) concreteComponent;
        if (e.widget == namespaceCombo) {
            String newValue = namespaceCombo.getText();
            boolean removeAttribute = false;
            if (newValue.length() == 0) {
                removeAttribute = true;
            }
            // element); //$NON-NLS-1$
            if (removeAttribute) {
                wildcard.unsetLexicalNamespaceConstraint();
            } else {
                wildcard.setStringLexicalNamespaceConstraint(newValue);
            }
        // endRecording(element);
        } else if (e.widget == processContentsCombo) {
            String newValue = processContentsCombo.getText();
            boolean removeAttribute = false;
            if (newValue.length() == 0) {
                removeAttribute = true;
            }
            // element); //$NON-NLS-1$
            if (removeAttribute) {
                wildcard.unsetProcessContents();
            } else {
                wildcard.setProcessContents(XSDProcessContents.get(processContentsCombo.getItem(processContentsCombo.getSelectionIndex())));
            }
        // endRecording(element);
        }
    }
    super.doWidgetSelected(e);
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDWildcard(org.eclipse.xsd.XSDWildcard)

Example 27 with XSDConcreteComponent

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

the class AbstractSectionDescriptor method appliesTo.

/* (non-Javadoc)
   * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
   */
public boolean appliesTo(IWorkbenchPart part, ISelection selection) {
    Object object = null;
    if (selection instanceof StructuredSelection) {
        StructuredSelection structuredSelection = (StructuredSelection) selection;
        object = structuredSelection.getFirstElement();
        if (object instanceof XSDConcreteComponent || object instanceof Element) {
            return true;
        }
    }
    return false;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Element(org.w3c.dom.Element) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 28 with XSDConcreteComponent

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

the class ExtensionsSection method isTreeViewerInputElement.

protected boolean isTreeViewerInputElement(Element element) {
    if (input instanceof XSDConcreteComponent) {
        XSDConcreteComponent component = (XSDConcreteComponent) input;
        Element componentElement = component.getElement();
        Node parent = element.getParentNode();
        Node grandParent = parent != null ? parent.getParentNode() : null;
        return componentElement == element || componentElement == parent || componentElement == grandParent;
    }
    return false;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node)

Example 29 with XSDConcreteComponent

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

the class ExtensionsSection method setInput.

public void setInput(IWorkbenchPart part, ISelection selection) {
    super.setInput(part, selection);
    if (adapter == null) {
        if (selection instanceof StructuredSelection) {
            Object obj = ((StructuredSelection) selection).getFirstElement();
            if (obj instanceof XSDConcreteComponent) {
                Element element = ((XSDConcreteComponent) obj).getElement();
                if (element != null) {
                    adapter = XSDModelAdapter.lookupOrCreateModelAdapter(element.getOwnerDocument());
                    if (adapter != null) {
                        ModelReconcileAdapter modelReconcileAdapter = adapter.getModelReconcileAdapter();
                        if (modelReconcileAdapter != null) {
                            modelReconcileAdapter.addListener(internalNodeAdapter);
                        }
                    }
                }
            }
        }
    }
    extensionTreeViewer.expandToLevel(2);
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Element(org.w3c.dom.Element) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ModelReconcileAdapter(org.eclipse.wst.xsd.ui.internal.util.ModelReconcileAdapter)

Example 30 with XSDConcreteComponent

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

the class AddXSDModelGroupCommand method getOwner.

private XSDConcreteComponent getOwner() {
    XSDConcreteComponent owner = null;
    if (parent instanceof XSDElementDeclaration) {
        XSDElementDeclaration ed = (XSDElementDeclaration) parent;
        if (ed.getTypeDefinition() != null) {
            if (ed.getAnonymousTypeDefinition() == null) {
                ed.setTypeDefinition(null);
                XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
                ed.setAnonymousTypeDefinition(td);
                owner = ed.getTypeDefinition();
            } else {
                XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
                ed.setAnonymousTypeDefinition(td);
                owner = td;
            }
        } else if (ed.getAnonymousTypeDefinition() == null) {
            XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
            ed.setAnonymousTypeDefinition(td);
            owner = td;
        } else if (ed.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition) {
            owner = ed.getAnonymousTypeDefinition();
        } else if (ed.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition) {
            XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
            ed.setAnonymousTypeDefinition(td);
            owner = td;
        }
    } else if (parent instanceof XSDModelGroup) {
        newModelGroup = createModelGroup();
        ((XSDModelGroup) parent).getContents().add(newModelGroup.getContainer());
    } else if (parent instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) parent;
        owner = parent;
        if (ct.getContent() instanceof XSDParticle) {
            XSDParticle particle = (XSDParticle) ct.getContent();
            if (particle.getContent() instanceof XSDModelGroup) {
                owner = null;
                newModelGroup = createModelGroup();
                XSDModelGroup newParent = (XSDModelGroup) particle.getContent();
                newParent.getContents().add(newModelGroup.getContainer());
            }
        }
    } else if (parent instanceof XSDModelGroupDefinition) {
        XSDModelGroupDefinition modelGroupDefinition = (XSDModelGroupDefinition) parent;
        owner = null;
        newModelGroup = createModelGroup();
        if (modelGroupDefinition.getModelGroup() != null) {
            XSDModelGroup newParent = modelGroupDefinition.getModelGroup();
            newParent.getContents().add(newModelGroup.getContainer());
        } else {
            modelGroupDefinition.setModelGroup(newModelGroup);
        }
    }
    return owner;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

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