[no bug] Prevent recursive model group references
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.java
index 8e0596d..7fa85ea 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.java
@@ -61,11 +61,19 @@
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
particle.setContent(def);
List list = parent.getSchema().getModelGroupDefinitions();
- if (list.size() > 0)
+ int length = list.size();
+ if (length > 1)
{
- def.setResolvedModelGroupDefinition((XSDModelGroupDefinition) list.get(0));
+ for (int i = 0; i < length; i++)
+ {
+ XSDModelGroupDefinition gr = (XSDModelGroupDefinition) list.get(i);
+ if (gr.getModelGroup() != parent)
+ {
+ def.setResolvedModelGroupDefinition(gr);
+ }
+ }
}
- else
+ else if (length <= 1)
{
XSDModelGroupDefinition newGroupDef = createXSDModelGroupDefinition();
def.setResolvedModelGroupDefinition(newGroupDef);
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java
index 4e2a055..fd989a1 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java
@@ -32,6 +32,7 @@
import org.eclipse.wst.xsd.ui.internal.common.util.Messages;
import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds;
import org.eclipse.wst.xsd.ui.internal.util.TypesHelper;
+import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDModelGroupDefinition;
import org.eclipse.xsd.XSDNamedComponent;
import org.eclipse.xsd.util.XSDConstants;
@@ -220,6 +221,20 @@
TypesHelper helper = new TypesHelper(xsdSchema);
List items = new ArrayList();
items = helper.getModelGroups();
+ if (input instanceof XSDModelGroupDefinition)
+ {
+ XSDModelGroupDefinition group = (XSDModelGroupDefinition) input;
+ XSDConcreteComponent parent = group.getContainer();
+ while (parent != null)
+ {
+ if (parent instanceof XSDModelGroupDefinition)
+ {
+ items.remove(((XSDModelGroupDefinition)parent).getQName());
+ break;
+ }
+ parent = parent.getContainer();
+ }
+ }
items.add(0, ""); //$NON-NLS-1$
componentNameCombo.setItems((String [])items.toArray(new String[0]));
}