]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/MenuAction.java
Salome HOME
Modifications to respect PMD rules.
[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 = ApplicationSettings.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                         _item = menu.getSelection();
38                         if (_item == null) {
39                                 _item = "none";
40                         }
41                 } else { // Selection of another menu item
42                         menu.selects(_item);
43                 }
44                 return _item;
45         }
46
47         // ==============================================================================================================================
48         // Getters and setters
49         // ==============================================================================================================================
50
51         /**
52          * Get selected menu item.
53          * @return the selected menu item
54          */
55         public String getItem() {
56                 return _item;
57         }
58
59         /**
60          * Get current menu name. 
61          * @return the menu name
62          */
63         public String getMenu() {
64                 return _menu;
65         }
66
67         /**
68          * Set current menu name.
69          * @param name the menu name
70          */
71         public void setMenu(final String name) {
72                 this._menu = name;
73         }
74
75         /**
76          * Set the selected menu item.
77          * @param item the selected item
78          */
79         public void setItem(final String item) {
80                 this._item = item;
81         }
82 }