use of org.eclipse.xsd.XSDDerivationMethod in project webtools.sourceediting by eclipse.
the class XSDComplexTypeDefinitionAdapter method getActions.
public String[] getActions(Object object) {
List list = new ArrayList();
Object schema = getEditorSchema();
XSDComplexTypeDefinition complexType = getXSDComplexTypeDefinition();
Object contentType = getContentType();
XSDDerivationMethod derivation = complexType.getDerivationMethod();
if (contentType instanceof XSDSimpleTypeDefinition) {
List fields = getFields();
boolean hasSimpleContentAttributes = false;
for (Iterator iterator = fields.iterator(); iterator.hasNext(); ) {
Object field = iterator.next();
// We have attributes, so we need to add the compartment for housing the attributes
if (field instanceof XSDAttributeDeclarationAdapter) {
hasSimpleContentAttributes = true;
break;
}
}
if (hasSimpleContentAttributes || XSDDerivationMethod.EXTENSION_LITERAL.equals(derivation)) {
list.add(AddXSDAttributeDeclarationAction.ID);
} else if (XSDDerivationMethod.RESTRICTION_LITERAL.equals(derivation)) {
list.add(AddXSDEnumerationFacetAction.ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(SetBaseTypeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(DeleteAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
} else {
list.add(AddXSDElementAction.ID);
list.add(AddXSDElementAction.REF_ID);
list.add(AddXSDAnyElementAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(AddXSDAttributeDeclarationAction.ID);
list.add(AddXSDAttributeDeclarationAction.REF_ID);
list.add(AddXSDAttributeGroupDefinitionAction.REF_ID);
list.add(AddXSDAnyAttributeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(AddXSDModelGroupAction.SEQUENCE_ID);
list.add(AddXSDModelGroupAction.CHOICE_ID);
list.add(AddXSDModelGroupAction.ALL_ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(DeleteAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(SetBaseTypeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
}
if (complexType.getSchema() == schema) {
XSDConcreteComponent container = complexType.getContainer();
if (container == schema || container instanceof XSDRedefine) {
list.add(SetInputToGraphView.ID);
}
} else {
list.add(OpenInNewEditor.ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(ShowPropertiesViewAction.ID);
String[] result = new String[list.size()];
list.toArray(result);
return result;
}
Aggregations