Beispiel #1
0
  @Override
  protected final void updateLayout(UmlChangeEvent mee) {
    super.updateLayout(mee);

    if (mee instanceof AttributeChangeEvent && mee.getPropertyName().equals("body")) {

      bodyTextFig.setText(mee.getNewValue().toString());
      calcBounds();
      setBounds(getBounds());
      damage();
    } else if (mee instanceof RemoveAssociationEvent
        && mee.getPropertyName().equals("annotatedElement")) {
      /* Remove the commentedge.
       * If there are more then one comment-edges between
       * the 2 objects, then delete them all. */
      Collection<FigEdgeNote> toRemove = new ArrayList<FigEdgeNote>();
      Collection c = getFigEdges(); // all connected edges
      for (Iterator i = c.iterator(); i.hasNext(); ) {
        FigEdgeNote fen = (FigEdgeNote) i.next();
        Object otherEnd = fen.getDestination(); // the UML object
        if (otherEnd == getOwner()) { // wrong end of the edge
          otherEnd = fen.getSource();
        }
        if (otherEnd == mee.getOldValue()) {
          toRemove.add(fen);
        }
      }

      for (FigEdgeNote fen : toRemove) {
        fen.removeFromDiagram();
      }
    }
  }
  /**
   * This is a template method called by the ArgoUML framework as the result of a change to a model
   * element. Do not call this method directly yourself.
   *
   * <p>Override this in any subclasses in order to redisplay the Fig due to change of any model
   * element that this Fig is listening to.
   *
   * <p>This method is guaranteed by the framework to be running on the Swing/AWT thread.
   *
   * @param event the UmlChangeEvent that caused the change
   */
  protected void updateLayout(UmlChangeEvent event) {
    assert event != null;

    if (notationProvider != null
        && (!"remove".equals(event.getPropertyName())
            || event.getSource() != getOwner())) { // not???
      this.setText(notationProvider.toString(getOwner(), getNotationSettings()));
      damage();
    }
  }