Search in sources :

Example 66 with XSDParticle

use of org.eclipse.xsd.XSDParticle 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 67 with XSDParticle

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

the class MatchRuleSelectionFilter method check.

public FilterResult check(Object obj) {
    if (obj instanceof XSDParticle) {
        XSDParticle particle = (XSDParticle) obj;
        int maxOccurs = particle.getMaxOccurs();
        if (maxOccurs > 1 || maxOccurs == -1) {
            return FilterResult.DISABLE;
        }
        XSDTerm term = particle.getTerm();
        if (term instanceof XSDElementDeclaration) {
            XSDElementDeclaration element = ((XSDElementDeclaration) term);
            XSDTypeDefinition type = element.getType();
            if (type instanceof XSDSimpleTypeDefinition) {
                return FilterResult.ENABLE;
            }
        }
    }
    return FilterResult.DISABLE;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDTerm(org.eclipse.xsd.XSDTerm) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 68 with XSDParticle

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

the class DataModelMainPage method setLabelForElement.

private void setLabelForElement(XSDElementDeclaration xSDEle, boolean isAdd) {
    if (xSDEle.getTypeDefinition() instanceof XSDComplexTypeDefinition) {
        XSDAnnotationsStructure struc = null;
        String labelValue = null;
        List childrenList = Util.getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) xSDEle.getTypeDefinition());
        for (int j = 0; j < childrenList.size(); j++) {
            List<XSDParticle> particles = new ArrayList<XSDParticle>();
            if (childrenList.get(j) instanceof XSDModelGroup) {
                particles = ((XSDModelGroup) childrenList.get(j)).getParticles();
            }
            for (int k = 0; k < particles.size(); k++) {
                XSDParticle xSDCom = particles.get(k);
                struc = new XSDAnnotationsStructure(xSDCom);
                if (xSDCom.getContent() instanceof XSDElementDeclaration) {
                    labelValue = ((XSDElementDeclaration) xSDCom.getContent()).getName();
                    setLabel(struc, labelValue, isAdd);
                    setLabelForElement((XSDElementDeclaration) xSDCom.getContent(), isAdd);
                }
            }
        }
    }
}
Also used : XSDAnnotationsStructure(com.amalto.workbench.utils.XSDAnnotationsStructure) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 69 with XSDParticle

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

the class DataModelMainPage method setAnnotationActions.

private void setAnnotationActions(Object obj, IMenuManager manager) {
    if (obj instanceof XSDElementDeclaration) {
        manager.add(setAnnotationDescriptionsAction);
        manager.add(setAnnotationLookupFieldsAction);
        manager.add(setAnnotationPrimaryKeyInfoAction);
    }
    if (obj instanceof XSDParticle) {
        manager.add(setAnnotationDescriptionsAction);
        manager.add(setAnnotationLabelAction);
        XSDTerm term = ((XSDParticle) obj).getTerm();
        if (term instanceof XSDElementDeclaration) {
            boolean isComplexType = ((XSDElementDeclaration) term).getTypeDefinition() instanceof XSDComplexTypeDefinition;
            if (!isComplexType) {
                String fkValue = skipToFKAction.getFKInfo((XSDElementDeclaration) term);
                if (fkValue != null) {
                    manager.add(skipToFKAction);
                }
                manager.add(setAnnotationForeignKeyAction);
                manager.add(setAnnotationFKFilterAction);
                manager.add(setAnnotationForeignKeyInfoAction);
            }
        }
    }
    if (exAdapter != null) {
        exAdapter.setAnnotationActions(obj, manager);
    }
    // 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());
        }
    }
}
Also used : IAvailableModel(com.amalto.workbench.availablemodel.IAvailableModel) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) Separator(org.eclipse.jface.action.Separator)

Example 70 with XSDParticle

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

the class DataModelMainPage method setAnnotationActions2.

private void setAnnotationActions2(Object obj, IMenuManager manager) {
    if (obj instanceof XSDElementDeclaration) {
        manager.add(setAnnotationLabelAction);
        manager.add(setAnnotationDescriptionsAction);
        manager.add(setAnnotationLookupFieldsAction);
        manager.add(setAnnotationPrimaryKeyInfoAction);
    }
    if (obj instanceof XSDParticle) {
        manager.add(setAnnotationDescriptionsAction);
        manager.add(setAnnotationLabelAction);
    }
    if (exAdapter != null) {
        exAdapter.setAnnotationActions2(obj, manager);
    }
    // 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());
        }
    }
}
Also used : IAvailableModel(com.amalto.workbench.availablemodel.IAvailableModel) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDParticle(org.eclipse.xsd.XSDParticle) Separator(org.eclipse.jface.action.Separator)

Aggregations

XSDParticle (org.eclipse.xsd.XSDParticle)146 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)103 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)93 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)75 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)36 ArrayList (java.util.ArrayList)34 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)34 XSDTerm (org.eclipse.xsd.XSDTerm)31 XSDFactory (org.eclipse.xsd.XSDFactory)27 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)24 XSDSchema (org.eclipse.xsd.XSDSchema)24 Test (org.junit.Test)23 Iterator (java.util.Iterator)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)21 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)19 EList (org.eclipse.emf.common.util.EList)17 XSDParticleContent (org.eclipse.xsd.XSDParticleContent)17 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 Element (org.w3c.dom.Element)16 List (java.util.List)15