Search in sources :

Example 51 with XSDConcreteComponent

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

the class XSDEditor method resetTreeSelection.

private void resetTreeSelection(int newPageIndex) {
    DataModelMainPage dataModelEditorPage = getDataModelEditorPage();
    if (dataModelEditorPage != null) {
        TreeViewer treeViewer = dataModelEditorPage.getTreeViewer();
        if (newPageIndex == MODEL_PAGE_INDEX) {
            treeViewer.setSelection(null);
        } else if (newPageIndex == SOURCE_PAGE_INDEX) {
            IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
            if (!selection.isEmpty()) {
                Object firstElement = selection.getFirstElement();
                if ((firstElement instanceof XSDIdentityConstraintDefinition)) {
                    XSDIdentityConstraintDefinition cdf = (XSDIdentityConstraintDefinition) firstElement;
                    XSDConcreteComponent container = cdf.getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                } else if ((firstElement instanceof XSDXPathDefinition)) {
                    XSDXPathDefinition pathdef = (XSDXPathDefinition) firstElement;
                    XSDConcreteComponent container = pathdef.getContainer().getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                } else if (firstElement instanceof XSDAnnotation) {
                    XSDAnnotation annotation = (XSDAnnotation) firstElement;
                    XSDConcreteComponent container = annotation.getContainer();
                    treeViewer.setSelection(new StructuredSelection(container));
                }
            }
        }
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DataModelMainPage(com.amalto.workbench.editors.DataModelMainPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) EObject(org.eclipse.emf.ecore.EObject) TreeObject(com.amalto.workbench.models.TreeObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation)

Example 52 with XSDConcreteComponent

use of org.eclipse.xsd.XSDConcreteComponent 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)

Example 53 with XSDConcreteComponent

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

the class Util method retrieveXSDComponentPath.

public static List<String> retrieveXSDComponentPath(Object component, XSDSchema schema, List<String> buffer) {
    String name = null;
    if (component instanceof XSDElementDeclaration) {
        XSDElementDeclaration decl = (XSDElementDeclaration) component;
        name = decl.getName();
        // $NON-NLS-1$//$NON-NLS-2$
        buffer.add("//xsd:element[@name='" + name + "']");
        if (decl.getContainer() instanceof XSDSchemaImpl) {
            return buffer;
        } else {
            return retrieveXSDComponentPath(decl.getContainer(), schema, buffer);
        }
    } else if (component instanceof XSDParticle) {
        XSDParticle particle = (XSDParticle) component;
        XSDTerm term = particle.getTerm();
        if (term instanceof XSDElementDeclaration && !(((XSDElementDeclaration) term).getContainer() instanceof XSDParticle)) {
            String prefix = null;
            String ns = ((XSDElementDeclaration) term).getTargetNamespace();
            Iterator<Map.Entry<String, String>> iter = schema.getQNamePrefixToNamespaceMap().entrySet().iterator();
            while (iter.hasNext() && ns != null) {
                Map.Entry<String, String> entry = iter.next();
                if (entry.getValue().equals(ns)) {
                    prefix = entry.getKey();
                }
            }
            name = ((XSDElementDeclaration) term).getName();
            buffer.add(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
            "//xsd:element[@name='" + name + "' or @ref='" + (prefix != null ? (prefix + ":" + name) : name) + "']");
            return retrieveXSDComponentPath(particle.getContainer(), schema, buffer);
        } else {
            retrieveXSDComponentPath(particle.getContainer(), schema, buffer);
        }
    } else if (component instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition type = (XSDComplexTypeDefinition) component;
        name = type.getName();
        // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
        buffer.add("//xsd:complexType" + (name != null ? "[@name='" + name + "']" : ""));
        if (type.getContainer() instanceof XSDSchemaImpl) {
            return buffer;
        }
        return retrieveXSDComponentPath(type.getContainer(), schema, buffer);
    } else if (component instanceof XSDSimpleTypeDefinition) {
        // TreePath tPath=((TreeSelection)selection).getPaths()[0];
        // Object elem = tPath.getSegment(0);
        // return retrieveXSDComponentPath(elem, schema, buffer, selection);
        String typeName = ((XSDSimpleTypeDefinition) component).getName();
        // $NON-NLS-1$//$NON-NLS-2$
        buffer.add("//xsd:simpleType[@name='" + typeName + "']");
        return buffer;
    } else if (component instanceof XSDModelGroup) {
        XSDModelGroup group = (XSDModelGroup) component;
        String literal = group.getCompositor().getLiteral();
        // $NON-NLS-1$
        buffer.add("//xsd:" + literal);
        return retrieveXSDComponentPath(group.getContainer(), schema, buffer);
    } else if (component instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition identify = (XSDIdentityConstraintDefinition) component;
        XSDConcreteComponent c = identify.getContainer();
        // $NON-NLS-1$//$NON-NLS-2$
        buffer.add("//xsd:unique[@name='" + identify.getName() + "']");
        return retrieveXSDComponentPath(c, schema, buffer);
    } else if (component instanceof XSDXPathDefinition) {
        XSDXPathDefinition path = (XSDXPathDefinition) component;
        // $NON-NLS-1$//$NON-NLS-2$
        buffer.add("//xsd:field[@xpath='" + path.getValue() + "']");
        return retrieveXSDComponentPath(path.getContainer(), schema, buffer);
    } else if (component instanceof XSDAnnotation) {
        XSDAnnotation annon = (XSDAnnotation) component;
        // $NON-NLS-1$
        buffer.add("//xsd:annotation");
        return retrieveXSDComponentPath(annon.getContainer(), schema, buffer);
    } else {
        return buffer;
    }
    return buffer;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ZipEntry(java.util.zip.ZipEntry) Entry(java.util.Map.Entry) JarEntry(java.util.jar.JarEntry) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSchemaImpl(org.eclipse.xsd.impl.XSDSchemaImpl) Iterator(java.util.Iterator) 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) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) MultiKeyMap(org.apache.commons.collections.map.MultiKeyMap) HashMap(java.util.HashMap) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 54 with XSDConcreteComponent

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

the class SelectXPathComposite method getXpath.

private String getXpath() {
    // $NON-NLS-1$
    String path = "";
    // $NON-NLS-1$
    String totalXpath = "";
    TreeItem item;
    TreeItem[] items = tvXPath.getTree().getSelection();
    for (int i = 0; i < items.length; i++) {
        item = items[i];
        XSDConcreteComponent component = (XSDConcreteComponent) item.getData();
        if (!(component instanceof XSDParticle) && !(component instanceof XSDElementDeclaration)) {
            continue;
        }
        do {
            component = (XSDConcreteComponent) item.getData();
            if (component instanceof XSDParticle) {
                if (((XSDParticle) component).getTerm() instanceof XSDElementDeclaration) {
                    // $NON-NLS-1$
                    path = "/" + ((XSDElementDeclaration) ((XSDParticle) component).getTerm()).getName() + path;
                }
            } else if (component instanceof XSDElementDeclaration) {
                // $NON-NLS-1$//$NON-NLS-2$
                path = (isAbsolutePath ? "/" : "") + ((XSDElementDeclaration) component).getName() + path;
            }
            item = item.getParentItem();
        } while (item != null);
        if (i == 0) {
            totalXpath = path;
        } else {
            // $NON-NLS-1$
            totalXpath += "&" + path;
        }
        // $NON-NLS-1$
        path = "";
    }
    // for(i=0
    if (context != null && conceptName != null) {
        if (totalXpath.equals(conceptName)) {
            // $NON-NLS-1$
            totalXpath = totalXpath.replaceAll(conceptName, "/");
        } else {
            // $NON-NLS-1$//$NON-NLS-2$
            totalXpath = totalXpath.replaceAll(conceptName + "/", "");
        }
        if (totalXpath.equals(context) || totalXpath.equals(context.replaceAll(conceptName + "/", ""))) {
            // $NON-NLS-1$//$NON-NLS-2$
            // $NON-NLS-1$
            totalXpath = ".";
        }
        if (// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
        totalXpath.indexOf('/') == -1 && !totalXpath.equals(".") && !"/".equals(totalXpath) && !"/".equals(context) && !context.equals(conceptName)) {
            // $NON-NLS-1$
            totalXpath = "../" + totalXpath;
        }
    }
    return totalXpath;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) TreeItem(org.eclipse.swt.widgets.TreeItem) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 55 with XSDConcreteComponent

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

the class XSDSimpleTypeDefinitionAdapter method getActions.

public String[] getActions(Object object) {
    List list = new ArrayList();
    list.add(AddXSDEnumerationFacetAction.ID);
    list.add(BaseSelectionAction.SEPARATOR_ID);
    list.add(SetBaseTypeAction.ID);
    list.add(BaseSelectionAction.SEPARATOR_ID);
    list.add(DeleteAction.ID);
    list.add(BaseSelectionAction.SEPARATOR_ID);
    Object schema = getEditorSchema();
    XSDTypeDefinition typeDefinition = getXSDTypeDefinition();
    if (typeDefinition.getSchema() == schema) {
        XSDConcreteComponent container = typeDefinition.getContainer();
        if (container == schema || container instanceof XSDRedefine) {
            list.add(SetInputToGraphView.ID);
        }
    } else {
        list.add(OpenInNewEditor.ID);
    }
    list.add(BaseSelectionAction.SEPARATOR_ID);
    list.add(ShowPropertiesViewAction.ID);
    return (String[]) list.toArray(new String[0]);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) EObject(org.eclipse.emf.ecore.EObject) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)88 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)30 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)25 XSDSchema (org.eclipse.xsd.XSDSchema)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)18 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)17 Adapter (org.eclipse.emf.common.notify.Adapter)15 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)15 XSDParticle (org.eclipse.xsd.XSDParticle)13 Iterator (java.util.Iterator)12 ArrayList (java.util.ArrayList)11 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)11 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)11 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)11 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)11 List (java.util.List)10 Element (org.w3c.dom.Element)10 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)9 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)9