Search in sources :

Example 21 with XSDAttributeGroupDefinition

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

the class TypesLabelProvider method getText.

@Override
public String getText(Object obj) {
    if (obj instanceof XSDElementDeclaration) {
        String name = ((XSDElementDeclaration) obj).getName();
        if (((XSDElementDeclaration) obj).isAbstract()) {
            name += Messages.TypesLabelProvider_0;
        }
        String tail = ((XSDElementDeclaration) obj).getTargetNamespace() == null ? "" : // $NON-NLS-1$//$NON-NLS-2$
        " : " + ((XSDElementDeclaration) obj).getTargetNamespace();
        return name + tail;
    }
    if (obj instanceof XSDParticle) {
        XSDParticle xsdParticle = (XSDParticle) obj;
        XSDParticleContent content = xsdParticle.getContent();
        XSDTerm xsdTerm = xsdParticle.getTerm();
        // $NON-NLS-1$
        String name = "";
        if (content instanceof XSDElementDeclaration) {
            XSDElementDeclaration decl = (XSDElementDeclaration) content;
            // $NON-NLS-1$
            name += (decl.getName() == null ? "" : decl.getName());
            if (decl.getTypeDefinition() == null) {
                // $NON-NLS-1$//$NON-NLS-2$
                name += " [" + ((XSDElementDeclaration) xsdTerm).getName() + "]";
            }
        } else if (content instanceof XSDModelGroup) {
            // System.out.println("SHOULD NOT HAPPEN????");
            if (xsdParticle.getContainer() instanceof XSDComplexTypeDefinition) {
                String ctdName = ((XSDComplexTypeDefinition) xsdParticle.getContainer()).getName();
                // $NON-NLS-1$
                name = (ctdName != null ? ctdName : "");
            }
        /*
                 * int type = ((XSDModelGroup)xsdTerm).getCompositor().getValue(); switch (type) { case
                 * XSDCompositor.ALL: name= ""; break; case XSDCompositor.CHOICE: name= ""; break; case
                 * XSDCompositor.SEQUENCE: name= ""; break; }
                 */
        } else {
            // $NON-NLS-1$
            name = "[Any]";
        }
        if (!((xsdParticle.getMinOccurs() == 1) && (xsdParticle.getMaxOccurs() == 1))) {
            // $NON-NLS-1$
            name += "  [";
            name += xsdParticle.getMinOccurs();
            // $NON-NLS-1$
            name += "...";
            // $NON-NLS-1$//$NON-NLS-2$
            name += (xsdParticle.getMaxOccurs() == -1) ? "many" : "" + xsdParticle.getMaxOccurs();
            // $NON-NLS-1$
            name += "]";
        }
        return name;
    }
    if (obj instanceof XSDSimpleTypeDefinition) {
        return getSimpleTypeDefinition((XSDSimpleTypeDefinition) obj);
    }
    if (obj instanceof XSDComplexTypeDefinition) {
        return getComplexTypeDefinition((XSDComplexTypeDefinition) obj);
    }
    if (obj instanceof XSDModelGroup) {
        // return the name of the complex type definition
        XSDParticle particle = (XSDParticle) (((XSDModelGroup) obj).getContainer());
        XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) particle.getContainer();
        String name = complexTypeDefinition.getName();
        if (name == null) {
            // $NON-NLS-1$
            name = "";
        }
        // return the occurrence
        if (!((particle.getMinOccurs() == 1) && (particle.getMaxOccurs() == 1))) {
            // $NON-NLS-1$
            name += "  [";
            name += particle.getMinOccurs();
            // $NON-NLS-1$
            name += "...";
            // $NON-NLS-1$//$NON-NLS-2$
            name += (particle.getMaxOccurs() == -1) ? "many" : "" + particle.getMaxOccurs();
            // $NON-NLS-1$
            name += "]";
        }
        XSDTypeDefinition extendType = complexTypeDefinition.getBaseTypeDefinition();
        // $NON-NLS-1$
        String extendTypeName = "";
        if (extendType != null && extendType != complexTypeDefinition && !"anyType".equals(extendType.getName())) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            extendTypeName = ":" + extendType.getName();
        }
        return name + extendTypeName;
    }
    if (obj instanceof XSDFacet) {
        // $NON-NLS-1$
        return ((XSDFacet) obj).getFacetName() + ": " + ((XSDFacet) obj).getLexicalValue();
    }
    if (obj instanceof XSDIdentityConstraintDefinition) {
        return ((XSDIdentityConstraintDefinition) obj).getName();
    }
    if (obj instanceof XSDXPathDefinition) {
        XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
        return xpath.getValue();
    }
    if (obj instanceof XSDAttributeGroupDefinition) {
        XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) obj;
        // $NON-NLS-1$
        String name = (attributeGroupDefinition.getName() == null ? "" : attributeGroupDefinition.getName());
        if (attributeGroupDefinition.getContents().size() == 0) {
            // $NON-NLS-1$//$NON-NLS-2$
            name += " [" + attributeGroupDefinition.getResolvedAttributeGroupDefinition().getName() + "]";
        }
        return name;
    }
    if (obj instanceof XSDAttributeUse) {
        XSDAttributeUse attributeUse = (XSDAttributeUse) obj;
        String name = attributeUse.getAttributeDeclaration().getName();
        if (name == null) {
            // $NON-NLS-1$//$NON-NLS-2$
            name = " [" + attributeUse.getAttributeDeclaration().getResolvedAttributeDeclaration().getName() + "]";
        }
        return name;
    }
    if (obj instanceof XSDAnnotation) {
        // $NON-NLS-1$
        return "Annotations";
    }
    if (obj instanceof Element) {
        try {
            Element e = (Element) obj;
            if (e.getLocalName().equals("documentation")) {
                // $NON-NLS-1$
                return Messages.TypesLabelProvider_1 + e.getChildNodes().item(0).getNodeValue();
            } else if (e.getLocalName().equals("appinfo")) {
                // $NON-NLS-1$
                // $NON-NLS-1$
                String source = e.getAttribute("source");
                if (source != null) {
                    if (source.startsWith("X_Label_")) {
                        // $NON-NLS-1$
                        return Util.iso2lang.get(source.substring(8).toLowerCase()) + Messages.TypesLabelProvider_2 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_ForeignKey")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_3 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_ForeignKey_NotSep")) {
                        // $NON-NLS-1$
                        Boolean v = Boolean.valueOf(e.getChildNodes().item(0).getNodeValue());
                        return Messages.SimpleXpathInputDialog_sepFkTabPanel + Messages.TypesLabelProvider_4 + v;
                    } else if (source.equals("X_ForeignKeyInfo")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_5 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_ForeignKey_Filter")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_6 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_SourceSystem")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_7 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_TargetSystem")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_8 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.startsWith("X_Description_")) {
                        // $NON-NLS-1$
                        return Util.iso2lang.get(source.substring(14).toLowerCase()) + Messages.TypesLabelProvider_9 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Write")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_10 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Deny_Create")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_11 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Deny_LogicalDelete")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_12 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Deny_PhysicalDelete")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_13 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Hide")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_14 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_AutoExpand")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_15 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Retrieve_FKinfos")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_23, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_FKIntegrity")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_24, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_FKIntegrity_Override")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_25, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Workflow")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_16, e.getChildNodes().item(0).getNodeValue());
                    }
                    if (source.equals("X_ForeignKey_Filter")) {
                        // $NON-NLS-1$
                        String nodeValue = e.getChildNodes().item(0).getNodeValue();
                        if (nodeValue.startsWith("$CFFP:")) {
                            // $NON-NLS-1$
                            nodeValue = StringEscapeUtils.unescapeXml(nodeValue).substring(6);
                        }
                        return Messages.bind(Messages.XSDTreeLabelProvider_26, nodeValue);
                    } else {
                        // $NON-NLS-1$
                        return source + ": " + Util.nodeToString((Element) obj);
                    }
                } else {
                    return Util.nodeToString((Element) obj);
                }
            } else {
                return Util.nodeToString((Element) obj);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    if (obj == null) {
        // $NON-NLS-1$
        return "NULL";
    }
    // $NON-NLS-1$//$NON-NLS-2$
    return "?? " + obj.getClass().getName() + " : " + obj.toString();
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Element(org.w3c.dom.Element) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDFacet(org.eclipse.xsd.XSDFacet) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 22 with XSDAttributeGroupDefinition

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

the class XSDVisitor method visitAttributeGroupDefinition.

public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) {
    for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext(); ) {
        Object o = it.next();
        if (o instanceof XSDAttributeUse) {
            XSDAttributeUse attrUse = (XSDAttributeUse) o;
            visitAttributeDeclaration(attrUse.getContent());
        } else if (o instanceof XSDAttributeGroupDefinition) {
            XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) o;
            visitAttributeGroupDefinition(attrGroup.getResolvedAttributeGroupDefinition());
        }
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) Iterator(java.util.Iterator) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 23 with XSDAttributeGroupDefinition

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

the class XSDVisitor method visitSchema.

public void visitSchema(XSDSchema schema) {
    this.schema = schema;
    for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
        XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
        visitAttributeDeclaration(attr);
    }
    for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
        visitTypeDefinition(type);
    }
    for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
        XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
        visitElementDeclaration(element);
    }
    for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
        XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
        visitIdentityConstraintDefinition(identityConstraint);
    }
    for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
        visitModelGroupDefinition(modelGroup);
    }
    for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
        visitAttributeGroupDefinition(attributeGroup);
    }
    for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
        XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
        visitNotationDeclaration(element);
    }
}
Also used : XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 24 with XSDAttributeGroupDefinition

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

the class AttributeGroupDefinitionEditPart method getModelChildren.

protected List getModelChildren() {
    List list = new ArrayList();
    XSDAttributeGroupDefinitionAdapter adapter = (XSDAttributeGroupDefinitionAdapter) getModel();
    XSDAttributeGroupDefinition attributeGroupDefinition = adapter.getXSDAttributeGroupDefinition();
    Iterator i = attributeGroupDefinition.getResolvedAttributeGroupDefinition().getContents().iterator();
    while (i.hasNext()) {
        XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) i.next();
        if (attrGroupContent instanceof XSDAttributeGroupDefinition) {
            list.add(XSDAdapterFactory.getInstance().adapt(attrGroupContent));
        } else if (attrGroupContent instanceof XSDAttributeUse) {
            list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) XSDAdapterFactory.getInstance().adapt(((XSDAttributeUse) attrGroupContent).getAttributeDeclaration())));
        } else {
            list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) getModel()));
        }
    }
    if (list.isEmpty()) {
        list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) getModel()));
    }
    return list;
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) ArrayList(java.util.ArrayList) XSDAttributeGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter) Iterator(java.util.Iterator) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) ArrayList(java.util.ArrayList) List(java.util.List) TargetConnectionSpaceFiller(org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller) XSDAttributeGroupContent(org.eclipse.xsd.XSDAttributeGroupContent) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 25 with XSDAttributeGroupDefinition

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

the class XSDAttributeGroupDefinitionAdapter method getChildren.

public ITreeElement[] getChildren() {
    XSDAttributeGroupDefinition xsdAttributeGroup = (XSDAttributeGroupDefinition) target;
    List list = new ArrayList();
    Iterator iterator = xsdAttributeGroup.getContents().iterator();
    while (iterator.hasNext()) {
        Object o = iterator.next();
        if (o instanceof XSDAttributeUse) {
            list.add(((XSDAttributeUse) o).getAttributeDeclaration());
        } else {
            list.add(o);
        }
    }
    XSDWildcard wildcard = xsdAttributeGroup.getAttributeWildcardContent();
    if (wildcard != null) {
        list.add(wildcard);
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Aggregations

XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)42 Iterator (java.util.Iterator)20 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)17 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)16 ArrayList (java.util.ArrayList)15 List (java.util.List)15 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)15 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)15 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)13 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)13 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)13 XSDSchema (org.eclipse.xsd.XSDSchema)12 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)11 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)11 XSDParticle (org.eclipse.xsd.XSDParticle)11 EList (org.eclipse.emf.common.util.EList)10 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)9 Element (org.w3c.dom.Element)9 XSDWildcard (org.eclipse.xsd.XSDWildcard)8 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)7