From 06fcaf57519ceafd08b475fb36effadd7cee3397 Mon Sep 17 00:00:00 2001
From: pompert <sdos@astron.nl>
Date: Wed, 26 Jul 2006 14:43:58 +0000
Subject: [PATCH] BugID: 791 Additions: -BBS Strategy Step Tree browser now
 loads steps present in the BBS OTDB tree -Name field in the Step Explorer to
 make it possible to specify its Step Identifier

---
 .../bbs/BBSStepExplorerPanel.form             |  32 ++-
 .../bbs/BBSStepExplorerPanel.java             |  18 +-
 .../otbcomponents/bbs/BBSStrategyPanel.java   |  86 +++----
 .../bbs/stepmanagement/BBSStep.java           |   8 +-
 .../stepmanagement/BBSStepDataManager.java    | 218 ++++++++++++++++++
 .../stepmanagement/BBSStepExplorerPanel.form  |  32 ++-
 .../stepmanagement/BBSStepExplorerPanel.java  |  18 +-
 .../stepmanagement/BBSStepTreeManager.java    |  30 +--
 8 files changed, 376 insertions(+), 66 deletions(-)
 create mode 100644 SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepDataManager.java

diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.form
index 7b7b6398526..f4965bcd6aa 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.form
@@ -52,7 +52,7 @@
                   </Properties>
                   <Constraints>
                     <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-                      <AbsoluteConstraints x="30" y="10" width="-1" height="-1"/>
+                      <AbsoluteConstraints x="360" y="10" width="-1" height="-1"/>
                     </Constraint>
                   </Constraints>
                 </Component>
@@ -62,7 +62,7 @@
                   </Properties>
                   <Constraints>
                     <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-                      <AbsoluteConstraints x="190" y="10" width="-1" height="-1"/>
+                      <AbsoluteConstraints x="730" y="70" width="-1" height="-1"/>
                     </Constraint>
                   </Constraints>
                 </Component>
@@ -73,7 +73,7 @@
                   </Properties>
                   <Constraints>
                     <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-                      <AbsoluteConstraints x="370" y="10" width="-1" height="-1"/>
+                      <AbsoluteConstraints x="730" y="40" width="-1" height="-1"/>
                     </Constraint>
                   </Constraints>
                 </Component>
@@ -1276,6 +1276,32 @@
                     </Container>
                   </SubComponents>
                 </Container>
+                <Component class="javax.swing.JLabel" name="stepExplorerStepNameLabel">
+                  <Properties>
+                    <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                      <Font name="Dialog" size="18" style="1"/>
+                    </Property>
+                    <Property name="text" type="java.lang.String" value="Step"/>
+                  </Properties>
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
+                      <AbsoluteConstraints x="30" y="10" width="-1" height="30"/>
+                    </Constraint>
+                  </Constraints>
+                </Component>
+                <Component class="javax.swing.JTextField" name="stepExplorerStepNameText">
+                  <Properties>
+                    <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                      <Font name="Dialog" size="18" style="1"/>
+                    </Property>
+                    <Property name="toolTipText" type="java.lang.String" value="This is the name of the displayed step"/>
+                  </Properties>
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
+                      <AbsoluteConstraints x="80" y="10" width="250" height="30"/>
+                    </Constraint>
+                  </Constraints>
+                </Component>
               </SubComponents>
             </Container>
           </SubComponents>
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.java
index 5b83ac97fb8..0956eb85317 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStepExplorerPanel.java
@@ -466,6 +466,8 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
         deleteSourceButton1 = new javax.swing.JButton();
         stepExplorerSourcesScrollPane = new javax.swing.JScrollPane();
         stepExplorerSourcesList = new javax.swing.JList();
+        stepExplorerStepNameLabel = new javax.swing.JLabel();
+        stepExplorerStepNameText = new javax.swing.JTextField();
 
         setLayout(new java.awt.BorderLayout());
 
@@ -483,14 +485,14 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
 
         explorePreviousStepButton.setText("View previous step");
         explorePreviousStepButton.setEnabled(false);
-        stepExplorerPanel.add(explorePreviousStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1));
+        stepExplorerPanel.add(explorePreviousStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 10, -1, -1));
 
         exploreParentStepButton.setText("View parent multistep");
-        stepExplorerPanel.add(exploreParentStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 10, -1, -1));
+        stepExplorerPanel.add(exploreParentStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(730, 70, -1, -1));
 
         exploreFirstChildStepButton.setText("View first child step");
         exploreFirstChildStepButton.setEnabled(false);
-        stepExplorerPanel.add(exploreFirstChildStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 10, -1, -1));
+        stepExplorerPanel.add(exploreFirstChildStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(730, 40, -1, -1));
 
         exploreNextStepButton.setText("View next step");
         stepExplorerPanel.add(exploreNextStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 10, -1, -1));
@@ -933,6 +935,14 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
 
         stepExplorerPanel.add(stepExplorerGlobalSources, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 40, 350, 180));
 
+        stepExplorerStepNameLabel.setFont(new java.awt.Font("Dialog", 1, 18));
+        stepExplorerStepNameLabel.setText("Step");
+        stepExplorerPanel.add(stepExplorerStepNameLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, 30));
+
+        stepExplorerStepNameText.setFont(new java.awt.Font("Dialog", 1, 18));
+        stepExplorerStepNameText.setToolTipText("This is the name of the displayed step");
+        stepExplorerPanel.add(stepExplorerStepNameText, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 10, 250, 30));
+
         stepExplorerScrollPanel.setViewportView(stepExplorerPanel);
 
         BBSStepExplorerPanel.add(stepExplorerScrollPanel, java.awt.BorderLayout.CENTER);
@@ -1063,6 +1073,8 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
     private javax.swing.JPanel stepExplorerSourcesPanel1;
     private javax.swing.JScrollPane stepExplorerSourcesScrollPane;
     private javax.swing.JScrollPane stepExplorerSourcesScrollPane1;
+    private javax.swing.JLabel stepExplorerStepNameLabel;
+    private javax.swing.JTextField stepExplorerStepNameText;
     // End of variables declaration//GEN-END:variables
     
     /**
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStrategyPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStrategyPanel.java
index 8179a8353d2..d0cbd0ef1cd 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStrategyPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/BBSStrategyPanel.java
@@ -116,36 +116,8 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
                     this.retrieveAndDisplayChildDataForNode(aNode);
                 }else if (LofarUtils.keyName(aNode.name).equals("Correlation")) {
                     this.retrieveAndDisplayChildDataForNode(aNode);
-                }
+                }           
             }
-            
-            //Add steps that make up the strategy to the steps tree browser
-            //
-            Vector steps = itsMainFrame.getSharedVars().getOTDBrmi().getRemoteMaintenance().getItemList(itsNode.treeID(), itsNode.parentID(), 1);
-            // get all the params per child
-            Enumeration se = steps.elements();
-            while( se.hasMoreElements()  ) {
-                aParam=null;
-                jOTDBnode aNode = (jOTDBnode)se.nextElement();
-                
-                // We need to keep all the nodes needed by this panel
-                // if the node is a leaf we need to get the pointed to value via Param.
-                if (aNode.leaf) {
-                
-                //we need to get all the childs from the following nodes as well.
-                }else if (LofarUtils.keyName(aNode.name).equals("Step")) {
-                    //Add steps to tree
-                    Object[] rootNodeArgs = new Object[3];
-                    rootNodeArgs[0]= new String("Strategy Steps");
-                    rootNodeArgs[1]=aNode;
-                    TreeNode newStepRootNode = BBSStepTreeManager.getInstance(itsMainFrame.getUserAccount()).getRootNode(rootNodeArgs);
-                    this.stepsTreePanel.newRootNode(newStepRootNode);
-                    
-                }
-            }
-            //
-            //End of code that handles step tree browser
-            
         } catch (RemoteException ex) {
             logger.debug("Error during getComponentParam: "+ ex);
             itsParamList=null;
@@ -240,7 +212,7 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
         }
         modifyStationText.setText("");
         addStationButton.setEnabled(false);
-        
+        this.setupStepTree(StrategySteps);
         //TODO: add other values accordingly.
     }
     
@@ -283,6 +255,9 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
         String parentName = String.valueOf(parent.name);
         
         if(parentName.equals("Strategy")){
+            //Setup step tree
+            this.setupStepTree(parent);
+            
             if (aKeyName.equals("InputData")) {
                 this.inputDataText.setToolTipText(aParam.description);
                 this.StrategyInputData=aNode;
@@ -367,10 +342,6 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
                     this.fillSelectionListFromString(correlationTypeList,aNode.limits,true);
                 }
             }
-        } else if(parentName.equals("Step")){
-            //Detected Step node
-            
-            
         }
     }
     
@@ -578,6 +549,34 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
         }
     }
     
+    private void setupStepTree(jOTDBnode strategyRootNode){
+        try {
+            
+            //Add steps that make up the strategy to the steps tree browser
+            //
+            Vector steps = itsMainFrame.getSharedVars().getOTDBrmi().getRemoteMaintenance().getItemList(strategyRootNode.treeID(), strategyRootNode.parentID(), 1);
+            // get all the params per child
+            Enumeration se = steps.elements();
+            while( se.hasMoreElements()  ) {
+                jOTDBnode aNode2 = (jOTDBnode)se.nextElement();
+                
+                if (aNode2.leaf) {
+                }else if (LofarUtils.keyName(aNode2.name).equals("Step")) {
+                    //Add steps to tree
+                    Object[] rootNodeArgs = new Object[3];
+                    rootNodeArgs[0]= new String("Strategy Steps");
+                    rootNodeArgs[1]=aNode2;
+                    TreeNode newStepRootNode = BBSStepTreeManager.getInstance(itsMainFrame.getUserAccount()).getRootNode(rootNodeArgs);
+                    this.stepsTreePanel.newRootNode(newStepRootNode);
+                    
+                }
+            }
+            StrategySteps = strategyRootNode;
+        } catch (RemoteException ex) {
+            logger.error("Strategy Step Tree could not be built.",ex);
+        }
+    }
+    
     /** This method is called from within the constructor to
      * initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is
@@ -936,7 +935,7 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
         add(strategyScrollPane, java.awt.BorderLayout.CENTER);
 
     }// </editor-fold>//GEN-END:initComponents
-
+    
     private void removeStepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeStepButtonActionPerformed
         TreePath selectedPath = this.stepsTreePanel.getTree().getSelectionPath();
         if(selectedPath != null){
@@ -958,7 +957,7 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
             
         }
     }//GEN-LAST:event_removeStepButtonActionPerformed
-
+    
     private void modifyStepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modifyStepButtonActionPerformed
         TreePath selectedPath = this.stepsTreePanel.getTree().getSelectionPath();
         if(selectedPath != null){
@@ -966,18 +965,25 @@ public class BBSStrategyPanel extends javax.swing.JPanel implements IViewPanel{
             logger.trace("BBS Step to be modified : "+someBBSStepNode.getName());
         }
     }//GEN-LAST:event_modifyStepButtonActionPerformed
-
+    
     private void stepsTreePanelValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_stepsTreePanelValueChanged
         TreePath selectedPath = this.stepsTreePanel.getTree().getSelectionPath();
         if(selectedPath != null){
-            this.modifyStepButton.setEnabled(true);
-            this.removeStepButton.setEnabled(true);
+            TreeNode someBBSStepNode = (TreeNode)selectedPath.getLastPathComponent();
+            //check if the root node was selected, which should not be editable
+            if(!someBBSStepNode.getName().equals("Strategy Steps")){
+                this.modifyStepButton.setEnabled(true);
+                this.removeStepButton.setEnabled(true);
+            }else{
+                this.modifyStepButton.setEnabled(false);
+                this.removeStepButton.setEnabled(false);
+            }
         }else{
             this.modifyStepButton.setEnabled(false);
             this.removeStepButton.setEnabled(false);
         }
     }//GEN-LAST:event_stepsTreePanelValueChanged
-
+    
     private void addStepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addStepButtonActionPerformed
         TreePath selectedPath = this.stepsTreePanel.getTree().getSelectionPath();
         if(selectedPath != null){
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStep.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStep.java
index bc2460bd51a..9f767773f4b 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStep.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStep.java
@@ -127,9 +127,9 @@ public class BBSStep{
     
     public void removeChildStep(BBSStep childStep){
         if(childSteps.contains(childStep)){
-            childStep.setParentStep(null);
             childSteps.remove(childStep);
             childSteps.trimToSize();
+            childStep.setParentStep(null);            
         }        
     }
     
@@ -137,4 +137,10 @@ public class BBSStep{
         return childSteps.size()>0;
     }
     
+    public void finalize(){
+        if(parentStep!=null){
+            parentStep.removeChildStep(this);
+        }
+    }
+    
 }
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepDataManager.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepDataManager.java
new file mode 100644
index 00000000000..48112477fb2
--- /dev/null
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepDataManager.java
@@ -0,0 +1,218 @@
+/*
+ * BBSStepDataManager.java
+ *
+ *  Copyright (C) 2002-2007
+ *  ASTRON (Netherlands Foundation for Research in Astronomy)
+ *  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+package nl.astron.lofar.sas.otbcomponents.bbs.stepmanagement;
+
+import java.rmi.RemoteException;
+import java.util.Enumeration;
+import java.util.Vector;
+import nl.astron.lofar.sas.otb.SharedVars;
+import nl.astron.lofar.sas.otb.jotdb2.jOTDBnode;
+import nl.astron.lofar.sas.otb.jotdb2.jOTDBparam;
+import org.apache.log4j.Logger;
+
+/**
+ * @version $Id$
+ * @created July 26, 2006, 10:04 AM
+ * @author pompert
+ */
+public class BBSStepDataManager{
+    
+    private static BBSStepDataManager instance;
+    private static Logger logger = Logger.getLogger(BBSStepDataManager.class);
+    
+    /** Creates a new instance of BBSStepDataManager */
+    private BBSStepDataManager() {
+        
+    }
+    
+    public static synchronized BBSStepDataManager getInstance(){
+        if(instance==null){
+            instance = new BBSStepDataManager();
+        }
+        return instance;
+    }
+    
+    public Vector<BBSStepNode> buildStepTree(BBSStepNode aRootNode, boolean buildStrategyStepTree) throws RemoteException{
+        Vector<BBSStepNode> returnNode = new Vector<BBSStepNode>();
+        
+        //Fetch the step names that are mentioned in the strategy tree (Strategy.Steps)
+        
+        //The following otdbnode should be the Step container node (Step)
+        jOTDBnode rootNode = aRootNode.getOTDBNode();
+        
+        jOTDBnode strategyStepsParameter=null;
+        Vector HWchilds = null;
+        if(buildStrategyStepTree){
+            //retrieve 2 levels of parameters to locate Strategy.Steps
+            //using the parent node of Step, which is the BBS root node itself
+            HWchilds = SharedVars.getOTDBrmi().getRemoteMaintenance().getItemList(rootNode.treeID(), rootNode.parentID(), 2);
+        }else{
+            //retrieve all subnodes of the node given to look for Step.XXX.Steps
+            HWchilds = SharedVars.getOTDBrmi().getRemoteMaintenance().getItemList(rootNode.treeID(), rootNode.nodeID(), 1);
+        }
+        // get all the params per child
+        Enumeration e1 = HWchilds.elements();
+        while( e1.hasMoreElements()  ) {
+            
+            jOTDBnode aHWNode = (jOTDBnode)e1.nextElement();
+            strategyStepsParameter=null;
+            //retrieving Strategy.Steps
+            if (aHWNode.leaf && aHWNode.name.equals("Steps")) {
+                strategyStepsParameter = aHWNode;
+                logger.trace("Strategy Steps defined :"+strategyStepsParameter.limits);
+                break;
+            }
+        }
+        if(strategyStepsParameter!=null){
+            //retrieve the step names mentioned in the strategy steps parameter (Strategy.Steps)
+            Vector<String> strategySteps = this.getVectorFromString(strategyStepsParameter.limits,true);
+            
+            if(strategySteps.size()>0){
+                //Get all the steps present in the BBS Step Container
+                Vector stepsVector = new Vector();
+                if(buildStrategyStepTree){
+                    //retrieve steps from location Step
+                    stepsVector = SharedVars.getOTDBrmi().getRemoteMaintenance().getItemList(rootNode.treeID(), rootNode.nodeID(), 1);
+                }else{
+                    //retrieve steps from location Step.XXX
+                    stepsVector = SharedVars.getOTDBrmi().getRemoteMaintenance().getItemList(rootNode.treeID(), rootNode.parentID(), 1);
+                }
+                Enumeration se = stepsVector.elements();
+                //loop through steps
+                while( se.hasMoreElements()  ) {
+                    jOTDBnode aHWNode = (jOTDBnode)se.nextElement();
+                    
+                    //limiting the search for steps that are mentioned in the strategy steps parameter (Strategy.Steps)
+                    if (strategySteps.contains(aHWNode.name)) {
+                        //Create a new step and build it (with its substeps as well)
+                        BBSStep newStep = new BBSStep(aHWNode.name);
+                        buildStep(newStep,aHWNode);
+                        BBSStepNode newChildStepNode = new BBSStepNode(newStep);
+                        
+                        newChildStepNode.setOTDBNode(aHWNode);
+                        returnNode.add(newChildStepNode);
+                        logger.trace("Strategy Step defined : "+newStep.getName());
+                    }
+                }
+            }
+        }        
+        return returnNode;
+    }
+    
+    public void buildStep(BBSStep parentNode, jOTDBnode parentOTDBnode) throws RemoteException{
+        
+        //
+        //TODO:add variables to step
+        //
+        
+        //Add substeps
+        jOTDBnode strategyStepsParameter=null;
+        //retrieve 1 levels of parameters to locate Step.XXX.Steps
+        
+        Vector HWchilds = SharedVars.getOTDBrmi().getRemoteMaintenance().getItemList(parentOTDBnode.treeID(), parentOTDBnode.nodeID(), 1);
+        // get all the params per child
+        Enumeration e1 = HWchilds.elements();
+        while( e1.hasMoreElements()  ) {
+            
+            jOTDBnode aHWNode = (jOTDBnode)e1.nextElement();
+            strategyStepsParameter=null;
+            //retrieving Strategy.Steps
+            if (aHWNode.leaf && aHWNode.name.equals("Steps")) {
+                strategyStepsParameter = aHWNode;
+                logger.trace("Strategy Steps defined :"+strategyStepsParameter.limits);
+            }
+        }
+        if(strategyStepsParameter!=null){
+            //retrieve the step names mentioned in the strategy steps parameter (Strategy.Steps)
+            Vector<String> strategySteps = this.getVectorFromString(strategyStepsParameter.limits,true);
+            
+            if(strategySteps.size()>0){
+                //Get all the steps present in the BBS Step Container
+                Vector stepsVector = SharedVars.getOTDBrmi().getRemoteMaintenance().getItemList(parentOTDBnode.treeID(), parentOTDBnode.parentID(), 1);
+                Enumeration se = stepsVector.elements();
+                //loop through steps
+                while( se.hasMoreElements()  ) {
+                    jOTDBnode aHWNode = (jOTDBnode)se.nextElement();
+                    
+                    //limiting the search for steps that are mentioned in the strategy steps parameter (Strategy.Steps)
+                    if (!aHWNode.leaf && strategySteps.contains(aHWNode.name)) {
+                        //Create a new step and build it (with its substeps as well)
+                        BBSStep newStep = new BBSStep(aHWNode.name);
+                        buildStep(newStep,aHWNode);
+                        parentNode.addChildStep(newStep);
+                        logger.trace("Strategy Step defined : "+newStep.getName());
+                    }
+                }
+            }
+        }
+    }
+    
+    public void persistStepTree(BBSStepNode aBBSStepTree, boolean isStrategyStepTree){
+        
+    }
+    
+    public void persistStep(BBSStepNode aBBSStepTree, boolean isStrategyStep){
+        
+    }
+    private Vector<String> getVectorFromString(String theList,boolean removeQuotes) {
+        Vector<String> listItems = new Vector<String>();
+        String aList = theList;
+        if (aList.startsWith("[")) {
+            aList = aList.substring(1,aList.length());
+        }
+        if (aList.endsWith("]")) {
+            aList = aList.substring(0,aList.length()-1);
+        }
+        if(!aList.equals("")){
+            String[] aS=aList.split(",");
+            for (int i=0; i< aS.length;i++) {
+                if(removeQuotes){
+                    listItems.add(aS[i].substring(1,aS[i].length()-1));
+                }else{
+                    listItems.add(aS[i]);
+                }
+            }
+        }
+        return listItems;
+    }
+    private String getStringFromVector(Vector<String> aStringVector,boolean createQuotes) {
+        String aList="[";
+        if (aStringVector.size() > 0) {
+            int i = 0;
+            for (String aString : aStringVector){
+                if(i>0) aList+= ",";
+                if(createQuotes){
+                    aList += "\"";
+                }
+                aList += aString;
+                if(createQuotes){
+                    aList += "\"";
+                }
+                i++;
+            }
+        }
+        aList+="]";
+        return aList;
+    }
+}
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.form
index 7b7b6398526..f4965bcd6aa 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.form
@@ -52,7 +52,7 @@
                   </Properties>
                   <Constraints>
                     <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-                      <AbsoluteConstraints x="30" y="10" width="-1" height="-1"/>
+                      <AbsoluteConstraints x="360" y="10" width="-1" height="-1"/>
                     </Constraint>
                   </Constraints>
                 </Component>
@@ -62,7 +62,7 @@
                   </Properties>
                   <Constraints>
                     <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-                      <AbsoluteConstraints x="190" y="10" width="-1" height="-1"/>
+                      <AbsoluteConstraints x="730" y="70" width="-1" height="-1"/>
                     </Constraint>
                   </Constraints>
                 </Component>
@@ -73,7 +73,7 @@
                   </Properties>
                   <Constraints>
                     <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-                      <AbsoluteConstraints x="370" y="10" width="-1" height="-1"/>
+                      <AbsoluteConstraints x="730" y="40" width="-1" height="-1"/>
                     </Constraint>
                   </Constraints>
                 </Component>
@@ -1276,6 +1276,32 @@
                     </Container>
                   </SubComponents>
                 </Container>
+                <Component class="javax.swing.JLabel" name="stepExplorerStepNameLabel">
+                  <Properties>
+                    <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                      <Font name="Dialog" size="18" style="1"/>
+                    </Property>
+                    <Property name="text" type="java.lang.String" value="Step"/>
+                  </Properties>
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
+                      <AbsoluteConstraints x="30" y="10" width="-1" height="30"/>
+                    </Constraint>
+                  </Constraints>
+                </Component>
+                <Component class="javax.swing.JTextField" name="stepExplorerStepNameText">
+                  <Properties>
+                    <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+                      <Font name="Dialog" size="18" style="1"/>
+                    </Property>
+                    <Property name="toolTipText" type="java.lang.String" value="This is the name of the displayed step"/>
+                  </Properties>
+                  <Constraints>
+                    <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
+                      <AbsoluteConstraints x="80" y="10" width="250" height="30"/>
+                    </Constraint>
+                  </Constraints>
+                </Component>
               </SubComponents>
             </Container>
           </SubComponents>
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.java
index 5b83ac97fb8..0956eb85317 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepExplorerPanel.java
@@ -466,6 +466,8 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
         deleteSourceButton1 = new javax.swing.JButton();
         stepExplorerSourcesScrollPane = new javax.swing.JScrollPane();
         stepExplorerSourcesList = new javax.swing.JList();
+        stepExplorerStepNameLabel = new javax.swing.JLabel();
+        stepExplorerStepNameText = new javax.swing.JTextField();
 
         setLayout(new java.awt.BorderLayout());
 
@@ -483,14 +485,14 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
 
         explorePreviousStepButton.setText("View previous step");
         explorePreviousStepButton.setEnabled(false);
-        stepExplorerPanel.add(explorePreviousStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, -1));
+        stepExplorerPanel.add(explorePreviousStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(360, 10, -1, -1));
 
         exploreParentStepButton.setText("View parent multistep");
-        stepExplorerPanel.add(exploreParentStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 10, -1, -1));
+        stepExplorerPanel.add(exploreParentStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(730, 70, -1, -1));
 
         exploreFirstChildStepButton.setText("View first child step");
         exploreFirstChildStepButton.setEnabled(false);
-        stepExplorerPanel.add(exploreFirstChildStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 10, -1, -1));
+        stepExplorerPanel.add(exploreFirstChildStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(730, 40, -1, -1));
 
         exploreNextStepButton.setText("View next step");
         stepExplorerPanel.add(exploreNextStepButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 10, -1, -1));
@@ -933,6 +935,14 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
 
         stepExplorerPanel.add(stepExplorerGlobalSources, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 40, 350, 180));
 
+        stepExplorerStepNameLabel.setFont(new java.awt.Font("Dialog", 1, 18));
+        stepExplorerStepNameLabel.setText("Step");
+        stepExplorerPanel.add(stepExplorerStepNameLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 10, -1, 30));
+
+        stepExplorerStepNameText.setFont(new java.awt.Font("Dialog", 1, 18));
+        stepExplorerStepNameText.setToolTipText("This is the name of the displayed step");
+        stepExplorerPanel.add(stepExplorerStepNameText, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 10, 250, 30));
+
         stepExplorerScrollPanel.setViewportView(stepExplorerPanel);
 
         BBSStepExplorerPanel.add(stepExplorerScrollPanel, java.awt.BorderLayout.CENTER);
@@ -1063,6 +1073,8 @@ public class BBSStepExplorerPanel extends javax.swing.JPanel implements IViewPan
     private javax.swing.JPanel stepExplorerSourcesPanel1;
     private javax.swing.JScrollPane stepExplorerSourcesScrollPane;
     private javax.swing.JScrollPane stepExplorerSourcesScrollPane1;
+    private javax.swing.JLabel stepExplorerStepNameLabel;
+    private javax.swing.JTextField stepExplorerStepNameText;
     // End of variables declaration//GEN-END:variables
     
     /**
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepTreeManager.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepTreeManager.java
index 79c7ed94c3e..a28e65cdb6f 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepTreeManager.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/bbs/stepmanagement/BBSStepTreeManager.java
@@ -22,10 +22,9 @@
 
 package nl.astron.lofar.sas.otbcomponents.bbs.stepmanagement;
 
-import java.util.Enumeration;
+import java.rmi.RemoteException;
 import java.util.Vector;
 import javax.swing.event.TreeModelEvent;
-import nl.astron.lofar.sas.otb.SharedVars;
 import nl.astron.lofar.sas.otb.jotdb2.jOTDBnode;
 import nl.astron.lofar.sas.otb.util.UserAccount;
 import nl.astron.lofar.sas.otb.util.treemanagers.GenericTreeManager;
@@ -81,11 +80,14 @@ public class BBSStepTreeManager extends GenericTreeManager implements ITreeManag
             logger.debug("Error - TreeManager BBSStepNode-defineChildNodes("+aNode.getName()+" does not contain a user object)");
             return;
         }
+        //get instance to the bbs step tree helper class
+        BBSStepDataManager BBSsdm = BBSStepDataManager.getInstance();
+        
         //BBS Node contained in the TreeNode
         BBSStepNode containedBBSNode = (BBSStepNode)aNode.getUserObject();
         //jOTDB Node contained that is needed to fetch child nodes from OTDB
         
-        jOTDBnode representedOTDBnode = containedBBSNode.getOTDBNode();
+        
         logger.trace("Entry - TreeManager BBSStepNode-defineChildNodes("+aNode.getName()+" ("+containedBBSNode.getName()+"))");
         
         // You must set the flag before defining children if you
@@ -94,7 +96,18 @@ public class BBSStepTreeManager extends GenericTreeManager implements ITreeManag
         // However, you could use "insert" in such a case.
         aNode.areChildrenDefined = true;
         if(containedBBSNode.isRootNode()){
-            //build the tree as a root node is detected
+            try {
+                //Build the complete BBS Step tree as a root node is detected
+                Vector<BBSStepNode> newPNodes = BBSsdm.buildStepTree(containedBBSNode,true);
+                for(BBSStepNode someNode : newPNodes){
+                    TreeNode newNode = new TreeNode(this.instance,someNode,someNode.getName());
+                    aNode.add(newNode);
+                    defineChildsForNode(newNode);
+                }
+            } catch (RemoteException ex) {
+                logger.error("defineChildNodes("+aNode.getName()+") resulted in an error  while retrieving the BBS strategy step names.",ex);
+        
+            }            
         }else{
             //expand the first steps in the tree
             BBSStep containedBBSStep = containedBBSNode.getContainedStep();
@@ -129,15 +142,6 @@ public class BBSStepTreeManager extends GenericTreeManager implements ITreeManag
         newPNode.leaf=false;
         TreeNode bbsNode = new TreeNode(this.instance,newPNode,newPNode.getName());
         
-        BBSStep aStep = new BBSStep("xyz");
-        aStep.addChildStep(new BBSStep("sl1"));
-        aStep.addChildStep(new BBSStep("sl2"));
-        BBSStepNode newPNode2 = new BBSStepNode(aStep);
-        newPNode2.setName(aStep.getName());
-        TreeNode newNode = new TreeNode(this.instance,newPNode2,newPNode2.getName());
-        
-        bbsNode.add(newNode);
-        
         return bbsNode;
     }
     
-- 
GitLab