use of org.eclipse.xsd.XSDAttributeGroupDefinition in project webtools.sourceediting by eclipse.
the class AddXSDAttributeGroupDefinitionCommand method execute.
public void execute() {
XSDAttributeGroupDefinition attributeGroup = XSDFactory.eINSTANCE.createXSDAttributeGroupDefinition();
try {
if (xsdSchema == null) {
beginRecording(xsdComplexTypeDefinition.getElement());
// $NON-NLS-1$
attributeGroup.setName(getNewName("AttributeGroup"));
List list = xsdComplexTypeDefinition.getSchema().getAttributeGroupDefinitions();
if (list.size() > 0) {
attributeGroup.setResolvedAttributeGroupDefinition((XSDAttributeGroupDefinition) list.get(0));
} else {
attributeGroup.setName(null);
XSDAttributeGroupDefinition attributeGroup2 = XSDFactory.eINSTANCE.createXSDAttributeGroupDefinition();
// $NON-NLS-1$
attributeGroup2.setName(XSDCommonUIUtils.createUniqueElementName("NewAttributeGroup", xsdComplexTypeDefinition.getSchema().getAttributeGroupDefinitions()));
xsdComplexTypeDefinition.getSchema().getContents().add(attributeGroup2);
attributeGroup.setResolvedAttributeGroupDefinition(attributeGroup2);
}
if (xsdComplexTypeDefinition.getAttributeContents() != null) {
xsdComplexTypeDefinition.getAttributeContents().add(attributeGroup);
}
addedXSDConcreteComponent = attributeGroup;
} else {
ensureSchemaElement(xsdSchema);
// put this after, since we don't have a DOM node yet
beginRecording(xsdSchema.getElement());
// $NON-NLS-1$
attributeGroup.setName(XSDCommonUIUtils.createUniqueElementName("NewAttributeGroup", xsdSchema.getAttributeGroupDefinitions()));
// $NON-NLS-1$
Text textNode = xsdSchema.getDocument().createTextNode("\n");
xsdSchema.getElement().appendChild(textNode);
xsdSchema.getContents().add(attributeGroup);
addedXSDConcreteComponent = attributeGroup;
}
} finally {
endRecording();
}
}
use of org.eclipse.xsd.XSDAttributeGroupDefinition in project webtools.sourceediting by eclipse.
the class AddXSDRedefinedAttributeGroupAction method buildComponentsList.
protected void buildComponentsList(XSDRedefine xsdRedefine, Set redefinedComponentsNames, IComponentList componentList) {
List attributeGroups = xsdRedefine.getIncorporatedSchema().getAttributeGroupDefinitions();
Iterator iterator = attributeGroups.iterator();
while (iterator.hasNext()) {
XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) iterator.next();
String attributeGroupDefinitionName = attributeGroupDefinition.getName();
if (!redefinedComponentsNames.contains(attributeGroupDefinitionName)) {
componentList.add(attributeGroupDefinition);
}
}
}
use of org.eclipse.xsd.XSDAttributeGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDAttributeGroupDefinitionSection method init.
protected void init() {
if (input instanceof XSDAttributeGroupDefinition) {
XSDAttributeGroupDefinition group = (XSDAttributeGroupDefinition) input;
isReference = group.isAttributeGroupDefinitionReference();
hideHyperLink = isReference;
}
}
use of org.eclipse.xsd.XSDAttributeGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDCommonUIUtils method getInputXSDAnnotation.
public static XSDAnnotation getInputXSDAnnotation(XSDConcreteComponent input, boolean createIfNotExist) {
XSDAnnotation xsdAnnotation = null;
XSDFactory factory = XSDFactory.eINSTANCE;
if (input instanceof XSDAttributeDeclaration) {
XSDAttributeDeclaration xsdComp = (XSDAttributeDeclaration) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDAttributeGroupDefinition) {
XSDAttributeGroupDefinition xsdComp = (XSDAttributeGroupDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdComp = (XSDElementDeclaration) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDNotationDeclaration) {
XSDNotationDeclaration xsdComp = (XSDNotationDeclaration) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDXPathDefinition) {
XSDXPathDefinition xsdComp = (XSDXPathDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDModelGroup) {
XSDModelGroup xsdComp = (XSDModelGroup) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition xsdComp = (XSDModelGroupDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDIdentityConstraintDefinition) {
XSDIdentityConstraintDefinition xsdComp = (XSDIdentityConstraintDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDWildcard) {
XSDWildcard xsdComp = (XSDWildcard) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDSchema) {
XSDSchema xsdComp = (XSDSchema) input;
List list = xsdComp.getAnnotations();
if (list.size() > 0) {
xsdAnnotation = (XSDAnnotation) list.get(0);
} else {
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
if (xsdComp.getContents() != null) {
xsdComp.getContents().add(0, xsdAnnotation);
}
}
}
return xsdAnnotation;
} else if (input instanceof XSDFacet) {
XSDFacet xsdComp = (XSDFacet) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDTypeDefinition) {
XSDTypeDefinition xsdComp = (XSDTypeDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDInclude) {
XSDInclude xsdComp = (XSDInclude) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDImport) {
XSDImport xsdComp = (XSDImport) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDRedefine) {
XSDRedefine xsdComp = (XSDRedefine) input;
List contents = xsdComp.getContents();
for (int i = 0; i < contents.size(); i++) {
Object content = contents.get(i);
if (content instanceof XSDAnnotation) {
xsdAnnotation = (XSDAnnotation) content;
break;
}
}
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
contents.add(0, xsdAnnotation);
}
return xsdAnnotation;
} else if (input instanceof XSDAnnotation) {
xsdAnnotation = (XSDAnnotation) input;
}
if (createIfNotExist) {
formatAnnotation(xsdAnnotation);
}
return xsdAnnotation;
}
use of org.eclipse.xsd.XSDAttributeGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDVisitor method visitComplexTypeDefinition.
public void visitComplexTypeDefinition(XSDComplexTypeDefinition type) {
XSDComplexTypeContent complexContent = type.getContent();
if (complexContent != null) {
if (complexContent instanceof XSDSimpleTypeDefinition) {
visitSimpleTypeDefinition((XSDSimpleTypeDefinition) complexContent);
} else if (complexContent instanceof XSDParticle) {
visitParticle((XSDParticle) complexContent);
}
}
if (type.getAttributeContents() != null) {
for (Iterator iter = type.getAttributeContents().iterator(); iter.hasNext(); ) {
XSDAttributeGroupContent attrGroupContent = (XSDAttributeGroupContent) iter.next();
if (attrGroupContent instanceof XSDAttributeUse) {
XSDAttributeUse attrUse = (XSDAttributeUse) attrGroupContent;
visitAttributeDeclaration(attrUse.getContent());
} else if (attrGroupContent instanceof XSDAttributeGroupDefinition) {
visitAttributeGroupDefinition((XSDAttributeGroupDefinition) attrGroupContent);
}
}
}
}
Aggregations