use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class XSDCommonUIUtils method getAnonymousSimpleType.
public static XSDSimpleTypeDefinition getAnonymousSimpleType(XSDFeature input, XSDSimpleTypeDefinition xsdSimpleTypeDefinition) {
XSDSimpleTypeDefinition anonymousSimpleType = null;
XSDTypeDefinition localType = null;
if (input instanceof XSDElementDeclaration) {
localType = ((XSDElementDeclaration) input).getAnonymousTypeDefinition();
} else if (input instanceof XSDAttributeDeclaration) {
localType = ((XSDAttributeDeclaration) input).getAnonymousTypeDefinition();
}
if (localType instanceof XSDSimpleTypeDefinition) {
anonymousSimpleType = (XSDSimpleTypeDefinition) localType;
}
return anonymousSimpleType;
}
use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class RenameComponentAction method canEnable.
protected boolean canEnable(XSDConcreteComponent selectedObject) {
selectedComponent = null;
if (selectedObject instanceof XSDNamedComponent) {
selectedComponent = (XSDNamedComponent) selectedObject;
// if it's element reference, then this action is not appropriate
if (selectedComponent instanceof XSDElementDeclaration) {
XSDElementDeclaration element = (XSDElementDeclaration) selectedComponent;
if (element.isElementDeclarationReference()) {
selectedComponent = null;
}
}
if (selectedComponent instanceof XSDTypeDefinition) {
XSDTypeDefinition type = (XSDTypeDefinition) selectedComponent;
XSDConcreteComponent parent = type.getContainer();
if (parent instanceof XSDElementDeclaration) {
XSDElementDeclaration element = (XSDElementDeclaration) parent;
if (element.getAnonymousTypeDefinition().equals(type)) {
selectedComponent = null;
}
} else if (parent instanceof XSDAttributeDeclaration) {
XSDAttributeDeclaration element = (XSDAttributeDeclaration) parent;
if (element.getAnonymousTypeDefinition().equals(type)) {
selectedComponent = null;
}
}
}
}
return canRun();
}
use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class RenameEnablementTester method canEnable.
protected boolean canEnable(XSDConcreteComponent selectedObject, XSDSchema schema) {
if (selectedObject == null) {
return false;
}
XSDNamedComponent selectedComponent = null;
boolean enable = false;
XSDSchema selectedComponentSchema = null;
selectedComponentSchema = selectedObject.getSchema();
if (selectedComponentSchema != null && selectedComponentSchema == schema) {
enable = true;
}
if (enable && selectedObject instanceof XSDNamedComponent) {
selectedComponent = (XSDNamedComponent) selectedObject;
if (selectedComponent instanceof XSDElementDeclaration) {
XSDElementDeclaration element = (XSDElementDeclaration) selectedComponent;
if (element.isElementDeclarationReference()) {
return false;
}
if (!element.isGlobal()) {
return false;
}
}
if (selectedComponent instanceof XSDTypeDefinition) {
XSDTypeDefinition type = (XSDTypeDefinition) selectedComponent;
XSDConcreteComponent parent = type.getContainer();
if (parent instanceof XSDElementDeclaration) {
XSDElementDeclaration element = (XSDElementDeclaration) parent;
if (element.getAnonymousTypeDefinition().equals(type)) {
return false;
}
} else if (parent instanceof XSDAttributeDeclaration) {
XSDAttributeDeclaration element = (XSDAttributeDeclaration) parent;
if (element.getAnonymousTypeDefinition().equals(type)) {
return false;
}
}
}
return true;
}
return false;
}
use of org.eclipse.xsd.XSDAttributeDeclaration 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