Salome HOME
Menus are improved
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditScenarioPropertiesAction.java
1 package org.splat.simer;
2
3 import java.text.SimpleDateFormat;
4 import java.util.ResourceBundle;
5
6 import org.splat.dal.bo.kernel.User;
7 import org.splat.dal.bo.som.Scenario;
8 import org.splat.service.ProjectElementService;
9 import org.splat.service.ScenarioService;
10 import org.splat.som.Step;
11 import org.splat.som.StepRights;
12
13 public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
14
15         private Scenario myscenario;
16         private String lasdate;
17         private String subject;
18         private ScenarioService _scenarioService;
19         private ProjectElementService _projectElementService;
20         
21         /**
22          * Value of the menu property. 
23          * It can be: none, create, open, study, knowledge, sysadmin, help.
24          */
25         private String _menuProperty;
26
27         /**
28          * Serial version ID.
29          */
30         private static final long serialVersionUID = 4964740932426016171L;
31
32         // ==============================================================================================================================
33         // Action methods
34         // ==============================================================================================================================
35
36         public String doInitialize() {
37                 // -----------------------------
38                 ResourceBundle label = ResourceBundle.getBundle("labels",
39                                 ApplicationSettings.getCurrentLocale());
40                 ResourceBundle custom = ResourceBundle.getBundle("som",
41                                 ApplicationSettings.getCurrentLocale());
42                 SimpleDateFormat datstring = new SimpleDateFormat(
43                                 custom.getString("date.format")); // Locale date display format
44                 Step step;
45
46                 mystudy = getOpenStudy();
47                 step = mystudy.getSelectedStep();
48                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
49                 lasdate = datstring.format(myscenario.getLastModificationDate());
50                 subject = label.getString("label.study") + " " + mystudy.getTitle();
51                 
52                 setMenuProperty("study");
53                 initializationScreenContext(_menuProperty);
54
55                 return SUCCESS;
56         }
57
58         public String doCheckin() {
59                 Step step;
60
61                 mystudy = getOpenStudy();
62                 selection = mystudy.getSelection();
63                 step = mystudy.getSelectedStep();
64                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
65
66                 getScenarioService().checkin(myscenario);
67
68                 mystudy.getMenu().refreshGivenStepItem(
69                                 getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
70                 
71                 setMenuProperty("study");
72                 initializationScreenContext(_menuProperty);
73                 
74                 return SUCCESS;
75         }
76
77         // ==============================================================================================================================
78         // Getters
79         // ==============================================================================================================================
80
81         public User getAuthor() {
82                 // ------------------------
83                 if (myscenario.isCheckedout())
84                         return myscenario.getUser();
85                 else
86                         return myscenario.getAuthor();
87         }
88
89         public String getLastModificationDate() {
90                 // ----------------------------------------
91                 return lasdate;
92         }
93
94         public StepRights getSelectedStep() {
95                 // ------------------------------------
96                 return mystudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
97         }
98
99         public String getSubject() {
100                 // ---------------------------
101                 return subject;
102         }
103
104         public String getTitle() {
105                 // -------------------------
106                 return myscenario.getTitle();
107         }
108
109         public boolean isCheckedout() {
110                 // ------------------------------
111                 return myscenario.isCheckedout();
112         }
113
114         /**
115          * Get the scenarioService.
116          * 
117          * @return the scenarioService
118          */
119         public ScenarioService getScenarioService() {
120                 return _scenarioService;
121         }
122
123         /**
124          * Set the scenarioService.
125          * 
126          * @param scenarioService
127          *            the scenarioService to set
128          */
129         public void setScenarioService(ScenarioService scenarioService) {
130                 _scenarioService = scenarioService;
131         }
132
133         /**
134          * Get the projectElementService.
135          * 
136          * @return the projectElementService
137          */
138         public ProjectElementService getProjectElementService() {
139                 return _projectElementService;
140         }
141
142         /**
143          * Set the projectElementService.
144          * 
145          * @param projectElementService
146          *            the projectElementService to set
147          */
148         public void setProjectElementService(
149                         ProjectElementService projectElementService) {
150                 _projectElementService = projectElementService;
151         }
152         
153         /**
154          * Get the menuProperty.
155          * @return the menuProperty
156          */
157         public String getMenuProperty() {
158                 return _menuProperty;
159         }
160
161         /**
162          * Set the menuProperty.
163          * @param menuProperty the menuProperty to set
164          */
165         public void setMenuProperty(String menuProperty) {
166                 this._menuProperty = menuProperty;
167         }
168 }