[80871] An element's simple type is not selectable from the graph view so the properties aren't accessible
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java
index 47773c2..ac31566 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/AddModelGroupAction.java
@@ -11,6 +11,7 @@
 package org.eclipse.wst.xsd.ui.internal.actions;
 
 import org.eclipse.jface.action.Action;
+import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
 import org.eclipse.wst.xsd.ui.internal.commands.AddModelGroupCommand;
 import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
 import org.eclipse.xsd.XSDCompositor;
@@ -20,6 +21,7 @@
 public class AddModelGroupAction extends Action
 {
    protected AddModelGroupCommand command;
+   protected XSDConcreteComponent parent;
   
    public static String getLabel(XSDCompositor compositor)
    {
@@ -41,11 +43,15 @@
    public AddModelGroupAction(XSDConcreteComponent parent, XSDCompositor compositor)
    {
      command = new AddModelGroupCommand(parent, compositor);
+     this.parent = parent;
      setText(getLabel(compositor));     
    }   
    
    public void run()
    {
+     DocumentImpl doc = (DocumentImpl) parent.getElement().getOwnerDocument();
+     doc.getModel().beginRecording(this, getText());
      command.run();
+     doc.getModel().endRecording(this);
    }
 }
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java
index 73428f2..f5518e2 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/commands/AddModelGroupCommand.java
@@ -17,6 +17,7 @@
 import org.eclipse.xsd.XSDFactory;
 import org.eclipse.xsd.XSDModelGroup;
 import org.eclipse.xsd.XSDParticle;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
 
 public class AddModelGroupCommand extends AbstractCommand
 {
@@ -42,8 +43,14 @@
           ed.setTypeDefinition(null);
           XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
           ed.setAnonymousTypeDefinition(td);
+          owner = ed.getTypeDefinition();
         }
-        owner = ed.getTypeDefinition();
+        else
+        {
+          XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
+          ed.setAnonymousTypeDefinition(td);
+          owner = td;        
+        }
       }        
       else if (ed.getAnonymousTypeDefinition() == null)
       {
@@ -54,7 +61,13 @@
       else if (ed.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition)
       {
         owner = ed.getAnonymousTypeDefinition();
-      }  
+      }
+      else if (ed.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition)
+      {
+        XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
+        ed.setAnonymousTypeDefinition(td);
+        owner = td;        
+      }
     }
     else if (parent instanceof XSDModelGroup)
     {
@@ -69,6 +82,7 @@
       XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); 
       XSDModelGroup modelGroup = createModelGroup();
       particle.setContent(modelGroup);
+
       XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition)owner;
       ctd.setContent(particle);
       formatChild(parent.getElement());
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java
index a5335ec..015f6c2 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/XSDGraphViewer.java
@@ -410,10 +410,22 @@
           topLevelSchema = (XSDSchema)currentInput;
         }                 
       }
-      else if (selectedComponent instanceof XSDSchemaDirective || selectedComponent instanceof XSDSimpleTypeDefinition || selectedComponent instanceof XSDNotationDeclaration)          
+      else if (selectedComponent instanceof XSDSchemaDirective || selectedComponent instanceof XSDNotationDeclaration)          
       {
         topLevelSchema = selectedComponent.getSchema();
       }
+      else if (selectedComponent instanceof XSDSimpleTypeDefinition)
+      {
+        XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)selectedComponent;
+        EditPart editPart = componentViewer.getEditPart(componentViewer.getRootEditPart(), st);
+        if (editPart == null)
+        {
+          if (st.getContainer() == editor.getXSDSchema())
+          {
+            topLevelSchema = selectedComponent.getSchema();
+          }
+        }
+      }
       
       if (topLevelSchema != null)
       {
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java
index ae8540c..36950bc 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/CategoryEditPart.java
@@ -23,8 +23,10 @@
 import org.eclipse.draw2d.geometry.Dimension;
 import org.eclipse.draw2d.geometry.Rectangle;
 import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
 import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
 import org.eclipse.wst.xsd.ui.internal.graph.GraphicsConstants;
+import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
 import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerFigure;
 import org.eclipse.wst.xsd.ui.internal.graph.figures.ContainerLayout;
 import org.eclipse.wst.xsd.ui.internal.graph.figures.FillLayout;
@@ -36,7 +38,8 @@
 {
   protected ScrollPane scrollpane;
   protected Label label;
-
+  protected ContainerFigure outerPane, r;
+  protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
 
   public int getType()
   {
@@ -45,11 +48,11 @@
 
   protected IFigure createFigure()
   {           
-    ContainerFigure outerPane = new ContainerFigure();    
+    outerPane = new ContainerFigure();    
     outerPane.setBorder(new RoundedLineBorder(1, 6));
     outerPane.setForegroundColor(categoryBorderColor);
 
-    ContainerFigure r = new ContainerFigure();  
+    r = new ContainerFigure();  
     r.setOutline(false);
     r.setMinimumSize(new Dimension(0, 0));
     r.setFill(true);
@@ -135,6 +138,14 @@
         
   public void refreshVisuals()
   {
+    outerPane.setBorder(new RoundedLineBorder(isSelected ? ColorConstants.black : categoryBorderColor, isSelected ? 1 : 1, 6));
+    outerPane.repaint();
+// Uncomment this for coloured titles
+//    r.setBackgroundColor(isSelected ? ColorConstants.blue : GraphicsConstants.elementBackgroundColor);
+//    label.setForegroundColor(isSelected ? ColorConstants.white : ColorConstants.black);
+//    r.repaint();
+//    outerPane.setForegroundColor(isSelected ? ColorConstants.black : elementBorderColor);
+    
     Category category = (Category)getModel();
     // temp hack --- added empty space to make the min width of groups bigger  
     label.setText("  " + category.getName() + "                                                    ");
@@ -161,4 +172,11 @@
     editPart.setParent(this);
     return editPart;
   }
+  
+  protected void createEditPolicies()
+  { 
+    selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
+    installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);   
+  }  
+
 }
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java
index b52d893..974d97b 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/ElementDeclarationEditPart.java
@@ -15,6 +15,7 @@
 import java.util.List;
 
 import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.Label;
 import org.eclipse.draw2d.LineBorder;
 import org.eclipse.draw2d.MarginBorder;
@@ -22,6 +23,7 @@
 import org.eclipse.draw2d.geometry.Point;
 import org.eclipse.gef.EditPart;
 import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
 import org.eclipse.gef.Request;
 import org.eclipse.gef.RequestConstants;
 import org.eclipse.gef.requests.LocationRequest;
@@ -82,7 +84,7 @@
     }      
     return depth <= 3;
   }
-                      
+                     
   protected GraphNodeFigure createGraphNodeFigure()
   {
     ExpandableGraphNodeFigure figure = new ExpandableGraphNodeFigure();
@@ -137,7 +139,20 @@
   }                                            
                     
   protected List getModelChildren() 
-  {                                                                    
+  {
+    XSDTypeDefinition typeDef = getXSDElementDeclaration().getTypeDefinition();
+    
+    // Special case simple type.   Need to add it to the list as well
+    List list = new ArrayList();
+    if (typeDef instanceof XSDSimpleTypeDefinition)
+    {
+      list.add((XSDSimpleTypeDefinition)typeDef);
+      if (getExpandableGraphNodeFigure().isExpanded())
+      {
+        list.addAll(getModelChildrenHelper());
+      }
+      return list;
+    }
     return getExpandableGraphNodeFigure().isExpanded() ? getModelChildrenHelper() : Collections.EMPTY_LIST;
   }  
                        
@@ -157,13 +172,8 @@
   {
     String iconName = null;
     XSDTypeDefinition td = getXSDElementDeclaration().getResolvedElementDeclaration().getTypeDefinition();
-    if (td instanceof XSDSimpleTypeDefinition)
-    {      
-      // TODO... we should probably show the overlay form of this icon in the case that its a
-      // restriction, list or union
-      iconName = "icons/XSDSimpleType.gif";
-    }  
-    else if (td instanceof XSDComplexTypeDefinition)
+
+    if (td instanceof XSDComplexTypeDefinition)
     {
       XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition)td;
       if (complexTypeDefinition.getAttributeUses().size() > 0)
@@ -182,14 +192,14 @@
                   getXSDElementDeclaration().getName();
 
     label.setText(text);
-
-                                                            
+    
     ContainerFigure rectangle = graphNodeFigure.getOutlinedArea();
     if (XSDGraphUtil.isEditable(getXSDElementDeclaration()))
     {
       rectangle.setBorder(new LineBorder(isSelected ? ColorConstants.black : elementBorderColor, 2));
       rectangle.setBackgroundColor(elementBackgroundColor);
       rectangle.setForegroundColor(elementBorderColor);
+      
       graphNodeFigure.getInnerContentArea().setForegroundColor(ColorConstants.black);
       if (XSDGraphUtil.isEditable(getXSDElementDeclaration().getResolvedElementDeclaration()))
       { 
@@ -269,7 +279,7 @@
  
                                                                         
   public void performRequest(Request request)
-  {  
+  {
   	if (request.getType() == RequestConstants.REQ_DIRECT_EDIT ||
         request.getType() == RequestConstants.REQ_OPEN)
     {                                        
@@ -288,11 +298,11 @@
           else if (hitTest(typeValueLabel, p))
           {                             
    		      performDirectEditForTypeValueLabel();
-          } 
+          }
         }
       }
     }
-  }   
+  } 
          
   private void performDirectEditForTypeValueLabel()
   {
@@ -376,4 +386,34 @@
   {
     return isContentIconLabelSelected;
   }
+
+  protected void addChildVisual(EditPart childEditPart, int index)
+  {
+    IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
+    if (childEditPart instanceof SimpleTypeDefinitionEditPart)
+    {
+      graphNodeFigure.getIconArea().add(child, index+ 1);
+      SpacingFigure spacingFigure = new SpacingFigure();
+      graphNodeFigure.getIconArea().add(spacingFigure, index+1);
+    }
+    else
+    {
+      getContentPane().add(child, index);
+    }
+  }
+  
+  protected void removeChildVisual(EditPart childEditPart)
+  {
+    IFigure child = ((GraphicalEditPart)childEditPart).getFigure();
+    if (childEditPart instanceof SimpleTypeDefinitionEditPart)
+    {
+      graphNodeFigure.getIconArea().remove(child);
+    }    
+    else
+    {
+      super.removeChildVisual(childEditPart);
+    }
+  }
+
+
 }
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java
new file mode 100644
index 0000000..ef78b30
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/SimpleTypeDefinitionEditPart.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.graph.editparts;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.ImageFigure;
+import org.eclipse.draw2d.Label;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.wst.xsd.ui.internal.XSDEditorPlugin;
+import org.eclipse.wst.xsd.ui.internal.graph.editpolicies.SelectionHandlesEditPolicyImpl;
+import org.eclipse.wst.xsd.ui.internal.graph.figures.RoundedLineBorder;
+
+public class SimpleTypeDefinitionEditPart extends BaseEditPart //GraphNodeEditPart
+{
+  protected Label label;
+  protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
+
+  ImageFigure figure;
+  Color color;
+  
+  protected IFigure createFigure()
+  {
+    String iconName = "icons/XSDSimpleType.gif";
+    Image image = XSDEditorPlugin.getXSDImage(iconName);
+  
+    figure = new ImageFigure(image);
+    RoundedLineBorder lb = new RoundedLineBorder(1, 6);
+    figure.setOpaque(true);
+    figure.setBorder(lb);
+    figure.setBackgroundColor(ColorConstants.white);
+    figure.setForegroundColor(elementBorderColor);
+    
+    return figure;
+  }
+
+  protected void refreshVisuals()
+  {
+    figure.setBorder(new RoundedLineBorder(isSelected ? ColorConstants.black : elementBorderColor, 1, 6));
+    figure.repaint();
+  }
+  
+  protected boolean isConnectedEditPart()
+  {
+    return false;
+  }
+
+  protected void createEditPolicies()
+  { 
+    selectionHandlesEditPolicy = new SelectionHandlesEditPolicyImpl();
+    installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, selectionHandlesEditPolicy);   
+  }  
+
+  public void deactivate() 
+  {
+    super.deactivate();
+    if (color != null)
+    {
+      color.dispose();
+    }
+  }   
+}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java
index f6c5de3..5d6ed1e 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/graph/editparts/XSDEditPartFactory.java
@@ -19,6 +19,7 @@
 import org.eclipse.xsd.XSDModelGroup;
 import org.eclipse.xsd.XSDModelGroupDefinition;
 import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDSimpleTypeDefinition;
 import org.eclipse.xsd.XSDWildcard;
 
 
@@ -81,6 +82,10 @@
     {                                  
       editPart = new WildcardEditPart();
     }
+    else if (model instanceof XSDSimpleTypeDefinition)
+    {
+      editPart = new SimpleTypeDefinitionEditPart();
+    }
 
     if (editPart != null)   
     {
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java
index 6af7a8f..e911823 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/properties/section/TypesDialog.java
@@ -615,6 +615,10 @@
     else if (xsdType.equals(XSDConstants.SIMPLETYPE_ELEMENT_TAG))
     {
       childNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.SIMPLETYPE_ELEMENT_TAG);
+      
+      Element restrictionNode = element.getOwnerDocument().createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + XSDConstants.RESTRICTION_ELEMENT_TAG);
+      restrictionNode.setAttribute(XSDConstants.BASE_ATTRIBUTE, prefix + "string");
+      childNode.appendChild(restrictionNode);      
     }
     if (childNode != null)
     {