1 package org.splat.simer;
3 import java.util.Iterator;
5 import java.util.ResourceBundle;
7 import org.splat.dal.bo.som.ProgressState;
8 import org.splat.dal.bo.som.SimulationContext;
9 import org.splat.dal.bo.som.SimulationContextType;
10 import org.splat.service.technical.ProjectSettingsService;
11 import org.splat.wapp.PopupMenu;
13 public class SimulationContextFacade {
15 private final SimulationContext _my;
18 private ProgressState _state;
19 private final PopupMenu _popup;
21 // ==============================================================================================================================
23 // ==============================================================================================================================
25 public SimulationContextFacade(final SimulationContext represented,
26 final List<ProjectSettingsService.Step> allSteps,
27 final ApplicationSettings app) {
29 _popup = app.getPopupMenu("scontext");
31 SimulationContextType type = _my.getType();
32 for (Iterator<ProjectSettingsService.Step> i = allSteps.iterator(); i
34 ProjectSettingsService.Step next = i.next();
35 if (!type.isAttachedTo(next)) {
38 _step = next.getNumber();
41 _state = _my.getProgressState(); // inCHECK or APPROVED
42 _name = type.getName();
43 if (type.isApproved()) {
44 _name = ResourceBundle.getBundle("som", app.getCurrentLocale())
45 .getString("type.context." + _name);
47 _state = ProgressState.inDRAFT;
51 // ==============================================================================================================================
53 // ==============================================================================================================================
55 public String getEditIcon() {
57 return "icon.ed" + _state + ".png";
60 public String getIndex() {
61 return String.valueOf(_my.getIndex());
64 public PopupMenu getPopup() {
66 _popup.setContext("scontext", this); // Cannot be done at construction because pop-ups are shared
70 public String getStateIcon() {
71 return "icon." + _state + ".png";
74 public String getStepNumber() {
75 return String.valueOf(_step);
78 public String getTypeName() {
82 public String getValue() {
83 return _my.getValue();
86 public boolean isApproved() {
87 return (_state == ProgressState.APPROVED);
90 public boolean isEditable() {
91 return !_my.isShared();
94 public boolean isFacadeOf(final SimulationContext represented) {
95 return _my.equals(represented);