use of org.eclipse.xsd.XSDSimpleTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDElementCommand method createXSDElementDeclarationForModelGroupDefinitions.
protected XSDParticle createXSDElementDeclarationForModelGroupDefinitions() {
// $NON-NLS-1$
XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
ArrayList usedAttributeNames = new ArrayList();
usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes(xsdModelGroupDefinition));
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.XSDSimpleTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDElementCommand method createGlobalXSDElementDeclaration.
protected XSDElementDeclaration createGlobalXSDElementDeclaration() {
ensureSchemaElement(xsdSchema);
// $NON-NLS-1$
XSDSimpleTypeDefinition type = xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string");
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
XSDElementDeclaration element = factory.createXSDElementDeclaration();
element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
xsdSchema.getElementDeclarations()));
element.setTypeDefinition(type);
return element;
}
use of org.eclipse.xsd.XSDSimpleTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDRedefinedSimpleTypeAction method buildComponentsList.
protected void buildComponentsList(XSDRedefine xsdRedefine, Set redefinedComponentsNames, IComponentList componentList) {
List typeDefinitions = xsdRedefine.getIncorporatedSchema().getTypeDefinitions();
Iterator iterator = typeDefinitions.iterator();
while (iterator.hasNext()) {
XSDTypeDefinition typeDefinition = (XSDTypeDefinition) iterator.next();
String typeDefinitionName = typeDefinition.getName();
if (typeDefinition instanceof XSDSimpleTypeDefinition && !redefinedComponentsNames.contains(typeDefinitionName)) {
componentList.add(typeDefinition);
}
}
}
use of org.eclipse.xsd.XSDSimpleTypeDefinition in project webtools.sourceediting by eclipse.
the class EnumerationsSection method refresh.
/*
* @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
*/
public void refresh() {
if (isReadOnly) {
composite.setEnabled(false);
} else {
composite.setEnabled(true);
}
XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input;
Iterator validFacets = st.getValidFacets().iterator();
boolean isApplicable = false;
while (validFacets.hasNext()) {
String aValidFacet = (String) validFacets.next();
if (aValidFacet.equals(XSDConstants.ENUMERATION_ELEMENT_TAG)) {
isApplicable = true;
}
}
if (isApplicable) {
addButton.setEnabled(true);
addManyButton.setEnabled(true);
} else {
addButton.setEnabled(false);
addManyButton.setEnabled(false);
}
enumerationsTable.setInput(input);
}
use of org.eclipse.xsd.XSDSimpleTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDSimpleTypeDefinitionCommand method execute.
public void execute() {
if (parent instanceof XSDSchema) {
ensureSchemaElement((XSDSchema) parent);
}
try {
beginRecording(parent.getElement());
XSDSimpleTypeDefinition typeDef = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition();
// $NON-NLS-1$
typeDef.setBaseTypeDefinition(parent.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
if (parent instanceof XSDSchema) {
// $NON-NLS-1$
typeDef.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewSimpleType" : nameToAdd, ((XSDSchema) parent).getTypeDefinitions()));
createdSimpleType = typeDef;
try {
XSDSchema xsdSchema = (XSDSchema) parent;
// $NON-NLS-1$
Text textNode = xsdSchema.getDocument().createTextNode("\n");
xsdSchema.getElement().appendChild(textNode);
xsdSchema.getContents().add(typeDef);
} catch (Exception e) {
}
} else if (parent instanceof XSDElementDeclaration) {
((XSDElementDeclaration) parent).setAnonymousTypeDefinition(typeDef);
} else if (parent instanceof XSDAttributeDeclaration) {
((XSDAttributeDeclaration) parent).setAnonymousTypeDefinition(typeDef);
}
formatChild(createdSimpleType.getElement());
addedXSDConcreteComponent = createdSimpleType;
} finally {
endRecording();
}
}
Aggregations