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]));
}
}
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();
}
}
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);
}
}
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();
}
}
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]);
}
Aggregations