Search in sources :

Example 21 with XSDModelGroupDefinition

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

the class UtilTest method testFilterOutDuplicatedElems.

@Test
public void testFilterOutDuplicatedElems() {
    // $NON-NLS-1$
    String simpletypeName = "simpletype";
    // $NON-NLS-1$
    String complextypeName = "complextype";
    // $NON-NLS-1$
    String concepName = "concept";
    // $NON-NLS-1$
    String idconstraintName = "identityconstraint";
    // $NON-NLS-1$
    String modelgroupName = "modelgroup";
    XSDFactory factory = XSDFactory.eINSTANCE;
    XSDSimpleTypeDefinition simpleTypeDefinition = factory.createXSDSimpleTypeDefinition();
    XSDComplexTypeDefinition complexTypeDefinition = factory.createXSDComplexTypeDefinition();
    XSDElementDeclaration elementDeclaration = factory.createXSDElementDeclaration();
    XSDIdentityConstraintDefinition identityConstraintDefinition = factory.createXSDIdentityConstraintDefinition();
    XSDModelGroupDefinition modelGroupDefinition = factory.createXSDModelGroupDefinition();
    simpleTypeDefinition.setName(simpletypeName);
    complexTypeDefinition.setName(complextypeName);
    elementDeclaration.setName(concepName);
    identityConstraintDefinition.setName(idconstraintName);
    modelGroupDefinition.setName(modelgroupName);
    XSDNamedComponent[] checkedElements = { simpleTypeDefinition, complexTypeDefinition, elementDeclaration, identityConstraintDefinition, modelGroupDefinition };
    Object[] duplicatedElems = Util.filterOutDuplicatedElems(checkedElements);
    List<XSDNamedComponent> allElements = Arrays.asList(checkedElements);
    assertNotNull(duplicatedElems);
    assertTrue(checkedElements.length == duplicatedElems.length);
    for (int i = 0; i < duplicatedElems.length; i++) {
        assertTrue(allElements.contains(duplicatedElems[i]));
    }
    // 
    XSDSimpleTypeDefinition simpleTypeDefinition2 = factory.createXSDSimpleTypeDefinition();
    XSDComplexTypeDefinition complexTypeDefinition2 = factory.createXSDComplexTypeDefinition();
    XSDElementDeclaration elementDeclaration2 = factory.createXSDElementDeclaration();
    XSDIdentityConstraintDefinition identityConstraintDefinition2 = factory.createXSDIdentityConstraintDefinition();
    XSDModelGroupDefinition modelGroupDefinition2 = factory.createXSDModelGroupDefinition();
    simpleTypeDefinition2.setName(simpletypeName);
    complexTypeDefinition2.setName(complextypeName);
    elementDeclaration2.setName(concepName);
    identityConstraintDefinition2.setName(idconstraintName);
    modelGroupDefinition2.setName(modelgroupName);
    XSDNamedComponent[] checkedElements2 = { simpleTypeDefinition, complexTypeDefinition, elementDeclaration, identityConstraintDefinition, modelGroupDefinition, simpleTypeDefinition2, complexTypeDefinition2, elementDeclaration2, identityConstraintDefinition2, modelGroupDefinition2 };
    duplicatedElems = Util.filterOutDuplicatedElems(checkedElements2);
    assertNotNull(duplicatedElems);
    assertTrue(checkedElements.length == duplicatedElems.length);
    for (int i = 0; i < duplicatedElems.length; i++) {
        assertTrue(allElements.contains(duplicatedElems[i]));
    }
}
Also used : XSDFactory(org.eclipse.xsd.XSDFactory) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) Test(org.junit.Test)

Example 22 with XSDModelGroupDefinition

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

the class XSDVisitor method visitModelGroupDefinition.

public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef) {
    if (!modelGroupDef.isModelGroupDefinitionReference()) {
        if (modelGroupDef.getModelGroup() != null) {
            if ((visitedGroups.contains(modelGroupDef.getResolvedModelGroupDefinition().getModelGroup()))) {
                circularDefinitionFound = true;
                return;
            }
            visitedGroups.push(modelGroupDef.getModelGroup());
            visitModelGroup(modelGroupDef.getModelGroup());
            visitedGroups.pop();
        }
    } else {
        XSDModelGroupDefinition resolvedGroupDef = modelGroupDef.getResolvedModelGroupDefinition();
        XSDModelGroup modelGroup = resolvedGroupDef.getModelGroup();
        if ((visitedGroups.contains(modelGroup))) {
            circularDefinitionFound = true;
            return;
        }
        visitedGroups.push(modelGroup);
        if (modelGroup != null) {
            visitModelGroup(modelGroup);
        }
        visitedGroups.pop();
    }
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 23 with XSDModelGroupDefinition

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

the class XSDVisitor method visitSchema.

public void visitSchema(XSDSchema schema) {
    this.schema = schema;
    for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
        XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
        visitAttributeDeclaration(attr);
    }
    for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
        XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
        visitTypeDefinition(type);
    }
    for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
        XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
        visitElementDeclaration(element);
    }
    for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
        XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
        visitIdentityConstraintDefinition(identityConstraint);
    }
    for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
        visitModelGroupDefinition(modelGroup);
    }
    for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
        XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
        visitAttributeGroupDefinition(attributeGroup);
    }
    for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
        XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
        visitNotationDeclaration(element);
    }
}
Also used : XSDNotationDeclaration(org.eclipse.xsd.XSDNotationDeclaration) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 24 with XSDModelGroupDefinition

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

the class XSDModelGroupDefinitionAdapter method isReadOnly.

public boolean isReadOnly() {
    XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition) target;
    if (hasSetReadOnlyField()) {
        deletedTypes.put(xsdModelGroupDefinition.getName(), new Boolean(true));
        changeReadOnlyField = false;
        return readOnly;
    } else {
        if (deletedTypes != null) {
            Boolean deleted = ((Boolean) deletedTypes.get(xsdModelGroupDefinition.getName()));
            if (deleted != null && deleted.booleanValue())
                return true;
            else
                return super.isReadOnly();
        } else
            return super.isReadOnly();
    }
}
Also used : XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 25 with XSDModelGroupDefinition

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

the class XSDModelGroupDefinitionAdapter method getActions.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider#getActions(java.lang.Object)
   */
public String[] getActions(Object object) {
    Collection list = new ArrayList();
    XSDModelGroupDefinition modelGroupDefinition = getXSDModelGroupDefinition();
    boolean isModelGroupReference = modelGroupDefinition.isModelGroupDefinitionReference();
    if (!isModelGroupReference) {
        list.add(AddXSDElementAction.ID);
        list.add(AddXSDElementAction.REF_ID);
        list.add(BaseSelectionAction.SEPARATOR_ID);
        list.add(AddXSDModelGroupAction.SEQUENCE_ID);
        list.add(AddXSDModelGroupAction.CHOICE_ID);
        list.add(AddXSDModelGroupAction.ALL_ID);
        list.add(BaseSelectionAction.SEPARATOR_ID);
    }
    list.add(DeleteAction.ID);
    if (isModelGroupReference) {
        list.add(BaseSelectionAction.SEPARATOR_ID);
        list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY);
        list.add(SetMultiplicityAction.REQUIRED_ID);
        list.add(SetMultiplicityAction.ZERO_OR_ONE_ID);
        list.add(SetMultiplicityAction.ZERO_OR_MORE_ID);
        list.add(SetMultiplicityAction.ONE_OR_MORE_ID);
        list.add(BaseSelectionAction.SUBMENU_END_ID);
    }
    list.add(BaseSelectionAction.SEPARATOR_ID);
    Object schema = getEditorSchema();
    if (modelGroupDefinition.getSchema() == schema) {
        XSDConcreteComponent container = modelGroupDefinition.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) Collection(java.util.Collection) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Aggregations

XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)43 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)19 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)18 List (java.util.List)15 ArrayList (java.util.ArrayList)13 Iterator (java.util.Iterator)12 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)11 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)11 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)11 XSDParticle (org.eclipse.xsd.XSDParticle)10 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)10 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)9 XSDSchema (org.eclipse.xsd.XSDSchema)9 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)8 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)7 XSDRedefine (org.eclipse.xsd.XSDRedefine)6 XSDWildcard (org.eclipse.xsd.XSDWildcard)6 Adapter (org.eclipse.emf.common.notify.Adapter)5 EObject (org.eclipse.emf.ecore.EObject)4 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)4