1 | protected ArgoJMenu buildShowPopUp() { | | 1 | /** |
2 | ArgoJMenu showMenu = super.buildShowPopUp(); | | 2 | * @param me the MouseEvent that triggered the popup menu request |
3 | | | 3 | * @return a Vector containing a combination of these 4 types: Action, |
4 | Iterator i = ActionCompartmentDisplay.getActions().iterator(); | | 4 | * JMenu, JMenuItem, JSeparator. |
5 | while (i.hasNext()) { | | 5 | */ |
6 | showMenu.add((Action) i.next()); | | 6 | @Override |
7 | } | | 7 | public Vector getPopUpActions(MouseEvent me) { |
8 | return showMenu; | | 8 | ActionList popUpActions = |
9 | } | | 9 | new ActionList(super.getPopUpActions(me), isReadOnly()); |
| | | 10 | |
| | | 11 | // Added this part to load the extra menu content |
| | | 12 | final List<Action> modulesActions = |
| | | 13 | ContextActionFactoryManager.getContextPopupActions(); |
| | | 14 | |
| | | 15 | for (Action a : modulesActions) { |
| | | 16 | if (a instanceof List) { |
| | | 17 | JMenu m = new JMenu((Action) a); |
| | | 18 | popUpActions.add(m); |
| | | 19 | for (Action subAction : (List<Action>) a) { |
| | | 20 | m.add(subAction); |
| | | 21 | } |
| | | 22 | } else { |
| | | 23 | popUpActions.add(a); |
| | | 24 | } |
| | | 25 | } |
| | | 26 | |
| | | 27 | // popupAddOffset should be equal to the number of items added here: |
| | | 28 | popUpActions.add(new JSeparator()); |
| | | 29 | popupAddOffset = 1; |
| | | 30 | if (removeFromDiagram) { |
| | | 31 | popUpActions.add( |
| | | 32 | ProjectActions.getInstance().getRemoveFromDiagramAction()); |
| | | 33 | popupAddOffset++; |
| | | 34 | } |
| | | 35 | popUpActions.add(new ActionDeleteModelElements()); |
| | | 36 | popupAddOffset++; |
| | | 37 | |
| | | 38 | if (TargetManager.getInstance().getTargets().size() == 1) { |
| | | 39 | ToDoList list = Designer.theDesigner().getToDoList(); |
| | | 40 | List<ToDoItem> items = list.elementListForOffender(getOwner()); |
| | | 41 | if (items != null && items.size() > 0) { |
| | | 42 | // TODO: This creates a dependency on the Critics subsystem. |
| | | 43 | // We need a generic way for modules (including our internal |
| | | 44 | // subsystems) to request addition of actions to the popup |
| | | 45 | // menu. - tfm 20080430 |
| | | 46 | ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques"); |
| | | 47 | ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY()); |
| | | 48 | if (itemUnderMouse != null) { |
| | | 49 | critiques.add(new ActionGoToCritique(itemUnderMouse)); |
| | | 50 | critiques.addSeparator(); |
| | | 51 | } |
| | | 52 | for (ToDoItem item : items) { |
| | | 53 | if (item == itemUnderMouse) { |
| | | 54 | continue; |
| | | 55 | } |
| | | 56 | critiques.add(new ActionGoToCritique(item)); |
| | | 57 | } |
| | | 58 | popUpActions.add(0, new JSeparator()); |
| | | 59 | popUpActions.add(0, critiques); |
| | | 60 | } |
| | | 61 | } |
| | | 62 | |
| | | 63 | // Add stereotypes submenu |
| | | 64 | Action[] stereoActions = getApplyStereotypeActions(); |
| | | 65 | if (stereoActions != null && stereoActions.length > 0) { |
| | | 66 | popUpActions.add(0, new JSeparator()); |
| | | 67 | ArgoJMenu stereotypes = new ArgoJMenu( |
| | | 68 | "menu.popup.apply-stereotypes"); |
| | | 69 | for (int i = 0; i < stereoActions.length; ++i) { |
| | | 70 | stereotypes.addCheckItem(stereoActions[i]); |
| | | 71 | } |
| | | 72 | popUpActions.add(0, stereotypes); |
| | | 73 | } |
| | | 74 | |
| | | 75 | return popUpActions; |
| | | 76 | } |