Exemplo n.º 1
0
  // reloads the element on all open panels and adds it to the custom element panel if not already
  // there.
  private void updateElement(Entity element) {

    //		if a new element has been created add it to current diagram
    if (this.originalElement == null) {
      DiagramHandler current = null;
      DrawPanel c = Umlet.getInstance().getGUI().getCurrentDiagram();
      if (c == null) {
        Umlet.getInstance().doNew();
        current = Umlet.getInstance().getGUI().getCurrentDiagram().getHandler();
      } else current = c.getHandler();

      Vector<Entity> ents = current.getDrawPanel().getAllEntities();
      // set location for element
      int x = 10, y = 10;
      for (Entity e : ents) {
        if (e.getY() + e.getHeight() + 10 > y) y = e.getY() + e.getHeight() + 10;
      }

      Rectangle bounds = new Rectangle(x, y, element.getWidth(), element.getHeight());
      this.addElementToDiagram(element, current, true, bounds, element.getState());
    } else { // replace edited element (and ONLY edited element)
      this.originalElement.getHandler().getDrawPanel().remove(this.originalElement);
      this.addElementToDiagram(
          element,
          this.originalElement.getHandler(),
          true,
          this.originalElement.getBounds(),
          this.originalElement.getState());
    }
  }
Exemplo n.º 2
0
 public boolean closeEntity() {
   if (this.changed) {
     /*          int ch=JOptionPane.showOptionDialog(Umlet.getInstance().getGUI(),"Save changes?","CustomElement",JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE,null, null, null);
     if (ch==JOptionPane.YES_OPTION)
         this.saveEntity();
     else if (ch==JOptionPane.CANCEL_OPTION)
         return false;
     else
      this.setChanged(false);*/
     this.setChanged(false);
   }
   this.stop();
   this.preview.closePreview();
   this.preview.getDrawPanel().getSelector().deselectAll();
   DrawPanel dia = Umlet.getInstance().getGUI().getCurrentDiagram();
   if (dia != null) dia.getSelector().updateSelectorInformation();
   else Umlet.getInstance().setPropertyPanelToEntity(null);
   return true;
 }