]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman/src/org/splat/simer/NewScenarioMenu.java
Salome HOME
Siman codebase is refactored. Spring beans are introduced in the context.
[tools/siman.git] / Workspace / Siman / src / org / splat / simer / NewScenarioMenu.java
index 157784673802f32685bd81414ee6cfd3e7e922b2..f5914a6b4992607ec932847a335b1e489f9977b3 100644 (file)
@@ -3,134 +3,198 @@ package org.splat.simer;
 import java.util.Iterator;
 import java.util.Vector;
 
-import org.splat.som.Scenario;
+import org.splat.dal.bo.som.Scenario;
+import org.splat.service.ProjectElementService;
+import org.splat.service.ScenarioService;
 import org.splat.som.Step;
-import org.splat.som.Study;
+import org.splat.dal.bo.som.Study;
 import org.splat.wapp.MenuItem;
 import org.splat.wapp.SlidMenu;
 
-
 public class NewScenarioMenu extends SlidMenu {
 
-    private  Study    study;
-    private  Scenario scopen;     // Currently "open" scenario
-    private  Step     stopen;     // Currently selected step
-    
-//  ==============================================================================================================================
-//  Constructor
-//  ==============================================================================================================================
-    public NewScenarioMenu (Study context) {
-//  -----------------------------------
-         super("scenarii", "study");
-      study  = context;
-      scopen = null;
-   }
-
-//  ==============================================================================================================================
-//  Member functions
-//  ==============================================================================================================================
-
-    public void selects (String name) {
-//  ---------------------------------
-      String[]   parse  = name.split("\\x2E");
-      Scenario[] scenes = study.getScenarii();
-      Scenario   scenew = scopen;
-      int        askid  = 0;
-
-//    Initialization
-      if (scenew == null && scenes.length == 1) scenew = scenes[0];
-      try {
-        int askdex = Integer.valueOf(parse[0]);
-        if (askdex > 0) {
-          while (askid < scenes.length) {
-            if (scenes[askid].getIndex() == askdex) break;
-            askid += 1;
-          }
-         scenew = scenes[askid];  // Throws an exception if the scenario does not exist (that is, if name is not correct)
-        }
-      } catch (Exception error) {
-       return;
-      }
-      if (scenew == null) {
-
-//    Study with several scenarii, non of them open
-
-//      Collection of steps to be displayed
-        Vector<Step> steps   = new Vector<Step>();
-        Step[]       newstep = scenes[0].getSteps();   // All scenarii have the same steps
-          
-       for (int i=0; i<scenes.length; i++) steps.add(scenes[i].getFirstStep());
-        newstep = study.getSteps();
-        stopen  = newstep[0];                          // Default selected step
-
-//      Creation of the menu
-       for (Iterator<Step> i=steps.iterator(); i.hasNext(); ) {
-          Step     step   = i.next();
-          int      number = step.getNumber();
-          Scenario group  = (Scenario)step.getOwner(); // The menu includes first scenario steps only
-          int      index  = group.getIndex();
-          String   value  = index + "." + number;
-          String   icon;
-          if      (group.isEmpty())    icon = "icon.empty.png";
-//        else if (group.isFinished()) icon = "icon.checked.png";
-          else                         icon = "icon.done.png";
-          addGroup(value, group.getTitle(),  icon, "select-step?selection=" + value + "&title=%{title}");                      
-        }
-      } else
-      if (scopen == null || !scenew.equals(scopen)) {
-
-//    Opening a scenario
-       this.clear();
-//      Collection of steps to be displayed
-        Vector<Step> steps   = new Vector<Step>();
-        Step[]       newstep = scenew.getSteps();
-        
-        for (int i=0; i<newstep.length; i++) {
-               steps.add(newstep[i]);
-        }
-        for (int i=askid-1; i>-1; i--) steps.add(0, scenes[i].getFirstStep());
-        newstep = study.getSteps();
-        for (int i=askid+1; i<scenes.length; i++) steps.add(scenes[i].getFirstStep());
-
-//      Creation of the menu
-        boolean   first  = true;   // For differentiating the first scenario step
-        int       askdex = Integer.valueOf(parse[1]);
-       for (Iterator<Step> i=steps.iterator(); i.hasNext(); ) {
-          Step    step   = i.next();
-          int     number = step.getNumber();
-          String  icon;
-          if      (!step.isStarted()) icon   = "icon.empty.png";
-          else if (step.isFinished()) icon   = "icon.checked.png";
-          else                        icon   = "icon.done.png";
-          if (number == askdex)       stopen = step;
-          Scenario group = (Scenario)step.getOwner();
-          int      index = group.getIndex();
-          String   value = index + "." + number;
-          if (index != scenew.getIndex()) {
-            if      (group.isEmpty())    icon = "icon.empty.png";
-//          else if (group.isFinished()) icon = "icon.checked.png";
-            else                         icon = "icon.done.png";
-            addGroup(value, group.getTitle(),  icon, "select-step?selection=" + value + "&title=%{title}");                    
-          } else if (first) {
-            addGroup(value, scenew.getTitle(), icon, "select-step?selection=" + value + "&title=%{title}");
-            first = false;
-          } else {
-           addSubItem(value, "menu.step." + number, icon, "select-step?selection=" + value + "&title=%{title}");
-          }
-       }
-       scopen = scenew;
-      }
-      super.selects(name);
-    }
-
-    public void refreshSelectedItem () {
-//  ----------------------------------
-      MenuItem item = this.getSelectedItem();
-      String   icon;
-      if      (!stopen.isStarted()) icon = "icon.empty.png";
-      else if (stopen.isFinished()) icon = "icon.checked.png";
-      else                          icon = "icon.done.png";
-      item.icon(icon);
-    }
+       private Study study;
+       private Scenario scopen; // Currently "open" scenario
+       private Step stopen; // Currently selected step
+       private ProjectElementService _projectElementService;
+       private ScenarioService _scenarioService;
+
+       // ==============================================================================================================================
+       // Constructor
+       // ==============================================================================================================================
+
+       public NewScenarioMenu(Study context) {
+               // -----------------------------------
+               super("scenarii", "study");
+               study = context;
+               scopen = null;
+       }
+
+       // ==============================================================================================================================
+       // Member functions
+       // ==============================================================================================================================
+
+       public void selects(String name) {
+               // ---------------------------------
+               String[] parse = name.split("\\x2E");
+               Scenario[] scenes = study.getScenarii();
+               Scenario scenew = scopen;
+               int askid = 0;
+
+               // Initialization
+               if (scenew == null && scenes.length == 1)
+                       scenew = scenes[0];
+               try {
+                       int askdex = Integer.valueOf(parse[0]);
+                       if (askdex > 0) {
+                               while (askid < scenes.length) {
+                                       if (scenes[askid].getIndex() == askdex)
+                                               break;
+                                       askid += 1;
+                               }
+                               scenew = scenes[askid]; // Throws an exception if the scenario does not exist (that is, if name is not correct)
+                       }
+               } catch (Exception error) {
+                       return;
+               }
+               if (scenew == null) {
+
+                       // Study with several scenarii, non of them open
+
+                       // Collection of steps to be displayed
+                       Vector<Step> steps = new Vector<Step>();
+                       Step[] newstep = getProjectElementService().getSteps(scenes[0]); // All scenarii have the same steps
+
+                       for (int i = 0; i < scenes.length; i++)
+                               steps.add(getProjectElementService().getFirstStep(scenes[i]));
+                       newstep = getProjectElementService().getSteps(study);
+                       stopen = newstep[0]; // Default selected step
+
+                       // Creation of the menu
+                       for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
+                               Step step = i.next();
+                               int number = step.getNumber();
+                               Scenario group = (Scenario) step.getOwner(); // The menu includes first scenario steps only
+                               int index = group.getIndex();
+                               String value = index + "." + number;
+                               String icon;
+                               if (getScenarioService().isEmpty(group))
+                                       icon = "icon.empty.png";
+                               // else if (group.isFinished()) icon = "icon.checked.png";
+                               else
+                                       icon = "icon.done.png";
+                               addGroup(value, group.getTitle(), icon,
+                                               "select-step?selection=" + value + "&title=%{title}");
+                       }
+               } else if (scopen == null || !scenew.equals(scopen)) {
+
+                       // Opening a scenario
+                       this.clear();
+                       // Collection of steps to be displayed
+                       Vector<Step> steps = new Vector<Step>();
+                       Step[] newstep = getProjectElementService().getSteps(scenew);
+
+                       for (int i = 0; i < newstep.length; i++) {
+                               steps.add(newstep[i]);
+                       }
+                       for (int i = askid - 1; i > -1; i--)
+                               steps.add(0, getProjectElementService().getFirstStep(scenes[i]));
+                       newstep = getProjectElementService().getSteps(study);
+                       for (int i = askid + 1; i < scenes.length; i++)
+                               steps.add(getProjectElementService().getFirstStep(scenes[i]));
+
+                       // Creation of the menu
+                       boolean first = true; // For differentiating the first scenario step
+                       int askdex = Integer.valueOf(parse[1]);
+                       for (Iterator<Step> i = steps.iterator(); i.hasNext();) {
+                               Step step = i.next();
+                               int number = step.getNumber();
+                               String icon;
+                               if (!step.isStarted())
+                                       icon = "icon.empty.png";
+                               else if (step.isFinished())
+                                       icon = "icon.checked.png";
+                               else
+                                       icon = "icon.done.png";
+                               if (number == askdex)
+                                       stopen = step;
+                               Scenario group = (Scenario) step.getOwner();
+                               int index = group.getIndex();
+                               String value = index + "." + number;
+                               if (index != scenew.getIndex()) {
+                                       if (getScenarioService().isEmpty(group))
+                                               icon = "icon.empty.png";
+                                       // else if (group.isFinished()) icon = "icon.checked.png";
+                                       else
+                                               icon = "icon.done.png";
+                                       addGroup(value, group.getTitle(), icon,
+                                                       "select-step?selection=" + value
+                                                                       + "&title=%{title}");
+                               } else if (first) {
+                                       addGroup(value, scenew.getTitle(), icon,
+                                                       "select-step?selection=" + value
+                                                                       + "&title=%{title}");
+                                       first = false;
+                               } else {
+                                       addSubItem(value, "menu.step." + number, icon,
+                                                       "select-step?selection=" + value
+                                                                       + "&title=%{title}");
+                               }
+                       }
+                       scopen = scenew;
+               }
+               super.selects(name);
+       }
+
+       public void refreshSelectedItem() {
+               // ----------------------------------
+               MenuItem item = this.getSelectedItem();
+               String icon;
+               if (!stopen.isStarted())
+                       icon = "icon.empty.png";
+               else if (stopen.isFinished())
+                       icon = "icon.checked.png";
+               else
+                       icon = "icon.done.png";
+               item.icon(icon);
+       }
+
+       /**
+        * Get the scenarioService.
+        * 
+        * @return the scenarioService
+        */
+       public ScenarioService getScenarioService() {
+               return _scenarioService;
+       }
+
+       /**
+        * Set the scenarioService.
+        * 
+        * @param scenarioService
+        *            the scenarioService to set
+        */
+       public void setScenarioService(ScenarioService scenarioService) {
+               _scenarioService = scenarioService;
+       }
+
+       /**
+        * Get the projectElementService.
+        * 
+        * @return the projectElementService
+        */
+       public ProjectElementService getProjectElementService() {
+               return _projectElementService;
+       }
+
+       /**
+        * Set the projectElementService.
+        * 
+        * @param projectElementService
+        *            the projectElementService to set
+        */
+       public void setProjectElementService(
+                       ProjectElementService projectElementService) {
+               _projectElementService = projectElementService;
+       }
 }
\ No newline at end of file