]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Salome HOME
Refactoring continues: UserService is created instead of UserDirectory. Database...
[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          * Serial version ID.
23          */
24         private static final long serialVersionUID = 4964740932426016171L;
25
26         // ==============================================================================================================================
27         // Action methods
28         // ==============================================================================================================================
29
30         public String doInitialize() {
31                 // -----------------------------
32                 ResourceBundle label = ResourceBundle.getBundle("labels",
33                                 ApplicationSettings.getCurrentLocale());
34                 ResourceBundle custom = ResourceBundle.getBundle("som",
35                                 ApplicationSettings.getCurrentLocale());
36                 SimpleDateFormat datstring = new SimpleDateFormat(
37                                 custom.getString("date.format")); // Locale date display format
38                 Step step;
39
40                 mystudy = getOpenStudy();
41                 step = mystudy.getSelectedStep();
42                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
43                 lasdate = datstring.format(myscenario.getLastModificationDate());
44                 subject = label.getString("label.study") + " " + mystudy.getTitle();
45
46                 return SUCCESS;
47         }
48
49         public String doCheckin() {
50                 Step step;
51
52                 mystudy = getOpenStudy();
53                 selection = mystudy.getSelection();
54                 step = mystudy.getSelectedStep();
55                 myscenario = (Scenario) step.getOwner(); // The selected step belong to a scenario
56
57                 getScenarioService().checkin(myscenario);
58
59                 mystudy.getMenu().refreshGivenStepItem(
60                                 getProjectElementService().getFirstStep(myscenario)); // For updating the scenario icon
61                 return SUCCESS;
62         }
63
64         // ==============================================================================================================================
65         // Getters
66         // ==============================================================================================================================
67
68         public User getAuthor() {
69                 // ------------------------
70                 if (myscenario.isCheckedout())
71                         return myscenario.getUser();
72                 else
73                         return myscenario.getAuthor();
74         }
75
76         public String getLastModificationDate() {
77                 // ----------------------------------------
78                 return lasdate;
79         }
80
81         public StepRights getSelectedStep() {
82                 // ------------------------------------
83                 return mystudy.getSelectedStepRights(); // Forget about the step as only step enabling is tested
84         }
85
86         public String getSubject() {
87                 // ---------------------------
88                 return subject;
89         }
90
91         public String getTitle() {
92                 // -------------------------
93                 return myscenario.getTitle();
94         }
95
96         public boolean isCheckedout() {
97                 // ------------------------------
98                 return myscenario.isCheckedout();
99         }
100
101         /**
102          * Get the scenarioService.
103          * 
104          * @return the scenarioService
105          */
106         public ScenarioService getScenarioService() {
107                 return _scenarioService;
108         }
109
110         /**
111          * Set the scenarioService.
112          * 
113          * @param scenarioService
114          *            the scenarioService to set
115          */
116         public void setScenarioService(ScenarioService scenarioService) {
117                 _scenarioService = scenarioService;
118         }
119
120         /**
121          * Get the projectElementService.
122          * 
123          * @return the projectElementService
124          */
125         public ProjectElementService getProjectElementService() {
126                 return _projectElementService;
127         }
128
129         /**
130          * Set the projectElementService.
131          * 
132          * @param projectElementService
133          *            the projectElementService to set
134          */
135         public void setProjectElementService(
136                         ProjectElementService projectElementService) {
137                 _projectElementService = projectElementService;
138         }
139 }