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;
}
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);
}
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);
}
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()));
}
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()));
}
Aggregations