Search in sources :

Example 31 with XSDAnnotation

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

the class ElementFKInfosSection method getEntities.

@Override
public Set<String> getEntities() {
    if (curXSDComponent instanceof XSDParticle) {
        XSDParticle ele = ((XSDParticle) curXSDComponent);
        XSDTerm term = ele.getTerm();
        if (term instanceof XSDElementDeclaration) {
            XSDAnnotation anno = ((XSDElementDeclaration) term).getAnnotation();
            if (null != anno) {
                Set<String> list = new HashSet<String>();
                Util.getForeignKeyofParcle(list, anno);
                return list;
            }
        }
    }
    return null;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDParticle(org.eclipse.xsd.XSDParticle) HashSet(java.util.HashSet)

Example 32 with XSDAnnotation

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

the class DataModelMainPage method getStructureByActiveItem.

public XSDAnnotationsStructure getStructureByActiveItem() {
    XSDComponent xSDCom = null;
    XSDAnnotationsStructure struc = null;
    IStructuredSelection selection = (TreeSelection) getTreeViewer().getSelection();
    if (selection.getFirstElement() instanceof Element) {
        TreePath tPath = ((TreeSelection) selection).getPaths()[0];
        for (int i = 0; i < tPath.getSegmentCount(); i++) {
            if (tPath.getSegment(i) instanceof XSDAnnotation) {
                xSDCom = (XSDAnnotation) (tPath.getSegment(i));
            }
        }
    } else {
        xSDCom = (XSDComponent) selection.getFirstElement();
    }
    if (xSDCom != null) {
        struc = new XSDAnnotationsStructure(xSDCom);
    }
    return struc;
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) XSDAnnotationsStructure(com.amalto.workbench.utils.XSDAnnotationsStructure) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Element(org.w3c.dom.Element) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDComponent(org.eclipse.xsd.XSDComponent)

Example 33 with XSDAnnotation

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

the class DataModelMainPage method hasVisibleRule.

public boolean hasVisibleRule(XSDElementDeclaration xsdEl) {
    XSDAnnotation annotation = xsdEl.getAnnotation();
    List<Element> informations = annotation.getApplicationInformation();
    for (Element el : informations) {
        String name = el.getLocalName();
        if ("appinfo".equals(name.toLowerCase())) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            name = el.getAttribute("source");
            if (name.matches("X_Visible_Rule")) {
                // $NON-NLS-1$
                return true;
            }
        }
    }
    return false;
}
Also used : Element(org.w3c.dom.Element) XSDAnnotation(org.eclipse.xsd.XSDAnnotation)

Example 34 with XSDAnnotation

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

the class TreeExpandHelper method getName.

private String getName(Object objA) {
    if (objA instanceof XSDElementDeclaration) {
        XSDElementDeclaration decl = (XSDElementDeclaration) objA;
        return decl.getName();
    }
    if (objA instanceof XSDModelGroup) {
        XSDModelGroup goup = (XSDModelGroup) objA;
        XSDParticle particle = (XSDParticle) goup.getContainer();
        XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) particle.getContainer();
        String name = complexTypeDefinition.getName();
        return name;
    }
    if (objA instanceof XSDModelGroupDefinition) {
        XSDModelGroupDefinition goupDef = (XSDModelGroupDefinition) objA;
        return goupDef.getName();
    }
    if (objA instanceof XSDParticle) {
        XSDParticle particle = (XSDParticle) objA;
        if (particle.getTerm() instanceof XSDElementDeclaration) {
            XSDElementDeclaration decl = (XSDElementDeclaration) particle.getTerm();
            return decl.getName();
        }
    }
    if (objA instanceof XSDAnnotation) {
        return null;
    }
    if (objA instanceof XSDIdentityConstraintDefinition) {
        XSDIdentityConstraintDefinition constraint = (XSDIdentityConstraintDefinition) objA;
        return constraint.getName();
    }
    if (objA instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition simpleDefine = (XSDSimpleTypeDefinition) objA;
        return simpleDefine.getName();
    }
    if (objA instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition complexDefine = (XSDComplexTypeDefinition) objA;
        return complexDefine.getName();
    }
    return null;
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 35 with XSDAnnotation

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

Aggregations

XSDAnnotation (org.eclipse.xsd.XSDAnnotation)55 Element (org.w3c.dom.Element)33 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)28 XSDParticle (org.eclipse.xsd.XSDParticle)21 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)20 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)20 XSDAnnotationsStructure (com.amalto.workbench.utils.XSDAnnotationsStructure)17 ArrayList (java.util.ArrayList)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 XSDTerm (org.eclipse.xsd.XSDTerm)16 TreePath (org.eclipse.jface.viewers.TreePath)13 TreeSelection (org.eclipse.jface.viewers.TreeSelection)13 XSDComponent (org.eclipse.xsd.XSDComponent)13 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)13 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)12 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)10 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)10 EList (org.eclipse.emf.common.util.EList)9 XSDSchema (org.eclipse.xsd.XSDSchema)8 Iterator (java.util.Iterator)7