]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/EditScenarioPropertiesAction.java
Salome HOME
SIMAN Eclipse workspace first version
[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.hibernate.Session;
7 import org.hibernate.Transaction;
8 import org.splat.kernel.User;
9 import org.splat.som.Database;
10 import org.splat.som.Scenario;
11 import org.splat.som.Step;
12 import org.splat.som.StepRights;
13
14
15 public class EditScenarioPropertiesAction extends DisplayStudyStepAction {
16
17     private Scenario  myscenario;
18     private String    lasdate;
19     private String    subject;
20
21         private static final long serialVersionUID = 4964740932426016171L;
22
23 //  ==============================================================================================================================
24 //  Action methods
25 //  ==============================================================================================================================
26
27         public String doInitialize () {
28 //  -----------------------------
29       ResourceBundle   label     = ResourceBundle.getBundle("labels", ApplicationSettings.getCurrentLocale());
30       ResourceBundle   custom    = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale());
31           SimpleDateFormat datstring = new SimpleDateFormat(custom.getString("date.format"));  // Locale date display format
32           Step             step;
33
34       mystudy    = getOpenStudy();
35       step       = mystudy.getSelectedStep();
36       myscenario = (Scenario)step.getOwner();   // The selected step belong to a scenario
37       lasdate    = datstring.format(myscenario.getLastModificationDate());
38       subject    = label.getString("label.study") + " " + mystudy.getTitle();
39
40       return SUCCESS;
41     }
42
43     public String doCheckin () {
44 //  --------------------------
45       Session      connex  = Database.getSession();
46       Transaction  transax = connex.beginTransaction();
47           Step         step;
48
49       mystudy    = getOpenStudy();
50       selection  = mystudy.getSelection();
51       step       = mystudy.getSelectedStep();
52       myscenario = (Scenario)step.getOwner();                              // The selected step belong to a scenario
53
54       myscenario.checkin();
55       transax.commit();
56
57       mystudy.getMenu().refreshGivenStepItem(myscenario.getFirstStep());   // For updating the scenario icon 
58       return SUCCESS;
59     }
60
61 //  ==============================================================================================================================
62 //  Getters
63 //  ==============================================================================================================================
64
65     public User getAuthor () {
66 //  ------------------------
67       if (myscenario.isCheckedout()) return myscenario.getUser();
68       else                           return myscenario.getAuthor();
69     }
70
71     public String getLastModificationDate () {
72 //  ----------------------------------------
73       return lasdate;
74     }
75
76     public StepRights getSelectedStep () {
77 //  ------------------------------------
78       return mystudy.getSelectedStepRights();                              // Forget about the step as only step enabling is tested
79     }
80
81     public String getSubject () {
82 //  ---------------------------
83       return subject;
84     }
85     public String getTitle () {
86 //  -------------------------
87       return myscenario.getTitle();
88     }
89
90     public boolean isCheckedout () {
91 //  ------------------------------
92       return myscenario.isCheckedout();
93     }
94 }