]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman/src/org/splat/simer/SimulationContextFacade.java
Salome HOME
Siman codebase is refactored. Spring beans are introduced in the context.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / SimulationContextFacade.java
1 package org.splat.simer;
2
3 import java.util.Iterator;
4 import java.util.ResourceBundle;
5
6 import org.splat.dal.bo.som.ProgressState;
7 import org.splat.service.technical.ProjectSettingsService;
8 import org.splat.dal.bo.som.SimulationContext;
9 import org.splat.dal.bo.som.SimulationContextType;
10 import org.splat.wapp.PopupMenu;
11
12
13 public class SimulationContextFacade {
14
15     private SimulationContext  my;
16     private String             name;
17     private int                step;
18     private ProgressState      state;
19     private PopupMenu          popup;
20         private ProjectSettingsService _projectSettingsService;
21
22 //  ==============================================================================================================================
23 //  Constructor
24 //  ==============================================================================================================================
25
26     public SimulationContextFacade (SimulationContext represented) {
27 //  --------------------------------------------------------------
28       my    = represented;
29       popup = ApplicationSettings.getPopupMenu("scontext");
30
31       SimulationContextType type = my.getType();
32       for (Iterator<ProjectSettingsService.Step> i=getProjectSettings().getAllSteps().iterator(); i.hasNext(); ) {
33         ProjectSettingsService.Step   next = i.next();
34         if (!type.isAttachedTo(next)) continue;
35         step = next.getNumber();
36         break;
37       }
38       state = my.getProgressState();                     // inCHECK or APPROVED
39       name  = type.getName();
40       if (type.isApproved()) {
41         name = ResourceBundle.getBundle("som", ApplicationSettings.getCurrentLocale()).getString("type.context." + name);
42       } else {
43         state  = ProgressState.inDRAFT;
44       }
45     }
46
47 //  ==============================================================================================================================
48 //  Getters
49 //  ==============================================================================================================================
50
51     public String getEditIcon () {
52 //  ----------------------------
53       return "icon.ed" + state + ".png";
54     }
55     public String getIndex () {
56 //  -------------------------
57       return String.valueOf(my.getIndex());
58     }
59     public PopupMenu getPopup () {
60 //  ----------------------------
61       popup.setContext("scontext", this);     // Cannot be done at construction because pop-ups are shared
62       return popup;
63     }
64     public String getStateIcon () {
65 //  -----------------------------
66       return "icon." + state + ".png";
67     }
68     public String getStepNumber () {
69 //  ------------------------------
70       return String.valueOf(step);
71     }
72     public String getTypeName () {
73 //  ----------------------------
74       return  name;
75     }
76     public String getValue () {
77 //  -------------------------
78       return  my.getValue();
79     }
80
81     public boolean isApproved () {
82 //  ----------------------------
83       return (state == ProgressState.APPROVED);
84     }
85     public boolean isEditable () {
86 //  ----------------------------
87       return !my.isShared();
88     }
89     public boolean isFacadeOf (SimulationContext represented) {
90 //  ---------------------------------------------------------
91       return  my.equals(represented);
92     }
93     /**
94      * Get project settings.
95          * @return Project settings service
96          */
97         private ProjectSettingsService getProjectSettings() {
98                 return _projectSettingsService;
99         }
100
101         /**
102          * Set project settings service.
103          * @param projectSettingsService project settings service
104          */
105         public void setProjectSettings(
106                         ProjectSettingsService projectSettingsService) {
107                 _projectSettingsService = projectSettingsService;
108         }
109 }