use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class AddXSDModelGroupDefinitionCommand method createXSDModelGroupDefinition.
protected XSDModelGroupDefinition createXSDModelGroupDefinition() {
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
XSDModelGroupDefinition def = factory.createXSDModelGroupDefinition();
List list = parent.getSchema().getModelGroupDefinitions();
// $NON-NLS-1$
String newName = XSDCommonUIUtils.createUniqueElementName("NewGroupDefinition", list);
def.setName(newName);
XSDModelGroup modelGroup = createModelGroup();
def.setModelGroup(modelGroup);
// $NON-NLS-1$
Text textNode = parent.getSchema().getDocument().createTextNode("\n");
parent.getSchema().getElement().appendChild(textNode);
parent.getSchema().getContents().add(def);
formatChild(def.getElement());
return def;
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDModelGroupDefinitionSection method init.
protected void init() {
if (input instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition group = (XSDModelGroupDefinition) input;
isReference = group.isModelGroupDefinitionReference();
hideHyperLink = isReference;
}
}
use of org.eclipse.xsd.XSDModelGroupDefinition 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.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class AddXSDModelGroupCommand method getOwner.
private XSDConcreteComponent getOwner() {
XSDConcreteComponent owner = null;
if (parent instanceof XSDElementDeclaration) {
XSDElementDeclaration ed = (XSDElementDeclaration) parent;
if (ed.getTypeDefinition() != null) {
if (ed.getAnonymousTypeDefinition() == null) {
ed.setTypeDefinition(null);
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = ed.getTypeDefinition();
} else {
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = td;
}
} else if (ed.getAnonymousTypeDefinition() == null) {
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = td;
} else if (ed.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition) {
owner = ed.getAnonymousTypeDefinition();
} else if (ed.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition) {
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = td;
}
} else if (parent instanceof XSDModelGroup) {
newModelGroup = createModelGroup();
((XSDModelGroup) parent).getContents().add(newModelGroup.getContainer());
} else if (parent instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) parent;
owner = parent;
if (ct.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) ct.getContent();
if (particle.getContent() instanceof XSDModelGroup) {
owner = null;
newModelGroup = createModelGroup();
XSDModelGroup newParent = (XSDModelGroup) particle.getContent();
newParent.getContents().add(newModelGroup.getContainer());
}
}
} else if (parent instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition modelGroupDefinition = (XSDModelGroupDefinition) parent;
owner = null;
newModelGroup = createModelGroup();
if (modelGroupDefinition.getModelGroup() != null) {
XSDModelGroup newParent = modelGroupDefinition.getModelGroup();
newParent.getContents().add(newModelGroup.getContainer());
} else {
modelGroupDefinition.setModelGroup(newModelGroup);
}
}
return owner;
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class RedefineModelGroupCommand method doExecute.
protected void doExecute() {
XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) redefinableComponent;
XSDModelGroupDefinition redefinedModelGroupDefinition = (XSDModelGroupDefinition) modelGroup.cloneConcreteComponent(true, false);
addedXSDConcreteComponent = redefinedModelGroupDefinition;
}
Aggregations