Search in sources :

Example 71 with XSDComplexTypeDefinition

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

the class MakeAnonymousTypeGlobalAction method canEnable.

private boolean canEnable(XSDConcreteComponent xsdComponent) {
    if (xsdComponent instanceof XSDComplexTypeDefinition) {
        fSelectedComponent = (XSDComplexTypeDefinition) xsdComponent;
        isComplexType = true;
        XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) xsdComponent;
        XSDConcreteComponent parent = typeDef.getContainer();
        if (parent instanceof XSDElementDeclaration) {
            fParentName = ((XSDElementDeclaration) parent).getName();
            return true;
        }
    } else if (xsdComponent instanceof XSDSimpleTypeDefinition) {
        fSelectedComponent = (XSDSimpleTypeDefinition) xsdComponent;
        isComplexType = false;
        XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) xsdComponent;
        XSDConcreteComponent parent = typeDef.getContainer();
        if (parent instanceof XSDElementDeclaration) {
            fParentName = ((XSDElementDeclaration) parent).getName();
            return true;
        } else if (parent instanceof XSDAttributeDeclaration) {
            fParentName = ((XSDAttributeDeclaration) parent).getName();
            return true;
        }
    }
    return false;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 72 with XSDComplexTypeDefinition

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

the class XSDBaseAdapter method getGlobalXSDContainer.

protected IADTObject getGlobalXSDContainer(XSDConcreteComponent component) {
    XSDConcreteComponent c = component.getContainer();
    // We want the top most structural component
    while (c != null && !(c.getContainer() instanceof XSDSchema) && !(c instanceof XSDComplexTypeDefinition) && !(c instanceof XSDSimpleTypeDefinition) && !(c instanceof XSDModelGroupDefinition) && !(c instanceof XSDAttributeGroupDefinition)) {
        c = c.getContainer();
    }
    Adapter adapter = XSDAdapterFactory.getInstance().adapt(c);
    if (adapter instanceof IADTObject)
        return (IADTObject) adapter;
    return null;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Adapter(org.eclipse.emf.common.notify.Adapter) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSchema(org.eclipse.xsd.XSDSchema) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 73 with XSDComplexTypeDefinition

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

the class XSDBaseAdapter method getContainerType.

/**
 * Implements IField getContainerType.  Get parent Complex Type containing the field
 * @return IComplexType
 */
public IComplexType getContainerType() {
    XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) target;
    XSDConcreteComponent parent = null;
    XSDComplexTypeDefinition ct = null;
    for (parent = xsdConcreteComponent.getContainer(); parent != null; ) {
        if (parent instanceof XSDComplexTypeDefinition) {
            ct = (XSDComplexTypeDefinition) parent;
            break;
        }
        parent = parent.getContainer();
    }
    if (ct != null) {
        return (IComplexType) XSDAdapterFactory.getInstance().adapt(ct);
    }
    return null;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType)

Example 74 with XSDComplexTypeDefinition

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

the class XSDRedefineAdapter method getCategoryChildren.

private List getCategoryChildren(int category) {
    List list = new ArrayList();
    XSDRedefine redefine = (XSDRedefine) target;
    Iterator iterator = redefine.getContents().iterator();
    while (iterator.hasNext()) {
        XSDRedefineContent redefineContent = (XSDRedefineContent) iterator.next();
        if (redefineContent instanceof XSDAttributeGroupDefinition && category == CategoryAdapter.ATTRIBUTES) {
            list.add(redefineContent);
        } else if (redefineContent instanceof XSDModelGroupDefinition && category == CategoryAdapter.GROUPS) {
            list.add(redefineContent);
        } else if (redefineContent instanceof XSDComplexTypeDefinition && category == CategoryAdapter.TYPES) {
            list.add(redefineContent);
        } else if (redefineContent instanceof XSDSimpleTypeDefinition && category == CategoryAdapter.TYPES) {
            list.add(redefineContent);
        }
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return adapterList;
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDRedefineContent(org.eclipse.xsd.XSDRedefineContent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 75 with XSDComplexTypeDefinition

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

the class CreateElementAction method run.

/*
   * @see IAction#run()
   */
public void run() {
    beginRecording(getDescription());
    final Element child = createAndAddNewChildElement();
    endRecording();
    if (selectionProvider != null) {
        final XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(child);
        // selectionProvider.setSelection(new StructuredSelection(comp));
        Runnable runnable = new Runnable() {

            public void run() {
                if (comp instanceof XSDAttributeDeclaration) {
                    if (((XSDAttributeDeclaration) comp).getContainer() instanceof XSDAttributeUse) {
                        if (comp.getContainer().getContainer() instanceof XSDAttributeGroupDefinition) {
                            selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
                        } else if (comp.getContainer().getContainer() instanceof XSDComplexTypeDefinition) {
                            if (XSDDOMHelper.inputEquals(child, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true)) {
                                selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
                            } else {
                                selectionProvider.setSelection(new StructuredSelection(comp));
                            }
                        } else {
                            selectionProvider.setSelection(new StructuredSelection(comp));
                        }
                    } else {
                        selectionProvider.setSelection(new StructuredSelection(comp));
                    }
                } else {
                    selectionProvider.setSelection(new StructuredSelection(comp));
                }
                if (comp instanceof XSDNamedComponent) {
                    if (sourceContext instanceof AbstractEditPartViewer) {
                    // AbstractEditPartViewer viewer = (AbstractEditPartViewer)sourceContext;
                    // Object obj = viewer.getSelectedEditParts().get(0);
                    // if (obj instanceof GraphicalEditPart)
                    // {
                    // if (obj instanceof ElementDeclarationEditPart)
                    // {
                    // XSDElementDeclaration elem = ((ElementDeclarationEditPart)obj).getXSDElementDeclaration();
                    // if (!elem.isElementDeclarationReference())
                    // {
                    // ((ElementDeclarationEditPart)obj).doEditName();
                    // }
                    // }
                    // else if (obj instanceof ModelGroupDefinitionEditPart)
                    // {
                    // XSDModelGroupDefinition group = ((ModelGroupDefinitionEditPart)obj).getXSDModelGroupDefinition();
                    // if (!group.isModelGroupDefinitionReference())
                    // {
                    // ((ModelGroupDefinitionEditPart)obj).doEditName();
                    // }
                    // }
                    // else if (obj instanceof ComplexTypeDefinitionEditPart)
                    // {
                    // XSDComplexTypeDefinition ct = ((ComplexTypeDefinitionEditPart)obj).getXSDComplexTypeDefinition();
                    // if (ct.getName() != null)
                    // {
                    // ((ComplexTypeDefinitionEditPart)obj).doEditName();
                    // }
                    // }
                    // else if (obj instanceof TopLevelComponentEditPart)
                    // {
                    // ((TopLevelComponentEditPart)obj).doEditName();
                    // }
                    // }
                    }
                }
            }
        };
        Display.getDefault().timerExec(50, runnable);
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Element(org.w3c.dom.Element) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AbstractEditPartViewer(org.eclipse.gef.ui.parts.AbstractEditPartViewer) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Aggregations

XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)162 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)93 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)76 XSDParticle (org.eclipse.xsd.XSDParticle)75 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)66 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)53 ArrayList (java.util.ArrayList)43 XSDSchema (org.eclipse.xsd.XSDSchema)37 Test (org.junit.Test)37 EList (org.eclipse.emf.common.util.EList)25 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)25 XSDFactory (org.eclipse.xsd.XSDFactory)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)21 XSDTerm (org.eclipse.xsd.XSDTerm)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)20 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)20 Iterator (java.util.Iterator)19 List (java.util.List)19 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)16