From fd41bd38f823f7ff2c6ce36584e4306ffcba578e Mon Sep 17 00:00:00 2001
From: Arthur Coolen <coolen@astron.nl>
Date: Tue, 27 Nov 2012 14:24:18 +0000
Subject: [PATCH] Task #3877:   Moved LOG_PROP file location to
 /opt/sas/otb/etc 	      Removed beamlets from Beam               Added
 Remove from Default button to defaultTemplate window and allowed multiple
 selection to be able to remove Default templates in one go

---
 .../astron/lofar/lofarutils/LofarUtils.java   |   28 -
 .../nl/astron/lofar/sas/otb/objects/Beam.java |   15 -
 .../lofar/sas/otb/panels/MainPanel.form       |    2 +-
 .../lofar/sas/otb/panels/MainPanel.java       | 1657 +++++++++--------
 .../BeamConfigurationTableModel.java          |    5 +-
 .../lofar/sas/otbcomponents/BeamDialog.form   |   35 +-
 .../lofar/sas/otbcomponents/BeamDialog.java   |   98 +-
 .../CreateDefaultTemplateDialog.form          |    8 +-
 .../CreateDefaultTemplateDialog.java          |   10 +-
 .../otbcomponents/ParamExtensionDialog.java   |    5 +-
 .../userpanels/ObservationPanel.java          |   67 +-
 11 files changed, 872 insertions(+), 1058 deletions(-)

diff --git a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java
index 42236b22751..18d8fcbc8b1 100644
--- a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java
+++ b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java
@@ -309,34 +309,6 @@ public abstract class LofarUtils {
         aComboBox.validate();
     }
 
-    static public BitSet beamletToBitSet(String aS) {
-
-        BitSet aBitSet = new BitSet(216);
-
-        if (aS == null || aS.length() <= 2) {
-            return aBitSet;
-        }
-        //remove [] from string
-        String beamlets = aS.substring(aS.indexOf("[") + 1, aS.lastIndexOf("]"));
-
-        // split into seperate beamlet nr's
-        String[] beamletList = beamlets.split("[,]");
-
-        //fill bitset
-
-        for (int j = 0; j < beamletList.length; j++) {
-            int val;
-            try {
-                val = Integer.parseInt(beamletList[j]);
-                aBitSet.set(val);
-            } catch (NumberFormatException ex) {
-                System.out.println("Error converting beamlet numbers");
-
-            }
-        }
-        return aBitSet;
-    }
-
     static public String ltrim(String aS, String matchSet) {
         String reg = "^[" + matchSet + "]*";
         return Pattern.compile(reg).matcher(aS).replaceAll("");
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/objects/Beam.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/objects/Beam.java
index 34e73be9933..0f949896415 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/objects/Beam.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/objects/Beam.java
@@ -5,8 +5,6 @@
 package nl.astron.lofar.sas.otb.objects;
 
 import java.util.ArrayList;
-import java.util.BitSet;
-import nl.astron.lofar.lofarutils.LofarUtils;
 import nl.astron.lofar.sas.otb.util.IBeam;
 
 /**
@@ -37,14 +35,6 @@ public class Beam implements IBeam {
         this.itsAngle2 = anAngle2;
     }
 
-    public String getBeamletList() {
-        return itsBeamletList;
-    }
-
-    public void setBeamletList(String aBeamletList) {
-        this.itsBeamletList = aBeamletList;
-    }
-
     public String getDirectionType() {
         return itsDirectionType;
     }
@@ -144,9 +134,6 @@ public class Beam implements IBeam {
         this.itsDirectionTypeChoices = directionTypeChoices;
     }
     
-    public BitSet getBeamletBitSet() {
-        return LofarUtils.beamletToBitSet(LofarUtils.expandedArrayString(itsBeamletList));
-    }
     
     public String getTreeType() {
         return itsTreeType;
@@ -170,7 +157,6 @@ public class Beam implements IBeam {
         clone.itsStartTime = itsStartTime;
         clone.itsDuration = itsDuration;
         clone.itsSubbandList = itsSubbandList;
-        clone.itsBeamletList = itsBeamletList;
         clone.itsMomID = itsMomID;
         clone.itsNrTiedArrayBeams = itsNrTiedArrayBeams;     // 
         clone.itsNrTabRings = itsNrTabRings;
@@ -196,7 +182,6 @@ public class Beam implements IBeam {
     private String                   itsStartTime;
     private String                   itsDuration;
     private String                   itsSubbandList;
-    private String                   itsBeamletList;
     private String                   itsMomID;
     private String                   itsNrTiedArrayBeams="1";     // 
     private String                   itsNrTabRings;
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.form
index d46ba855062..e56c37918ec 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.form
@@ -10,7 +10,7 @@
     <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
     <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
     <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-37,0,0,2,84"/>
+    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-37,0,0,3,116"/>
   </AuxValues>
 
   <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.java
index d105bc665b4..9cacee43595 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/panels/MainPanel.java
@@ -20,8 +20,8 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
-
 package nl.astron.lofar.sas.otb.panels;
+
 import java.io.BufferedInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -62,8 +62,8 @@ import org.apache.log4j.Logger;
  * @version $Id$
  * @updated deleteComponentNode added to component panel
  */
-public class MainPanel extends javax.swing.JPanel 
-                       implements IPluginPanel {
+public class MainPanel extends javax.swing.JPanel
+        implements IPluginPanel {
 
     static Logger logger = Logger.getLogger(MainPanel.class);
     static String name = "Home";
@@ -73,8 +73,7 @@ public class MainPanel extends javax.swing.JPanel
         initComponents();
         initializeButtons();
     }
-    
-           
+
     /** 
      * Initializes the buttonpanel. Every tab has different buttons 
      */
@@ -83,111 +82,114 @@ public class MainPanel extends javax.swing.JPanel
         switch (itsTabFocus) {
             case "PIC":
                 buttonPanel1.addButton("State History");
-                buttonPanel1.setButtonIcon("State History",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
+                buttonPanel1.setButtonIcon("State History", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
                 buttonPanel1.addButton("Query Panel");
-                buttonPanel1.setButtonIcon("Query Panel",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
+                buttonPanel1.setButtonIcon("Query Panel", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
                 buttonPanel1.addButton("New");
-                buttonPanel1.setButtonIcon("New",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_new.png")));
+                buttonPanel1.setButtonIcon("New", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_new.png")));
                 buttonPanel1.addButton("Delete");
-                buttonPanel1.setButtonIcon("Delete",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
+                buttonPanel1.setButtonIcon("Delete", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
                 buttonPanel1.addButton("Refresh");
-                buttonPanel1.setButtonIcon("Refresh",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
+                buttonPanel1.setButtonIcon("Refresh", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
                 buttonPanel1.addButton("View");
-                buttonPanel1.setButtonIcon("View",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
+                buttonPanel1.setButtonIcon("View", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
                 buttonPanel1.addButton("Info");
-                buttonPanel1.setButtonIcon("Info",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
-                buttonPanel1.setButtonEnabled("Delete",false);
-                buttonPanel1.setButtonEnabled("View",false);
-                buttonPanel1.setButtonEnabled("Info",false);
-                buttonPanel1.setButtonEnabled("State History",false);
+                buttonPanel1.setButtonIcon("Info", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
+                buttonPanel1.setButtonEnabled("Delete", false);
+                buttonPanel1.setButtonEnabled("View", false);
+                buttonPanel1.setButtonEnabled("Info", false);
+                buttonPanel1.setButtonEnabled("State History", false);
                 break;
             case "VIC":
                 buttonPanel1.addButton("State History");
-                buttonPanel1.setButtonIcon("State History",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
+                buttonPanel1.setButtonIcon("State History", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
                 buttonPanel1.addButton("Query Panel");
-                buttonPanel1.setButtonIcon("Query Panel",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
+                buttonPanel1.setButtonIcon("Query Panel", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
                 buttonPanel1.addButton("Delete");
-                buttonPanel1.setButtonIcon("Delete",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
+                buttonPanel1.setButtonIcon("Delete", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
                 buttonPanel1.addButton("Refresh");
-                buttonPanel1.setButtonIcon("Refresh",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
+                buttonPanel1.setButtonIcon("Refresh", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
                 buttonPanel1.addButton("View");
-                buttonPanel1.setButtonIcon("View",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
+                buttonPanel1.setButtonIcon("View", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
                 buttonPanel1.addButton("Schedule");
-                buttonPanel1.setButtonIcon("Schedule",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
-                buttonPanel1.setButtonEnabled("State History",false);
-                buttonPanel1.setButtonEnabled("Delete",false);
-                buttonPanel1.setButtonEnabled("View",false);
-                buttonPanel1.setButtonEnabled("Schedule",false);
+                buttonPanel1.setButtonIcon("Schedule", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
+                buttonPanel1.setButtonEnabled("State History", false);
+                buttonPanel1.setButtonEnabled("Delete", false);
+                buttonPanel1.setButtonEnabled("View", false);
+                buttonPanel1.setButtonEnabled("Schedule", false);
                 break;
             case "Templates":
                 buttonPanel1.addButton("State History");
-                buttonPanel1.setButtonIcon("State History",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
+                buttonPanel1.setButtonIcon("State History", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
                 buttonPanel1.addButton("Query Panel");
-                buttonPanel1.setButtonIcon("Query Panel",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
+                buttonPanel1.setButtonIcon("Query Panel", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
                 buttonPanel1.addButton("Duplicate");
-                buttonPanel1.setButtonIcon("Duplicate",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_copy.png")));
+                buttonPanel1.setButtonIcon("Duplicate", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_copy.png")));
                 buttonPanel1.addButton("Modify");
-                buttonPanel1.setButtonIcon("Modify",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
+                buttonPanel1.setButtonIcon("Modify", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
                 buttonPanel1.addButton("Delete");
-                buttonPanel1.setButtonIcon("Delete",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
+                buttonPanel1.setButtonIcon("Delete", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
                 buttonPanel1.addButton("Refresh");
-                buttonPanel1.setButtonIcon("Refresh",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
+                buttonPanel1.setButtonIcon("Refresh", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
                 buttonPanel1.addButton("Build VIC tree");
-                buttonPanel1.setButtonIcon("Build VIC tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_new.png")));
+                buttonPanel1.setButtonIcon("Build VIC tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_new.png")));
                 buttonPanel1.addButton("Change Status");
-                buttonPanel1.setButtonIcon("Change Status",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
+                buttonPanel1.setButtonIcon("Change Status", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
                 buttonPanel1.addButton("MultiEdit");
-                buttonPanel1.setButtonIcon("MultiEdit",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif" )));
+                buttonPanel1.setButtonIcon("MultiEdit", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
                 buttonPanel1.addButton("Set to Default");
-                buttonPanel1.setButtonIcon("Set to Default",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_redo.png")));
-                buttonPanel1.setButtonEnabled("Duplicate",false);
-                buttonPanel1.setButtonEnabled("Modify",false);
-                buttonPanel1.setButtonEnabled("Delete",false);
-                buttonPanel1.setButtonEnabled("Build VIC tree",false);
-                buttonPanel1.setButtonEnabled("Change Status",false);
-                buttonPanel1.setButtonEnabled("MultiEdit",false);
-                buttonPanel1.setButtonEnabled("Set to Default",false);
-                buttonPanel1.setButtonEnabled("State History",false);
+                buttonPanel1.setButtonIcon("Set to Default", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_redo.png")));
+                buttonPanel1.setButtonEnabled("Duplicate", false);
+                buttonPanel1.setButtonEnabled("Modify", false);
+                buttonPanel1.setButtonEnabled("Delete", false);
+                buttonPanel1.setButtonEnabled("Build VIC tree", false);
+                buttonPanel1.setButtonEnabled("Change Status", false);
+                buttonPanel1.setButtonEnabled("MultiEdit", false);
+                buttonPanel1.setButtonEnabled("Set to Default", false);
+                buttonPanel1.setButtonEnabled("State History", false);
                 break;
             case "Default Templates":
                 buttonPanel1.addButton("State History");
-                buttonPanel1.setButtonIcon("State History",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
+                buttonPanel1.setButtonIcon("State History", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_info.gif")));
                 buttonPanel1.addButton("Duplicate");
-                buttonPanel1.setButtonIcon("Duplicate",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_copy.png")));
+                buttonPanel1.setButtonIcon("Duplicate", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_copy.png")));
                 buttonPanel1.addButton("Modify");
-                buttonPanel1.setButtonIcon("Modify",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
+                buttonPanel1.setButtonIcon("Modify", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
                 buttonPanel1.addButton("Refresh");
-                buttonPanel1.setButtonIcon("Refresh",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
+                buttonPanel1.setButtonIcon("Refresh", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
+                buttonPanel1.addButton("Remove from Default");
+                buttonPanel1.setButtonIcon("Remove from Default", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
                 buttonPanel1.addButton("Change Status");
-                buttonPanel1.setButtonIcon("Change Status",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
-                buttonPanel1.setButtonEnabled("Modify",false);
-                buttonPanel1.setButtonEnabled("Duplicate",false);
-                buttonPanel1.setButtonEnabled("Change Status",false);
-                buttonPanel1.setButtonEnabled("State History",false);
+                buttonPanel1.setButtonIcon("Change Status", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_fileopen.gif")));
+                buttonPanel1.setButtonEnabled("Modify", false);
+                buttonPanel1.setButtonEnabled("Duplicate", false);
+                buttonPanel1.setButtonEnabled("Remove from Default", false);
+                buttonPanel1.setButtonEnabled("Change Status", false);
+                buttonPanel1.setButtonEnabled("State History", false);
                 break;
             case "Components":
                 buttonPanel1.addButton("Query Panel");
-                buttonPanel1.setButtonIcon("Query Panel",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
+                buttonPanel1.setButtonIcon("Query Panel", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_help.png")));
                 buttonPanel1.addButton("New");
-                buttonPanel1.setButtonIcon("New",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_new.png")));
+                buttonPanel1.setButtonIcon("New", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_new.png")));
                 buttonPanel1.addButton("Modify");
-                buttonPanel1.setButtonIcon("Modify",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
+                buttonPanel1.setButtonIcon("Modify", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_edit.gif")));
                 buttonPanel1.addButton("Delete");
-                buttonPanel1.setButtonIcon("Delete",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
+                buttonPanel1.setButtonIcon("Delete", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_delete.png")));
                 buttonPanel1.addButton("Refresh");
-                buttonPanel1.setButtonIcon("Refresh",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
+                buttonPanel1.setButtonIcon("Refresh", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_refresh_e.gif")));
                 buttonPanel1.addButton("Build TemplateTree");
-                buttonPanel1.setButtonIcon("Build TemplateTree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_redo.png")));
+                buttonPanel1.setButtonIcon("Build TemplateTree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_redo.png")));
                 //            buttonPanel1.setButtonEnabled("Delete",false);
-                buttonPanel1.setButtonEnabled("Modify",false);
-                buttonPanel1.setButtonEnabled("Build TemplateTree",false);
+                buttonPanel1.setButtonEnabled("Modify", false);
+                buttonPanel1.setButtonEnabled("Build TemplateTree", false);
                 break;
             case "Query Results":
                 break;
         }
         buttonPanel1.addButton("Quit");
-        buttonPanel1.setButtonIcon("Quit",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_exit2.png")));
-        buttonsInitialized=true;
+        buttonPanel1.setButtonIcon("Quit", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_exit2.png")));
+        buttonsInitialized = true;
     }
 
     /** 
@@ -199,25 +201,25 @@ public class MainPanel extends javax.swing.JPanel
      */
     public boolean initializePlugin(MainFrame mainframe) {
         itsMainFrame = mainframe;
-        
+
         // check access
         UserAccount userAccount = itsMainFrame.getUserAccount();
-        if(userAccount.isAdministrator()) {
+        if (userAccount.isAdministrator()) {
             // enable/disable certain controls
         }
-        if(userAccount.isAstronomer()) {
+        if (userAccount.isAstronomer()) {
             // enable/disable certain controls
         }
-        if(userAccount.isInstrumentScientist()) {
+        if (userAccount.isInstrumentScientist()) {
             // enable/disable certain controls
         }
-        
+
         initializeTabs();
-        
+
         return true;
-        
+
     }
-    
+
     /** 
      * Initializes the tab-panels. Each tab has a specific table model that
      * contains the data for the table in the tab
@@ -226,45 +228,45 @@ public class MainPanel extends javax.swing.JPanel
         PICtableModel PICmodel = new PICtableModel(SharedVars.getOTDBrmi());
         PICPanel.setTableModel(PICmodel);
         PICPanel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-        PICPanel.setColumnSize("ID",35);
-        PICPanel.setColumnSize("Description",700);
+        PICPanel.setColumnSize("ID", 35);
+        PICPanel.setColumnSize("Description", 700);
         PICPanel.setAutoCreateRowSorter(true);
         PICPanel.setTableCellAlignment(JLabel.LEFT);
-        
+
 
         VICtableModel VICmodel = new VICtableModel(SharedVars.getOTDBrmi());
         VICPanel.setTableModel(VICmodel);
         VICPanel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-        VICPanel.setColumnSize("ID",40);
+        VICPanel.setColumnSize("ID", 40);
         VICPanel.setColumnSize("PType", 60);
         VICPanel.setColumnSize("PStype", 60);
         VICPanel.setColumnSize("Strat", 60);
-        VICPanel.setColumnSize("StartTime",150);
-        VICPanel.setColumnSize("StopTime",150);
-        VICPanel.setColumnSize("Description",300);
+        VICPanel.setColumnSize("StartTime", 150);
+        VICPanel.setColumnSize("StopTime", 150);
+        VICPanel.setColumnSize("Description", 300);
         VICPanel.setAutoCreateRowSorter(true);
         VICPanel.setTableCellAlignment(JLabel.LEFT);
-        
+
         TemplatetableModel Templatemodel = new TemplatetableModel(SharedVars.getOTDBrmi());
         TemplatesPanel.setTableModel(Templatemodel);
         TemplatesPanel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-        TemplatesPanel.setColumnSize("ID",40);
+        TemplatesPanel.setColumnSize("ID", 40);
         TemplatesPanel.setColumnSize("PType", 60);
         TemplatesPanel.setColumnSize("PStype", 60);
         TemplatesPanel.setColumnSize("Strat", 60);
-        TemplatesPanel.setColumnSize("Description",300);
+        TemplatesPanel.setColumnSize("Description", 300);
         TemplatesPanel.setAutoCreateRowSorter(true);
         TemplatesPanel.setTableCellAlignment(JLabel.LEFT);
 
         DefaultTemplatetableModel DefaultTemplatemodel = new DefaultTemplatetableModel(SharedVars.getOTDBrmi());
         DefaultTemplatesPanel.setTableModel(DefaultTemplatemodel);
-        DefaultTemplatesPanel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-        DefaultTemplatesPanel.setColumnSize("ID",40);
-        DefaultTemplatesPanel.setColumnSize("Name",150);
+        DefaultTemplatesPanel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+        DefaultTemplatesPanel.setColumnSize("ID", 40);
+        DefaultTemplatesPanel.setColumnSize("Name", 150);
         DefaultTemplatesPanel.setColumnSize("PType", 60);
         DefaultTemplatesPanel.setColumnSize("PStype", 60);
         DefaultTemplatesPanel.setColumnSize("Strat", 60);
-        DefaultTemplatesPanel.setColumnSize("Description",300);
+        DefaultTemplatesPanel.setColumnSize("Description", 300);
         DefaultTemplatesPanel.setAutoCreateRowSorter(true);
         DefaultTemplatesPanel.setTableCellAlignment(JLabel.LEFT);
 
@@ -272,14 +274,14 @@ public class MainPanel extends javax.swing.JPanel
         ComponentTableModel Componentmodel = new ComponentTableModel(SharedVars.getOTDBrmi());
         ComponentsPanel.setTableModel(Componentmodel);
         ComponentsPanel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-        ComponentsPanel.setColumnSize("ID",50);
-        ComponentsPanel.setColumnSize("Description",685);
+        ComponentsPanel.setColumnSize("ID", 50);
+        ComponentsPanel.setColumnSize("Description", 685);
         ComponentsPanel.setAutoCreateRowSorter(true);
         ComponentsPanel.setTableCellAlignment(JLabel.LEFT);
-        
+
         //TODO: do the same for the other tabs
     }
-    
+
     /** 
      * Returns the human-readable name of this panel
      *
@@ -288,16 +290,15 @@ public class MainPanel extends javax.swing.JPanel
     public String getFriendlyName() {
         return getFriendlyNameStatic();
     }
-    
+
     public boolean hasChanged() {
         return changed;
     }
-    
+
     public void setChanged(boolean flag) {
         changed = flag;
     }
 
-
     public void checkChanged() {
         if (inputFieldBuilder.currentInputField != null) {
             inputFieldBuilder.currentInputField.checkPopup();
@@ -305,31 +306,31 @@ public class MainPanel extends javax.swing.JPanel
         logger.debug("Check Changed status");
         if (this.hasChanged()) {
             // keep selected tree
-            int aSavedID=itsMainFrame.getSharedVars().getTreeID();
+            int aSavedID = itsMainFrame.getSharedVars().getTreeID();
             itsMainFrame.setHourglassCursor();
             switch (itsTabFocus) {
                 case "PIC":
-                    if (!((PICtableModel)PICPanel.getTableModel()).fillTable()) {
+                    if (!((PICtableModel) PICPanel.getTableModel()).fillTable()) {
                         logger.error("error filling PICtable");
                     }
                     break;
                 case "VIC":
-                    if (!((VICtableModel)VICPanel.getTableModel()).fillTable()) {
+                    if (!((VICtableModel) VICPanel.getTableModel()).fillTable()) {
                         logger.error("error filling VICtable");
                     }
                     break;
                 case "Templates":
-                    if (!((TemplatetableModel)TemplatesPanel.getTableModel()).fillTable()) {
+                    if (!((TemplatetableModel) TemplatesPanel.getTableModel()).fillTable()) {
                         logger.error("error filling templateTable");
                     }
                     break;
                 case "Default Templates":
-                    if (!((DefaultTemplatetableModel)DefaultTemplatesPanel.getTableModel()).fillTable()) {
+                    if (!((DefaultTemplatetableModel) DefaultTemplatesPanel.getTableModel()).fillTable()) {
                         logger.error("error filling Default templateTable");
                     }
                     break;
                 case "Components":
-                    if (!((ComponentTableModel)ComponentsPanel.getTableModel()).fillTable()) {
+                    if (!((ComponentTableModel) ComponentsPanel.getTableModel()).fillTable()) {
                         logger.error("error filling ComponentsTable");
                     }
                     break;
@@ -337,14 +338,14 @@ public class MainPanel extends javax.swing.JPanel
             if (aSavedID > 0) {
                 itsMainFrame.getSharedVars().setTreeID(aSavedID);
                 this.setSelectedID(aSavedID);
-            }   
+            }
             this.setChanged(false);
             this.validate();
             this.validateButtons();
             itsMainFrame.setNormalCursor();
-        } 
+        }
     }
-    
+
     /** 
      * Static method that returns the human-readable name of this panel
      *
@@ -353,7 +354,7 @@ public class MainPanel extends javax.swing.JPanel
     public static String getFriendlyNameStatic() {
         return name;
     }
-    
+
     /** This method is called from within the constructor to
      * initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is
@@ -444,15 +445,14 @@ public class MainPanel extends javax.swing.JPanel
     }//GEN-LAST:event_jTabbedPane1PropertyChange
 
     private void QueryResultsPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_QueryResultsPanelMouseClicked
-        if(evt.getClickCount() == 1) {
+        if (evt.getClickCount() == 1) {
             validateButtons();
         } else {
-
         }
     }//GEN-LAST:event_QueryResultsPanelMouseClicked
 
     private void ComponentsPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ComponentsPanelMouseClicked
-        if(evt.getClickCount() == 1) {
+        if (evt.getClickCount() == 1) {
             validateButtons();
         } else {
             if (buttonPanel1.isButtonEnabled("Modify") && buttonPanel1.isButtonVisible("Modify")) {
@@ -462,7 +462,7 @@ public class MainPanel extends javax.swing.JPanel
     }//GEN-LAST:event_ComponentsPanelMouseClicked
 
     private void TemplatesPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TemplatesPanelMouseClicked
-        if(evt.getClickCount() == 1) {
+        if (evt.getClickCount() == 1) {
             validateButtons();
         } else {
             if (buttonPanel1.isButtonEnabled("Modify") && buttonPanel1.isButtonVisible("Modify")) {
@@ -472,7 +472,7 @@ public class MainPanel extends javax.swing.JPanel
     }//GEN-LAST:event_TemplatesPanelMouseClicked
 
     private void VICPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_VICPanelMouseClicked
-        if(evt.getClickCount() == 1) {
+        if (evt.getClickCount() == 1) {
             validateButtons();
         } else {
             if (buttonPanel1.isButtonEnabled("View") && buttonPanel1.isButtonVisible("View")) {
@@ -482,7 +482,7 @@ public class MainPanel extends javax.swing.JPanel
     }//GEN-LAST:event_VICPanelMouseClicked
 
     private void PICPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_PICPanelMouseClicked
-        if(evt.getClickCount() == 1) {
+        if (evt.getClickCount() == 1) {
             validateButtons();
         } else {
             if (buttonPanel1.isButtonEnabled("View") && buttonPanel1.isButtonVisible("View")) {
@@ -493,19 +493,19 @@ public class MainPanel extends javax.swing.JPanel
 
     private void jTabbedPane1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jTabbedPane1StateChanged
         if (!itsTabFocus.equals(jTabbedPane1.getTitleAt(jTabbedPane1.getSelectedIndex()))) {
-            itsTabFocus=jTabbedPane1.getTitleAt(jTabbedPane1.getSelectedIndex());
+            itsTabFocus = jTabbedPane1.getTitleAt(jTabbedPane1.getSelectedIndex());
             // force reload
-            logger.debug("Tab changed, force reload: "+ itsTabFocus);
+            logger.debug("Tab changed, force reload: " + itsTabFocus);
             this.setChanged(true);
         }
-        if (buttonsInitialized) {        
+        if (buttonsInitialized) {
             initializeButtons();
             validateButtons();
-           // Force a refresh since MoM/scheduler might have added something to the trees
-           //set changed flag, we want to refresh the tree
-           logger.debug("Refresh table");
-           itsMainFrame.setChanged(this.getFriendlyName(),true);
-           checkChanged();
+            // Force a refresh since MoM/scheduler might have added something to the trees
+            //set changed flag, we want to refresh the tree
+            logger.debug("Refresh table");
+            itsMainFrame.setChanged(this.getFriendlyName(), true);
+            checkChanged();
         }
 
 
@@ -517,7 +517,7 @@ public class MainPanel extends javax.swing.JPanel
     }//GEN-LAST:event_buttonPanel1ActionPerformed
 
     private void DefaultTemplatesPanelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DefaultTemplatesPanelMouseClicked
-        if(evt.getClickCount() == 1) {
+        if (evt.getClickCount() == 1) {
             validateButtons();
         } else {
             if (buttonPanel1.isButtonEnabled("Modify") && buttonPanel1.isButtonVisible("Modify")) {
@@ -525,10 +525,10 @@ public class MainPanel extends javax.swing.JPanel
             }
         }
     }//GEN-LAST:event_DefaultTemplatesPanelMouseClicked
-    
+
     /** Returns the selected row in the present tree */
     private int getSelectedRow() {
-        int aRow=-1;
+        int aRow = -1;
         switch (itsTabFocus) {
             case "PIC":
                 aRow = PICPanel.getSelectedRow();
@@ -551,7 +551,7 @@ public class MainPanel extends javax.swing.JPanel
 
     /** Returns the selected rows in the present tree */
     private int[] getSelectedRows() {
-        int [] rows=null;
+        int[] rows = null;
         switch (itsTabFocus) {
             case "PIC":
                 rows = PICPanel.getSelectedRows();
@@ -594,51 +594,51 @@ public class MainPanel extends javax.swing.JPanel
             }
         }
     }
-    
+
     /** Returns the ids of the selected Trees in case of a multiple selection */
-    private int [] getSelectedTreeIDs() {
-        int [] rows=this.getSelectedRows();
-        int [] treeIDs=new int[rows.length];
+    private int[] getSelectedTreeIDs() {
+        int[] rows = this.getSelectedRows();
+        int[] treeIDs = new int[rows.length];
         switch (itsTabFocus) {
             case "PIC":
-                for (int i=0; i < rows.length; i++) {
-                    treeIDs[i] = ((Integer)PICPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
+                for (int i = 0; i < rows.length; i++) {
+                    treeIDs[i] = ((Integer) PICPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
                 }
                 break;
             case "VIC":
-                for (int i=0; i < rows.length; i++) {
-                    treeIDs[i] = ((Integer)VICPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
+                for (int i = 0; i < rows.length; i++) {
+                    treeIDs[i] = ((Integer) VICPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
                 }
                 break;
             case "Templates":
-                for (int i=0; i < rows.length; i++) {
-                    treeIDs[i] = ((Integer)TemplatesPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
+                for (int i = 0; i < rows.length; i++) {
+                    treeIDs[i] = ((Integer) TemplatesPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
                 }
                 break;
             case "Default Templates":
-                for (int i=0; i < rows.length; i++) {
-                    treeIDs[i] = ((Integer)DefaultTemplatesPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
+                for (int i = 0; i < rows.length; i++) {
+                    treeIDs[i] = ((Integer) DefaultTemplatesPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
                 }
                 break;
             case "Components":
-                for (int i=0; i < rows.length; i++) {
+                for (int i = 0; i < rows.length; i++) {
                     // is the node ID in the case of Components
-                    treeIDs[i] = ((Integer)ComponentsPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
+                    treeIDs[i] = ((Integer) ComponentsPanel.getTableModel().getValueAt(rows[i], 0)).intValue();
                 }
                 break;
         }
 
-        return treeIDs;   
+        return treeIDs;
     }
 
     /** Returns the id of the selected Tree */
     private int getSelectedTreeID() {
-        int treeID=0;
-        int aRow=this.getSelectedRow();
+        int treeID = 0;
+        int aRow = this.getSelectedRow();
         switch (itsTabFocus) {
             case "PIC":
-                if ( aRow > -1) {
-                    treeID = ((Integer)PICPanel.getTableModel().getValueAt(aRow, 0)).intValue();
+                if (aRow > -1) {
+                    treeID = ((Integer) PICPanel.getTableModel().getValueAt(aRow, 0)).intValue();
                     if (treeID > 0) {
                         itsMainFrame.getSharedVars().setTreeID(treeID);
                     } else {
@@ -647,8 +647,8 @@ public class MainPanel extends javax.swing.JPanel
                 }
                 break;
             case "VIC":
-                if ( aRow > -1) {
-                    treeID = ((Integer)VICPanel.getTableModel().getValueAt(aRow, 0)).intValue();
+                if (aRow > -1) {
+                    treeID = ((Integer) VICPanel.getTableModel().getValueAt(aRow, 0)).intValue();
                     if (treeID > 0) {
                         itsMainFrame.getSharedVars().setTreeID(treeID);
                     } else {
@@ -657,8 +657,8 @@ public class MainPanel extends javax.swing.JPanel
                 }
                 break;
             case "Templates":
-                if ( aRow > -1) {
-                    treeID = ((Integer)TemplatesPanel.getTableModel().getValueAt(aRow, 0)).intValue();
+                if (aRow > -1) {
+                    treeID = ((Integer) TemplatesPanel.getTableModel().getValueAt(aRow, 0)).intValue();
                     if (treeID > 0) {
                         itsMainFrame.getSharedVars().setTreeID(treeID);
                     } else {
@@ -667,8 +667,8 @@ public class MainPanel extends javax.swing.JPanel
                 }
                 break;
             case "Default Templates":
-                if ( aRow > -1) {
-                    treeID = ((Integer)DefaultTemplatesPanel.getTableModel().getValueAt(aRow, 0)).intValue();
+                if (aRow > -1) {
+                    treeID = ((Integer) DefaultTemplatesPanel.getTableModel().getValueAt(aRow, 0)).intValue();
                     if (treeID > 0) {
                         itsMainFrame.getSharedVars().setTreeID(treeID);
                     } else {
@@ -677,9 +677,9 @@ public class MainPanel extends javax.swing.JPanel
                 }
                 break;
             case "Components":
-                if ( aRow > -1) {
+                if (aRow > -1) {
                     // is the node ID in the case of Components
-                    treeID = ((Integer)ComponentsPanel.getTableModel().getValueAt(aRow, 0)).intValue();
+                    treeID = ((Integer) ComponentsPanel.getTableModel().getValueAt(aRow, 0)).intValue();
                     if (treeID > 0) {
                         itsMainFrame.getSharedVars().setComponentID(treeID);
                     } else {
@@ -690,24 +690,24 @@ public class MainPanel extends javax.swing.JPanel
         }
         return treeID;
     }
-    
+
     /** Perform actions depending on the Button pressed and the Tab active
      *
      * @param   aButton     Name of the pressed button
      */
     private void buttonPanelAction(String aButton) {
-        logger.debug("Button pressed: "+aButton+ "  ActiveTab: " + itsTabFocus);
+        logger.debug("Button pressed: " + aButton + "  ActiveTab: " + itsTabFocus);
         if (inputFieldBuilder.currentInputField != null) {
             inputFieldBuilder.currentInputField.checkPopup();
         }
-        int treeID=getSelectedTreeID();
+        int treeID = getSelectedTreeID();
         switch (aButton) {
             case "Quit":
                 itsMainFrame.exit();
                 return;
             case "Refresh":
                 //set changed flag, we want to refresh the tree
-                itsMainFrame.setChanged(this.getFriendlyName(),true);
+                itsMainFrame.setChanged(this.getFriendlyName(), true);
                 checkChanged();
                 return;
         }
@@ -716,576 +716,604 @@ public class MainPanel extends javax.swing.JPanel
                 if (treeID > 0) {
                     itsMainFrame.getSharedVars().setTreeID(treeID);
                 } else if (!aButton.equals("New")) {
-                    LofarUtils.showErrorPanel(this,"You didn't select a tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                    LofarUtils.showErrorPanel(this, "You didn't select a tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
 
                     return;
                 }
-        switch (aButton) {
-            case "Query Panel":
-                // TODO open Query Panel
-                itsMainFrame.ToDo();
-                break;
-            case "State History":
-                if (treeID > 0) {
-                    viewStateChanges(treeID);
-                }
-                break;
-            case "New":
-                if (getFile("PIC-tree")) {
-                    try {
-                       // the file obviously resides at the client side, and needs to be transfered to the server side.
-                       byte uldata[] = new byte[(int)itsNewFile.length()]; 
-                try (BufferedInputStream input = new BufferedInputStream(new FileInputStream(itsNewFile))) {
-                    input.read(uldata,0,uldata.length);
-                }
-                       String aFileName= "/tmp/"+itsMainFrame.getUserAccount().getUserName()+"_"+itsNewFile.getName();
-                       if (OtdbRmi.getRemoteFileTrans().uploadFile(uldata,aFileName)) {
-                           logger.debug("upload finished");                       
-                           // Create a new Tree from the found file.
-                           int aTreeID=OtdbRmi.getRemoteMaintenance().loadMasterFile(aFileName);
-                           if (aTreeID < 1) {
-                               String aS="Error on fileLoad: " + aFileName;
-                               logger.error(aS);
-                               LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                           } else {
-                               // set changed flag to reload mainpanel
-                               itsMainFrame.setChanged(this.getFriendlyName(),true);
-                               // set the new created TreeID to active and fill description stuff if needed
-                               itsMainFrame.getSharedVars().setTreeID(aTreeID);
-                               checkChanged();
-                               if (!itsFileDescription.equals("")) {
-                                  if (!OtdbRmi.getRemoteMaintenance().setDescription(aTreeID,itsFileDescription)) {
-                                      String aS="Error during setDescription in Tree "+OtdbRmi.getRemoteMaintenance().errorMsg();
-                                     logger.error(aS);
-                                     LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                                  }
-                               }
-                                  
-                               if (!itsFileStatus.equals("")) {
-                                  if (!OtdbRmi.getRemoteMaintenance().setTreeState(aTreeID,OtdbRmi.getRemoteTypes().getTreeState(itsFileStatus))) {
-                                      String aS="Error during setStatus in Tree "+OtdbRmi.getRemoteMaintenance().errorMsg();
-                                     logger.error(aS);
-                                     LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                                  }
-                               }                               
-                           }
-                           ResultBrowserPanel aP=(ResultBrowserPanel)itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ResultBrowserPanel", true, true);
-                           if (aP != null) {
-                              itsMainFrame.showPanel(aP.getFriendlyName());
-                           }
+                switch (aButton) {
+                    case "Query Panel":
+                        // TODO open Query Panel
+                        itsMainFrame.ToDo();
+                        break;
+                    case "State History":
+                        if (treeID > 0) {
+                            viewStateChanges(treeID);
                         }
-                   } catch (RemoteException ex) {
-                       String aS="Error during newPICTree creation: "+ ex;
-                       logger.error(aS);
-                       LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                   } catch (FileNotFoundException ex) {
-                       String aS="Error during newPICTree creation: "+ ex;
-                       logger.error(aS);
-                       LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                   } catch (IOException ex) {
-                       String aS="Error during newPICTree creation: "+ ex;
-                       logger.error(aS);
-                       LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                   }
-                }
-                break;
-            case "Delete":
-                if (JOptionPane.showConfirmDialog(this,"Are you sure you want to delete this tree(s): ?","Delete Tree",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-                    try {
-                        int[] treeIDs=getSelectedTreeIDs();
-                        for (int i=0;i< treeIDs.length;i++) {
-                            if (!OtdbRmi.getRemoteMaintenance().deleteTree(treeIDs[i])) {
-                                String aS="Failed to delete tree: "+treeIDs[i];
+                        break;
+                    case "New":
+                        if (getFile("PIC-tree")) {
+                            try {
+                                // the file obviously resides at the client side, and needs to be transfered to the server side.
+                                byte uldata[] = new byte[(int) itsNewFile.length()];
+                                try (BufferedInputStream input = new BufferedInputStream(new FileInputStream(itsNewFile))) {
+                                    input.read(uldata, 0, uldata.length);
+                                }
+                                String aFileName = "/tmp/" + itsMainFrame.getUserAccount().getUserName() + "_" + itsNewFile.getName();
+                                if (OtdbRmi.getRemoteFileTrans().uploadFile(uldata, aFileName)) {
+                                    logger.debug("upload finished");
+                                    // Create a new Tree from the found file.
+                                    int aTreeID = OtdbRmi.getRemoteMaintenance().loadMasterFile(aFileName);
+                                    if (aTreeID < 1) {
+                                        String aS = "Error on fileLoad: " + aFileName;
+                                        logger.error(aS);
+                                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                    } else {
+                                        // set changed flag to reload mainpanel
+                                        itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                        // set the new created TreeID to active and fill description stuff if needed
+                                        itsMainFrame.getSharedVars().setTreeID(aTreeID);
+                                        checkChanged();
+                                        if (!itsFileDescription.equals("")) {
+                                            if (!OtdbRmi.getRemoteMaintenance().setDescription(aTreeID, itsFileDescription)) {
+                                                String aS = "Error during setDescription in Tree " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                                logger.error(aS);
+                                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                            }
+                                        }
+
+                                        if (!itsFileStatus.equals("")) {
+                                            if (!OtdbRmi.getRemoteMaintenance().setTreeState(aTreeID, OtdbRmi.getRemoteTypes().getTreeState(itsFileStatus))) {
+                                                String aS = "Error during setStatus in Tree " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                                logger.error(aS);
+                                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                            }
+                                        }
+                                    }
+                                    ResultBrowserPanel aP = (ResultBrowserPanel) itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ResultBrowserPanel", true, true);
+                                    if (aP != null) {
+                                        itsMainFrame.showPanel(aP.getFriendlyName());
+                                    }
+                                }
+                            } catch (RemoteException ex) {
+                                String aS = "Error during newPICTree creation: " + ex;
                                 logger.error(aS);
-                                LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            } catch (FileNotFoundException ex) {
+                                String aS = "Error during newPICTree creation: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            } catch (IOException ex) {
+                                String aS = "Error during newPICTree creation: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                             }
                         }
-                    } catch (RemoteException ex) {
-                        String aS="Remote error during deleteTree: "+ ex;
-                        logger.error(aS);
-                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    }
-                    itsMainFrame.setHourglassCursor();
-                    ((PICtableModel)PICPanel.getTableModel()).fillTable();
-                    itsMainFrame.setNormalCursor();
-                }
-                break;
-            case "View":
-                ResultBrowserPanel aP=(ResultBrowserPanel)itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ResultBrowserPanel", true, true);
-                if (aP != null) {
-                    itsMainFrame.showPanel(aP.getFriendlyName());
-                }
-                break;
-            case "Info":
-                if (treeID > 0) {
-                    int [] id=new int[1];
-                    id[0]=treeID;
-                    if (viewInfo(id)) {
-                        
-                        logger.debug("Tree has been changed, reloading tableline");
-                          itsMainFrame.setChanged(this.getFriendlyName(),true);
-                          checkChanged();
-                    }
+                        break;
+                    case "Delete":
+                        if (JOptionPane.showConfirmDialog(this, "Are you sure you want to delete this tree(s): ?", "Delete Tree", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
+                            try {
+                                int[] treeIDs = getSelectedTreeIDs();
+                                for (int i = 0; i < treeIDs.length; i++) {
+                                    if (!OtdbRmi.getRemoteMaintenance().deleteTree(treeIDs[i])) {
+                                        String aS = "Failed to delete tree: " + treeIDs[i];
+                                        logger.error(aS);
+                                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                    }
+                                }
+                            } catch (RemoteException ex) {
+                                String aS = "Remote error during deleteTree: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            }
+                            itsMainFrame.setHourglassCursor();
+                            ((PICtableModel) PICPanel.getTableModel()).fillTable();
+                            itsMainFrame.setNormalCursor();
+                        }
+                        break;
+                    case "View":
+                        ResultBrowserPanel aP = (ResultBrowserPanel) itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ResultBrowserPanel", true, true);
+                        if (aP != null) {
+                            itsMainFrame.showPanel(aP.getFriendlyName());
+                        }
+                        break;
+                    case "Info":
+                        if (treeID > 0) {
+                            int[] id = new int[1];
+                            id[0] = treeID;
+                            if (viewInfo(id)) {
+
+                                logger.debug("Tree has been changed, reloading tableline");
+                                itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                checkChanged();
+                            }
+                        }
+                        break;
                 }
                 break;
-        }
-                break;
             case "VIC":
                 if (treeID > 0) {
                     itsMainFrame.getSharedVars().setTreeID(treeID);
                 } else {
-                    LofarUtils.showErrorPanel(this, "You didn't select a tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                    LofarUtils.showErrorPanel(this, "You didn't select a tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                     return;
                 }
-        switch (aButton) {
-            case "Query Panel":
-                // TODO open Query Panel
-                itsMainFrame.ToDo();
-                break;
-            case "State History":
-                if (treeID > 0) {
-                    viewStateChanges(treeID);
-                }
-                break;
-            case "Delete":
-                if (JOptionPane.showConfirmDialog(this,"Are you sure you want to delete this tree(s): ?","Delete Tree",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-                    try {
-                        int[] treeIDs=getSelectedTreeIDs();
-                        for (int i=0;i< treeIDs.length;i++) {
-                            if (!OtdbRmi.getRemoteMaintenance().deleteTree(treeIDs[i])) {
-                                String aS="Failed to delete tree: "+treeIDs[i];
+                switch (aButton) {
+                    case "Query Panel":
+                        // TODO open Query Panel
+                        itsMainFrame.ToDo();
+                        break;
+                    case "State History":
+                        if (treeID > 0) {
+                            viewStateChanges(treeID);
+                        }
+                        break;
+                    case "Delete":
+                        if (JOptionPane.showConfirmDialog(this, "Are you sure you want to delete this tree(s): ?", "Delete Tree", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
+                            try {
+                                int[] treeIDs = getSelectedTreeIDs();
+                                for (int i = 0; i < treeIDs.length; i++) {
+                                    if (!OtdbRmi.getRemoteMaintenance().deleteTree(treeIDs[i])) {
+                                        String aS = "Failed to delete tree: " + treeIDs[i];
+                                        logger.error(aS);
+                                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                    }
+                                }
+                            } catch (RemoteException ex) {
+                                String aS = "Remote error during deleteTree: " + ex;
                                 logger.error(aS);
-                                LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                             }
+                            itsMainFrame.setHourglassCursor();
+                            ((VICtableModel) VICPanel.getTableModel()).fillTable();
+                            itsMainFrame.setNormalCursor();
                         }
-                    } catch (RemoteException ex) {
-                        String aS="Remote error during deleteTree: "+ ex;
-                        logger.error(aS);
-                        LofarUtils.showErrorPanel(this, aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    }
-                    itsMainFrame.setHourglassCursor();
-                    ((VICtableModel)VICPanel.getTableModel()).fillTable();
-                    itsMainFrame.setNormalCursor();
-                }
-                break;
-            case "View":
-                ResultBrowserPanel aP=(ResultBrowserPanel)itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ResultBrowserPanel", true, true);
-                if (aP != null) {
-                    itsMainFrame.showPanel(aP.getFriendlyName());
+                        break;
+                    case "View":
+                        ResultBrowserPanel aP = (ResultBrowserPanel) itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ResultBrowserPanel", true, true);
+                        if (aP != null) {
+                            itsMainFrame.showPanel(aP.getFriendlyName());
+                        }
+                        break;
+                    case "Schedule":
+                        // in case of VICtree we have the possibility of changing a multiple selection
+                        // so things like start and/or stoptimes can be set for a few entries at once
+                        if (this.VICPanel.getSelectedRowCount() > 0) {
+                            if (viewInfo(this.getSelectedTreeIDs())) {
+                                logger.debug("Tree has been changed, reloading tableline");
+                                itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                checkChanged();
+                            }
+
+                        }
+                        break;
                 }
                 break;
-            case "Schedule":
-                // in case of VICtree we have the possibility of changing a multiple selection
-                // so things like start and/or stoptimes can be set for a few entries at once
-                if (this.VICPanel.getSelectedRowCount() > 0) {
-                    if (viewInfo(this.getSelectedTreeIDs()) ) {
-                        logger.debug("Tree has been changed, reloading tableline");
-                          itsMainFrame.setChanged(this.getFriendlyName(),true);
-                          checkChanged();
+            case "Templates": {
+                jOTDBtree aTree = null;
+                String aTreeState = "";
+                if (treeID > 0) {
+                    itsMainFrame.getSharedVars().setTreeID(treeID);
+                    try {
+                        aTree = OtdbRmi.getRemoteOTDB().getTreeInfo(treeID, false);
+                        aTreeState = OtdbRmi.getRemoteTypes().getTreeState(aTree.state);
+                    } catch (RemoteException ex) {
+                        String aS = "Error during Remote treeMaintenance";
+                        logger.debug(aS);
+                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                     }
-                    
+                } else {
+
+                    LofarUtils.showErrorPanel(this, "You didn't select a tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                    return;
                 }
-                break;
-        }
-                break;
-            case "Templates":
-                {
-                    jOTDBtree aTree=null;
-                    String aTreeState="";
-                    if (treeID > 0) {
-                        itsMainFrame.getSharedVars().setTreeID(treeID);
-                        try {
-                            aTree =    OtdbRmi.getRemoteOTDB().getTreeInfo(treeID,false);
-                            aTreeState=OtdbRmi.getRemoteTypes().getTreeState(aTree.state);
-                        } catch (RemoteException ex) {
-                            String aS="Error during Remote treeMaintenance";
-                            logger.debug(aS);
-                            LofarUtils.showErrorPanel(this, aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                switch (aButton) {
+                    case "Query Panel":
+                        itsMainFrame.ToDo();
+                        break;
+                    case "State History":
+                        if (treeID > 0) {
+                            viewStateChanges(treeID);
                         }
-                    } else {
+                        break;
+                    case "Duplicate":
+                        if (treeID < 1) {
+                            LofarUtils.showErrorPanel(this, "You didn't select a tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                        } else {
+                            try {
+                                int newTreeID = OtdbRmi.getRemoteMaintenance().copyTemplateTree(treeID);
+                                if (newTreeID > 0) {
+                                    JOptionPane.showMessageDialog(this, "New Tree created with ID: " + newTreeID,
+                                            "New Tree Message",
+                                            JOptionPane.INFORMATION_MESSAGE);
+                                    // set back treestate to described
+                                    jOTDBtree aT = OtdbRmi.getRemoteOTDB().getTreeInfo(newTreeID, false);
+                                    if (aT.state != OtdbRmi.getRemoteTypes().getTreeState("described")) {
+                                        aT.state = OtdbRmi.getRemoteTypes().getTreeState("described");
+                                        if (!OtdbRmi.getRemoteMaintenance().setTreeState(aT.treeID(), aT.state)) {
+                                            String aS = "Error during setTreeState: " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                            logger.error(aS);
+                                            LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                        }
+                                    }
+                                    // check momID, if not zero set to zero
+                                    if (aT.momID() != 0) {
+                                        if (!OtdbRmi.getRemoteMaintenance().setMomInfo(aT.treeID(), 0, aT.groupID, aT.campaign)) {
+                                            String aS = "Error during setMomInfo: " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                            logger.debug(aS);
+                                            LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                        }
 
-                        LofarUtils.showErrorPanel(this, "You didn't select a tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                        return;
-                    }
-            switch (aButton) {
-                case "Query Panel":
-                    itsMainFrame.ToDo();
-                    break;
-                case "State History":
-                    if (treeID > 0) {
-                        viewStateChanges(treeID);
-                    }
-                    break;
-                case "Duplicate":
-                    if (treeID < 1) {
-                        LofarUtils.showErrorPanel(this, "You didn't select a tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    } else {
-                        try {
-                            int newTreeID=OtdbRmi.getRemoteMaintenance().copyTemplateTree(treeID);
-                            if (newTreeID > 0) {
-                                JOptionPane.showMessageDialog(this,"New Tree created with ID: "+newTreeID,
-                                    "New Tree Message",
-                                    JOptionPane.INFORMATION_MESSAGE);
-                                // set back treestate to described
-                                jOTDBtree aT=OtdbRmi.getRemoteOTDB().getTreeInfo(newTreeID, false); 
-                                if (aT.state != OtdbRmi.getRemoteTypes().getTreeState("described") ) {
-                                    aT.state=OtdbRmi.getRemoteTypes().getTreeState("described");
-                                    if (!OtdbRmi.getRemoteMaintenance().setTreeState(aT.treeID(), aT.state)) {
-                                        String aS="Error during setTreeState: "+OtdbRmi.getRemoteMaintenance().errorMsg();
-                                        logger.error(aS);
-                                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                                     }
+                                    itsMainFrame.getSharedVars().setTreeID(newTreeID);
+                                    // set changed flag to reload mainpanel
+                                    itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                    checkChanged();
+                                } else {
+                                    logger.debug("No Template Tree created!!!");
                                 }
-                                // check momID, if not zero set to zero
-                                if (aT.momID() != 0) {
-                                    if (!OtdbRmi.getRemoteMaintenance().setMomInfo(aT.treeID(),0,aT.groupID,aT.campaign)) {
-                                        String aS="Error during setMomInfo: "+OtdbRmi.getRemoteMaintenance().errorMsg();
-                                        logger.debug(aS);
-                                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                                    }
 
+                            } catch (RemoteException ex) {
+                                String aS = "Remote error during Build TemplateTree: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            }
+                        }
+                        break;
+                    case "Modify":
+                        TemplateMaintenancePanel aP = (TemplateMaintenancePanel) itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.TemplateMaintenancePanel", true, true);
+                        if (aP != null) {
+                            itsMainFrame.showPanel(aP.getFriendlyName());
+                        }
+                        break;
+                    case "Delete":
+                        if (JOptionPane.showConfirmDialog(this, "Are you sure you want to delete this tree(s) ?", "Delete Tree", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
+                            try {
+                                int[] treeIDs = getSelectedTreeIDs();
+                                for (int i = 0; i < treeIDs.length; i++) {
+                                    if (!OtdbRmi.getRemoteMaintenance().deleteTree(treeIDs[i])) {
+                                        String aS = "Failed to delete tree: " + treeIDs[i];
+                                        logger.error(aS);
+                                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                    }
                                 }
-                                itsMainFrame.getSharedVars().setTreeID(newTreeID);
-                                // set changed flag to reload mainpanel
-                                itsMainFrame.setChanged(this.getFriendlyName(),true);
+                            } catch (RemoteException ex) {
+                                String aS = "Remote error during deleteTree: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            }
+                            itsMainFrame.getSharedVars().setTreeID(-1);
+                            itsMainFrame.setHourglassCursor();
+                            ((TemplatetableModel) TemplatesPanel.getTableModel()).fillTable();
+                            itsMainFrame.setNormalCursor();
+                            // set changed flag to reload mainpanel
+                            //                  itsMainFrame.setChanged(this.getFriendlyName(),true);
+                            //                    checkChanged();
+                        }
+                        break;
+                    case "Build VIC tree":
+                        if (treeID < 1) {
+                            LofarUtils.showErrorPanel(this, "You didn't select a tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                        } else {
+                            try {
+                                int newTreeID = OtdbRmi.getRemoteMaintenance().instanciateTree(itsMainFrame.getSharedVars().getTreeID());
+                                if (newTreeID > 0) {
+                                    JOptionPane.showMessageDialog(this, "New VICTree created with ID: " + newTreeID,
+                                            "New Tree Message",
+                                            JOptionPane.INFORMATION_MESSAGE);
+                                    itsMainFrame.getSharedVars().setTreeID(newTreeID);
+                                    // set changed flag to reload mainpanel
+                                    itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                    checkChanged();
+                                } else {
+                                    String aS = "No VIC Tree created!!! : " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                    logger.error(aS);
+                                    LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                }
+
+                            } catch (RemoteException ex) {
+                                String aS = "Remote error during Build VICTree: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            }
+                        }
+                        break;
+                    case "Change Status":
+                        // in case of templatetree we have the possibility of changing a multiple selection
+                        // so things like status can be set for a few entries at once
+                        if (TemplatesPanel.getSelectedRowCount() > 0) {
+                            if (viewInfo(this.getSelectedTreeIDs())) {
+                                logger.debug("Tree has been changed, reloading tableline");
+                                itsMainFrame.setChanged(this.getFriendlyName(), true);
                                 checkChanged();
-                            } else {
-                                logger.debug("No Template Tree created!!!");
                             }
-               
-                        } catch (RemoteException ex) {
-                            String aS="Remote error during Build TemplateTree: "+ ex;
-                            logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+
                         }
-                    }
-                    break;
-                case "Modify":
-                    TemplateMaintenancePanel aP =(TemplateMaintenancePanel)itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.TemplateMaintenancePanel", true, true);
-                    if (aP != null) {
-                        itsMainFrame.showPanel(aP.getFriendlyName());
-                    }
-                    break;
-                case "Delete":
-                    if (JOptionPane.showConfirmDialog(this,"Are you sure you want to delete this tree(s) ?","Delete Tree",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-                        try {
-                           int[] treeIDs=getSelectedTreeIDs();
-                           for (int i=0;i< treeIDs.length;i++) {
-                               if (!OtdbRmi.getRemoteMaintenance().deleteTree(treeIDs[i])) {
-                                   String aS="Failed to delete tree: "+treeIDs[i];
-                                   logger.error(aS);
-                                   LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                               }
-                           }
-                        } catch (RemoteException ex) {
-                           String aS="Remote error during deleteTree: "+ ex;
-                           logger.error(aS);
-                           LofarUtils.showErrorPanel(this, aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                       }
-                       itsMainFrame.getSharedVars().setTreeID(-1);                              
-                       itsMainFrame.setHourglassCursor();
-                       ((TemplatetableModel)TemplatesPanel.getTableModel()).fillTable();
-                       itsMainFrame.setNormalCursor();
-                       // set changed flag to reload mainpanel
-   //                  itsMainFrame.setChanged(this.getFriendlyName(),true);
-   //                    checkChanged();
-                   }break;
-                case "Build VIC tree":
-                    if (treeID < 1) {
-                        LofarUtils.showErrorPanel(this, "You didn't select a tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    } else {
-                        try {
-                            int newTreeID=OtdbRmi.getRemoteMaintenance().instanciateTree(itsMainFrame.getSharedVars().getTreeID());
-                            if (newTreeID > 0) {
-                                JOptionPane.showMessageDialog(this,"New VICTree created with ID: "+newTreeID,
-                                    "New Tree Message",
-                                    JOptionPane.INFORMATION_MESSAGE);
-                                itsMainFrame.getSharedVars().setTreeID(newTreeID);
-                                // set changed flag to reload mainpanel
-                                itsMainFrame.setChanged(this.getFriendlyName(),true);
+                        break;
+                    case "MultiEdit":
+                        // in case of templatetree we have the possibility to change a few crucial settings for all trees chosen
+                        if (TemplatesPanel.getSelectedRowCount() > 0) {
+                            if (viewMultiEditDialog(this.getSelectedTreeIDs())) {
+                                logger.debug("Trees have been changed, reloading tablelines");
+                                itsMainFrame.setChanged(this.getFriendlyName(), true);
                                 checkChanged();
-                            } else {
-                                String aS="No VIC Tree created!!! : "+ OtdbRmi.getRemoteMaintenance().errorMsg();
+                            }
+
+                        }
+                        break;
+                    case "Set to Default":
+                        if (itsMainFrame.getSharedVars().getTreeID() > 0) {
+                            try {
+                                ArrayList<jDefaultTemplate> aDFList = new ArrayList(OtdbRmi.getRemoteOTDB().getDefaultTemplates());
+                                if (createDefaultTemplateDialog(aTree, aDFList)) {
+                                    // check momID, if not zero set to zero
+                                    if (aTree.momID() != 0) {
+                                        if (!OtdbRmi.getRemoteMaintenance().setMomInfo(aTree.treeID(), 0, aTree.groupID, aTree.campaign)) {
+                                            String aS = "Error during setMomInfo: " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                            logger.error(aS);
+                                            LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                        }
+                                    }
+                                    itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                    checkChanged();
+                                }
+                            } catch (RemoteException ex) {
+                                String aS = "Error during Remote treeMaintenance" + ex;
                                 logger.error(aS);
-                                LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                             }
-               
-                        } catch (RemoteException ex) {
-                            String aS="Remote error during Build VICTree: "+ ex;
-                            logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                         }
+                        break;
+                }
+                break;
+            }
+            case "Default Templates": {
+                jOTDBtree aTree = null;
+                String aTreeState = "";
+                if (treeID > 0) {
+                    itsMainFrame.getSharedVars().setTreeID(treeID);
+                    try {
+                        aTree = OtdbRmi.getRemoteOTDB().getTreeInfo(treeID, false);
+                        aTreeState = OtdbRmi.getRemoteTypes().getTreeState(aTree.state);
+                    } catch (RemoteException ex) {
+                        String aS = "Error during Remote treeMaintenance" + ex;
+                        logger.error(aS);
+                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                     }
-                    break;
-                case "Change Status":
-                    // in case of templatetree we have the possibility of changing a multiple selection
-                    // so things status can be set for a few entries at once
-                    if (TemplatesPanel.getSelectedRowCount() > 0) {
-                        if (viewInfo(this.getSelectedTreeIDs()) ) {
-                            logger.debug("Tree has been changed, reloading tableline");
-                              itsMainFrame.setChanged(this.getFriendlyName(),true);
-                              checkChanged();
+                } else {
+                    LofarUtils.showErrorPanel(this, "You didn't select a tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                    return;
+                }
+                switch (aButton) {
+                    case "Query Panel":
+                        itsMainFrame.ToDo();
+                        break;
+                    case "State History":
+                        if (treeID > 0) {
+                            viewStateChanges(treeID);
                         }
+                        break;
+                    case "Duplicate":
+                        if (treeID < 1) {
+                            LofarUtils.showErrorPanel(this, "You didn't select a tree", new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                        } else {
+                            try {
+                                int newTreeID = OtdbRmi.getRemoteMaintenance().copyTemplateTree(treeID);
+                                if (newTreeID > 0) {
+                                    JOptionPane.showMessageDialog(this, "New Tree (Not Default!!!) created with ID: " + newTreeID,
+                                            "New Tree Message",
+                                            JOptionPane.INFORMATION_MESSAGE);
+                                    // set back treestate to described
+                                    jOTDBtree aT = OtdbRmi.getRemoteOTDB().getTreeInfo(newTreeID, false);
+                                    if (aT.state != OtdbRmi.getRemoteTypes().getTreeState("described")) {
+                                        aT.state = OtdbRmi.getRemoteTypes().getTreeState("described");
+                                        if (!OtdbRmi.getRemoteMaintenance().setTreeState(aT.treeID(), aT.state)) {
+                                            String aS = "Error during setTreeState: " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                            logger.error(aS);
+                                            LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                        }
+                                    }
+                                    // check momID, if not zero set to zero
+                                    if (aT.momID() != 0) {
+                                        if (!OtdbRmi.getRemoteMaintenance().setMomInfo(aT.treeID(), 0, aT.groupID, aT.campaign)) {
+                                            String aS = "Error during setMomInfo: " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                            logger.error(aS);
+                                            LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                        }
 
-                    }
-                    break;
-                case "MultiEdit":
-                    // in case of templatetree we have the possibility to change a few crucial settings for all trees chosen
-                    if (TemplatesPanel.getSelectedRowCount() > 0) {
-                        if (viewMultiEditDialog(this.getSelectedTreeIDs()) ) {
-                            logger.debug("Trees have been changed, reloading tablelines");
-                              itsMainFrame.setChanged(this.getFriendlyName(),true);
-                              checkChanged();
+                                    }
+                                    itsMainFrame.getSharedVars().setTreeID(newTreeID);
+                                    // set changed flag to reload mainpanel
+                                    itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                    checkChanged();
+                                } else {
+                                    String aS = "No Template Tree created!!!";
+                                    logger.error(aS);
+                                    LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                }
+
+                            } catch (RemoteException ex) {
+                                String aS = "Remote error during Build TemplateTree: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            }
+                        }
+                        break;
+                    case "Modify":
+                        TemplateMaintenancePanel aP = (TemplateMaintenancePanel) itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.TemplateMaintenancePanel", true, true);
+                        if (aP != null) {
+                            itsMainFrame.showPanel(aP.getFriendlyName());
                         }
+                        break;
+                    case "Remove from Default":
+                        if (JOptionPane.showConfirmDialog(this, "Are you sure you want to move this default template(s) to an ordinary template ?", "Remove template from Default templates", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
+                            try {
+                                int[] treeIDs = getSelectedTreeIDs();
+                                for (int i = 0; i < treeIDs.length; i++) {
+                                    jOTDBtree tmpTree = OtdbRmi.getRemoteOTDB().getTreeInfo(treeIDs[i], false);
 
-                    }
-                    break;
-                case "Set to Default":
-                    if (itsMainFrame.getSharedVars().getTreeID() > 0) {
-                        try {
-                            ArrayList<jDefaultTemplate> aDFList = new ArrayList(OtdbRmi.getRemoteOTDB().getDefaultTemplates());
-                            if (createDefaultTemplateDialog(aTree, aDFList)) {
-                                // check momID, if not zero set to zero
-                                if (aTree.momID() != 0) {
-                                    if (!OtdbRmi.getRemoteMaintenance().setMomInfo(aTree.treeID(), 0, aTree.groupID, aTree.campaign)) {
-                                        String aS = "Error during setMomInfo: " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                    if (!OtdbRmi.getRemoteMaintenance().assignTemplateName(tmpTree.treeID(), "")) {
+                                        String aS = "Error during assignTemplateName(" + tmpTree.treeID() + ", ): " + OtdbRmi.getRemoteMaintenance().errorMsg();
                                         logger.error(aS);
                                         LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                    } else {
+                                        itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                        checkChanged();
                                     }
                                 }
+                            } catch (RemoteException ex) {
+                                try {
+                                    String aS = "RemoteExceptionError while setting TemplateName " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                    logger.error(aS);
+                                    LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                } catch (RemoteException ex1) {
+                                    String aS = "Remote Exception Error getting the remote errorMessage";
+                                    logger.error(aS);
+                                    LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                }
+                            }
+                            }
+                            break;
+                    case "Change Status":
+                        if (itsMainFrame.getSharedVars().getTreeID() > 0) {
+                            int[] id = new int[1];
+                            id[0] = itsMainFrame.getSharedVars().getTreeID();
+                            if (viewInfo(id)) {
+                                logger.debug("Tree has been changed, reloading table line");
                                 itsMainFrame.setChanged(this.getFriendlyName(), true);
                                 checkChanged();
                             }
-                        } catch (RemoteException ex) {
-                            String aS="Error during Remote treeMaintenance" + ex;
-                            logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                         }
-                    }
-                    break;
-            }
-                    break;
+                        break;
                 }
-            case "Default Templates":
-                {
-                    jOTDBtree aTree=null;
-                    String aTreeState="";
-                    if (treeID > 0) {
-                        itsMainFrame.getSharedVars().setTreeID(treeID);
-                        try {
-                            aTree =    OtdbRmi.getRemoteOTDB().getTreeInfo(treeID,false);
-                            aTreeState=OtdbRmi.getRemoteTypes().getTreeState(aTree.state);
-                        } catch (RemoteException ex) {
-                            String aS="Error during Remote treeMaintenance" + ex;
-                            logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                        }
-                    } else {
-                        LofarUtils.showErrorPanel(this, "You didn't select a tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                        return;
-                    }
-            switch (aButton) {
-                case "Query Panel":
-                    itsMainFrame.ToDo();
-                    break;
-                case "State History":
-                    if (treeID > 0) {
-                        viewStateChanges(treeID);
-                    }
-                    break;
-                case "Duplicate":
-                    if (treeID < 1) {
-                        LofarUtils.showErrorPanel(this, "You didn't select a tree",new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    } else {
-                        try {
-                            int newTreeID=OtdbRmi.getRemoteMaintenance().copyTemplateTree(treeID);
-                            if (newTreeID > 0) {
-                                JOptionPane.showMessageDialog(this,"New Tree (Not Default!!!) created with ID: "+newTreeID,
-                                    "New Tree Message",
-                                    JOptionPane.INFORMATION_MESSAGE);
-                                // set back treestate to described
-                                jOTDBtree aT=OtdbRmi.getRemoteOTDB().getTreeInfo(newTreeID, false);
-                                if (aT.state != OtdbRmi.getRemoteTypes().getTreeState("described") ) {
-                                    aT.state=OtdbRmi.getRemoteTypes().getTreeState("described");
-                                    if (!OtdbRmi.getRemoteMaintenance().setTreeState(aT.treeID(), aT.state)) {
-                                        String aS="Error during setTreeState: "+OtdbRmi.getRemoteMaintenance().errorMsg();
-                                        logger.error(aS);
-                                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                                    }
+                break;
+            }
+            case "Components":
+                switch (aButton) {
+                    case "Query Panel":
+                        itsMainFrame.ToDo();
+                        break;
+                    case "New":
+                        if (getFile("VIC-component")) {
+                            try {
+                                // the file obviously resides at the client side, and needs to be transfered to the server side.
+                                byte uldata[] = new byte[(int) itsNewFile.length()];
+                                try (BufferedInputStream input = new BufferedInputStream(new FileInputStream(itsNewFile))) {
+                                    input.read(uldata, 0, uldata.length);
                                 }
-                                // check momID, if not zero set to zero
-                                if (aT.momID() != 0) {
-                                    if (!OtdbRmi.getRemoteMaintenance().setMomInfo(aT.treeID(),0, aT.groupID, aT.campaign)) {
-                                        String aS="Error during setMomInfo: "+OtdbRmi.getRemoteMaintenance().errorMsg();
+                                String aFileName = "/tmp/" + itsMainFrame.getUserAccount().getUserName() + "_" + itsNewFile.getName();
+                                if (OtdbRmi.getRemoteFileTrans().uploadFile(uldata, aFileName)) {
+                                    logger.debug("upload finished");
+                                    // Create a new Tree from the found file.
+                                    int anID = OtdbRmi.getRemoteMaintenance().loadComponentFile(aFileName, "", "");
+                                    if (anID < 1) {
+                                        String aS = "Error on ComponentfileLoad: " + itsNewFile.getPath();
                                         logger.error(aS);
-                                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                    } else {
+                                        // set the new created fill description stuff if needed
+                                        itsMainFrame.getSharedVars().setComponentID(anID);
+                                        if (!itsFileDescription.equals("")) {
+                                            jVICnodeDef aND = OtdbRmi.getRemoteMaintenance().getComponentNode(anID);
+                                            aND.description = itsFileDescription;
+                                            if (!OtdbRmi.getRemoteMaintenance().saveComponentNode(aND)) {
+                                                String aS = "Error during setDescription in Component " + OtdbRmi.getRemoteMaintenance().errorMsg();
+                                                logger.error(aS);
+                                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                            }
+                                        }
+                                        // set changed flag to reload mainpanel
+                                        itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                        checkChanged();
                                     }
-
+                                    ComponentMaintenancePanel aP = (ComponentMaintenancePanel) itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ComponentMaintenancePanel", true, true);
+                                    if (aP != null) {
+                                        itsMainFrame.showPanel(aP.getFriendlyName());
+                                    }
+                                } else {
+                                    String aS = "upload failed";
+                                    logger.error(aS);
+                                    LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/tb/icons/16_warn.gif")));
                                 }
-                                itsMainFrame.getSharedVars().setTreeID(newTreeID);
-                                // set changed flag to reload mainpanel
-                                itsMainFrame.setChanged(this.getFriendlyName(),true);
-                                checkChanged();
-                            } else {
-                                String aS="No Template Tree created!!!";
+                            } catch (FileNotFoundException ex) {
+                                String aS = "Error during new Component creation: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            } catch (RemoteException ex) {
+                                String aS = "Error during new Component creation: " + ex;
                                 logger.error(aS);
-                                LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            } catch (IOException ex) {
+                                String aS = "Error during new Component creation: " + ex;
+                                logger.error(aS);
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                             }
-
-                        } catch (RemoteException ex) {
-                            String aS="Remote error during Build TemplateTree: "+ ex;
-                            logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                         }
-                    }
-                    break;
-                case "Modify":
-                    TemplateMaintenancePanel aP =(TemplateMaintenancePanel)itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.TemplateMaintenancePanel", true, true);
-                    if (aP != null) {
-                        itsMainFrame.showPanel(aP.getFriendlyName());
-                    }
-                    break;
-                case "Change Status":
-                    if (itsMainFrame.getSharedVars().getTreeID() > 0) {
-                        int [] id = new int[1];
-                        id[0]=itsMainFrame.getSharedVars().getTreeID();
-                        if (viewInfo(id)) {
-                            logger.debug("Tree has been changed, reloading table line");
-                              itsMainFrame.setChanged(this.getFriendlyName(),true);
-                              checkChanged();
+                        break;
+                    case "Modify":
+                        ComponentMaintenancePanel aP = (ComponentMaintenancePanel) itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ComponentMaintenancePanel", true, true);
+                        if (aP != null) {
+                            itsMainFrame.showPanel(aP.getFriendlyName());
                         }
-                    }
-                    break;
-            }
-                    break;
-                }
-            case "Components":
-        switch (aButton) {
-            case "Query Panel":
-                itsMainFrame.ToDo();
-                break;
-            case "New":
-                if (getFile("VIC-component") ) {
-                    try {
-                        // the file obviously resides at the client side, and needs to be transfered to the server side.
-                        byte uldata[] = new byte[(int)itsNewFile.length()]; 
-                try (BufferedInputStream input = new BufferedInputStream(new FileInputStream(itsNewFile))) {
-                    input.read(uldata,0,uldata.length);
-                }
-                        String aFileName= "/tmp/"+itsMainFrame.getUserAccount().getUserName()+"_"+itsNewFile.getName();
-                        if (OtdbRmi.getRemoteFileTrans().uploadFile(uldata,aFileName)) {
-                            logger.debug("upload finished");
-                            // Create a new Tree from the found file.
-                            int anID=OtdbRmi.getRemoteMaintenance().loadComponentFile(aFileName,"","");
-                            if (anID < 1) {
-                                String aS="Error on ComponentfileLoad: " + itsNewFile.getPath();
-                                logger.error(aS);
-                                LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                            } else {
-                                // set the new created fill description stuff if needed
-                                itsMainFrame.getSharedVars().setComponentID(anID);
-                                if (!itsFileDescription.equals("")) {
-                                    jVICnodeDef aND=OtdbRmi.getRemoteMaintenance().getComponentNode(anID);
-                                    aND.description=itsFileDescription;
-                                    if (!OtdbRmi.getRemoteMaintenance().saveComponentNode(aND)) {
-                                        String aS="Error during setDescription in Component "+OtdbRmi.getRemoteMaintenance().errorMsg();
-                                        logger.error(aS);
-                                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                                    }
+                        break;
+                    case "Build TemplateTree":
+                        int nodeID = itsMainFrame.getSharedVars().getComponentID();
+                        short classifID;
+                        try {
+                            classifID = OtdbRmi.getRemoteTypes().getClassif("operational");
+                            if (OtdbRmi.getRemoteMaintenance().isTopComponent(nodeID)) {
+                                int newTreeID = OtdbRmi.getRemoteMaintenance().buildTemplateTree(nodeID, classifID);
+                                if (newTreeID > 0) {
+                                    JOptionPane.showMessageDialog(this, "New Tree created with ID: " + newTreeID,
+                                            "New Tree Message",
+                                            JOptionPane.INFORMATION_MESSAGE);
+                                    itsMainFrame.getSharedVars().setTreeID(newTreeID);
+                                    // set changed flag to reload mainpanel
+                                    itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                    checkChanged();
+                                } else {
+                                    String aS = "No Template Tree created!!!";
+                                    logger.error(aS);
+                                    LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                                 }
-                                // set changed flag to reload mainpanel
-                                itsMainFrame.setChanged(this.getFriendlyName(),true);
-                                checkChanged();
-                            }
-                            ComponentMaintenancePanel aP=(ComponentMaintenancePanel)itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ComponentMaintenancePanel", true, true);
-                            if (aP != null) {
-                                itsMainFrame.showPanel(aP.getFriendlyName());
                             }
-                        } else {
-                            String aS="upload failed";
-                            logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/tb/icons/16_warn.gif")));
-                        }
-                    } catch (FileNotFoundException ex) {
-                        String aS="Error during new Component creation: "+ ex;
-                        logger.error(aS);
-                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    } catch (RemoteException ex) {
-                        String aS="Error during new Component creation: "+ ex;
-                        logger.error(aS);
-                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    } catch (IOException ex) {
-                        String aS="Error during new Component creation: "+ ex;
-                        logger.error(aS);
-                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    }
-                }
-                break;
-            case "Modify":
-                ComponentMaintenancePanel aP = (ComponentMaintenancePanel)itsMainFrame.registerPlugin("nl.astron.lofar.sas.otb.panels.ComponentMaintenancePanel", true, true);
-                if (aP != null) {
-                    itsMainFrame.showPanel(aP.getFriendlyName());
-                }
-                break;
-            case "Build TemplateTree":
-                int nodeID=itsMainFrame.getSharedVars().getComponentID();
-                short classifID;
-                try {
-                    classifID = OtdbRmi.getRemoteTypes().getClassif("operational");
-                    if (OtdbRmi.getRemoteMaintenance().isTopComponent(nodeID)) {
-                        int newTreeID=OtdbRmi.getRemoteMaintenance().buildTemplateTree(nodeID,classifID);
-                        if (newTreeID > 0) {
-                            JOptionPane.showMessageDialog(this,"New Tree created with ID: "+newTreeID,
-                                "New Tree Message",
-                                JOptionPane.INFORMATION_MESSAGE);
-                            itsMainFrame.getSharedVars().setTreeID(newTreeID);
-                            // set changed flag to reload mainpanel
-                            itsMainFrame.setChanged(this.getFriendlyName(),true);
-                            checkChanged();
-                        } else {
-                            String aS="No Template Tree created!!!";
+                        } catch (RemoteException ex) {
+                            String aS = "Remote error during Build TemplateTree: " + ex;
                             logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                         }
-                    }
-                } catch (RemoteException ex) {
-                    String aS="Remote error during Build TemplateTree: "+ ex;
-                    logger.error(aS);
-                    LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                }
-                break;
-            case "Delete":
-                if (JOptionPane.showConfirmDialog(this,"Are you sure you want to delete this component(s): ?","Delete Component",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-                    try {
-                        int[] componentIDs=getSelectedTreeIDs();
-                        for (int i=0;i< componentIDs.length;i++) {
-                            if (!OtdbRmi.getRemoteMaintenance().deleteComponentNode(componentIDs[i])) {
-                                String aS="Failed to delete component: "+componentIDs[i];
+                        break;
+                    case "Delete":
+                        if (JOptionPane.showConfirmDialog(this, "Are you sure you want to delete this component(s): ?", "Delete Component", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
+                            try {
+                                int[] componentIDs = getSelectedTreeIDs();
+                                for (int i = 0; i < componentIDs.length; i++) {
+                                    if (!OtdbRmi.getRemoteMaintenance().deleteComponentNode(componentIDs[i])) {
+                                        String aS = "Failed to delete component: " + componentIDs[i];
+                                        logger.error(aS);
+                                        LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                                    } else {
+                                        // set changed flag to reload mainpanel
+                                        itsMainFrame.setChanged(this.getFriendlyName(), true);
+                                        checkChanged();
+                                    }
+                                }
+                            } catch (RemoteException ex) {
+                                String aS = "Remote error during deleteComponents: " + ex;
                                 logger.error(aS);
-                                LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                            } else {
-                                // set changed flag to reload mainpanel
-                               itsMainFrame.setChanged(this.getFriendlyName(),true);
-                               checkChanged();
+                                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                             }
+                            itsMainFrame.setHourglassCursor();
+                            ((ComponentTableModel) ComponentsPanel.getTableModel()).fillTable();
+                            itsMainFrame.setNormalCursor();
                         }
-                    } catch (RemoteException ex) {
-                        String aS="Remote error during deleteComponents: "+ ex;
-                        logger.error(aS);
-                        LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
-                    }
-                    itsMainFrame.setHourglassCursor();
-                    ((ComponentTableModel)ComponentsPanel.getTableModel()).fillTable();
-                    itsMainFrame.setNormalCursor();
+                        break;
                 }
                 break;
-        }
-                break;
             case "Query Results":
                 itsMainFrame.ToDo();
                 break;
             default:
-                logger.debug("Other command found: "+aButton);
+                logger.debug("Other command found: " + aButton);
                 break;
         }
     }
@@ -1296,10 +1324,10 @@ public class MainPanel extends javax.swing.JPanel
      */
     private void viewStateChanges(int treeID) {
         // create tableModel
-        itsStateChangeModel = new StateChangeHistoryTableModel(SharedVars.getOTDBrmi(),treeID);
+        itsStateChangeModel = new StateChangeHistoryTableModel(SharedVars.getOTDBrmi(), treeID);
         // showstateChangeInfo
         if (stateChangeHistoryDialog == null) {
-            stateChangeHistoryDialog = new TableDialog(itsMainFrame,true,itsStateChangeModel, "State change history");
+            stateChangeHistoryDialog = new TableDialog(itsMainFrame, true, itsStateChangeModel, "State change history");
         } else {
             itsStateChangeModel.setTree(treeID);
             stateChangeHistoryDialog.setModel(itsStateChangeModel);
@@ -1312,7 +1340,6 @@ public class MainPanel extends javax.swing.JPanel
 
     }
 
-
     /** Launch multiEditDialog,
      *
      * @param  treeIDs  The IDs of the chosen trees.
@@ -1320,13 +1347,13 @@ public class MainPanel extends javax.swing.JPanel
     private boolean viewInfo(int[] treeIDs) {
         logger.debug("viewInfo for treeID: " + treeIDs);
         //get the selected tree from the database
-        boolean multiple=false;
+        boolean multiple = false;
 
 
         if (treeIDs.length > 0) {
             // show treeInfo dialog
-            if (treeInfoDialog == null ) {
-                treeInfoDialog = new TreeInfoDialog(true,treeIDs, itsMainFrame);
+            if (treeInfoDialog == null) {
+                treeInfoDialog = new TreeInfoDialog(true, treeIDs, itsMainFrame);
             } else {
                 treeInfoDialog.setTree(treeIDs);
             }
@@ -1352,11 +1379,11 @@ public class MainPanel extends javax.swing.JPanel
     private boolean viewMultiEditDialog(int[] treeIDs) {
         logger.debug("viewMultiEditDialog for treeID: " + treeIDs);
         //get the selected tree from the database
-       
+
         if (treeIDs.length > 0) {
             // show multiEdit dialog
-            if (multiEditDialog == null ) {
-                multiEditDialog = new MultiEditDialog(true,treeIDs, itsMainFrame);
+            if (multiEditDialog == null) {
+                multiEditDialog = new MultiEditDialog(true, treeIDs, itsMainFrame);
             } else {
                 multiEditDialog.setTree(treeIDs);
             }
@@ -1368,7 +1395,7 @@ public class MainPanel extends javax.swing.JPanel
             } else {
                 logger.debug("trees have not been changed");
             }
-               
+
         } else {
             logger.debug("no trees selected");
         }
@@ -1379,15 +1406,15 @@ public class MainPanel extends javax.swing.JPanel
      *
      * @param  aList Vector<jDefaultTemplate> all default template names.
      */
-    private boolean createDefaultTemplateDialog(jOTDBtree aTree,ArrayList<jDefaultTemplate> aList) {
+    private boolean createDefaultTemplateDialog(jOTDBtree aTree, ArrayList<jDefaultTemplate> aList) {
         logger.debug("createDefaultTemplateDialog started");
 
         if (itsMainFrame.getSharedVars().getTreeID() > 0) {
-            // show multiEdit dialog
-            if (defaultTemplateDialog == null ) {
-                defaultTemplateDialog = new CreateDefaultTemplateDialog(true,aList,aTree,itsMainFrame);
+            // show defaultTemplate dialog
+            if (defaultTemplateDialog == null) {
+                defaultTemplateDialog = new CreateDefaultTemplateDialog(true, aList, aTree, itsMainFrame);
             } else {
-                defaultTemplateDialog.setNew(aList,aTree);
+                defaultTemplateDialog.setNew(aList, aTree);
             }
             defaultTemplateDialog.setLocationRelativeTo(this);
             defaultTemplateDialog.setVisible(true);
@@ -1405,25 +1432,24 @@ public class MainPanel extends javax.swing.JPanel
         return defaultTemplateDialog.isOk();
     }
 
-    
     /** Launch LoadFileDialog to get a file to work with.
      *
      * @param   aType   PIC-tree or VIC-component
      *
      */
     private boolean getFile(String aType) {
-        File aNewFile=null;
-        String aFileStatus="";
-        String aFileDescription="";
-        
+        File aNewFile = null;
+        String aFileStatus = "";
+        String aFileDescription = "";
+
         // Reset the File info fields
         itsNewFile = null;
-        itsFileDescription="";
-        itsFileStatus="";
-        
+        itsFileDescription = "";
+        itsFileStatus = "";
+
         // show login dialog
-        if (loadFileDialog == null ) {
-            loadFileDialog = new LoadFileDialog(itsMainFrame,true,aType);
+        if (loadFileDialog == null) {
+            loadFileDialog = new LoadFileDialog(itsMainFrame, true, aType);
         } else {
             loadFileDialog.setType(aType);
         }
@@ -1432,10 +1458,10 @@ public class MainPanel extends javax.swing.JPanel
             loadFileDialog.setStatusVisible(false);
         }
         loadFileDialog.setVisible(true);
-        if(loadFileDialog.isOk()) {
+        if (loadFileDialog.isOk()) {
             aFileDescription = loadFileDialog.getDescription();
             aFileStatus = loadFileDialog.getStatus();
-            aNewFile = loadFileDialog.getFile();       
+            aNewFile = loadFileDialog.getFile();
         } else {
             logger.info("No File chosen");
             return false;
@@ -1443,7 +1469,7 @@ public class MainPanel extends javax.swing.JPanel
         if (aNewFile != null && aNewFile.exists()) {
             logger.trace("File to load: " + aNewFile.getName());
             logger.debug("Status: " + aFileStatus);
-            logger.debug("Description: "+ aFileDescription);
+            logger.debug("Description: " + aFileDescription);
             itsNewFile = aNewFile;
             if (aType.equals("VIC-component")) {
                 itsFileStatus = "";
@@ -1455,227 +1481,227 @@ public class MainPanel extends javax.swing.JPanel
         }
         return false;
     }
-    
+
     private void validateButtons() {
         // depending on the tabfocus and the info the selected row contains
         // certain buttons are valid and others need to be grey out
-        jOTDBtree aTree=null;
-        String aTreeState="";
-        String aClassif="";
-        
-        int treeID=getSelectedTreeID();
-        int componentID=itsMainFrame.getSharedVars().getComponentID();
-        logger.debug("Selected Tree: "+treeID);
+        jOTDBtree aTree = null;
+        String aTreeState = "";
+        String aClassif = "";
+
+        int treeID = getSelectedTreeID();
+        int componentID = itsMainFrame.getSharedVars().getComponentID();
+        logger.debug("Selected Tree: " + treeID);
 
         if (treeID > 0) {
             try {
-                aTree      = OtdbRmi.getRemoteOTDB().getTreeInfo(treeID,false);
+                aTree = OtdbRmi.getRemoteOTDB().getTreeInfo(treeID, false);
                 aTreeState = OtdbRmi.getRemoteTypes().getTreeState(aTree.state);
-                aClassif   = OtdbRmi.getRemoteTypes().getClassif(aTree.classification);
+                aClassif = OtdbRmi.getRemoteTypes().getClassif(aTree.classification);
             } catch (RemoteException ex) {
-                String aS="Couldn't get Tree "+ treeID;
+                String aS = "Couldn't get Tree " + treeID;
                 logger.error(aS);
-                LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                 return;
             }
         }
         switch (itsTabFocus) {
             case "PIC":
-                if (treeID>0) {
+                if (treeID > 0) {
                     if (aTreeState.equals("active")) {
-                        buttonPanel1.setButtonEnabled("Delete",false);
+                        buttonPanel1.setButtonEnabled("Delete", false);
                     } else {
-                        buttonPanel1.setButtonEnabled("Delete",true);                    
+                        buttonPanel1.setButtonEnabled("Delete", true);
                     }
-                    buttonPanel1.setButtonEnabled("View",true);
-                    buttonPanel1.setButtonEnabled("Info",true);
-                    buttonPanel1.setButtonEnabled("State History",true);
+                    buttonPanel1.setButtonEnabled("View", true);
+                    buttonPanel1.setButtonEnabled("Info", true);
+                    buttonPanel1.setButtonEnabled("State History", true);
                 } else {
-                    buttonPanel1.setButtonEnabled("State History",false);
-                    buttonPanel1.setButtonEnabled("Delete",false);
-                    buttonPanel1.setButtonEnabled("View",false);
-                    buttonPanel1.setButtonEnabled("Info",false);
+                    buttonPanel1.setButtonEnabled("State History", false);
+                    buttonPanel1.setButtonEnabled("Delete", false);
+                    buttonPanel1.setButtonEnabled("View", false);
+                    buttonPanel1.setButtonEnabled("Info", false);
                 }
                 break;
             case "VIC":
                 if (VICPanel.getSelectedRowCount() > 1) {
-                    multipleSelection=true;
+                    multipleSelection = true;
                 } else {
-                    multipleSelection=false;
+                    multipleSelection = false;
                 }
-                if (treeID>0) {
+                if (treeID > 0) {
                     // !!!!!!!!!!!!!!
                     // Need to see if buttons need to be invalidated under certain states....
                     //
                     if (!multipleSelection) {
-                        buttonPanel1.setButtonEnabled("State History",true);
-                        buttonPanel1.setButtonEnabled("View",true);
-                        buttonPanel1.setButtonEnabled("Query Panel",true);
-                        buttonPanel1.setButtonEnabled("Refresh",true);
+                        buttonPanel1.setButtonEnabled("State History", true);
+                        buttonPanel1.setButtonEnabled("View", true);
+                        buttonPanel1.setButtonEnabled("Query Panel", true);
+                        buttonPanel1.setButtonEnabled("Refresh", true);
                     } else {
-                        buttonPanel1.setButtonEnabled("Query Panel",false);
-                        buttonPanel1.setButtonEnabled("Refresh",false);
-                        buttonPanel1.setButtonEnabled("State History",false);
-                        buttonPanel1.setButtonEnabled("View",false);
+                        buttonPanel1.setButtonEnabled("Query Panel", false);
+                        buttonPanel1.setButtonEnabled("Refresh", false);
+                        buttonPanel1.setButtonEnabled("State History", false);
+                        buttonPanel1.setButtonEnabled("View", false);
                     }
-                    buttonPanel1.setButtonEnabled("Delete",true);
-                    buttonPanel1.setButtonEnabled("Schedule",true);
+                    buttonPanel1.setButtonEnabled("Delete", true);
+                    buttonPanel1.setButtonEnabled("Schedule", true);
                 } else {
-                    buttonPanel1.setButtonEnabled("Delete",false);
-                    buttonPanel1.setButtonEnabled("View",false);
-                    buttonPanel1.setButtonEnabled("State History",false);
-                    buttonPanel1.setButtonEnabled("Schedule",false);
+                    buttonPanel1.setButtonEnabled("Delete", false);
+                    buttonPanel1.setButtonEnabled("View", false);
+                    buttonPanel1.setButtonEnabled("State History", false);
+                    buttonPanel1.setButtonEnabled("Schedule", false);
                 }
                 break;
             case "Templates":
                 if (TemplatesPanel.getSelectedRowCount() > 1) {
-                    multipleSelection=true;
+                    multipleSelection = true;
                 } else {
-                    multipleSelection=false;
+                    multipleSelection = false;
                 }
                 if (treeID > 0) {
-                    if ((aTreeState.equals("idle") ||
-                            aTreeState.equals("described") ||
-                            aTreeState.equals("prepared") ||
-                            aTreeState.equals("approved")) && !multipleSelection) {
-                        buttonPanel1.setButtonEnabled("Duplicate",true);
-                        buttonPanel1.setButtonEnabled("Modify",true);
-                        buttonPanel1.setButtonEnabled("Set to Default",true);
-                        buttonPanel1.setButtonEnabled("Query Panel",true);
+                    if ((aTreeState.equals("idle")
+                            || aTreeState.equals("described")
+                            || aTreeState.equals("prepared")
+                            || aTreeState.equals("approved")) && !multipleSelection) {
+                        buttonPanel1.setButtonEnabled("Duplicate", true);
+                        buttonPanel1.setButtonEnabled("Modify", true);
+                        buttonPanel1.setButtonEnabled("Set to Default", true);
+                        buttonPanel1.setButtonEnabled("Query Panel", true);
                         if (aTreeState.equals("approved") || aTreeState.equals("on_hold") || aTreeState.equals("prescheduled")) {
-                            buttonPanel1.setButtonEnabled("Build VIC tree",true);
+                            buttonPanel1.setButtonEnabled("Build VIC tree", true);
                         } else {
-                            buttonPanel1.setButtonEnabled("Build VIC tree",false);
+                            buttonPanel1.setButtonEnabled("Build VIC tree", false);
                         }
                     } else {
-                        buttonPanel1.setButtonEnabled("Duplicate",false);
-                        buttonPanel1.setButtonEnabled("Modify",false);                                        
-                        buttonPanel1.setButtonEnabled("Set to Default",false);
+                        buttonPanel1.setButtonEnabled("Duplicate", false);
+                        buttonPanel1.setButtonEnabled("Modify", false);
+                        buttonPanel1.setButtonEnabled("Set to Default", false);
                     }
                     if (multipleSelection) {
-                        buttonPanel1.setButtonEnabled("State History",false);
-                        buttonPanel1.setButtonEnabled("Duplicate",false);
-                        buttonPanel1.setButtonEnabled("Modify",false);
-                        buttonPanel1.setButtonEnabled("MultiEdit",true);
-                        buttonPanel1.setButtonEnabled("Query Panel",false);
-                        buttonPanel1.setButtonEnabled("Refresh",false);
+                        buttonPanel1.setButtonEnabled("State History", false);
+                        buttonPanel1.setButtonEnabled("Duplicate", false);
+                        buttonPanel1.setButtonEnabled("Modify", false);
+                        buttonPanel1.setButtonEnabled("MultiEdit", true);
+                        buttonPanel1.setButtonEnabled("Query Panel", false);
+                        buttonPanel1.setButtonEnabled("Refresh", false);
                     } else {
-                        buttonPanel1.setButtonEnabled("State History",true);
-                        buttonPanel1.setButtonEnabled("Duplicate",true);
-                        buttonPanel1.setButtonEnabled("Modify",true);
-                        buttonPanel1.setButtonEnabled("MultiEdit",false);
-                        buttonPanel1.setButtonEnabled("Query Panel",true);
-                        buttonPanel1.setButtonEnabled("Refresh",true);
+                        buttonPanel1.setButtonEnabled("State History", true);
+                        buttonPanel1.setButtonEnabled("Duplicate", true);
+                        buttonPanel1.setButtonEnabled("Modify", true);
+                        buttonPanel1.setButtonEnabled("MultiEdit", false);
+                        buttonPanel1.setButtonEnabled("Query Panel", true);
+                        buttonPanel1.setButtonEnabled("Refresh", true);
                     }
-                    buttonPanel1.setButtonEnabled("Delete",true);
-                    buttonPanel1.setButtonEnabled("Change Status",true);
+                    buttonPanel1.setButtonEnabled("Delete", true);
+                    buttonPanel1.setButtonEnabled("Change Status", true);
                 } else {
-                    buttonPanel1.setButtonEnabled("Duplicate",false);
-                    buttonPanel1.setButtonEnabled("State History",false);
-                    buttonPanel1.setButtonEnabled("Modify",false);
-                    buttonPanel1.setButtonEnabled("Delete",false);                
-                    buttonPanel1.setButtonEnabled("Change Status",false);  
-                    buttonPanel1.setButtonEnabled("Build VIC tree",false);
-                    buttonPanel1.setButtonEnabled("Set to Default",false);
+                    buttonPanel1.setButtonEnabled("Duplicate", false);
+                    buttonPanel1.setButtonEnabled("State History", false);
+                    buttonPanel1.setButtonEnabled("Modify", false);
+                    buttonPanel1.setButtonEnabled("Delete", false);
+                    buttonPanel1.setButtonEnabled("Change Status", false);
+                    buttonPanel1.setButtonEnabled("Build VIC tree", false);
+                    buttonPanel1.setButtonEnabled("Set to Default", false);
                 }
                 break;
             case "Default Templates":
                 if (DefaultTemplatesPanel.getSelectedRowCount() > 1) {
-                    multipleSelection=true;
+                    multipleSelection = true;
                 } else {
-                    multipleSelection=false;
+                    multipleSelection = false;
                 }
                 if (treeID > 0) {
-                    if ((aTreeState.equals("idle") ||
-                            aTreeState.equals("described") ||
-                            aTreeState.equals("prepared") ||
-                            aTreeState.equals("approved")) && !multipleSelection) {
-                        buttonPanel1.setButtonEnabled("Duplicate",true);
-                        buttonPanel1.setButtonEnabled("Modify",true);
+                    if ((aTreeState.equals("idle")
+                            || aTreeState.equals("described")
+                            || aTreeState.equals("prepared")
+                            || aTreeState.equals("approved")) && !multipleSelection) {
+                        buttonPanel1.setButtonEnabled("Duplicate", true);
+                        buttonPanel1.setButtonEnabled("Modify", true);
                     } else {
-                        buttonPanel1.setButtonEnabled("Duplicate",false);
-                        buttonPanel1.setButtonEnabled("Modify",false);
+                        buttonPanel1.setButtonEnabled("Duplicate", false);
+                        buttonPanel1.setButtonEnabled("Modify", false);
                     }
                     if (multipleSelection) {
-                        buttonPanel1.setButtonEnabled("State History",false);
-                        buttonPanel1.setButtonEnabled("Duplicate",false);
-                        buttonPanel1.setButtonEnabled("Modify",false);
+                        buttonPanel1.setButtonEnabled("State History", false);
+                        buttonPanel1.setButtonEnabled("Duplicate", false);
+                        buttonPanel1.setButtonEnabled("Modify", false);
+                        buttonPanel1.setButtonEnabled("Change Status", false);
                     } else {
-                        buttonPanel1.setButtonEnabled("State History",true);
-                        buttonPanel1.setButtonEnabled("Duplicate",true);
-                        buttonPanel1.setButtonEnabled("Modify",true);
+                        buttonPanel1.setButtonEnabled("State History", true);
+                        buttonPanel1.setButtonEnabled("Duplicate", true);
+                        buttonPanel1.setButtonEnabled("Modify", true);
+                        buttonPanel1.setButtonEnabled("Change Status", true);
                     }
-                    buttonPanel1.setButtonEnabled("Change Status",true);
+                    buttonPanel1.setButtonEnabled("Remove from Default", true);
                 } else {
-                    buttonPanel1.setButtonEnabled("Duplicate",false);
-                    buttonPanel1.setButtonEnabled("Modify",false);
-                    buttonPanel1.setButtonEnabled("State History",false);
-                    buttonPanel1.setButtonEnabled("Change Status",false);
-               }break;
+                    buttonPanel1.setButtonEnabled("Duplicate", false);
+                    buttonPanel1.setButtonEnabled("Modify", false);
+                    buttonPanel1.setButtonEnabled("State History", false);
+                    buttonPanel1.setButtonEnabled("Change Status", false);
+                    buttonPanel1.setButtonEnabled("Remove from Default", false);
+                }
+                break;
             case "Components":
                 if (ComponentsPanel.getSelectedRowCount() > 1) {
-                    multipleSelection=true;
+                    multipleSelection = true;
                 } else {
-                    multipleSelection=false;
+                    multipleSelection = false;
                 }
-                if (componentID > 0 ) {
+                if (componentID > 0) {
                     if (multipleSelection) {
-                        buttonPanel1.setButtonEnabled("Modify",false);
-                        buttonPanel1.setButtonEnabled("Query Panel",false);
-                        buttonPanel1.setButtonEnabled("New",false);
-                        buttonPanel1.setButtonEnabled("Refresh",false);
-                        buttonPanel1.setButtonEnabled("Build TemplateTree",false);
+                        buttonPanel1.setButtonEnabled("Modify", false);
+                        buttonPanel1.setButtonEnabled("Query Panel", false);
+                        buttonPanel1.setButtonEnabled("New", false);
+                        buttonPanel1.setButtonEnabled("Refresh", false);
+                        buttonPanel1.setButtonEnabled("Build TemplateTree", false);
                     } else {
-                        buttonPanel1.setButtonEnabled("Modify",true);
-                        buttonPanel1.setButtonEnabled("Query Panel",true);
-                        buttonPanel1.setButtonEnabled("New",true);
-                        buttonPanel1.setButtonEnabled("Refresh",true);
-                        buttonPanel1.setButtonEnabled("Build TemplateTree",true);
+                        buttonPanel1.setButtonEnabled("Modify", true);
+                        buttonPanel1.setButtonEnabled("Query Panel", true);
+                        buttonPanel1.setButtonEnabled("New", true);
+                        buttonPanel1.setButtonEnabled("Refresh", true);
+                        buttonPanel1.setButtonEnabled("Build TemplateTree", true);
                         try {
                             if (OtdbRmi.getRemoteMaintenance().isTopComponent(componentID)) {
-                                buttonPanel1.setButtonEnabled("Build TemplateTree",true);
+                                buttonPanel1.setButtonEnabled("Build TemplateTree", true);
                             } else {
-                                buttonPanel1.setButtonEnabled("Build TemplateTree",false);
+                                buttonPanel1.setButtonEnabled("Build TemplateTree", false);
                             }
                         } catch (RemoteException ex) {
-                            String aS="Error checking isTopComponent";
+                            String aS = "Error checking isTopComponent";
                             logger.error(aS);
-                            LofarUtils.showErrorPanel(this,aS,new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
+                            LofarUtils.showErrorPanel(this, aS, new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_warn.gif")));
                         }
                     }
-                    buttonPanel1.setButtonEnabled("Delete",true);
+                    buttonPanel1.setButtonEnabled("Delete", true);
                 } else {
-                    buttonPanel1.setButtonEnabled("Delete",false);
-                    buttonPanel1.setButtonEnabled("Modify",false);
-                    buttonPanel1.setButtonEnabled("Query Panel",false);
-                    buttonPanel1.setButtonEnabled("New",false);
-                    buttonPanel1.setButtonEnabled("Refresh",false);
-                    buttonPanel1.setButtonEnabled("Build TemplateTree",false);
+                    buttonPanel1.setButtonEnabled("Delete", false);
+                    buttonPanel1.setButtonEnabled("Modify", false);
+                    buttonPanel1.setButtonEnabled("Query Panel", false);
+                    buttonPanel1.setButtonEnabled("New", false);
+                    buttonPanel1.setButtonEnabled("Refresh", false);
+                    buttonPanel1.setButtonEnabled("Build TemplateTree", false);
                 }
                 break;
             case "Query Results":
                 break;
         }
     }
-    
-    private MainFrame                   itsMainFrame = null;
-    private String                      itsTabFocus="PIC";
-    private boolean                     buttonsInitialized=false;
-    private LoadFileDialog              loadFileDialog = null;
-    private TreeInfoDialog              treeInfoDialog = null;
-    private MultiEditDialog             multiEditDialog = null;
+    private MainFrame itsMainFrame = null;
+    private String itsTabFocus = "PIC";
+    private boolean buttonsInitialized = false;
+    private LoadFileDialog loadFileDialog = null;
+    private TreeInfoDialog treeInfoDialog = null;
+    private MultiEditDialog multiEditDialog = null;
     private CreateDefaultTemplateDialog defaultTemplateDialog = null;
-    private TableDialog                 stateChangeHistoryDialog = null;
+    private TableDialog stateChangeHistoryDialog = null;
     private StateChangeHistoryTableModel itsStateChangeModel = null;
-    private boolean                     changed=false;
-    private boolean                     multipleSelection=false;
-    
+    private boolean changed = false;
+    private boolean multipleSelection = false;
     // File to be loaded info
-    File itsNewFile=null;
-    String itsFileDescription="";
+    File itsNewFile = null;
+    String itsFileDescription = "";
     String itsFileStatus = "";
-            
-    
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JPanel AdminPanel;
     private nl.astron.lofar.sas.otbcomponents.TablePanel ComponentsPanel;
@@ -1687,5 +1713,4 @@ public class MainPanel extends javax.swing.JPanel
     private nl.astron.lofar.sas.otbcomponents.ButtonPanel buttonPanel1;
     private javax.swing.JTabbedPane jTabbedPane1;
     // End of variables declaration//GEN-END:variables
-    
 }
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/tablemodels/BeamConfigurationTableModel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/tablemodels/BeamConfigurationTableModel.java
index e2f9b7b94ca..637c406b936 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/tablemodels/BeamConfigurationTableModel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otb/util/tablemodels/BeamConfigurationTableModel.java
@@ -61,7 +61,6 @@ public class BeamConfigurationTableModel extends javax.swing.table.DefaultTableM
         this.addColumn("coordtype");
         this.addColumn("#TAB");
         this.addColumn("subbands");
-        this.addColumn("beamlets");
     }
     
     /** fills the table with the initial settings
@@ -138,8 +137,7 @@ public class BeamConfigurationTableModel extends javax.swing.table.DefaultTableM
                              aBeam.getAngle2(),
                              aBeam.getCoordType(),
                              aBeam.getNrTiedArrayBeams(),
-                             aBeam.getSubbandList(),
-                             aBeam.getBeamletList() };
+                             aBeam.getSubbandList() };
         this.addRow(newRow);
         itsBeams.trimToSize();
 
@@ -171,7 +169,6 @@ public class BeamConfigurationTableModel extends javax.swing.table.DefaultTableM
         this.setValueAt(newBeam.getCoordType(),row,3);
         this.setValueAt(newBeam.getNrTiedArrayBeams(),row,5);
         this.setValueAt(newBeam.getSubbandList(),row,6);
-        this.setValueAt(newBeam.getBeamletList(),row,7);
         
         isChanged=true;
 
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.form
index a1ff016b431..b41add2590a 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.form
@@ -107,25 +107,14 @@
                               <EmptySpace max="-2" attributes="0"/>
                           </Group>
                           <Group type="102" alignment="1" attributes="0">
-                              <Group type="103" groupAlignment="0" attributes="0">
-                                  <Group type="102" alignment="0" attributes="0">
-                                      <Component id="labelSubbandList" pref="87" max="32767" attributes="1"/>
-                                      <EmptySpace type="separate" max="-2" attributes="0"/>
-                                  </Group>
-                                  <Group type="102" alignment="0" attributes="0">
-                                      <Component id="labelBeamletList" min="-2" max="-2" attributes="1"/>
-                                      <EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
-                                  </Group>
-                              </Group>
-                              <Group type="103" groupAlignment="0" max="-2" attributes="0">
-                                  <Component id="inputBeamletList" max="32767" attributes="1"/>
-                                  <Component id="inputSubbandList" alignment="0" pref="1077" max="32767" attributes="1"/>
-                              </Group>
+                              <Component id="labelSubbandList" pref="102" max="32767" attributes="1"/>
+                              <EmptySpace type="separate" max="-2" attributes="0"/>
+                              <Component id="inputSubbandList" min="-2" pref="1077" max="-2" attributes="1"/>
                               <EmptySpace min="-2" pref="665" max="-2" attributes="0"/>
                           </Group>
                           <Group type="102" alignment="0" attributes="0">
                               <Component id="jPanel3" min="-2" pref="1201" max="-2" attributes="1"/>
-                              <EmptySpace pref="646" max="32767" attributes="0"/>
+                              <EmptySpace pref="661" max="32767" attributes="0"/>
                           </Group>
                       </Group>
                   </Group>
@@ -173,12 +162,7 @@
                           <Component id="labelSubbandList" alignment="3" min="-2" max="-2" attributes="0"/>
                           <Component id="inputSubbandList" alignment="3" min="-2" max="-2" attributes="0"/>
                       </Group>
-                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                      <Group type="103" groupAlignment="3" attributes="0">
-                          <Component id="labelBeamletList" alignment="3" min="-2" max="-2" attributes="0"/>
-                          <Component id="inputBeamletList" alignment="3" min="-2" max="-2" attributes="0"/>
-                      </Group>
-                      <EmptySpace type="separate" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
                       <Component id="jPanel3" min="-2" pref="267" max="-2" attributes="1"/>
                       <EmptySpace min="-2" pref="94" max="-2" attributes="0"/>
                       <Group type="103" groupAlignment="3" attributes="0">
@@ -224,13 +208,6 @@
             </Component>
             <Component class="javax.swing.JTextField" name="inputSubbandList">
             </Component>
-            <Component class="javax.swing.JLabel" name="labelBeamletList">
-              <Properties>
-                <Property name="text" type="java.lang.String" value="Beamlets :"/>
-              </Properties>
-            </Component>
-            <Component class="javax.swing.JTextField" name="inputBeamletList">
-            </Component>
             <Component class="javax.swing.JButton" name="cancelButton">
               <Properties>
                 <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
@@ -311,7 +288,7 @@
                 <DimensionLayout dim="1">
                   <Group type="103" groupAlignment="0" attributes="0">
                       <Group type="102" alignment="1" attributes="0">
-                          <Component id="TABConfigurationPanel" pref="201" max="32767" attributes="0"/>
+                          <Component id="TABConfigurationPanel" pref="202" max="32767" attributes="0"/>
                           <EmptySpace type="separate" max="-2" attributes="0"/>
                           <Group type="103" groupAlignment="3" attributes="0">
                               <Component id="addTiedArrayBeamButton" alignment="3" min="-2" max="-2" attributes="0"/>
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.java
index 2d4b0ba1a1e..60c7b3ddd62 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/BeamDialog.java
@@ -21,7 +21,6 @@
 
 package nl.astron.lofar.sas.otbcomponents;
 import java.util.ArrayList;
-import java.util.BitSet;
 import javax.swing.JOptionPane;
 import javax.swing.ListSelectionModel;
 import javax.swing.border.TitledBorder;
@@ -49,20 +48,17 @@ public class BeamDialog extends javax.swing.JDialog {
      *
      * @param   parent                  Frame where this dialog belongs
      * @param   modal                   Should the Dialog be modal or not
-     * @param   usedBeamlets            Bitset of all used beamlets(in case edit, the old ones have been xorred allready)
      * @param   selection               Vector of all Beam parameters
      * @param   directionTypeChoices    String with all possible choices + default for combobox
      * @param   edit                    indicates edit or add mode
      * @param   show                    indicates show only mode
      */
-    public BeamDialog(java.awt.Frame parent, String treeType, boolean modal,BitSet usedBeamlets, Beam aBeam, boolean edit, boolean show ) {
+    public BeamDialog(java.awt.Frame parent, String treeType, boolean modal,Beam aBeam, boolean edit, boolean show ) {
 
         super(parent, modal);
         initComponents();
         LofarUtils.setPopupComboChoices(inputDirectionTypes,aBeam.getDirectionTypeChoices());
         itsBeam = aBeam;
-        itsSavedBeamlets=(BitSet)usedBeamlets.clone();
-        itsUsedBeamlets=(BitSet)usedBeamlets.clone();
         editting=edit;
         showing=show;
         itsTreeType = treeType;
@@ -99,29 +95,6 @@ public class BeamDialog extends javax.swing.JDialog {
         return true;
     }
 
-    // check if Beamlets are spelled correctly and if Beamlets are not used by other Beams'
-    private boolean checkBeamlets(){
-        if (inputBeamletList.getText().length() <=2) {
-            return true;
-        }
-        
-        BitSet aBitSet = LofarUtils.beamletToBitSet(LofarUtils.expandedArrayString(inputBeamletList.getText()));
-        if(itsUsedBeamlets.intersects(aBitSet)) {
-            return false;
-        } else {
-            itsUsedBeamlets.or(aBitSet);
-        }
-        return true;
-    }
-
-    // check if nr of beamlets used and nr of subbands used are equal
-    private boolean checkNrOfBeamletsAndSubbands() {
-        if (LofarUtils.nrArrayStringElements(inputBeamletList.getText())!= LofarUtils.nrArrayStringElements(inputSubbandList.getText()) ) {
-            return false;
-        }
-
-        return true;
-    }
     
     private void initialize() {
         
@@ -144,7 +117,6 @@ public class BeamDialog extends javax.swing.JDialog {
         inputAngle2.setText(itsBeam.getAngle2());
         coordTypeChange.setSelectedItem(itsBeam.getCoordType());
         inputSubbandList.setText(itsBeam.getSubbandList());
-        inputBeamletList.setText(itsBeam.getBeamletList());
         inputDuration.setText(itsBeam.getDuration());
         inputTarget.setText(itsBeam.getTarget());
         inputStartTime.setText(itsBeam.getStartTime());
@@ -171,7 +143,6 @@ public class BeamDialog extends javax.swing.JDialog {
         inputAngle2.setEnabled(flag);
         coordTypeChange.setEnabled(flag);
         inputSubbandList.setEnabled(flag);
-        inputBeamletList.setEnabled(flag);
         inputDuration.setEnabled(flag);
         inputTarget.setEnabled(flag);
         inputStartTime.setEnabled(flag);
@@ -183,10 +154,6 @@ public class BeamDialog extends javax.swing.JDialog {
         return isChanged;
     }
     
-    public BitSet getBeamletList() {
-        return itsUsedBeamlets;
-    }
-    
     public void setBorderTitle(String text) {
         TitledBorder aBorder=(TitledBorder)jPanel1.getBorder();
         aBorder.setTitle(text);
@@ -212,8 +179,6 @@ public class BeamDialog extends javax.swing.JDialog {
         inputAngle2 = new javax.swing.JTextField();
         labelSubbandList = new javax.swing.JLabel();
         inputSubbandList = new javax.swing.JTextField();
-        labelBeamletList = new javax.swing.JLabel();
-        inputBeamletList = new javax.swing.JTextField();
         cancelButton = new javax.swing.JButton();
         saveButton = new javax.swing.JButton();
         labelDirectionTypes = new javax.swing.JLabel();
@@ -255,8 +220,6 @@ public class BeamDialog extends javax.swing.JDialog {
 
         labelSubbandList.setText("Subbands :");
 
-        labelBeamletList.setText("Beamlets :");
-
         cancelButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/nl/astron/lofar/sas/otb/icons/16_cancel.png"))); // NOI18N
         cancelButton.setText("Cancel");
         cancelButton.addActionListener(new java.awt.event.ActionListener() {
@@ -338,7 +301,7 @@ public class BeamDialog extends javax.swing.JDialog {
         jPanel3Layout.setVerticalGroup(
             jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
             .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
-                .add(TABConfigurationPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
+                .add(TABConfigurationPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                 .add(18, 18, 18)
                 .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(addTiedArrayBeamButton)
@@ -398,20 +361,13 @@ public class BeamDialog extends javax.swing.JDialog {
                             .add(org.jdesktop.layout.GroupLayout.LEADING, labelNrTabRings, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                         .addContainerGap())
                     .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
-                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-                            .add(jPanel1Layout.createSequentialGroup()
-                                .add(labelSubbandList, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
-                                .add(18, 18, 18))
-                            .add(jPanel1Layout.createSequentialGroup()
-                                .add(labelBeamletList)
-                                .add(45, 45, 45)))
-                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
-                            .add(inputBeamletList)
-                            .add(inputSubbandList, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1077, Short.MAX_VALUE))
+                        .add(labelSubbandList, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
+                        .add(18, 18, 18)
+                        .add(inputSubbandList, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1077, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                         .add(665, 665, 665))
                     .add(jPanel1Layout.createSequentialGroup()
                         .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1201, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-                        .addContainerGap(646, Short.MAX_VALUE))))
+                        .addContainerGap(661, Short.MAX_VALUE))))
         );
         jPanel1Layout.setVerticalGroup(
             jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -448,11 +404,7 @@ public class BeamDialog extends javax.swing.JDialog {
                 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                     .add(labelSubbandList)
                     .add(inputSubbandList, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-                    .add(labelBeamletList)
-                    .add(inputBeamletList, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-                .add(18, 18, 18)
+                .add(49, 49, 49)
                 .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 267, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                 .add(94, 94, 94)
                 .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
@@ -482,33 +434,12 @@ public class BeamDialog extends javax.swing.JDialog {
     private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
         //check if input is correct
         checkChanged();
-        if (hasChanged() && !checkBeamlets()) {
-            if (JOptionPane.showConfirmDialog(this,"There is an error in the beamletList, some of them are allready in use by other Beams. continueing discards all changes. Continue?","Beamlet Error",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-                itsUsedBeamlets=(BitSet)itsSavedBeamlets.clone();
-                isChanged=false;
-                setVisible(false);
-                dispose();
-            } else {
-                itsUsedBeamlets=(BitSet)itsSavedBeamlets.clone();
-                return;
-            }
-        } else if (hasChanged() && !checkSubbands()) {
-            if (JOptionPane.showConfirmDialog(this,"There is an error in the SubbandsList , Only subbands 1-511 can be used. continueing discards all changes. Continue?","Beamlet Error",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-                itsUsedBeamlets=(BitSet)itsSavedBeamlets.clone();
+        if (hasChanged() && !checkSubbands()) {
+            if (JOptionPane.showConfirmDialog(this,"There is an error in the SubbandsList , Only subbands 1-511 can be used. continueing discards all changes. Continue?","SubbandNr Error",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
                 isChanged=false;
                 setVisible(false);
                 dispose();
             } else {
-                itsUsedBeamlets=(BitSet)itsSavedBeamlets.clone();
-                return;
-            }
-
-        } else if (hasChanged() && !checkNrOfBeamletsAndSubbands() ) {
-            if (JOptionPane.showConfirmDialog(this,"The number of beamlets and subbands differ.","Beamlet-subband amount differ  Error",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION ) {
-                setVisible(false);
-                dispose();
-            } else {
-                itsUsedBeamlets=(BitSet)itsSavedBeamlets.clone();
                 return;
             }
 
@@ -523,7 +454,6 @@ public class BeamDialog extends javax.swing.JDialog {
 
     private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
         isChanged=false;
-        itsUsedBeamlets=(BitSet)itsSavedBeamlets.clone();
         setVisible(false);
         TABConfigurationPanel=null;
         itsTABConfigurationTableModel = null;
@@ -626,10 +556,6 @@ public class BeamDialog extends javax.swing.JDialog {
             isChanged=true;
             return;
         }
-        if (!itsBeam.getBeamletList().equals(inputBeamletList.getText())) {
-            isChanged=true;
-            return;
-        }
         if (!itsBeam.getDuration().equals(inputDuration.getText())) {
             isChanged=true;
             return;
@@ -669,7 +595,6 @@ public class BeamDialog extends javax.swing.JDialog {
         itsBeam.setDuration(inputDuration.getText());
         itsBeam.setStartTime(inputStartTime.getText());
         itsBeam.setSubbandList(LofarUtils.compactedArrayString(inputSubbandList.getText()));
-        itsBeam.setBeamletList(LofarUtils.compactedArrayString(inputBeamletList.getText()));
         itsBeam.setNrTabRings(inputNrTabRings.getText());
         itsBeam.setTabRingSize(inputTabRingSize.getText());
         itsBeam.setNrTiedArrayBeams(Integer.toString(itsTiedArrayBeams.size()-offset));
@@ -680,7 +605,6 @@ public class BeamDialog extends javax.swing.JDialog {
     private void deleteTiedArrayBeam() {
         itsSelectedRow = TABConfigurationPanel.getSelectedRow();
         if (JOptionPane.showConfirmDialog(this,"Are you sure you want to delete this TAB ?","Delete TAB",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-            // if removed then the old Beamlets's should be removed form the checklist also
             if (itsSelectedRow > -1) {
                 itsTABConfigurationTableModel.removeRow(itsSelectedRow);
                 // No selection anymore after delete, so buttons disabled again
@@ -737,8 +661,6 @@ public class BeamDialog extends javax.swing.JDialog {
     private boolean   editTiedArrayBeam = false;
     private boolean   editting          = false;
     private boolean   showing           = false;
-    private BitSet    itsUsedBeamlets   = null;
-    private BitSet    itsSavedBeamlets  = null;
     private String    itsTreeType       = null;
     
     private TiedArrayBeamConfigurationTableModel itsTABConfigurationTableModel = null;
@@ -753,7 +675,6 @@ public class BeamDialog extends javax.swing.JDialog {
     private javax.swing.JButton editTiedArrayBeamButton;
     private javax.swing.JTextField inputAngle1;
     private javax.swing.JTextField inputAngle2;
-    private javax.swing.JTextField inputBeamletList;
     private javax.swing.JComboBox inputDirectionTypes;
     private javax.swing.JTextField inputDuration;
     private javax.swing.JTextField inputNrTabRings;
@@ -766,7 +687,6 @@ public class BeamDialog extends javax.swing.JDialog {
     private javax.swing.JScrollPane jScrollPane1;
     private javax.swing.JLabel labelAngle1;
     private javax.swing.JLabel labelAngle2;
-    private javax.swing.JLabel labelBeamletList;
     private javax.swing.JLabel labelDirectionTypes;
     private javax.swing.JLabel labelDuration;
     private javax.swing.JLabel labelNrTabRings;
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.form
index 85269c31886..290ea233931 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.form
@@ -75,7 +75,7 @@
     <Component class="javax.swing.JTextField" name="nameInput">
       <Constraints>
         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-          <AbsoluteConstraints x="170" y="200" width="300" height="-1"/>
+          <AbsoluteConstraints x="220" y="200" width="300" height="-1"/>
         </Constraint>
       </Constraints>
     </Component>
@@ -92,7 +92,7 @@
     <Component class="javax.swing.JTextField" name="processTypeInput">
       <Constraints>
         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-          <AbsoluteConstraints x="170" y="230" width="300" height="-1"/>
+          <AbsoluteConstraints x="220" y="230" width="300" height="-1"/>
         </Constraint>
       </Constraints>
     </Component>
@@ -109,7 +109,7 @@
     <Component class="javax.swing.JTextField" name="processSubtypeInput">
       <Constraints>
         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-          <AbsoluteConstraints x="170" y="260" width="300" height="-1"/>
+          <AbsoluteConstraints x="220" y="260" width="300" height="-1"/>
         </Constraint>
       </Constraints>
     </Component>
@@ -126,7 +126,7 @@
     <Component class="javax.swing.JTextField" name="strategyInput">
       <Constraints>
         <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
-          <AbsoluteConstraints x="170" y="290" width="300" height="-1"/>
+          <AbsoluteConstraints x="220" y="290" width="300" height="-1"/>
         </Constraint>
       </Constraints>
     </Component>
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.java
index d94e66c2b68..c19b6155fff 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/CreateDefaultTemplateDialog.java
@@ -116,21 +116,21 @@ public class CreateDefaultTemplateDialog extends javax.swing.JDialog {
             }
         });
         getContentPane().add(jButtonOK, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 350, -1, -1));
-        getContentPane().add(nameInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 200, 300, -1));
+        getContentPane().add(nameInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 200, 300, -1));
 
         jLabel2.setText("ProcessType:");
         getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 230, -1, -1));
-        getContentPane().add(processTypeInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 230, 300, -1));
+        getContentPane().add(processTypeInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 230, 300, -1));
 
         jLabel3.setText("ProcessSubtype:");
         getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 260, -1, -1));
-        getContentPane().add(processSubtypeInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 260, 300, -1));
+        getContentPane().add(processSubtypeInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 260, 300, -1));
 
         jLabel4.setText("Strategy:");
         getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 290, -1, -1));
-        getContentPane().add(strategyInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 290, 300, -1));
+        getContentPane().add(strategyInput, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 290, 300, -1));
 
-        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
+        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14));
         jLabel5.setText("Create new Default Template");
         getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 10, 220, -1));
 
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParamExtensionDialog.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParamExtensionDialog.java
index d6236d16c01..b338925e885 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParamExtensionDialog.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/ParamExtensionDialog.java
@@ -1,4 +1,4 @@
-/* BeamDialog.java
+/* ParamExtensionDialog.java
  *
  *  Copyright (C) 2002-2007
  *  ASTRON (Netherlands Foundation for Research in Astronomy)
@@ -40,10 +40,7 @@ public class ParamExtensionDialog extends javax.swing.JDialog {
      *
      * @param   parent                  Frame where this dialog belongs
      * @param   modal                   Should the Dialog be modal or not
-     * @param   usedBeamlets            Bitset of all used beamlets(in case edit, the old ones have been xorred allready)
      * @param   selection               Vector of all Beam parameters
-     * @param   directionTypeChoices    String with all possible choices + default for combobox
-     * @param   edit                    indicates edit or add mode
      */
     public ParamExtensionDialog(java.awt.Frame parent, boolean modal, String[] selection) {
 
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.java
index f9a0411a9e6..0266542a67d 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.java
@@ -32,7 +32,6 @@ import java.io.IOException;
 import java.rmi.RemoteException;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.BitSet;
 import java.util.Collection;
 import javax.swing.DefaultListModel;
 import javax.swing.JFileChooser;
@@ -487,12 +486,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
                    } else {
                         itsActiveBeam.setStartTime(aNode.limits);
                    }break;
-                case "beamletList":
-                    if (isRef && aParam != null) {
-                        itsActiveBeam.setBeamletList(aNode.limits + " : " + aParam.limits);
-                   } else {
-                        itsActiveBeam.setBeamletList(aNode.limits);
-                   }break;
                 case "subbandList":
                     if (isRef && aParam != null) {
                         itsActiveBeam.setSubbandList(aNode.limits + " : " + aParam.limits);
@@ -721,13 +714,8 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
       inputDescription.setText("");
       inputTreeDescription.setText(itsOldTreeDescription);
     
-      if (!itsTreeType.equals("VHtree")) {
-         // Observation Beam parameters
-         // create original Beamlet Bitset
-         fillBeamletBitset();
-      }
-        // set tables back to initial values
-        boolean fillTable = itsBeamConfigurationTableModel.fillTable(itsTreeType,itsBeamList,false);
+      // set tables back to initial values
+      boolean fillTable = itsBeamConfigurationTableModel.fillTable(itsTreeType,itsBeamList,false);
       itsAnaBeamConfigurationTableModel.fillTable(itsTreeType,itsAnaBeamList,false);
       
       itsBeamformerConfigurationTableModel.fillTable(itsTreeType, itsStations);
@@ -762,27 +750,7 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
      // also restore antennaConfigPanel
       antennaConfigPanel.restore();
     }
-
-    
-    /** fill the Beamlet bitset to see what Beamlets have been set. To be able to determine later if a given Beamlet is indeed free.
-     */
-    private void fillBeamletBitset() {
-        itsUsedBeamlets.clear();
-        for (Beam b : itsBeamList) {
-            BitSet aNewBitSet=b.getBeamletBitSet();
-            // check if no duplication between the two bitsets
-            if (itsUsedBeamlets.intersects(aNewBitSet)) {
-                String errorMsg = "ERROR:  This BeamletList has beamlets defined that are allready used in a prior BeamConfiguration!!!!!  Beam: "+b;
-                JOptionPane.showMessageDialog(this,errorMsg,"BeamletError",JOptionPane.ERROR_MESSAGE);
-                logger.debug(errorMsg );
-                return;
-            }
-            
-            // No intersection, both bitsets can be or
-            itsUsedBeamlets.or(aNewBitSet);
-        }
-    }
-    
+   
      
     private void initialize() {
         buttonPanel1.addButton("Restore");
@@ -803,7 +771,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
         beamConfigurationPanel.setColumnSize("coordtype",24);
         beamConfigurationPanel.setColumnSize("#TAB",24);
         beamConfigurationPanel.setColumnSize("subbands",65);
-        beamConfigurationPanel.setColumnSize("beamlets",65);
         beamConfigurationPanel.repaint();
         
         itsAnaBeamConfigurationTableModel = new AnaBeamConfigurationTableModel();
@@ -862,7 +829,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
         }
         
         // set defaults
-        // create initial beamletBitset
         // create initial table
         restore();
         
@@ -1126,9 +1092,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
                                 case "subbandList" :
                                     n.limits=b.getSubbandList();
                                     break;
-                                case "beamletList" :
-                                    n.limits=b.getBeamletList();
-                                    break;
                                 case "momID" :
                                     n.limits=b.getMomID();
                                     break;
@@ -1477,11 +1440,8 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
     private void deleteBeam() {
         int row = beamConfigurationPanel.getSelectedRow();
         if (JOptionPane.showConfirmDialog(this,"Are you sure you want to delete this Beam ?","Delete Beam",JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION ) {
-            // if removed then the old Beamlets's should be removed form the checklist also
-            BitSet beamletSet = itsBeamConfigurationTableModel.getSelection(row).getBeamletBitSet();
             if (row > -1) {
                 itsBeamConfigurationTableModel.removeRow(row);
-                itsUsedBeamlets.xor(beamletSet);
                 // No selection anymore after delete, so buttons disabled again
                 this.editBeamButton.setEnabled(false);
                 this.deleteBeamButton.setEnabled(false);
@@ -1522,7 +1482,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
 
     private void addBeam() {
      
-        BitSet aBS=itsUsedBeamlets;
         itsSelectedRow=-1;
         itsSelectedRow = beamConfigurationPanel.getSelectedRow();
         // set selection to defaults.
@@ -1530,10 +1489,8 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
         if (editBeam) {
             selection = itsBeamConfigurationTableModel.getSelection(itsSelectedRow);
                        
-            BitSet oldBeamlets = selection.getBeamletBitSet();
-            aBS.xor(oldBeamlets);
         }
-        beamDialog = new BeamDialog(itsMainFrame,itsTreeType,true,aBS,selection.clone(),editBeam,showBeam);
+        beamDialog = new BeamDialog(itsMainFrame,itsTreeType,true,selection.clone(),editBeam,showBeam);
         
         beamDialog.setLocationRelativeTo(this);
         if (editBeam) {
@@ -1550,7 +1507,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
         // check if something has changed 
         if (beamDialog.hasChanged()) {
             Beam newBeam = beamDialog.getBeam();
-            itsUsedBeamlets=beamDialog.getBeamletList();
             // check if we are editting an entry or adding a new entry
             if (editBeam) {
                 itsBeamConfigurationTableModel.updateRow(newBeam,itsSelectedRow);
@@ -1648,7 +1604,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
         // beam0.directionType=AZEL
         // beam0.duration=300
         // beam0.subbandList=[1,2,3,4,5]
-        // beam0.beamletList[1,2,3,4,5]
         // beam0.tiedarraybeam0.angle1 = 1
         // #
         // beam1.target=test2
@@ -1658,7 +1613,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
         // beam1.directionType=LMN
         // beam1.duration=360
         // beam1.subbandList=[6..10]
-        // beam1.beamletList[6..10]
         //
         if (choice.equals("AnaBeams") || choice.equals("Beams")) {
             File aNewFile=null;
@@ -1913,17 +1867,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
                                 break;
                         }
                         break;
-                    case "beamletlist" :
-                        switch (check) {
-                            case "beam" :
-                                readBeams.get(idx+1).setBeamletList(keyVal[1]);
-                                break;
-                            case "anabeam" :
-                                break;
-                            case "tiedarraybeam" :
-                                break;
-                        }
-                        break;
                     case "nrtiedarraybeams" :
                         switch (check) {
                             case "beam" :
@@ -2761,8 +2704,6 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
     // keeps lists of available (unused)  and all used stations for Beamformer creation
     private ArrayList<String>    itsAvailableBeamformStations       = new ArrayList<>();
     private ArrayList<String>    itsUsedBeamformStations            = new ArrayList<>();
-    // each beamlet has its bit in the bitset
-    private BitSet   itsUsedBeamlets = new BitSet(216);
     private boolean  editBeam = false;
     private boolean  editAnaBeam = false;
     private boolean  showBeam = false;
-- 
GitLab