public void run() {
    ArrayList<DiagramElement> list = new ArrayList<DiagramElement>();

    if (element != null) {
      addToModel(element);
      ProjectBrowser.frame.getDiagramManager().updateOLEDFromInclusion(element);
    }

    if (addToDiagram && diagramElement != null) {
      addToDiagram(diagramElement, redo);
      ModelHelper.addMapping(element, ((ClassElement) diagramElement));
      list.add(diagramElement);
    }

    DiagramEditor d = ((DiagramEditor) notification);
    // notify
    if (d != null) {
      d.notifyChange(
          (List<DiagramElement>) list,
          ChangeType.ELEMENTS_ADDED,
          redo ? NotificationType.REDO : NotificationType.DO);
      UndoableEditEvent event = new UndoableEditEvent(((DiagramEditor) d), this);
      for (UndoableEditListener l : ((DiagramEditor) d).editListeners)
        l.undoableEditHappened(event);
    }
  }
 public AddNodeCommand(
     DiagramNotification editorNotification,
     CompositeElement parent,
     RefOntoUML.Element element,
     double x,
     double y,
     UmlProject project,
     RefOntoUML.Element eContainer) {
   this.parent = parent;
   this.project = project;
   this.notification = editorNotification;
   if (notification == null) this.addToDiagram = false;
   else this.addToDiagram = true;
   this.element = element;
   this.eContainer = eContainer;
   this.diagramElement =
       ModelHelper.getDiagramElementByEditor(element, (DiagramEditor) notification);
   if (this.diagramElement == null) {
     if (element instanceof RefOntoUML.Class
         || element instanceof RefOntoUML.Association
         || element instanceof RefOntoUML.DataType
         || element instanceof RefOntoUML.Generalization) {
       if (notification != null)
         this.diagramElement =
             ((DiagramEditor) this.notification)
                 .getCreationHandler()
                 .createNode((RefOntoUML.Type) element, eContainer);
     }
   }
   absx = x;
   absy = y;
 }
  private void myPostInit() {
    modelDataTypes = new HashMap<String, DataType>();
    List<DataType> dataTypes = ModelHelper.getModelDataTypes(diagramManager.getCurrentProject());
    for (DataType item : dataTypes) {
      modelDataTypes.put(item.getName(), item);
    }

    TableColumn typeColumn = table.getColumnModel().getColumn(1);
    typeColumn.setCellEditor(createEditor(modelDataTypes.keySet().toArray()));

    TableColumn typeColumn2 = table.getColumnModel().getColumn(2);
    typeColumn2.setCellEditor(createEditor(new String[] {"1", "0..1", "0..*", "1..*"}));

    table.setSurrendersFocusOnKeystroke(true);

    if (element instanceof DataType) {
      DataType dataType = (DataType) element;
      for (Property attribute : dataType.getAttribute()) {
        attributesTableModel.addEntry(attribute);
      }
    } else {
      Class umlclass = (Class) element;
      for (Property attribute : umlclass.getAttribute()) {
        attributesTableModel.addEntry(attribute);
      }
    }
  }
  @Override
  public void undo() {
    super.undo();

    if (element != null) {
      //			System.out.println("Undoing = "+element);
      project.getEditingDomain().getCommandStack().undo();
      ProjectBrowser.frame.getDiagramManager().updateOLEDFromDeletion(element);
    }

    if (addToDiagram && diagramElement != null) {
      parent.removeChild(diagramElement);
      ModelHelper.removeMapping(diagramElement);
    }

    if (notification != null) {
      List<DiagramElement> elements = new ArrayList<DiagramElement>();
      elements.add(diagramElement);
      notification.notifyChange(elements, ChangeType.ELEMENTS_ADDED, NotificationType.UNDO);
    }
  }