Search in sources :

Example 81 with XSDComplexTypeDefinition

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

the class ComplexTypeConfigComposite method refresh.

private void refresh() {
    XSDTypeDefinition selectedExtends = getExtends();
    radGroupAll.setEnabled(!isExtendsSelected());
    radGroupSequence.setEnabled(!isExtendsSelected());
    radGroupChoice.setEnabled(!isExtendsSelected());
    if (!getDefaultExtends().equals(selectedExtends) && selectedExtends instanceof XSDComplexTypeDefinition && !Util.isAllComplexType((XSDComplexTypeDefinition) selectedExtends)) {
        radGroupAll.setSelection(false);
        radGroupSequence.setSelection(Util.isSequenceComplexType((XSDComplexTypeDefinition) selectedExtends));
        radGroupChoice.setSelection(Util.isChoiceComplexType((XSDComplexTypeDefinition) selectedExtends));
    }
    comboExtends.getCombo().setEnabled(!isGroupAll());
}
Also used : XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 82 with XSDComplexTypeDefinition

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

the class SimpleTypeInputDialog method modifyText.

public void modifyText(ModifyEvent e) {
    getButton(IDialogConstants.OK_ID).setEnabled(true);
    // $NON-NLS-1$
    infoLabel.setText("");
    String type = elemPanel.getText();
    if (// $NON-NLS-1$
    Pattern.compile("^\\s+\\w+\\s*").matcher(type).matches() || type.trim().replaceAll("\\s", "").length() != type.trim().length()) {
        // $NON-NLS-1$//$NON-NLS-2$
        infoLabel.setText(Messages.SimpleTypeInputDialog_infoLabelText);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;
    }
    type = type.trim();
    if (!XSDUtil.isValidatedXSDName(type)) {
        infoLabel.setText(Messages.InvalidName_Message);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;
    }
    for (XSDTypeDefinition simpType : xsdSchema.getTypeDefinitions()) {
        String typeToCompare = simpType.getName();
        // $NON-NLS-1$
        int delimiter = type.indexOf(" : ");
        if (delimiter != -1) {
            type = type.substring(0, delimiter);
        }
        if (typeToCompare.equals(type)) {
            if (caller instanceof XSDNewSimpleTypeDefinition) {
                infoLabel.setText(Messages.SimpleTypeInputDialog_SameName);
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            } else if ((caller instanceof XSDChangeToSimpleTypeAction || caller instanceof XSDChangeBaseTypeAction) && simpType instanceof XSDComplexTypeDefinition) {
                infoLabel.setText(Messages.SimpleTypeInputDialog_SameName);
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            }
            return;
        }
    }
}
Also used : XSDNewSimpleTypeDefinition(com.amalto.workbench.actions.XSDNewSimpleTypeDefinition) XSDChangeBaseTypeAction(com.amalto.workbench.actions.XSDChangeBaseTypeAction) XSDChangeToSimpleTypeAction(com.amalto.workbench.actions.XSDChangeToSimpleTypeAction) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 83 with XSDComplexTypeDefinition

use of org.eclipse.xsd.XSDComplexTypeDefinition 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 84 with XSDComplexTypeDefinition

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

the class DataModelMainPage method validateType.

private void validateType() throws IllegalAccessException {
    HashMap<String, Boolean> typeCntMap = new HashMap<String, Boolean>();
    EList<XSDTypeDefinition> types = xsdSchema.getTypeDefinitions();
    // $NON-NLS-1$
    String tail = "";
    for (XSDTypeDefinition type : types) {
        if (type instanceof XSDComplexTypeDefinition) {
            tail = Messages.ComplexText;
        } else {
            tail = Messages.SimpleText;
        }
        if (typeCntMap.get(type.getName() + tail + type.getTargetNamespace()) == Boolean.TRUE) {
        }
        typeCntMap.put(type.getName() + tail + type.getTargetNamespace(), Boolean.TRUE);
    }
}
Also used : HashMap(java.util.HashMap) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 85 with XSDComplexTypeDefinition

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

Aggregations

XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)162 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)93 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)76 XSDParticle (org.eclipse.xsd.XSDParticle)75 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)66 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)53 ArrayList (java.util.ArrayList)43 XSDSchema (org.eclipse.xsd.XSDSchema)37 Test (org.junit.Test)37 EList (org.eclipse.emf.common.util.EList)25 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)25 XSDFactory (org.eclipse.xsd.XSDFactory)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)21 XSDTerm (org.eclipse.xsd.XSDTerm)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)20 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)20 Iterator (java.util.Iterator)19 List (java.util.List)19 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)16