1 | protected ArgoJMenu buildShowPopUp() { | | 1 | /** |
2 | ArgoJMenu showMenu = super.buildShowPopUp(); | | 2 | * This method returns a Vector of one of these 4 types: |
3 | | | 3 | * AbstractAction, JMenu, JMenuItem, JSeparator. |
4 | Iterator i = ActionCompartmentDisplay.getActions().iterator(); | | 4 | * {@inheritDoc} |
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 | final List<Action> modulesActions = |
| | | 12 | ContextActionFactoryManager.getContextPopupActions(); |
| | | 13 | |
| | | 14 | for (Action a : modulesActions) { |
| | | 15 | if (a instanceof List) { |
| | | 16 | JMenu m = new JMenu(a); |
| | | 17 | popUpActions.add(m); |
| | | 18 | for (Action subAction : (List<Action>) a) { |
| | | 19 | m.add(subAction); |
| | | 20 | } |
| | | 21 | } else { |
| | | 22 | popUpActions.add(a); |
| | | 23 | } |
| | | 24 | } |
| | | 25 | |
| | | 26 | // Show ... |
| | | 27 | ArgoJMenu show = buildShowPopUp(); |
| | | 28 | if (show.getMenuComponentCount() > 0) { |
| | | 29 | popUpActions.add(show); |
| | | 30 | } |
| | | 31 | |
| | | 32 | // popupAddOffset should be equal to the number of items added here: |
| | | 33 | popUpActions.add(new JSeparator()); |
| | | 34 | popupAddOffset = 1; |
| | | 35 | if (removeFromDiagram) { |
| | | 36 | popUpActions.add( |
| | | 37 | ProjectActions.getInstance().getRemoveFromDiagramAction()); |
| | | 38 | popupAddOffset++; |
| | | 39 | } |
| | | 40 | |
| | | 41 | if (!isReadOnly()) { |
| | | 42 | popUpActions.add(new ActionDeleteModelElements()); |
| | | 43 | popupAddOffset++; |
| | | 44 | } |
| | | 45 | |
| | | 46 | /* Check if multiple items are selected: */ |
| | | 47 | if (TargetManager.getInstance().getTargets().size() == 1) { |
| | | 48 | |
| | | 49 | // TODO: Having Critics actions here introduces an unnecessary |
| | | 50 | // dependency on the Critics subsystem. Have it register its |
| | | 51 | // desired actions using an extension mechanism - tfm |
| | | 52 | ToDoList tdList = Designer.theDesigner().getToDoList(); |
| | | 53 | List<ToDoItem> items = tdList.elementListForOffender(getOwner()); |
| | | 54 | if (items != null && items.size() > 0) { |
| | | 55 | // TODO: This creates a dependency on the Critics subsystem. |
| | | 56 | // We need a generic way for modules (including our internal |
| | | 57 | // subsystems) to request addition of actions to the popup |
| | | 58 | // menu. - tfm 20080430 |
| | | 59 | ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques"); |
| | | 60 | ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY()); |
| | | 61 | if (itemUnderMouse != null) { |
| | | 62 | critiques.add(new ActionGoToCritique(itemUnderMouse)); |
| | | 63 | critiques.addSeparator(); |
| | | 64 | } |
| | | 65 | for (ToDoItem item : items) { |
| | | 66 | if (item != itemUnderMouse) { |
| | | 67 | critiques.add(new ActionGoToCritique(item)); |
| | | 68 | } |
| | | 69 | } |
| | | 70 | popUpActions.add(0, new JSeparator()); |
| | | 71 | popUpActions.add(0, critiques); |
| | | 72 | } |
| | | 73 | } |
| | | 74 | |
| | | 75 | // Add stereotypes submenu |
| | | 76 | Collection<Object> elements = new ArrayList<Object>(); |
| | | 77 | Object owner = getOwner(); |
| | | 78 | if (owner != null) { |
| | | 79 | elements.add(owner); |
| | | 80 | } |
| | | 81 | for (Object o : TargetManager.getInstance().getTargets()) { |
| | | 82 | Object element = null; |
| | | 83 | if (Model.getFacade().isAUMLElement(o)) { |
| | | 84 | element = o; |
| | | 85 | } else if (o instanceof Fig) { |
| | | 86 | element = ((Fig) o).getOwner(); |
| | | 87 | } |
| | | 88 | if (element != null && element != owner) { |
| | | 89 | elements.add(element); |
| | | 90 | } |
| | | 91 | } |
| | | 92 | final Action[] stereoActions = |
| | | 93 | StereotypeUtility.getApplyStereotypeActions(elements); |
| | | 94 | if (stereoActions != null) { |
| | | 95 | popUpActions.add(0, new JSeparator()); |
| | | 96 | final ArgoJMenu stereotypes = |
| | | 97 | new ArgoJMenu("menu.popup.apply-stereotypes"); |
| | | 98 | for (Action action : stereoActions) { |
| | | 99 | stereotypes.addCheckItem(action); |
| | | 100 | } |
| | | 101 | popUpActions.add(0, stereotypes); |
| | | 102 | } |
| | | 103 | |
| | | 104 | if (TargetManager.getInstance().getTargets().size() == 1) { |
| | | 105 | // add stereotype view submenu |
| | | 106 | ArgoJMenu stereotypesView = |
| | | 107 | new ArgoJMenu("menu.popup.stereotype-view"); |
| | | 108 | |
| | | 109 | // TODO: There are cyclic dependencies between ActionStereotypeView* |
| | | 110 | // and FigNodeModelElement. Register these actions opaquely since |
| | | 111 | // we don't what they are. - tfm |
| | | 112 | stereotypesView.addRadioItem(new ActionStereotypeViewTextual(this)); |
| | | 113 | stereotypesView.addRadioItem(new ActionStereotypeViewBigIcon(this)); |
| | | 114 | stereotypesView.addRadioItem( |
| | | 115 | new ActionStereotypeViewSmallIcon(this)); |
| | | 116 | |
| | | 117 | popUpActions.add(0, stereotypesView); |
| | | 118 | } |
| | | 119 | |
| | | 120 | return popUpActions; |
| | | 121 | } |