use of org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter in project webtools.sourceediting by eclipse.
the class AddRedefinedComponentCommand method execute.
public void execute() {
Element element = redefine.getElement();
try {
beginRecording(element);
doExecute();
Object adapter = redefinableComponent.eAdapters().get(0);
if (adapter instanceof XSDComplexTypeDefinitionAdapter) {
((XSDComplexTypeDefinitionAdapter) adapter).updateDeletedMap(redefinableComponent.getName());
} else if (adapter instanceof XSDSimpleTypeDefinitionAdapter) {
((XSDSimpleTypeDefinitionAdapter) adapter).updateDeletedMap(redefinableComponent.getName());
} else if (adapter instanceof XSDAttributeGroupDefinitionAdapter) {
((XSDAttributeGroupDefinitionAdapter) adapter).updateDeletedMap(redefinableComponent.getName());
} else if (adapter instanceof XSDModelGroupDefinitionAdapter) {
((XSDModelGroupDefinitionAdapter) adapter).updateDeletedMap(redefinableComponent.getName());
}
redefine.getContents().add(addedXSDConcreteComponent);
formatChild(addedXSDConcreteComponent.getElement());
} finally {
endRecording();
}
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter 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.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter in project webtools.sourceediting by eclipse.
the class XSDGroupsForAnnotationEditPart method getModelChildren.
protected List getModelChildren() {
List xsdModelGroupList = new ArrayList();
List adapterList = new ArrayList();
IStructure structure = ((Annotation) getModel()).getOwner();
if (structure instanceof IComplexType) {
complexType = (IComplexType) structure;
if (complexType instanceof XSDComplexTypeDefinitionAdapter) {
XSDComplexTypeDefinitionAdapter adapter = (XSDComplexTypeDefinitionAdapter) complexType;
xsdModelGroupList = adapter.getModelGroups();
}
for (Iterator i = xsdModelGroupList.iterator(); i.hasNext(); ) {
Object obj = i.next();
if (obj instanceof XSDModelGroup) {
adapterList.add(XSDAdapterFactory.getInstance().adapt((XSDModelGroup) obj));
} else if (obj instanceof XSDModelGroupDefinition) {
adapterList.add(XSDAdapterFactory.getInstance().adapt((XSDModelGroupDefinition) obj));
}
}
} else if (structure instanceof XSDModelGroupDefinitionAdapter) {
XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter) structure;
XSDModelGroup group = adapter.getXSDModelGroupDefinition().getModelGroup();
if (group != null) {
adapterList.add(XSDAdapterFactory.getInstance().adapt(group));
}
}
return adapterList;
}
use of org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter in project webtools.sourceediting by eclipse.
the class DeleteCommand method execute.
public void execute() {
XSDVisitor visitor = new XSDVisitor() {
public void visitElementDeclaration(org.eclipse.xsd.XSDElementDeclaration element) {
if (element.getTypeDefinition() == target) {
// $NON-NLS-1$
XSDSimpleTypeDefinition type = target.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
element.setTypeDefinition(type);
}
super.visitElementDeclaration(element);
}
};
XSDConcreteComponent parent = target.getContainer();
XSDSchema schema = target.getSchema();
try {
beginRecording(parent.getElement());
boolean doCleanup = false;
if (target instanceof XSDModelGroup || target instanceof XSDElementDeclaration || target instanceof XSDModelGroupDefinition) {
doCleanup = true;
if (parent instanceof XSDParticle) {
if (parent.getContainer() instanceof XSDModelGroup) {
XSDModelGroup modelGroup = (XSDModelGroup) ((XSDParticle) parent).getContainer();
modelGroup.getContents().remove(parent);
} else if (parent.getContainer() instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) parent.getContainer();
complexType.setContent(null);
}
} else if (parent instanceof XSDSchema) {
visitor.visitSchema(target.getSchema());
((XSDSchema) parent).getContents().remove(target);
} else if (parent instanceof XSDRedefine) {
Object adapter = target.eAdapters().get(0);
if (adapter instanceof XSDModelGroupDefinitionAdapter) {
((XSDModelGroupDefinitionAdapter) adapter).setReadOnly(true);
((XSDModelGroupDefinitionAdapter) adapter).setChangeReadOnlyField(true);
}
((XSDRedefine) parent).getContents().remove(target);
}
} else if (target instanceof XSDAttributeDeclaration) {
doCleanup = true;
if (parent instanceof XSDAttributeUse) {
EObject obj = parent.eContainer();
XSDComplexTypeDefinition complexType = null;
while (obj != null) {
if (obj instanceof XSDComplexTypeDefinition) {
complexType = (XSDComplexTypeDefinition) obj;
break;
}
obj = obj.eContainer();
}
if (complexType != null) {
complexType.getAttributeContents().remove(parent);
}
if (parent.getContainer() instanceof XSDAttributeGroupDefinition) {
XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) parent.getContainer();
attrGroup.getContents().remove(parent);
}
} else if (parent instanceof XSDSchema) {
visitor.visitSchema(target.getSchema());
((XSDSchema) parent).getContents().remove(target);
}
} else if (target instanceof XSDAttributeGroupDefinition && parent instanceof XSDComplexTypeDefinition) {
doCleanup = true;
((XSDComplexTypeDefinition) parent).getAttributeContents().remove(target);
} else if (target instanceof XSDEnumerationFacet) {
XSDEnumerationFacet enumerationFacet = (XSDEnumerationFacet) target;
enumerationFacet.getSimpleTypeDefinition().getFacetContents().remove(enumerationFacet);
} else if (target instanceof XSDWildcard) {
if (parent instanceof XSDParticle) {
if (parent.getContainer() instanceof XSDModelGroup) {
XSDModelGroup modelGroup = (XSDModelGroup) ((XSDParticle) parent).getContainer();
modelGroup.getContents().remove(parent);
}
} else if (parent instanceof XSDComplexTypeDefinition) {
((XSDComplexTypeDefinition) parent).setAttributeWildcardContent(null);
} else if (parent instanceof XSDAttributeGroupDefinition) {
((XSDAttributeGroupDefinition) parent).setAttributeWildcardContent(null);
}
} else if (target instanceof XSDTypeDefinition && parent instanceof XSDElementDeclaration) {
doCleanup = true;
((XSDElementDeclaration) parent).setTypeDefinition(target.resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
} else {
if (parent instanceof XSDSchema) {
doCleanup = true;
visitor.visitSchema(target.getSchema());
((XSDSchema) parent).getContents().remove(target);
} else if (parent instanceof XSDRedefine) {
doCleanup = false;
EList contents = ((XSDRedefine) parent).getContents();
Object adapter = target.eAdapters().get(0);
if (adapter instanceof XSDComplexTypeDefinitionAdapter) {
((XSDComplexTypeDefinitionAdapter) adapter).setReadOnly(true);
((XSDComplexTypeDefinitionAdapter) adapter).setChangeReadOnlyField(true);
} else if (adapter instanceof XSDSimpleTypeDefinitionAdapter) {
((XSDSimpleTypeDefinitionAdapter) adapter).setReadOnly(true);
((XSDSimpleTypeDefinitionAdapter) adapter).setChangeReadOnlyField(true);
} else if (adapter instanceof XSDAttributeGroupDefinitionAdapter) {
((XSDAttributeGroupDefinitionAdapter) adapter).setReadOnly(true);
((XSDAttributeGroupDefinitionAdapter) adapter).setChangeReadOnlyField(true);
}
contents.remove(target);
}
}
if (doCleanup)
XSDDirectivesManager.removeUnusedXSDImports(schema);
} finally {
endRecording();
}
}
Aggregations