Search in sources :

Example 1 with XSDWildcard

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

the class DataModelMainPage method fillContextMenu.

protected void fillContextMenu(IMenuManager manager, boolean isType) {
    IStructuredSelection selection;
    if (!isType) {
        selection = ((IStructuredSelection) viewer.getSelection());
    } else {
        selection = ((IStructuredSelection) typesViewer.getSelection());
    }
    Object[] selectedObjs = selection.toArray();
    Object obj = selection.getFirstElement();
    if (!isType) {
        manager.add(newConceptAction);
    } else {
        manager.add(newComplexTypeAction);
        manager.add(newSimpleTypeAction);
        // add by ymli; fix the bug:0012228. Made the multiple types can be deleted.
        XSDDeleteTypeDefinition deleteTypeDefinition1;
        if (selectedObjs.length > 1) {
            deleteTypeDefinition1 = new XSDDeleteTypeDefinition(this, true);
        } else {
            deleteTypeDefinition1 = new XSDDeleteTypeDefinition(this, false);
        }
        if (selectedObjs.length >= 1 && deleteTypeDefinition1.isTypeDefinition(selectedObjs)) {
            manager.add(deleteTypeDefinition1);
        }
        deleteConceptWrapAction.regisExtraClassToDel(XSDComplexTypeDefinitionImpl.class);
        if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInDeletableType(selectedObjs)) {
            deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
        }
        if (selectedObjs.length > 1 && deleteConceptWrapAction.outPutDeleteActions() != null) {
            manager.add(deleteConceptWrapAction.outPutDeleteActions());
            if (deleteConceptWrapAction.checkOutAllConcept(selectedObjs)) {
                manager.add(newBrowseItemAction);
            }
        }
        if (exAdapter != null && obj instanceof XSDComplexTypeDefinition && selectedObjs.length == 1) {
            exAdapter.fillContextMenu(manager);
        }
    }
    manager.add(new Separator());
    if (!isType && ((selection == null) || (selection.getFirstElement() == null))) {
        if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 0) {
            manager.add(new Separator(ADDITIONMENUID));
            // add by ymli, fix bug 0009770
            // $NON-NLS-1$
            String title = "";
            if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1) {
                title = Messages.PasteEntityText;
            } else if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1) {
                title = Messages.PasteEntitiesText;
            }
            XSDPasteConceptAction pasteConceptAction = new XSDPasteConceptAction(this, title);
            if (pasteConceptAction.checkInPasteType()) {
                manager.add(new Separator());
                manager.add(pasteConceptAction);
            }
        }
        return;
    }
    // Element Declaration
    if (obj instanceof XSDElementDeclaration && selectedObjs.length == 1) {
        // check if concept or "just" element
        XSDElementDeclaration decl = (XSDElementDeclaration) obj;
        boolean isConcept = Util.checkConcept(decl);
        if (!Util.IsAImporedElement(decl, xsdSchema)) {
            if (isConcept) {
                manager.add(editConceptAction);
                manager.add(deleteConceptAction);
                manager.add(newBrowseItemAction);
            } else {
                manager.add(editElementAction);
                manager.add(deleteElementAction);
            }
            // add by ymli. fix bug 0009770 add the copy of concepts
            copyConceptAction.setText(Messages.CopyEntityText);
            if (Util.checkInCopy(selectedObjs)) {
                manager.add(new Separator());
                manager.add(copyConceptAction);
            }
            /*
                 * boolean isMulti = false; if(WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size()>1)
                 * isMulti = true;
                 */
            // $NON-NLS-1$
            String title = "";
            if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() > 1) {
                title = Messages.PasteEntitiesText;
            } else if (WorkbenchClipboard.getWorkbenchClipboard().getConcepts().size() == 1) {
                title = Messages.PasteEntityText;
            } else if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() > 1) {
                title = Messages.PasteElementsText;
            } else if (WorkbenchClipboard.getWorkbenchClipboard().getParticles().size() == 1) {
                title = Messages.PasteElement;
            }
            XSDPasteConceptAction pasteConceptAction = new XSDPasteConceptAction(this, title);
            if (pasteConceptAction.checkInPasteType()) {
                manager.add(pasteConceptAction);
            }
            manager.add(new Separator());
            manager.add(newElementAction);
            manager.add(new Separator());
            manager.add(changeToComplexTypeAction);
            manager.add(changeToSimpleTypeAction);
            // add by fliu, see bugID:0009157
            if (((XSDElementDeclaration) obj).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
                manager.add(setFacetMsgAction);
                manager.add(setAnnotationDisplayFomatAction);
            }
            manager.add(new Separator());
            manager.add(newIdentityConstraintAction);
        } else {
            if (isConcept) {
                manager.add(newBrowseItemAction);
            }
            manager.add(newElementAction);
        }
        // Annotations
        if (!Util.IsAImporedElement(decl, xsdSchema) || !Util.IsAImporedElement(decl.getTypeDefinition(), xsdSchema)) {
            setAnnotationActions2(obj, manager);
        }
    }
    // add by rhou.fix bug 0012073: Enable to create element from sub element group
    if (obj instanceof XSDModelGroup) {
        manager.add(new Separator());
        manager.add(getAddElementMenuForTypeClass(XSDModelGroup.class, Messages._AddElement));
        manager.add(new Separator());
        manager.add(changeSubElementGroupAction);
        manager.add(new Separator());
        manager.add(setAnnotationLabelAction);
        addPasteElementAction(manager);
    }
    if (obj instanceof XSDAttributeUse && selectedObjs.length == 1) {
        manager.add(deleteAttributeAction);
    }
    if (obj instanceof XSDAttributeDeclaration && selectedObjs.length == 1) {
        manager.add(deleteAttributeAction);
    }
    if (obj instanceof XSDParticle && selectedObjs.length == 1) {
        XSDTerm term = ((XSDParticle) obj).getTerm();
        if (!(term instanceof XSDWildcard)) {
            if (term instanceof XSDElementDeclaration) {
                manager.add(editParticleAction);
                if (!Util.IsAImporedElement(term, xsdSchema) || term.getContainer() instanceof XSDSchema) {
                    manager.add(getAddElementMenuForTypeClass(XSDParticle.class, Messages._AddElementAfter));
                    if (term instanceof XSDModelGroup) {
                        manager.add(getAddElementMenuForTypeClass(XSDModelGroup.class, Messages._AddElement));
                        manager.add(newGroupFromTypeAction);
                    }
                    manager.add(deleteParticleAction);
                    // edit by ymli. fix the bug:0011523
                    copyConceptAction.setText(Messages.CopyElementText);
                    manager.add(copyConceptAction);
                    if (((XSDElementDeclaration) term).getTypeDefinition() instanceof XSDComplexTypeDefinition) {
                        addPasteElementAction(manager);
                    }
                    manager.add(new Separator());
                    manager.add(changeToComplexTypeAction);
                    manager.add(changeToSimpleTypeAction);
                    // add by fliu, see bugID:0009157
                    manager.add(new Separator());
                    // Annotations
                    XSDTypeDefinition type = ((XSDElementDeclaration) term).getTypeDefinition();
                    setAnnotationActions(obj, manager);
                    if (((XSDElementDeclaration) term).getTypeDefinition() instanceof XSDSimpleTypeDefinition) {
                        manager.add(setFacetMsgAction);
                        manager.add(setAnnotationDisplayFomatAction);
                    }
                    // Xpath
                    manager.add(new Separator());
                    manager.add(getXPathAction);
                }
            }
        }
    }
    if (obj instanceof XSDComplexTypeDefinition && selectedObjs.length == 1 && ((XSDComplexTypeDefinition) obj).getTargetNamespace() == null) {
        if (!isType && !Util.IsAImporedElement((XSDParticle) obj, xsdSchema)) {
            manager.add(getAddElementMenuForTypeClass(XSDComplexTypeDefinition.class, Messages._AddElement));
            manager.add(newGroupFromTypeAction);
        }
        if (!Util.IsAImporedElement((XSDComplexTypeDefinition) obj, xsdSchema)) {
            // add by rhou.fix bug 0012073: Enable to create element from sub element group
            manager.add(new Separator());
            manager.add(getAddElementMenuForTypeClass(XSDComplexTypeDefinition.class, Messages._AddElement));
            manager.add(new Separator());
            manager.add(editComplexTypeAction);
        }
        manager.add(setAnnotationLabelAction);
        addPasteElementAction(manager);
    }
    if (obj instanceof XSDIdentityConstraintDefinition && selectedObjs.length == 1 && ((XSDIdentityConstraintDefinition) obj).getTargetNamespace() == null && !Util.IsAImporedElement((XSDIdentityConstraintDefinition) obj, xsdSchema)) {
        manager.add(deleteIdentityConstraintAction);
        manager.add(new Separator());
        manager.add(newXPathAction);
    }
    if (obj instanceof XSDXPathDefinition && selectedObjs.length == 1 && ((XSDXPathDefinition) obj).getSchema().getTargetNamespace() == null && !Util.IsAImporedElement((XSDXPathDefinition) obj, xsdSchema)) {
        manager.add(editXPathAction);
        manager.add(newXPathAction);
        XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
        if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL)) {
            manager.add(deleteXPathAction);
        }
    }
    // for the anonymous simpleType
    if (obj instanceof XSDSimpleTypeDefinition && selectedObjs.length == 1 && (!Util.IsAImporedElement((XSDSimpleTypeDefinition) obj, xsdSchema) || ((XSDSimpleTypeDefinition) obj).getName() == null)) {
        XSDSimpleTypeDefinition typedef = (XSDSimpleTypeDefinition) obj;
        manager.add(changeBaseTypeAction);
        manager.add(new Separator());
        if (typedef.getBaseTypeDefinition() != null) {
            EList list = typedef.getBaseTypeDefinition().getValidFacets();
            for (Iterator iter = list.iterator(); iter.hasNext(); ) {
                String element = (String) iter.next();
                manager.add(new XSDEditFacetAction(this, element));
            }
        }
    }
    if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInDeletableType(selectedObjs)) {
        deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
    }
    if (selectedObjs.length > 1 && deleteConceptWrapAction.checkInAllElementType(selectedObjs)) {
        manager.add(newBrowseItemAction);
    }
    if (selectedObjs.length > 1 && deleteConceptWrapAction.outPutDeleteActions() != null) {
        if (!isType) {
            manager.add(deleteConceptWrapAction.outPutDeleteActions());
        }
        // $NON-NLS-1$
        String title = "";
        if (Util.checkInCopyTypeElement(selectedObjs)) {
            title = Messages.CopyEntitiesText;
        } else if (Util.checkInCOpyTypeParticle(selectedObjs)) {
            title = Messages.CopyElements;
        }
        copyConceptAction.setText(title);
        if (Util.checkInCopy(selectedObjs)) {
            manager.add(copyConceptAction);
        }
        // add by ymli; fix bug:0016645
        if (selectedObjs.length > 1 && isXSDParticles(selectedObjs)) {
            manager.add(getAddElementMenuForTypeClass(XSDParticle.class, Messages._AddElementAfter));
        }
    }
    if (exAdapter != null) {
        exAdapter.fillContextMenu(manager, selectedObjs);
    }
    // available models
    java.util.List<IAvailableModel> availablemodels = AvailableModelUtil.getAvailableModels(isLocalInput());
    for (int i = 0; i < availablemodels.size(); i++) {
        IAvailableModel model = availablemodels.get(i);
        model.fillContextMenu(obj, manager, this, dataModelName);
        if (i == 1) {
            manager.add(new Separator());
        }
    }
    // 
    manager.add(new Separator());
    drillDownAdapter.addNavigationActions(manager);
    // Other plug-ins can contribute there actions here
    manager.add(new Separator(ADDITIONMENUID));
    deleteConceptWrapAction.clearExtraClassToDel();
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) Iterator(java.util.Iterator) XSDTerm(org.eclipse.xsd.XSDTerm) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema) IAvailableModel(com.amalto.workbench.availablemodel.IAvailableModel) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDPasteConceptAction(com.amalto.workbench.actions.XSDPasteConceptAction) XSDWildcard(org.eclipse.xsd.XSDWildcard) EList(org.eclipse.emf.common.util.EList) XSDEditFacetAction(com.amalto.workbench.actions.XSDEditFacetAction) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject) XSDDeleteTypeDefinition(com.amalto.workbench.actions.XSDDeleteTypeDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) Separator(org.eclipse.jface.action.Separator)

Example 2 with XSDWildcard

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

the class XPathTreeContentProvider method getXSDParticleChildren.

private Object[] getXSDParticleChildren(XSDParticle particle) {
    // System.out.println("getXSDParticleChildren() CLASS "+particle.getClass().getName());
    // System.out.println("getXSDParticleChildren() TERM "+particle.getTerm().getClass().getName()+": "+particle.getTerm());
    XSDTerm term = particle.getTerm();
    if (term instanceof XSDElementDeclaration) {
        XSDTypeDefinition typeDef = ((XSDElementDeclaration) term).getTypeDefinition();
        if (typeDef == null)
            // elements with not type declaration (allowed)
            return new Object[0];
        ArrayList<Object> list = new ArrayList<Object>();
        if (typeDef instanceof XSDComplexTypeDefinition) {
            list.addAll(getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) typeDef));
        } else {
            list.add(typeDef);
        }
        // }
        return list.toArray(new Object[list.size()]);
    }
    if (term instanceof XSDModelGroup) {
        // a ModelGroup skip it and get children directtly
        EList list = ((XSDModelGroup) term).getContents();
        return list.toArray(new XSDParticle[list.size()]);
    }
    if (term instanceof XSDWildcard) {
    }
    return new Object[] {};
}
Also used : EList(org.eclipse.emf.common.util.EList) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDTerm(org.eclipse.xsd.XSDTerm) XSDWildcard(org.eclipse.xsd.XSDWildcard) TreeObject(com.amalto.workbench.models.TreeObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 3 with XSDWildcard

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

the class XSDTreeContentProvider method getXSDParticleChildren.

private Object[] getXSDParticleChildren(XSDParticle particle) {
    // System.out.println("getXSDParticleChildren() CLASS "+particle.getClass().getName());
    // System.out.println("getXSDParticleChildren() TERM "+particle.getTerm().getClass().getName()+": "+particle.getTerm());
    XSDTerm term = particle.getTerm();
    if (term instanceof XSDElementDeclaration) {
        XSDTypeDefinition typeDef = ((XSDElementDeclaration) term).getTypeDefinition();
        if (typeDef == null)
            // elements with not type declaration (allowed)
            return new Object[0];
        ArrayList<Object> list = new ArrayList<Object>();
        if (typeDef instanceof XSDComplexTypeDefinition) {
            list.addAll(Util.getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) typeDef));
        } else {
            list.add(typeDef);
        }
        list.addAll(((XSDElementDeclaration) term).getIdentityConstraintDefinitions());
        XSDAnnotation annotation = ((XSDElementDeclaration) term).getAnnotation();
        if (filter != null && !filter.isAll()) {
        } else {
            if (annotation != null) {
                list.add(annotation);
            }
        }
        return list.toArray(new Object[list.size()]);
    }
    if (term instanceof XSDModelGroup) {
        // a ModelGroup skip it and get children directtly
        EList list = ((XSDModelGroup) term).getContents();
        return list.toArray(new XSDParticle[list.size()]);
    }
    if (term instanceof XSDWildcard) {
    }
    return new Object[] {};
}
Also used : EList(org.eclipse.emf.common.util.EList) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDTerm(org.eclipse.xsd.XSDTerm) XSDWildcard(org.eclipse.xsd.XSDWildcard) TreeObject(com.amalto.workbench.models.TreeObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 4 with XSDWildcard

use of org.eclipse.xsd.XSDWildcard 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 5 with XSDWildcard

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

the class AddXSDAnyAttributeCommand method execute.

public void execute() {
    try {
        beginRecording(input.getElement());
        XSDWildcard anyAttribute = XSDFactory.eINSTANCE.createXSDWildcard();
        if (xsdComplexTypeDefinition != null) {
            xsdComplexTypeDefinition.setAttributeWildcardContent(anyAttribute);
            formatChild(xsdComplexTypeDefinition.getElement());
        } else if (xsdAttributeGroupDefinition != null) {
            xsdAttributeGroupDefinition.setAttributeWildcardContent(anyAttribute);
            formatChild(xsdAttributeGroupDefinition.getElement());
        }
        addedXSDConcreteComponent = anyAttribute;
    } finally {
        endRecording();
    }
}
Also used : XSDWildcard(org.eclipse.xsd.XSDWildcard)

Aggregations

XSDWildcard (org.eclipse.xsd.XSDWildcard)25 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)16 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)15 XSDParticle (org.eclipse.xsd.XSDParticle)13 ArrayList (java.util.ArrayList)10 Iterator (java.util.Iterator)10 EList (org.eclipse.emf.common.util.EList)10 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)9 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)8 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)8 XSDTerm (org.eclipse.xsd.XSDTerm)8 List (java.util.List)7 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)7 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)6 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)6 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)6 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)5 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)5 TreeObject (com.amalto.workbench.models.TreeObject)4 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)4