use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDAttributeGroupDefinitionCommand method getNewName.
protected String getNewName(String description) {
// $NON-NLS-1$
String candidateName = "New" + description;
XSDConcreteComponent parent = xsdComplexTypeDefinition;
names = new ArrayList();
int i = 1;
if (parent instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) parent;
walkUpInheritance(ct);
boolean ready = false;
while (!ready) {
ready = true;
for (Iterator iter = names.iterator(); iter.hasNext(); ) {
String attrName = (String) iter.next();
if (candidateName.equals(attrName)) {
ready = false;
// $NON-NLS-1$
candidateName = "New" + description + String.valueOf(i);
i++;
}
}
}
}
return candidateName;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDElementCommand method createXSDElementDeclaration.
protected XSDParticle createXSDElementDeclaration() {
// $NON-NLS-1$
XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
XSDConcreteComponent comp = xsdModelGroup.getContainer();
ArrayList usedAttributeNames = new ArrayList();
XSDCommonUIUtils.resetVisitedGroupsStack();
usedAttributeNames.addAll(XSDCommonUIUtils.getChildElements(xsdModelGroup));
while (comp != null) {
if (comp instanceof XSDModelGroupDefinition) {
usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDModelGroupDefinition) comp));
break;
} else if (comp instanceof XSDComplexTypeDefinition) {
usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDComplexTypeDefinition) comp));
usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes((XSDComplexTypeDefinition) comp));
break;
}
comp = comp.getContainer();
}
element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
usedAttributeNames));
element.setTypeDefinition(type);
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
particle.setContent(element);
addedXSDConcreteComponent = element;
return particle;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDEnumerationFacetAction method calculateEnabled.
protected boolean calculateEnabled() {
boolean parentResult = super.calculateEnabled();
boolean endResult = true;
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDComplexTypeDefinitionAdapter) {
XSDComplexTypeDefinition definition = ((XSDComplexTypeDefinitionAdapter) selection).getXSDComplexTypeDefinition();
XSDTypeDefinition baseType = definition.getBaseType();
if (baseType instanceof XSDSimpleTypeDefinition)
endResult = false;
}
endResult = endResult & parentResult;
return endResult;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDEnumerationFacetAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
int index = -1;
AddEnumerationsCommand command = null;
XSDSimpleTypeDefinition st = null;
if (selection instanceof XSDSimpleTypeDefinition) {
st = (XSDSimpleTypeDefinition) selection;
command = new AddEnumerationsCommand(getText(), st);
} else if (selection instanceof XSDEnumerationFacet) {
st = ((XSDEnumerationFacet) selection).getSimpleTypeDefinition();
index = st.getFacetContents().indexOf(selection);
doDirectEdit = true;
command = new AddEnumerationsCommand(getText(), st, getId(), index);
} else if (// Support for Complex Type's simple Content with enumerations
selection instanceof XSDComplexTypeDefinition) {
st = (XSDSimpleTypeDefinition) ((XSDComplexTypeDefinition) selection).getContent();
command = new AddEnumerationsCommand(getText(), st);
} else // null
{
return;
}
List enumList = st.getEnumerationFacets();
// $NON-NLS-1$
String newName = XSDCommonUIUtils.createUniqueEnumerationValue("value", enumList);
command.setValue(newName);
getCommandStack().execute(command);
addedComponent = command.getAddedComponent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
selectAddedComponent(adapter);
}
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class RedefineComplexTypeCommand method doExecute.
protected void doExecute() {
XSDComplexTypeDefinition redefinedComplexTypeDefinition = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
redefinedComplexTypeDefinition.setName(redefinableComponent.getName());
redefinedComplexTypeDefinition.setContent(XSDFactory.eINSTANCE.createXSDComplexTypeDefinition().getContent());
redefinedComplexTypeDefinition.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
redefinedComplexTypeDefinition.setBaseTypeDefinition((XSDComplexTypeDefinition) redefinableComponent);
addedXSDConcreteComponent = redefinedComplexTypeDefinition;
}
Aggregations