Search in sources :

Example 11 with XSDRedefine

use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.

the class XSDSimpleTypeDefinitionAdapter method getActions.

public String[] getActions(Object object) {
    List list = new ArrayList();
    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);
    Object schema = getEditorSchema();
    XSDTypeDefinition typeDefinition = getXSDTypeDefinition();
    if (typeDefinition.getSchema() == schema) {
        XSDConcreteComponent container = typeDefinition.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);
    return (String[]) list.toArray(new String[0]);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) EObject(org.eclipse.emf.ecore.EObject) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 12 with XSDRedefine

use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.

the class XSDAttributeGroupDefinitionAdapter method getActions.

public String[] getActions(Object object) {
    List list = new ArrayList();
    list.add(AddXSDAttributeDeclarationAction.ID);
    list.add(AddXSDAnyAttributeAction.ID);
    list.add(BaseSelectionAction.SEPARATOR_ID);
    list.add(DeleteAction.ID);
    list.add(BaseSelectionAction.SEPARATOR_ID);
    Object schema = getEditorSchema();
    XSDAttributeGroupDefinition attributeGroupDefinition = getXSDAttributeGroupDefinition();
    if (attributeGroupDefinition.getSchema() == schema) {
        XSDConcreteComponent container = attributeGroupDefinition.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);
    return (String[]) list.toArray(new String[0]);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 13 with XSDRedefine

use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.

the class XSDModelGroupDefinitionAdapter method getActions.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider#getActions(java.lang.Object)
   */
public String[] getActions(Object object) {
    Collection list = new ArrayList();
    XSDModelGroupDefinition modelGroupDefinition = getXSDModelGroupDefinition();
    boolean isModelGroupReference = modelGroupDefinition.isModelGroupDefinitionReference();
    if (!isModelGroupReference) {
        list.add(AddXSDElementAction.ID);
        list.add(AddXSDElementAction.REF_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);
    if (isModelGroupReference) {
        list.add(BaseSelectionAction.SEPARATOR_ID);
        list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY);
        list.add(SetMultiplicityAction.REQUIRED_ID);
        list.add(SetMultiplicityAction.ZERO_OR_ONE_ID);
        list.add(SetMultiplicityAction.ZERO_OR_MORE_ID);
        list.add(SetMultiplicityAction.ONE_OR_MORE_ID);
        list.add(BaseSelectionAction.SUBMENU_END_ID);
    }
    list.add(BaseSelectionAction.SEPARATOR_ID);
    Object schema = getEditorSchema();
    if (modelGroupDefinition.getSchema() == schema) {
        XSDConcreteComponent container = modelGroupDefinition.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);
    return (String[]) list.toArray(new String[0]);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) Collection(java.util.Collection) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 14 with XSDRedefine

use of org.eclipse.xsd.XSDRedefine 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)

Example 15 with XSDRedefine

use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.

the class XSDSchemaAdapter method notifyChanged.

public void notifyChanged(final Notification msg) {
    class CategoryNotification extends NotificationImpl {

        protected Object category;

        public CategoryNotification(Object category) {
            super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition());
            this.category = category;
        }

        public Object getNotifier() {
            return category;
        }

        public Object getFeature() {
            return msg.getFeature();
        }
    }
    if (children == null) {
        getChildren();
    }
    Object newValue = msg.getNewValue();
    Object oldValue = msg.getOldValue();
    // Bug 245480 - Deletion of Include, Import and Redefine is not reflected in the Outline view
    // We only want to refresh the Directives folder for any changes to XSDDirectives.  The first case covers
    // changes to one directive, whereas the missing case as reported in bug 245480 covers changes to a list
    // of directives.
    boolean updateDirectivesCategory = false;
    if (oldValue instanceof XSDSchemaDirective) {
        updateDirectivesCategory = true;
    } else if (oldValue instanceof Collection) {
        Iterator iterator = ((Collection) oldValue).iterator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();
            if (obj instanceof XSDSchemaDirective) {
                // if we find at least one directive, then we should refresh the folder
                updateDirectivesCategory = true;
                break;
            }
        }
    }
    if (newValue instanceof XSDInclude || newValue instanceof XSDImport || newValue instanceof XSDRedefine || // handle the case for delete directive
    (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Contents() && updateDirectivesCategory) || // updates to the imports/includes
    msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_IncorporatedVersions()) {
        CategoryAdapter adapter = getCategory(CategoryAdapter.DIRECTIVES);
        Assert.isTrue(adapter != null);
        XSDSchema xsdSchema = adapter.getXSDSchema();
        adapter.setChildren(getDirectives(xsdSchema));
        adapter.setAllChildren(getDirectives(xsdSchema));
        notifyListeners(new CategoryNotification(adapter), adapter.getText());
        return;
    } else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ElementDeclarations()) {
        CategoryAdapter adapter = getCategory(CategoryAdapter.ELEMENTS);
        Assert.isTrue(adapter != null);
        XSDSchema xsdSchema = adapter.getXSDSchema();
        adapter.setChildren(getGlobalElements(xsdSchema));
        adapter.setAllChildren(getGlobalElements(xsdSchema, true));
        notifyListeners(new CategoryNotification(adapter), adapter.getText());
        return;
    } else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeDeclarations() || msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeGroupDefinitions()) {
        CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES);
        Assert.isTrue(adapter != null);
        XSDSchema xsdSchema = adapter.getXSDSchema();
        adapter.setChildren(getAttributeList(xsdSchema));
        adapter.setAllChildren(getAttributeList(xsdSchema, true));
        notifyListeners(new CategoryNotification(adapter), adapter.getText());
        return;
    } else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_TypeDefinitions()) {
        CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES);
        Assert.isTrue(adapter != null);
        XSDSchema xsdSchema = adapter.getXSDSchema();
        List types = getComplexTypes(xsdSchema);
        types.addAll(getSimpleTypes(xsdSchema));
        adapter.setChildren(types);
        adapter.setAllChildren(getTypes(xsdSchema, true));
        notifyListeners(new CategoryNotification(adapter), adapter.getText());
        return;
    } else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ModelGroupDefinitions()) {
        CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS);
        Assert.isTrue(adapter != null);
        XSDSchema xsdSchema = adapter.getXSDSchema();
        adapter.setChildren(getGroups(xsdSchema));
        adapter.setAllChildren(getGroups(xsdSchema, true));
        notifyListeners(new CategoryNotification(adapter), adapter.getText());
        return;
    } else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) {
        return;
    } else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_SchemaLocation()) {
        notifyListeners(msg, null);
        return;
    }
    types = null;
    getTypes();
    super.notifyChanged(msg);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) NotificationImpl(org.eclipse.emf.common.notify.impl.NotificationImpl) XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) Iterator(java.util.Iterator) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) XSDImport(org.eclipse.xsd.XSDImport) XSDInclude(org.eclipse.xsd.XSDInclude) XSDSchema(org.eclipse.xsd.XSDSchema)

Aggregations

XSDRedefine (org.eclipse.xsd.XSDRedefine)20 XSDSchema (org.eclipse.xsd.XSDSchema)11 ArrayList (java.util.ArrayList)8 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)8 List (java.util.List)7 EObject (org.eclipse.emf.ecore.EObject)6 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)6 XSDInclude (org.eclipse.xsd.XSDInclude)6 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)6 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)5 Iterator (java.util.Iterator)4 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)4 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)4 IFile (org.eclipse.core.resources.IFile)3 EList (org.eclipse.emf.common.util.EList)3 IEditorInput (org.eclipse.ui.IEditorInput)3 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)3 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)3 XSDImport (org.eclipse.xsd.XSDImport)3 XSDSchemaDirective (org.eclipse.xsd.XSDSchemaDirective)3