コード例 #1
0
  /** @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;
  }