]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/MenuAction.java
Salome HOME
Fix for updating the left menu of the "Search knowledge" screen.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / MenuAction.java
1 package org.splat.simer;
2
3 import org.splat.wapp.SimpleMenu;
4
5 /**
6  * Menu selection action.
7  */
8 public class MenuAction extends Action {
9         /**
10          * Serial version ID.
11          */
12         private static final long serialVersionUID = 5904292225286579036L;
13
14         /**
15          * Current menu.
16          */
17         private String _menu;
18         /**
19          * Selected item.
20          */
21         private String _item;
22
23         // ==============================================================================================================================
24         // Action methods
25         // ==============================================================================================================================
26
27         /**
28          * Activate the menu and select the menu item.
29          * 
30          * @return the selected menu item
31          */
32         public String doSelectItem() {
33                 SimpleMenu menu = getApplicationSettings().getMenu(_menu);
34
35                 if (_item == null) { // Switch back to the menu, keeping the last selection
36                         getSession().put("menu.open", menu); // Activates the menu
37                         if (menu != null) {
38                                 _item = menu.getSelection();
39                                 if (_item == null) { // Select default menu item if nothing has been selected
40                                         _item = menu.getDefaultSelection();
41                                         menu.selects(_item);
42                                 }
43                         }
44                 } else { // Selection of another menu item
45                         getSession().put("menu.open", menu); // Activates the menu
46                         if (menu != null) {
47                                 menu.selects(_item);
48                         }
49                 }
50                 return _item;
51         }
52
53         // ==============================================================================================================================
54         // Getters and setters
55         // ==============================================================================================================================
56
57         /**
58          * Get selected menu item.
59          * @return the selected menu item
60          */
61         public String getItem() {
62                 return _item;
63         }
64
65         /**
66          * Get current menu name. 
67          * @return the menu name
68          */
69         public String getMenu() {
70                 return _menu;
71         }
72
73         /**
74          * Set current menu name.
75          * @param name the menu name
76          */
77         public void setMenu(final String name) {
78                 this._menu = name;
79         }
80
81         /**
82          * Set the selected menu item.
83          * @param item the selected item
84          */
85         public void setItem(final String item) {
86                 this._item = item;
87         }
88 }