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.service.technical.ProjectSettingsService;
9 import org.splat.dal.bo.som.SimulationContext;
10 import org.splat.dal.bo.som.SimulationContextType;
11 import org.splat.wapp.PopupMenu;
14 public class SimulationContextFacade {
16 private SimulationContext my;
19 private ProgressState state;
20 private PopupMenu popup;
22 // ==============================================================================================================================
24 // ==============================================================================================================================
26 public SimulationContextFacade (SimulationContext represented, List<ProjectSettingsService.Step> allSteps) {
27 // --------------------------------------------------------------
29 popup = ApplicationSettings.getPopupMenu("scontext");
31 SimulationContextType type = my.getType();
32 for (Iterator<ProjectSettingsService.Step> i=allSteps.iterator(); i.hasNext(); ) {
33 ProjectSettingsService.Step next = i.next();
34 if (!type.isAttachedTo(next)) continue;
35 step = next.getNumber();
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);
43 state = ProgressState.inDRAFT;
47 // ==============================================================================================================================
49 // ==============================================================================================================================
51 public String getEditIcon () {
52 // ----------------------------
53 return "icon.ed" + state + ".png";
55 public String getIndex () {
56 // -------------------------
57 return String.valueOf(my.getIndex());
59 public PopupMenu getPopup () {
60 // ----------------------------
61 popup.setContext("scontext", this); // Cannot be done at construction because pop-ups are shared
64 public String getStateIcon () {
65 // -----------------------------
66 return "icon." + state + ".png";
68 public String getStepNumber () {
69 // ------------------------------
70 return String.valueOf(step);
72 public String getTypeName () {
73 // ----------------------------
76 public String getValue () {
77 // -------------------------
81 public boolean isApproved () {
82 // ----------------------------
83 return (state == ProgressState.APPROVED);
85 public boolean isEditable () {
86 // ----------------------------
87 return !my.isShared();
89 public boolean isFacadeOf (SimulationContext represented) {
90 // ---------------------------------------------------------
91 return my.equals(represented);