Search in sources :

Example 1 with XSDFacet

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

the class XpathSelectDialog method provideViwerContent.

// changeDomTree(
protected void provideViwerContent(XSDSchema xsdSchema, String filter) {
    drillDownAdapter = new DrillDownAdapter(domViewer);
    domViewer.setLabelProvider(new XSDTreeLabelProvider(selectionFilter));
    XPathTreeContentProvider provider = new XPathTreeContentProvider(this.site, xsdSchema, parent, filter);
    // filter the entity with the filter text but not the concept name.
    // provider.setConceptName(this.conceptName);
    domViewer.setContentProvider(provider);
    domViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent e) {
            StructuredSelection sel = (StructuredSelection) e.getSelection();
            xpath = getXpath(sel);
            xpathText.setText(xpath);
            boolean enable = false;
            if (selectionFilter == null) {
                enable = xpath.length() > 0;
            } else {
                enable = xpath.length() > 0 && (selectionFilter.check(sel.getFirstElement()) == FilterResult.ENABLE);
            }
            getButton(IDialogConstants.OK_ID).setEnabled(enable);
        }
    });
    domViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    domViewer.setSorter(new ViewerSorter() {

        @Override
        public int category(Object element) {
            // SimpleTypeDefinition
            if (element instanceof XSDFacet) {
                return 100;
            }
            // unique keys after element declarations and before other keys
            if (element instanceof XSDIdentityConstraintDefinition) {
                XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) element;
                if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
                    return 300;
                } else if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.KEY_LITERAL)) {
                    return 301;
                } else {
                    return 302;
                }
            }
            return 200;
        }

        @Override
        public int compare(Viewer theViewer, Object e1, Object e2) {
            int cat1 = category(e1);
            int cat2 = category(e2);
            return cat1 - cat2;
        }
    });
    domViewer.setInput(site);
}
Also used : DrillDownAdapter(org.eclipse.ui.part.DrillDownAdapter) XSDTreeLabelProvider(com.amalto.workbench.providers.XSDTreeLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) XPathTreeContentProvider(com.amalto.workbench.providers.XPathTreeContentProvider) XSDFacet(org.eclipse.xsd.XSDFacet) GridData(org.eclipse.swt.layout.GridData) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject)

Example 2 with XSDFacet

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

the class XSDTreeLabelProvider method getText.

@Override
public String getText(Object obj) {
    if (obj instanceof XSDElementDeclaration) {
        String name = ((XSDElementDeclaration) obj).getName();
        if (((XSDElementDeclaration) obj).isAbstract()) {
            name += Messages.XSDTreeLabelProvider_0;
        }
        String tail = ((XSDElementDeclaration) obj).getTargetNamespace() != null ? // $NON-NLS-1$
        " : " + ((XSDElementDeclaration) obj).getTargetNamespace() : // $NON-NLS-1$
        "";
        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) {
            // log.info("SHOULD NOT HAPPEN????");
            if (xsdParticle.getContainer() instanceof XSDComplexTypeDefinition) {
                String ctdName = ((XSDComplexTypeDefinition) xsdParticle.getContainer()).getName();
                // $NON-NLS-1$
                name = (ctdName != null ? ctdName : "");
            }
        } 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 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 = "anonymous type ";
        }
        // 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 += "]";
        }
        // get extend type
        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();
        }
        XSDSchema schema = particle.getSchema();
        // $NON-NLS-1$
        String tail = "";
        if (schema != null && schema.getTargetNamespace() != null) {
            tail = // $NON-NLS-1$
            " : " + schema.getTargetNamespace();
        }
        return name + tail + 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 XSDAttributeDeclaration) {
        XSDAttributeDeclaration attributeDec = (XSDAttributeDeclaration) obj;
        String name = attributeDec.getName();
        if (name == null) {
            name = attributeDec.getAliasName();
            if (name == null) {
                // $NON-NLS-1$
                name = " [null]";
            }
        }
        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 "Documentation: " + 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 Messages.bind(Messages.XSDTreeLabelProvider_1, Util.iso2lang.get(source.substring(8).toLowerCase()), e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_ForeignKey")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_2, 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.bind(Messages.XSDTreeLabelProvider_3, Messages.SimpleXpathInputDialog_sepFkTabPanel, v);
                    } else if (source.equals("X_Visible_Rule")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_4, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Default_Value_Rule")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_5, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_ForeignKeyInfo")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_6, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_ForeignKeyInfoFormat")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_20, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_PrimaryKeyInfo")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_7, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_SourceSystem")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_8, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_TargetSystem")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_9, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.startsWith("X_Description_")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_10, Util.iso2lang.get(source.substring(14).toLowerCase()), e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Write")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_11, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Deny_Create")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_12, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Deny_LogicalDelete")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_13, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Deny_PhysicalDelete")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_14, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Lookup_Field")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_15, 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());
                    } else if (source.equals("X_Hide")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_17, e.getChildNodes().item(0).getNodeValue());
                    // add by ymli; bugId 0009157
                    } else if (source.equals("X_AutoExpand")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_18, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.startsWith("X_Facet")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_19, source.substring(2, 7), source.substring(8), e.getChildNodes().item(0).getNodeValue());
                    // made schematron show:Schematron: schematron
                    } else if (source.startsWith("X_Display_Format_")) {
                        // $NON-NLS-1$
                        return source + ": " + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Schematron")) {
                        // $NON-NLS-1$
                        // $NON-NLS-1$
                        String pattern = (String) e.getFirstChild().getUserData("pattern_name");
                        if (pattern == null) {
                            Element el = Util.parse(e.getChildNodes().item(0).getNodeValue()).getDocumentElement();
                            if (el.getAttributes().getNamedItem("name") != null) {
                                // $NON-NLS-1$
                                // $NON-NLS-1$
                                pattern = el.getAttributes().getNamedItem("name").getTextContent();
                            }
                        }
                        return Messages.bind(Messages.XSDTreeLabelProvider_21, // e.getChildNodes().item(0).getNodeValue();
                        (pattern == null ? Messages.XSDTreeLabelProvider_22 : pattern));
                    // end
                    } 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());
                    }
                    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) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 3 with XSDFacet

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

the class TypesLabelProvider method getImage.

@Override
public Image getImage(Object obj) {
    if (obj instanceof XSDElementDeclaration) {
        // top declaration
        XSDElementDeclaration decl = (XSDElementDeclaration) obj;
        // check if concept or "just" element
        boolean isConcept = false;
        EList l = decl.getIdentityConstraintDefinitions();
        for (Iterator iter = l.iterator(); iter.hasNext(); ) {
            XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
            if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
                isConcept = true;
                break;
            }
        }
        // display approprite image
        if (isConcept) {
            return ImageCache.getCreatedImage(EImage.CONCEPT.getPath());
        } else {
            return ImageCache.getCreatedImage(EImage.ELEMENT_ONLY.getPath());
        /*
                 * if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) return
                 * PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_FOLDER); else
                 * return ImageCache.getCreatedImage( "icons/elements_obj_+.gif");
                 */
        }
    }
    if (obj instanceof XSDParticle) {
        XSDParticle xsdParticle = (XSDParticle) obj;
        XSDTerm xsdTerm = xsdParticle.getTerm();
        if (xsdTerm instanceof XSDElementDeclaration) {
            // get Type of Parent Group
            // if (Util.getKeyInfo(xsdTerm) != null && Util.getKeyInfo(xsdTerm).size() > 0) {
            // return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
            // }
            XSDConcreteComponent xsdConcreteComponent = xsdParticle.getContainer();
            if (XSDUtil.hasFKInfo((XSDElementDeclaration) xsdTerm)) {
                return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
            }
            if (xsdConcreteComponent instanceof XSDModelGroup) {
                return ImageCache.getCreatedImage(EImage.SCHEMAELEMENT.getPath());
            }
        /*
                 * if(((XSDElementDeclaration) xsdTerm).getAnonymousTypeDefinition() instanceof
                 * XSDComplexTypeDefinition) return ImageCache.getCreatedImage( EImage.COMPLEXTYPE.getPath()); else
                 * return ImageCache.getCreatedImage( EImage.SIMPLETYPE.getPath());
                 */
        } else if (xsdTerm instanceof XSDModelGroup) {
            int type = ((XSDModelGroup) xsdTerm).getCompositor().getValue();
            switch(type) {
                case XSDCompositor.ALL:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
                case XSDCompositor.CHOICE:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
                case XSDCompositor.SEQUENCE:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
            }
        } else if (xsdTerm instanceof XSDWildcard) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/wildcard.gif");
        } else {
            log.info(Messages.TypesLabelProvider_16 + xsdTerm.getClass().getName());
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/error.gif");
        }
    }
    if (obj instanceof XSDSimpleTypeDefinition) {
        return ImageCache.getCreatedImage(EImage.SIMPLETYPE.getPath());
    }
    if (obj instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition) obj;
        XSDComplexTypeContent ctc = ctd.getContent();
        if (ctc instanceof XSDParticle) {
            if (((XSDParticle) ctc).getTerm() instanceof XSDModelGroup) {
                int type = ((XSDModelGroup) ((XSDParticle) ctc).getTerm()).getCompositor().getValue();
                switch(type) {
                    case XSDCompositor.ALL:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
                    case XSDCompositor.CHOICE:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
                    case XSDCompositor.SEQUENCE:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
                }
            }
        } else {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/error.gif");
        }
    }
    if (obj instanceof XSDModelGroup) {
        int type = ((XSDModelGroup) obj).getCompositor().getValue();
        switch(type) {
            case XSDCompositor.ALL:
                return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
            case XSDCompositor.CHOICE:
                return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
            case XSDCompositor.SEQUENCE:
                return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
        }
    }
    if (obj instanceof XSDFacet) {
        return ImageCache.getCreatedImage(EImage.FACET.getPath());
    }
    if (obj instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition identity = (XSDIdentityConstraintDefinition) obj;
        if (identity.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
            return ImageCache.getCreatedImage(EImage.KEYS.getPath());
        }
        return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
    }
    if (obj instanceof XSDXPathDefinition) {
        XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
        if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL)) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/field.gif");
        }
        // $NON-NLS-1$
        return ImageCache.getCreatedImage("icons/selector.gif");
    }
    if (obj instanceof XSDAttributeGroupDefinition) {
        // $NON-NLS-1$
        return ImageCache.getCreatedImage("icons/attribute_group.gif");
    }
    if (obj instanceof XSDAttributeUse) {
        XSDAttributeUse att = (XSDAttributeUse) obj;
        if ("xmlns".equals(att.getAttributeDeclaration().getTargetNamespace())) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
        }
        if (att.getUse().equals(XSDAttributeUseCategory.REQUIRED_LITERAL)) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute_mandatory.gif");
        } else {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute.gif");
        }
    }
    if (obj instanceof XSDAnnotation) {
        return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
    }
    if (obj instanceof Element) {
        try {
            Element e = (Element) obj;
            if (e.getLocalName().equals("documentation")) {
                // $NON-NLS-1$
                return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
            } 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 ImageCache.getCreatedImage(EImage.LABEL.getPath());
                    } else if (source.equals("X_ForeignKey")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
                    } else if (source.equals("X_ForeignKeyInfo")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_FKIntegrity")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_FKIntegrity_Override")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_SourceSystem")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SOURCESYSTEM.getPath());
                    } else if (source.equals("X_TargetSystem")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.TARGETSYSTEM.getPath());
                    } else if (source.startsWith("X_Description_")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                    } else if (source.equals("X_Write")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Hide")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_Create")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_LogicalDelete")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_PhysicalDelete")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_AutoExpand")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.DEFAULT.getPath());
                    } else {
                        return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                    }
                } else {
                    return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                }
            } else {
                return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    // $NON-NLS-1$
    return ImageCache.getCreatedImage("icons/tree_object.gif");
// return PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_ELEMENT);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Element(org.w3c.dom.Element) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDFacet(org.eclipse.xsd.XSDFacet) EList(org.eclipse.emf.common.util.EList) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDTerm(org.eclipse.xsd.XSDTerm) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 4 with XSDFacet

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

the class XSDCommonUIUtils method getInputXSDAnnotation.

public static XSDAnnotation getInputXSDAnnotation(XSDConcreteComponent input, boolean createIfNotExist) {
    XSDAnnotation xsdAnnotation = null;
    XSDFactory factory = XSDFactory.eINSTANCE;
    if (input instanceof XSDAttributeDeclaration) {
        XSDAttributeDeclaration xsdComp = (XSDAttributeDeclaration) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDAttributeGroupDefinition) {
        XSDAttributeGroupDefinition xsdComp = (XSDAttributeGroupDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDElementDeclaration) {
        XSDElementDeclaration xsdComp = (XSDElementDeclaration) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDNotationDeclaration) {
        XSDNotationDeclaration xsdComp = (XSDNotationDeclaration) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDXPathDefinition) {
        XSDXPathDefinition xsdComp = (XSDXPathDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDModelGroup) {
        XSDModelGroup xsdComp = (XSDModelGroup) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDModelGroupDefinition) {
        XSDModelGroupDefinition xsdComp = (XSDModelGroupDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition xsdComp = (XSDIdentityConstraintDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDWildcard) {
        XSDWildcard xsdComp = (XSDWildcard) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDSchema) {
        XSDSchema xsdComp = (XSDSchema) input;
        List list = xsdComp.getAnnotations();
        if (list.size() > 0) {
            xsdAnnotation = (XSDAnnotation) list.get(0);
        } else {
            if (createIfNotExist && xsdAnnotation == null) {
                xsdAnnotation = factory.createXSDAnnotation();
                if (xsdComp.getContents() != null) {
                    xsdComp.getContents().add(0, xsdAnnotation);
                }
            }
        }
        return xsdAnnotation;
    } else if (input instanceof XSDFacet) {
        XSDFacet xsdComp = (XSDFacet) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDTypeDefinition) {
        XSDTypeDefinition xsdComp = (XSDTypeDefinition) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDInclude) {
        XSDInclude xsdComp = (XSDInclude) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDImport) {
        XSDImport xsdComp = (XSDImport) input;
        xsdAnnotation = xsdComp.getAnnotation();
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            xsdComp.setAnnotation(xsdAnnotation);
        }
    } else if (input instanceof XSDRedefine) {
        XSDRedefine xsdComp = (XSDRedefine) input;
        List contents = xsdComp.getContents();
        for (int i = 0; i < contents.size(); i++) {
            Object content = contents.get(i);
            if (content instanceof XSDAnnotation) {
                xsdAnnotation = (XSDAnnotation) content;
                break;
            }
        }
        if (createIfNotExist && xsdAnnotation == null) {
            xsdAnnotation = factory.createXSDAnnotation();
            contents.add(0, xsdAnnotation);
        }
        return xsdAnnotation;
    } else if (input instanceof XSDAnnotation) {
        xsdAnnotation = (XSDAnnotation) input;
    }
    if (createIfNotExist) {
        formatAnnotation(xsdAnnotation);
    }
    return xsdAnnotation;
}
Also used : XSDFactory(org.eclipse.xsd.XSDFactory) XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDFacet(org.eclipse.xsd.XSDFacet) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) EObject(org.eclipse.emf.ecore.EObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDImport(org.eclipse.xsd.XSDImport) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDSchema(org.eclipse.xsd.XSDSchema) XSDInclude(org.eclipse.xsd.XSDInclude)

Example 5 with XSDFacet

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

the class XSDTreeLabelProvider method getImage.

@Override
public Image getImage(Object obj) {
    if (obj instanceof XSDElementDeclaration) {
        // top declaration
        XSDElementDeclaration decl = (XSDElementDeclaration) obj;
        // check if concept or "just" element
        boolean isConcept = false;
        EList l = decl.getIdentityConstraintDefinitions();
        for (Iterator iter = l.iterator(); iter.hasNext(); ) {
            XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
            if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
                isConcept = true;
                break;
            }
        }
        // display approprite image
        if (isConcept) {
            return ImageCache.getCreatedImage(EImage.CONCEPT.getPath());
        } else {
            return ImageCache.getCreatedImage(EImage.ELEMENT_ONLY.getPath());
        /*
                 * if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) return
                 * PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_FOLDER); else
                 * return ImageCache.getCreatedImage( "icons/elements_obj_+.gif");
                 */
        }
    }
    if (obj instanceof XSDParticle) {
        XSDParticle xsdParticle = (XSDParticle) obj;
        XSDTerm xsdTerm = xsdParticle.getTerm();
        if (xsdTerm instanceof XSDElementDeclaration) {
            // get Type of Parent Group
            List<Object> realKeyInfos = Util.getRealKeyInfos(entity, xsdParticle);
            if (realKeyInfos != null && realKeyInfos.size() > 0) {
                return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
            }
            if (XSDUtil.hasFKInfo((XSDElementDeclaration) xsdTerm)) {
                return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
            }
            XSDConcreteComponent xsdConcreteComponent = xsdParticle.getContainer();
            if (xsdConcreteComponent instanceof XSDModelGroup) {
                return ImageCache.getCreatedImage(EImage.SCHEMAELEMENT.getPath());
            }
        /*
                 * if(((XSDElementDeclaration) xsdTerm).getAnonymousTypeDefinition() instanceof
                 * XSDComplexTypeDefinition) return ImageCache.getCreatedImage( EImage.COMPLEXTYPE.getPath()); else
                 * return ImageCache.getCreatedImage( EImage.SIMPLETYPE.getPath());
                 */
        } else if (xsdTerm instanceof XSDModelGroup) {
            int type = ((XSDModelGroup) xsdTerm).getCompositor().getValue();
            switch(type) {
                case XSDCompositor.ALL:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
                case XSDCompositor.CHOICE:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
                case XSDCompositor.SEQUENCE:
                    return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
            }
        } else if (xsdTerm instanceof XSDWildcard) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/wildcard.gif");
        } else {
            log.info(Messages.bind(Messages.XSDTreeLabelProvider_27, xsdTerm.getClass().getName()));
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/error.gif");
        }
    }
    if (obj instanceof XSDSimpleTypeDefinition) {
        return ImageCache.getCreatedImage(EImage.SIMPLETYPE.getPath());
    }
    if (obj instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition) obj;
        XSDComplexTypeContent ctc = ctd.getContent();
        if (ctc instanceof XSDParticle) {
            if (((XSDParticle) ctc).getTerm() instanceof XSDModelGroup) {
                int type = ((XSDModelGroup) ((XSDParticle) ctc).getTerm()).getCompositor().getValue();
                switch(type) {
                    case XSDCompositor.ALL:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
                    case XSDCompositor.CHOICE:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
                    case XSDCompositor.SEQUENCE:
                        return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
                }
            }
        } else {
            // simple Type!!!
            log.info(Messages.bind(Messages.XSDTreeLabelProvider_28, ctc.getClass().getName()));
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/error.gif");
        }
    }
    if (obj instanceof XSDModelGroup) {
        int type = ((XSDModelGroup) obj).getCompositor().getValue();
        switch(type) {
            case XSDCompositor.ALL:
                return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
            case XSDCompositor.CHOICE:
                return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
            case XSDCompositor.SEQUENCE:
                return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
        }
    }
    if (obj instanceof XSDFacet) {
        return ImageCache.getCreatedImage(EImage.FACET.getPath());
    }
    if (obj instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition identity = (XSDIdentityConstraintDefinition) obj;
        if (identity.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
            return ImageCache.getCreatedImage(EImage.KEYS.getPath());
        }
        return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
    }
    if (obj instanceof XSDXPathDefinition) {
        XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
        if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL)) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/field.gif");
        }
        // $NON-NLS-1$
        return ImageCache.getCreatedImage("icons/selector.gif");
    }
    if (obj instanceof XSDAttributeGroupDefinition) {
        // $NON-NLS-1$
        return ImageCache.getCreatedImage("icons/attribute_group.gif");
    }
    if (obj instanceof XSDAttributeUse) {
        XSDAttributeUse att = (XSDAttributeUse) obj;
        if ("xmlns".equals(att.getAttributeDeclaration().getTargetNamespace())) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
        }
        if (att.getUse().equals(XSDAttributeUseCategory.REQUIRED_LITERAL)) {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute_mandatory.gif");
        } else {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute.gif");
        }
    }
    if (obj instanceof XSDAttributeDeclaration) {
        XSDAttributeDeclaration attributeDec = (XSDAttributeDeclaration) obj;
        if (// $NON-NLS-1$
        "xmlns".equals(attributeDec.getTargetNamespace())) {
            return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
        } else {
            // $NON-NLS-1$
            return ImageCache.getCreatedImage("icons/attribute.gif");
        }
    }
    if (obj instanceof XSDAnnotation) {
        return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
    }
    if (obj instanceof Element) {
        try {
            Element e = (Element) obj;
            if (e.getLocalName().equals("documentation")) {
                // $NON-NLS-1$
                return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
            } 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 ImageCache.getCreatedImage(EImage.LABEL.getPath());
                    } else if (source.equals("X_ForeignKey")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
                    } else if (source.equals("X_Visible_Rule")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
                    } else if (source.equals("X_Default_Value_Rule")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
                    } else if (source.equals("X_ForeignKeyInfo")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_ForeignKeyInfoFormat")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    // fix bug 0013194 by rhou.
                    } else if (source.equals("X_FKIntegrity")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_FKIntegrity_Override")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_Retrieve_FKinfos")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
                    } else if (source.equals("X_SourceSystem")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SOURCESYSTEM.getPath());
                    } else if (source.equals("X_TargetSystem")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.TARGETSYSTEM.getPath());
                    } else if (source.startsWith("X_Description_")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                    } else if (source.equals("X_Write")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_Create")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_LogicalDelete")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Deny_PhysicalDelete")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Lookup_Field")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.BROWSE.getPath());
                    } else if (source.equals("X_Hide")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
                    } else if (source.equals("X_Schematron")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
                    } else if (source.equals("X_Workflow")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.WORKFLOW_PROCESS.getPath());
                    } else if (source.equals("X_AutoExpand")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.DEFAULT.getPath());
                    }
                    if (source.equals("X_ForeignKey_Filter")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.FILTER_PS.getPath());
                    } else if (source.startsWith("X_Display_Format_")) {
                        // $NON-NLS-1$
                        return ImageCache.getCreatedImage(EImage.THIN_MIN_VIEW.getPath());
                    } else {
                        return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                    }
                } else {
                    return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
                }
            } else {
                return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    // $NON-NLS-1$
    return ImageCache.getCreatedImage("icons/small_warn.gif");
// return PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_ELEMENT);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) Element(org.w3c.dom.Element) XSDFacet(org.eclipse.xsd.XSDFacet) Iterator(java.util.Iterator) XSDTerm(org.eclipse.xsd.XSDTerm) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) EList(org.eclipse.emf.common.util.EList) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Aggregations

XSDFacet (org.eclipse.xsd.XSDFacet)6 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)6 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)5 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)5 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)5 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)5 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)5 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)4 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)4 XSDParticle (org.eclipse.xsd.XSDParticle)4 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)4 XSDTerm (org.eclipse.xsd.XSDTerm)4 Element (org.w3c.dom.Element)4 EList (org.eclipse.emf.common.util.EList)3 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)3 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)3 XSDWildcard (org.eclipse.xsd.XSDWildcard)3 Iterator (java.util.Iterator)2 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)2 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)2