/*
   * @see org.argouml.uml.diagram.static_structure.ui.FigClassifierBox#buildAddMenu()
   */
  @Override
  protected ArgoJMenu buildAddMenu() {
    ArgoJMenu addMenu = super.buildAddMenu();

    Action addEnumerationLiteral = new ActionAddEnumerationLiteral();
    addEnumerationLiteral.setEnabled(isSingleTarget());
    addMenu.add(addEnumerationLiteral);
    return addMenu;
  }
Example #2
0
  /**
   * Build a collection of menu items relevant for a right-click popup menu on a Class.
   *
   * @param me a mouse event
   * @return a collection of menu items
   * @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(java.awt.event.MouseEvent)
   */
  public Vector getPopUpActions(MouseEvent me) {
    Vector popUpActions = super.getPopUpActions(me);

    // Add...
    ArgoJMenu addMenu = new ArgoJMenu("menu.popup.add");
    addMenu.add(TargetManager.getInstance().getAddAttributeAction());
    addMenu.add(TargetManager.getInstance().getAddOperationAction());
    addMenu.add(new ActionAddNote());
    addMenu.add(ActionEdgesDisplay.getShowEdges());
    addMenu.add(ActionEdgesDisplay.getHideEdges());
    popUpActions.insertElementAt(addMenu, popUpActions.size() - getPopupAddOffset());

    // Show ...
    ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
    Iterator i = ActionCompartmentDisplay.getActions().iterator();
    while (i.hasNext()) {
      showMenu.add((Action) i.next());
    }
    popUpActions.insertElementAt(showMenu, popUpActions.size() - getPopupAddOffset());

    // Modifiers ...
    popUpActions.insertElementAt(
        buildModifierPopUp(ABSTRACT | LEAF | ROOT | ACTIVE),
        popUpActions.size() - getPopupAddOffset());

    // Visibility ...
    popUpActions.insertElementAt(buildVisibilityPopUp(), popUpActions.size() - getPopupAddOffset());

    return popUpActions;
  }
  /** @see org.tigris.gef.ui.PopupGenerator#getPopUpActions(java.awt.event.MouseEvent) */
  public Vector getPopUpActions(MouseEvent me) {
    Vector popUpActions = super.getPopUpActions(me);

    // TODO: Remove this line after 0.20.
    // This is a hack that removes the ordering menu according to issue 3645
    popUpActions.remove(0);

    // popupAddOffset should be equal to the number of items added here:
    popUpActions.addElement(new JSeparator());
    popupAddOffset = 1;
    if (removeFromDiagram) {
      popUpActions.addElement(ProjectBrowser.getInstance().getRemoveFromDiagramAction());
      popupAddOffset++;
    }
    popUpActions.addElement(new ActionDeleteModelElements());
    popupAddOffset++;

    /* Check if multiple items are selected: */
    boolean ms = TargetManager.getInstance().getTargets().size() > 1;
    if (!ms) {
      // #if defined(COGNITIVE)
      // @#$LPS-COGNITIVE:GranularityType:Statement
      // @#$LPS-COGNITIVE:Localization:NestedStatement
      ToDoList list = Designer.theDesigner().getToDoList();
      Vector items = (Vector) list.elementsForOffender(getOwner()).clone();
      if (items != null && items.size() > 0) {
        ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques");
        ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY());
        if (itemUnderMouse != null) {
          critiques.add(new ActionGoToCritique(itemUnderMouse));
          critiques.addSeparator();
        }
        int size = items.size();
        for (int i = 0; i < size; i++) {
          ToDoItem item = (ToDoItem) items.elementAt(i);
          if (item == itemUnderMouse) continue;
          critiques.add(new ActionGoToCritique(item));
        }
        popUpActions.insertElementAt(new JSeparator(), 0);
        popUpActions.insertElementAt(critiques, 0);
      }
    }
    // #endif

    // Add stereotypes submenu
    Action[] stereoActions = getApplyStereotypeActions();
    if (stereoActions != null) {
      popUpActions.insertElementAt(new JSeparator(), 0);
      ArgoJMenu stereotypes = new ArgoJMenu("menu.popup.apply-stereotypes");
      for (int i = 0; i < stereoActions.length; ++i) {
        stereotypes.addCheckItem(stereoActions[i]);
      }
      popUpActions.insertElementAt(stereotypes, 0);
    }
    return popUpActions;
  }