Ejemplo n.º 1
0
  protected void removeFromDiagramImpl() {
    Object o = getOwner();
    if (o != null) {
      removeElementListener(o);
    }
    ArgoEventPump.removeListener(this);

    Iterator it = getPathItemFigs().iterator();
    while (it.hasNext()) {
      Fig fig = (Fig) it.next();
      fig.removeFromDiagram();
    }

    /* TODO: MVW: Why the next action?
     * Deleting a fig from 1 diagram should not influence others!
     * */
    // GEF does not take into account the multiple diagrams we have
    // therefore we loop through our diagrams and delete each and every
    // occurence on our own
    it = ProjectManager.getManager().getCurrentProject().getDiagrams().iterator();
    while (it.hasNext()) {
      ArgoDiagram diagram = (ArgoDiagram) it.next();
      diagram.damage();
    }

    /* TODO: MVW: Should we not call damage()
     * for diagrams AFTER the next step? */
    super.removeFromDiagram();
  }
 /** @see javax.swing.Action#isEnabled() */
 public boolean isEnabled() {
   Object target = TargetManager.getInstance().getTarget();
   ArgoDiagram dia = ProjectManager.getManager().getCurrentProject().getActiveDiagram();
   if (dia == null) return false;
   MutableGraphModel gm = (MutableGraphModel) dia.getGraphModel();
   return gm.canAddNode(target);
 }
Ejemplo n.º 3
0
  /**
   * selects a diagram without affecting the gui.
   *
   * @param diagram the diagram
   */
  public void setCurrentDiagram(ArgoDiagram diagram) {

    if (diagram == null) {
      throw new RuntimeException("you can't select a null diagram");
    }

    currentGM = (ClassDiagramGraphModel) diagram.getGraphModel();
    currentLayer = diagram.getLayer();
    currentDiagram = diagram;

    markDiagramAsModified(diagram);
  }
Ejemplo n.º 4
0
  /**
   * 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);
  }
Ejemplo n.º 5
0
  /**
   * Check if a given package has a representation in the current diagram.
   *
   * @param p The package to lookup in the current diagram.
   * @return true if this package has a figure in the current diagram, false otherwise.
   */
  public boolean isInDiagram(Object p) {

    if (currentDiagram == null) {
      return false;
    } else {
      return currentDiagram.getNodes().contains(p);
    }
  }