use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDRedefineAdapter 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();
if (XSDPackage.eINSTANCE.getXSDRedefine_Contents() == msg.getFeature()) {
if ((newValue instanceof XSDAttributeGroupDefinition) || oldValue instanceof XSDAttributeGroupDefinition) {
CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES);
Assert.isTrue(adapter != null);
List list = getCategoryChildren(CategoryAdapter.ATTRIBUTES);
adapter.setChildren(list);
adapter.setAllChildren(list);
if (adapter.getModel() instanceof XSDSchemaAdapter) {
XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
schemaAdapter.notifyChanged(msg);
}
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if ((newValue instanceof XSDComplexTypeDefinition || newValue instanceof XSDSimpleTypeDefinition) || (oldValue instanceof XSDComplexTypeDefinition || oldValue instanceof XSDSimpleTypeDefinition)) {
CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES);
Assert.isTrue(adapter != null);
List types = getCategoryChildren(CategoryAdapter.TYPES);
adapter.setChildren(types);
adapter.setAllChildren(types);
if (adapter.getModel() instanceof XSDSchemaAdapter) {
XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
schemaAdapter.notifyChanged(msg);
}
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (newValue instanceof XSDModelGroupDefinition || oldValue instanceof XSDModelGroupDefinition) {
CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS);
Assert.isTrue(adapter != null);
List list = getCategoryChildren(CategoryAdapter.GROUPS);
adapter.setChildren(list);
adapter.setAllChildren(list);
if (adapter.getModel() instanceof XSDSchemaAdapter) {
XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
schemaAdapter.notifyChanged(msg);
}
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) {
return;
}
}
super.notifyChanged(msg);
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDVisitor method visitParticleContent.
public void visitParticleContent(XSDParticleContent particleContent) {
if (particleContent instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition modelGroupDef = (XSDModelGroupDefinition) particleContent;
if (particleStack.contains(modelGroupDef)) {
return;
}
particleStack.push(modelGroupDef);
visitModelGroupDefinition(modelGroupDef);
particleStack.pop();
} else if (particleContent instanceof XSDModelGroup) {
visitModelGroup((XSDModelGroup) particleContent);
} else if (particleContent instanceof XSDElementDeclaration) {
visitElementDeclaration((XSDElementDeclaration) particleContent);
} else if (particleContent instanceof XSDWildcard) {
visitWildcard((XSDWildcard) particleContent);
}
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDVisitor method visitSchema.
public void visitSchema(XSDSchema schema) {
this.schema = schema;
for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
visitAttributeDeclaration(attr);
}
for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
visitTypeDefinition(type);
}
for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
visitElementDeclaration(element);
}
for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
visitIdentityConstraintDefinition(identityConstraint);
}
for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
visitModelGroupDefinition(modelGroup);
}
for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
visitAttributeGroupDefinition(attributeGroup);
}
for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
visitNotationDeclaration(element);
}
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDModelGroupAdapter method getChildren.
public ITreeElement[] getChildren() {
XSDModelGroup xsdModelGroup = getXSDModelGroup();
List list = new ArrayList();
for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) {
Object object = i.next();
XSDParticleContent particle = ((XSDParticle) object).getContent();
if (particle instanceof XSDElementDeclaration) {
list.add(particle);
} else if (particle instanceof XSDWildcard) {
list.add(particle);
} else if (particle instanceof XSDModelGroup) {
list.add(particle);
} else if (particle instanceof XSDModelGroupDefinition) {
// list.add(((XSDModelGroupDefinition)particle).getResolvedModelGroupDefinition());
list.add(particle);
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDVisitor method visitSchema.
public void visitSchema(XSDSchema schema) {
this.schema = schema;
for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
visitAttributeDeclaration(attr);
}
for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
visitTypeDefinition(type);
}
for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
visitElementDeclaration(element);
}
for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
visitIdentityConstraintDefinition(identityConstraint);
}
for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
visitModelGroupDefinition(modelGroup);
}
for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
visitAttributeGroupDefinition(attributeGroup);
}
for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
visitNotationDeclaration(element);
}
}
Aggregations