Search in sources :

Example 26 with XSDAttributeUse

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

the class XSDAdapterFactory method createAdapter.

public Adapter createAdapter(Notifier target) {
    XSDSwitch xsdSwitch = new XSDSwitch() {

        public Object caseXSDSchemaDirective(XSDSchemaDirective object) {
            return new XSDSchemaDirectiveAdapter();
        }

        public Object caseXSDWildcard(XSDWildcard object) {
            return new XSDWildcardAdapter();
        }

        public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition object) {
            return new XSDAttributeGroupDefinitionAdapter();
        }

        public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object) {
            return new XSDModelGroupDefinitionAdapter();
        }

        public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration object) {
            return new XSDAttributeDeclarationAdapter();
        }

        public Object caseXSDAttributeUse(XSDAttributeUse object) {
            return new XSDAttributeUseAdapter();
        }

        public Object caseXSDParticle(XSDParticle object) {
            return new XSDParticleAdapter();
        }

        public Object caseXSDElementDeclaration(XSDElementDeclaration object) {
            return new XSDElementDeclarationAdapter();
        }

        public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object) {
            return new XSDSimpleTypeDefinitionAdapter();
        }

        public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object) {
            // 
            if (// $NON-NLS-1$
            "anyType".equals(object.getName())) {
                return new XSDAnyTypeDefinitionAdapter();
            } else {
                return new XSDComplexTypeDefinitionAdapter();
            }
        }

        public Object caseXSDModelGroup(XSDModelGroup object) {
            return new XSDModelGroupAdapter();
        }

        public Object caseXSDSchema(XSDSchema object) {
            return new XSDSchemaAdapter();
        }

        public Object caseXSDEnumerationFacet(XSDEnumerationFacet object) {
            return new XSDEnumerationFacetAdapter();
        }

        public Object caseXSDRedefine(XSDRedefine object) {
            return new XSDRedefineAdapter();
        }
    };
    Object o = xsdSwitch.doSwitch((EObject) target);
    Adapter result = null;
    if (o instanceof Adapter) {
        result = (Adapter) o;
    } else {
    // Thread.dumpStack();
    }
    return result;
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) Adapter(org.eclipse.emf.common.notify.Adapter) XSDEnumerationFacet(org.eclipse.xsd.XSDEnumerationFacet) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDSwitch(org.eclipse.xsd.util.XSDSwitch) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) EObject(org.eclipse.emf.ecore.EObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 27 with XSDAttributeUse

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

the class XSDCommonUIUtils method getChildAttributes.

public static List getChildAttributes(XSDComplexTypeDefinition ct) {
    EList attrContents = ct.getAttributeContents();
    List attrs = new ArrayList();
    for (int i = 0; i < attrContents.size(); i++) {
        Object next = attrContents.get(i);
        if (next instanceof XSDAttributeUse) {
            attrs.add(((XSDAttributeUse) next).getContent().getResolvedAttributeDeclaration());
        } else if (next instanceof XSDAttributeGroupDefinition) {
        // XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) next;
        }
    }
    return attrs;
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) EObject(org.eclipse.emf.ecore.EObject) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 28 with XSDAttributeUse

use of org.eclipse.xsd.XSDAttributeUse in project tmdm-studio-se by Talend.

the class XSDDeleteAttributeAction method doAction.

@Override
protected IStatus doAction() {
    try {
        XSDAttributeUse attriUse = attributeUse;
        XSDAttributeDeclaration attriDec = attributeDeclaration;
        if (attriUse == null || attriDec == null) {
            ISelection selection = page.getTreeViewer().getSelection();
            Object firstElement = ((IStructuredSelection) selection).getFirstElement();
            if (firstElement instanceof XSDAttributeUse) {
                attriUse = (XSDAttributeUse) firstElement;
            } else if (firstElement instanceof XSDAttributeDeclaration) {
                attriDec = (XSDAttributeDeclaration) firstElement;
            }
        }
        if (attriUse != null) {
            if (attriUse.getContainer() == null) {
                return Status.CANCEL_STATUS;
            }
            XSDConcreteComponent container = attriUse.getContainer();
            if (container instanceof XSDComplexTypeDefinition) {
                XSDComplexTypeDefinition cType = (XSDComplexTypeDefinition) container;
                cType.getAttributeUses().remove(attriUse);
                cType.getAttributeContents().remove(attriUse);
                cType.updateElement();
            }
        } else if (attriDec != null) {
            if (attriDec.getContainer() == null) {
                return Status.CANCEL_STATUS;
            }
            XSDConcreteComponent container = attriDec.getContainer();
            if (container instanceof XSDSchema) {
                XSDSchema xsdschema = (XSDSchema) container;
                xsdschema.getContents().remove(attriDec);
            }
        }
        schema.update();
        attributeUse = null;
        attributeDeclaration = null;
        page.refresh();
        page.markDirtyWithoutCommit();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDDeleteElementAction_ErrorMsg, e.getLocalizedMessage()));
        return Status.CANCEL_STATUS;
    }
    return Status.OK_STATUS;
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDSchema(org.eclipse.xsd.XSDSchema)

Aggregations

XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)28 Iterator (java.util.Iterator)17 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)17 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)14 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)14 XSDParticle (org.eclipse.xsd.XSDParticle)12 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)11 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)11 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)10 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)9 XSDSchema (org.eclipse.xsd.XSDSchema)9 List (java.util.List)8 XSDWildcard (org.eclipse.xsd.XSDWildcard)8 ArrayList (java.util.ArrayList)7 EList (org.eclipse.emf.common.util.EList)7 Element (org.w3c.dom.Element)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)6 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)6 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)6