Salome HOME
Show URLs for previous versions of the document's files.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / EditStudyAction.java
1 package org.splat.simer;
2
3 import org.splat.dal.bo.som.Study;
4
5 public class EditStudyAction extends DisplayStudyStepAction {
6
7         /**
8          * Serial version ID.
9          */
10         private static final long serialVersionUID = -4865668290514118396L;
11
12         /**
13          * Possible operations on a study.
14          */
15         private enum Execute {
16                 /**
17                  * Publish a study.
18                  */
19                 publish,
20                 /**
21                  * Make published study private.
22                  */
23                 protect,
24                 /**
25                  * Promote a study to the next state.
26                  */
27                 promote,
28                 /**
29                  * Demote a study from In-Draft or In-Check to In-Work.
30                  */
31                 demote
32         }
33
34         // =========================================================================
35         // Action methods
36         // =========================================================================
37
38         /**
39          * Perform operation on the selected study.
40          * 
41          * @return SUCCESS
42          */
43         public String doEdition() {
44                 _openStudy = getOpenStudy();
45
46                 Execute todo = Execute.valueOf(_action);
47                 Study study = _openStudy.getStudyObject();
48
49                 if (todo == Execute.publish) {
50                         getStudyService().moveToPublic(study);
51                 } else if (todo == Execute.protect) {
52                         getStudyService().moveToPrivate(study);
53                 } else if (todo == Execute.promote) {
54                         getStudyService().promote(study);
55                 } else if (todo == Execute.demote) {
56                         getStudyService().demote(study);
57                 }
58 //              _openStudy.getMenu().refreshSelectedItem(); // Updates the menu icon, in case of other documents in approved state
59                 _openStudy.getPopup().setContext("study", _openStudy.getStudyRights()); // The context has changed
60
61                 setMenu();
62
63                 _myindex = null;
64                 _selection = _openStudy.getSelection(); // actually, value doesn't matter, it just has to be not null
65                 doOpen();
66                 return SUCCESS;
67         }
68
69         /**
70          * Mark study as reference functionality.
71          * 
72          * @return SUCCESS
73          */
74         public String doMarkAsReference() {
75
76                 _openStudy = getOpenStudy();
77                 Study study = _openStudy.getStudyObject();
78
79                 getStudyService().markStudyAsReference(study);
80
81                 _myindex = null;
82                 _selection = _openStudy.getSelection(); // actually, value doesn't matter, it just has to be not null
83                 doOpen();
84                 return SUCCESS;
85         }
86
87         /**
88          * Remove study as reference functionality.
89          * 
90          * @return SUCCESS
91          */
92         public String doRemoveAsReference() {
93
94                 _openStudy = getOpenStudy();
95                 Study study = _openStudy.getStudyObject();
96
97                 getStudyService().removeStudyAsReference(study);
98
99                 _myindex = null;
100                 _selection = _openStudy.getSelection(); // actually, value doesn't matter, it just has to be not null
101                 doOpen();
102                 return SUCCESS;
103         }
104 }