Search in sources :

Example 21 with XSDSchemaDirective

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

the class XSDSchemaDirectiveAdapter method getModel.

public IModel getModel() {
    XSDSchema object = ((XSDSchemaDirective) target).getSchema();
    Adapter adapter = XSDAdapterFactory.getInstance().adapt(object);
    return (IModel) adapter;
}
Also used : XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) Adapter(org.eclipse.emf.common.notify.Adapter) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 22 with XSDSchemaDirective

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

Example 23 with XSDSchemaDirective

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

the class XSDUnusedTests method testImport001RepeatRemovalOnce.

public void testImport001RepeatRemovalOnce() {
    XSDSchema schema = getXSDSchema(TC_ROOT_FOLDER + "/Simple/Test.xsd");
    importManager.performRemoval(schema);
    List list = importManager.getUnusedXSDDirectives();
    assertTrue(list.size() == 1);
    XSDSchemaDirective d1 = (XSDSchemaDirective) list.get(0);
    assertTrue("Import001.xsd".equals(d1.getSchemaLocation()));
    importManager.performRemoval(schema);
    list = importManager.getUnusedXSDDirectives();
    assertTrue(list.size() == 0);
}
Also used : XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) List(java.util.List) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 24 with XSDSchemaDirective

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

the class XSDUnusedTests method testImport002.

public void testImport002() {
    XSDSchema schema = getXSDSchema(TC_ROOT_FOLDER + "/Unused/test/Main001.xsd");
    importManager.performRemoval(schema);
    List list = importManager.getUnusedXSDDirectives();
    assertTrue(list.size() == 1);
    XSDSchemaDirective d1 = (XSDSchemaDirective) list.get(0);
    assertTrue("../Include1.xsd".equals(d1.getSchemaLocation()));
}
Also used : XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) List(java.util.List) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 25 with XSDSchemaDirective

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

the class XSDUnusedTests method testImport009.

public void testImport009() {
    XSDSchema schema = getXSDSchema(TC_ROOT_FOLDER + "/Unused/test/Main008.xsd");
    importManager.performRemoval(schema);
    List list = importManager.getUnusedXSDDirectives();
    assertTrue(list.size() == 2);
    XSDSchemaDirective d1 = (XSDSchemaDirective) list.get(0);
    assertTrue("../Import1.xsd".equals(d1.getSchemaLocation()));
    XSDSchemaDirective d2 = (XSDSchemaDirective) list.get(1);
    assertTrue("../Include2.xsd".equals(d2.getSchemaLocation()));
}
Also used : XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) List(java.util.List) XSDSchema(org.eclipse.xsd.XSDSchema)

Aggregations

XSDSchemaDirective (org.eclipse.xsd.XSDSchemaDirective)33 XSDSchema (org.eclipse.xsd.XSDSchema)28 List (java.util.List)24 Iterator (java.util.Iterator)5 XSDImport (org.eclipse.xsd.XSDImport)4 XSDRedefine (org.eclipse.xsd.XSDRedefine)4 EObject (org.eclipse.emf.ecore.EObject)3 ArrayList (java.util.ArrayList)2 Adapter (org.eclipse.emf.common.notify.Adapter)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 XSDSchemaDirectiveAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaDirectiveAdapter)2 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)2 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)2 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)2 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)2 XSDInclude (org.eclipse.xsd.XSDInclude)2 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)2 MissingJarsException (com.amalto.workbench.service.MissingJarsException)1 InaccessibleWSDLException (com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException)1 IOException (java.io.IOException)1