Search in sources :

Example 1 with XSDDerivationMethod

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;
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) XSDDerivationMethod(org.eclipse.xsd.XSDDerivationMethod) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1 XSDDerivationMethod (org.eclipse.xsd.XSDDerivationMethod)1 XSDRedefine (org.eclipse.xsd.XSDRedefine)1 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)1