/**
   * Add a new class diagram for a package to the project.
   *
   * @param ns The namespace to contain the diagram. If null, the root model will be used.
   * @param name The fully qualified name of the package, which is used to generate the diagram name
   *     from.
   */
  public void addClassDiagram(Object ns, String name) {
    Project p = ProjectManager.getManager().getCurrentProject();

    ArgoDiagram d =
        DiagramFactory.getInstance()
            .createDiagram(UMLClassDiagram.class, ns == null ? p.getRoot() : ns, null);

    try {
      d.setName(getDiagramName(name));
    } catch (PropertyVetoException pve) {
      LOG.error("Failed to set diagram name.", pve);
    }
    p.addMember(d);
    setCurrentDiagram(d);
  }
 /*
  * @see org.argouml.uml.diagram.ui.UMLDiagram#propertyChange(java.beans.PropertyChangeEvent)
  */
 @Override
 public void propertyChange(PropertyChangeEvent evt) {
   if ((evt.getSource() == theStateMachine)
       && (evt instanceof DeleteInstanceEvent)
       && "remove".equals(evt.getPropertyName())) {
     Model.getPump()
         .removeModelEventListener(this, theStateMachine, new String[] {"remove", "namespace"});
     if (getProject() != null) {
       getProject().moveToTrash(this);
     } else {
       DiagramFactory.getInstance().removeDiagram(this);
     }
   }
   if (evt.getSource() == theStateMachine && "namespace".equals(evt.getPropertyName())) {
     Object newNamespace = evt.getNewValue();
     if (newNamespace != null // this in case we are being deleted
         && getNamespace() != newNamespace) {
       /* The namespace of the statemachine is changed! */
       setNamespace(newNamespace);
       ((UMLMutableGraphSupport) getGraphModel()).setHomeModel(newNamespace);
     }
   }
 }