use of org.eclipse.xsd.XSDNamedComponent 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;
}
Aggregations