use of org.eclipse.xsd.XSDAttributeUse in project webtools.sourceediting by eclipse.
the class XSDAdapterFactory method createAdapter.
public Adapter createAdapter(Notifier target) {
XSDSwitch xsdSwitch = new XSDSwitch() {
public Object caseXSDSchemaDirective(XSDSchemaDirective object) {
return new XSDSchemaDirectiveAdapter();
}
public Object caseXSDWildcard(XSDWildcard object) {
return new XSDWildcardAdapter();
}
public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition object) {
return new XSDAttributeGroupDefinitionAdapter();
}
public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object) {
return new XSDModelGroupDefinitionAdapter();
}
public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration object) {
return new XSDAttributeDeclarationAdapter();
}
public Object caseXSDAttributeUse(XSDAttributeUse object) {
return new XSDAttributeUseAdapter();
}
public Object caseXSDParticle(XSDParticle object) {
return new XSDParticleAdapter();
}
public Object caseXSDElementDeclaration(XSDElementDeclaration object) {
return new XSDElementDeclarationAdapter();
}
public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object) {
return new XSDSimpleTypeDefinitionAdapter();
}
public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object) {
//
if (// $NON-NLS-1$
"anyType".equals(object.getName())) {
return new XSDAnyTypeDefinitionAdapter();
} else {
return new XSDComplexTypeDefinitionAdapter();
}
}
public Object caseXSDModelGroup(XSDModelGroup object) {
return new XSDModelGroupAdapter();
}
public Object caseXSDSchema(XSDSchema object) {
return new XSDSchemaAdapter();
}
public Object caseXSDEnumerationFacet(XSDEnumerationFacet object) {
return new XSDEnumerationFacetAdapter();
}
public Object caseXSDRedefine(XSDRedefine object) {
return new XSDRedefineAdapter();
}
};
Object o = xsdSwitch.doSwitch((EObject) target);
Adapter result = null;
if (o instanceof Adapter) {
result = (Adapter) o;
} else {
// Thread.dumpStack();
}
return result;
}
use of org.eclipse.xsd.XSDAttributeUse in project webtools.sourceediting by eclipse.
the class XSDCommonUIUtils method getChildAttributes.
public static List getChildAttributes(XSDComplexTypeDefinition ct) {
EList attrContents = ct.getAttributeContents();
List attrs = new ArrayList();
for (int i = 0; i < attrContents.size(); i++) {
Object next = attrContents.get(i);
if (next instanceof XSDAttributeUse) {
attrs.add(((XSDAttributeUse) next).getContent().getResolvedAttributeDeclaration());
} else if (next instanceof XSDAttributeGroupDefinition) {
// XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) next;
}
}
return attrs;
}
use of org.eclipse.xsd.XSDAttributeUse in project tmdm-studio-se by Talend.
the class XSDDeleteAttributeAction method doAction.
@Override
protected IStatus doAction() {
try {
XSDAttributeUse attriUse = attributeUse;
XSDAttributeDeclaration attriDec = attributeDeclaration;
if (attriUse == null || attriDec == null) {
ISelection selection = page.getTreeViewer().getSelection();
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
if (firstElement instanceof XSDAttributeUse) {
attriUse = (XSDAttributeUse) firstElement;
} else if (firstElement instanceof XSDAttributeDeclaration) {
attriDec = (XSDAttributeDeclaration) firstElement;
}
}
if (attriUse != null) {
if (attriUse.getContainer() == null) {
return Status.CANCEL_STATUS;
}
XSDConcreteComponent container = attriUse.getContainer();
if (container instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition cType = (XSDComplexTypeDefinition) container;
cType.getAttributeUses().remove(attriUse);
cType.getAttributeContents().remove(attriUse);
cType.updateElement();
}
} else if (attriDec != null) {
if (attriDec.getContainer() == null) {
return Status.CANCEL_STATUS;
}
XSDConcreteComponent container = attriDec.getContainer();
if (container instanceof XSDSchema) {
XSDSchema xsdschema = (XSDSchema) container;
xsdschema.getContents().remove(attriDec);
}
}
schema.update();
attributeUse = null;
attributeDeclaration = null;
page.refresh();
page.markDirtyWithoutCommit();
} catch (Exception e) {
log.error(e.getMessage(), e);
MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDDeleteElementAction_ErrorMsg, e.getLocalizedMessage()));
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
Aggregations