示例#1
0
文件: FigComment.java 项目: kopl/misc
  @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();
      }
    }
  }
示例#2
0
文件: FigComment.java 项目: kopl/misc
 private void updateBody() {
   if (getOwner() != null) {
     String body = (String) Model.getFacade().getBody(getOwner());
     if (body != null) {
       bodyTextFig.setText(body);
     }
   }
 }
 /** Updates the discriminator text. Called if the model is changed and on construction time. */
 public void updateDiscriminatorText() {
   Object me = getOwner(); // MGeneralization
   if (me == null) {
     return;
   }
   String disc = (String) Model.getFacade().getDiscriminator(me);
   if (disc == null) {
     disc = "";
   }
   discriminator.setText(disc);
 }
  /** generate the notation for the modelelement and stuff it into the text Fig */
  protected void updateNameText() {

    if (getOwner() == null) {
      return;
    }
    if (notationProviderName != null) {
      String nameStr = notationProviderName.toString();
      nameFig.setText(nameStr);
      calcBounds();
      setBounds(getBounds());
    }
  }
  public FigShallowHistoryState() {
    _bigPort = new FigCircle(x, y, width, height, Color.cyan, Color.cyan);
    _head = new FigCircle(x, y, width, height, Color.black, Color.white);
    _name = new FigText(x + 5, y + 5, width - 10, height - 10);
    _name.setText("H");
    _name.setTextColor(Color.black);
    _name.setFilled(false);
    _name.setLineWidth(0);

    // add Figs to the FigNode in back-to-front order
    addFig(_bigPort);
    addFig(_head);
    addFig(_name);

    setBlinkPorts(false); // make port invisble unless mouse enters
    Rectangle r = getBounds();
  }
 /**
  * This method is called after the user finishes editing a text field that is in the
  * FigEdgeModelElement. Determine which field and update the model. This class handles the name,
  * subclasses should override to handle other text elements.
  *
  * @param ft the text Fig that has been edited
  */
 protected void textEdited(FigText ft) {
   if (ft == nameFig) {
     if (getOwner() == null) return;
     ft.setText(notationProviderName.parse(ft.getText()));
   }
 }
 /**
  * This method is called when the user doubleclicked on the text field, and starts editing.
  * Subclasses should overrule this field to e.g. supply help to the user about the used format.
  *
  * <p>It is also possible to alter the text to be edited already here, e.g. by adding the
  * stereotype in front of the name, but that seems not user-friendly.
  *
  * @param ft the FigText that will be edited and contains the start-text
  */
 protected void textEditStarted(FigText ft) {
   if (ft == getNameFig()) {
     showHelp(notationProviderName.getParsingHelp());
     ft.setText(notationProviderName.toString());
   }
 }