use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class UpdateComplexTypeDerivationBy method execute.
public void execute() {
super.execute();
try {
beginRecording(complexType.getElement());
XSDTypeDefinition originalBaseType = complexType.getBaseType();
if (derivation.equals(XSDConstants.EXTENSION_ELEMENT_TAG)) {
complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL);
} else if (derivation.equals(XSDConstants.RESTRICTION_ELEMENT_TAG)) {
complexType.setDerivationMethod(XSDDerivationMethod.RESTRICTION_LITERAL);
}
complexType.setBaseTypeDefinition(originalBaseType);
} finally {
endRecording();
}
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class UpdateTypeReferenceAndManageDirectivesCommand method execute.
public void execute() {
try {
beginRecording(concreteComponent.getElement());
XSDComponent td = computeComponent();
if (td != null && td instanceof XSDTypeDefinition) {
UpdateTypeReferenceCommand command = new UpdateTypeReferenceCommand(concreteComponent, (XSDTypeDefinition) td);
command.execute();
XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
}
} catch (Exception e) {
} finally {
endRecording();
}
}
use of org.eclipse.xsd.XSDTypeDefinition 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.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class SetBaseTypeAndManagerDirectivesCommand method execute.
public void execute() {
try {
beginRecording(concreteComponent.getElement());
XSDComponent td = computeComponent();
if (td != null && td instanceof XSDTypeDefinition) {
SetBaseTypeCommand command = new SetBaseTypeCommand(concreteComponent, (XSDTypeDefinition) td);
command.execute();
XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
}
} catch (Exception e) {
} finally {
endRecording();
}
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDImpl method findTypesDerivedFrom.
/**
* Adapted from public static List findTypesDerivedFrom(XSDSchema schema,
* String namespace, String localName) in class XSDSchemaQueryTools found in
* org.eclipse.xsd plugin.
*
* Find typeDefinitions that derive from a given type.
*
* @param type
* the type derived from
* @return List of any XSDTypeDefinitions found
*/
public static List findTypesDerivedFrom(XSDTypeDefinition type) {
ArrayList typesDerivedFrom = new ArrayList();
if (type != null) {
XSDSchema schema = type.getSchema();
String localName = type.getName();
if ((null != schema) && (null != localName)) {
String namespace = schema.getTargetNamespace();
// A handy convenience method quickly gets all
// typeDefinitions within our schema; note that
// whether or not this returns types in included,
// imported, or redefined schemas is subject to change
List typedefs = schema.getTypeDefinitions();
for (Iterator iter = typedefs.iterator(); iter.hasNext(); ) {
XSDTypeDefinition typedef = (XSDTypeDefinition) iter.next();
if (typedef instanceof XSDComplexTypeDefinition) {
// of them match the requested one
if (isTypeDerivedFrom(typedef, namespace, localName)) {
// We found it, return the original one and continue
typesDerivedFrom.add(typedef);
continue;
}
}
}
}
}
return typesDerivedFrom;
}
Aggregations