From d6ce83c68d4ca811962997097266f947ee0d0e6d Mon Sep 17 00:00:00 2001
From: Arthur Coolen <coolen@astron.nl>
Date: Tue, 29 Sep 2009 11:12:57 +0000
Subject: [PATCH] Bug1377: nullpointers when no active PIC tree

---
 .../otbcomponents/StationSelectionPanel.java   |  6 ++++++
 .../userpanels/ObservationPanel.form           | 17 +++++++++--------
 .../userpanels/ObservationPanel.java           | 18 +++++++++---------
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/StationSelectionPanel.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/StationSelectionPanel.java
index 901ff86ca0e..cf236f0315e 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/StationSelectionPanel.java
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/StationSelectionPanel.java
@@ -99,6 +99,12 @@ public class StationSelectionPanel extends javax.swing.JPanel {
                 }
             }
 
+            // if no active PIC tree we can't continue
+            if (itsTree == null) {
+                enableAllButtons(false);
+                return;
+            }
+
             // Now we have the operational PIC tree, we need to search for the Ring Node to find
             // all available  stations for that ring
             Vector stations = OtdbRmi.getRemoteMaintenance().getItemList(itsTree.treeID(), "LOFAR_PIC_"+itsName);
diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.form b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.form
index 74cdd1e851a..82fba623e41 100644
--- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.form
+++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/userpanels/ObservationPanel.form
@@ -109,7 +109,7 @@
                   <Group type="103" groupAlignment="0" attributes="0">
                       <Group type="102" attributes="0">
                           <Group type="103" groupAlignment="0" attributes="0">
-                              <Component id="jPanel10" alignment="0" min="0" pref="884" max="32767" attributes="1"/>
+                              <Component id="jPanel10" alignment="0" min="0" max="32767" attributes="1"/>
                               <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
                                   <Group type="102" alignment="0" attributes="1">
                                       <Component id="jPanel4" min="-2" pref="632" max="-2" attributes="0"/>
@@ -218,17 +218,18 @@
                               <Group type="103" groupAlignment="0" attributes="0">
                                   <Component id="labelMSNameMask" min="-2" pref="103" max="-2" attributes="1"/>
                                   <Component id="labelReceiverList" min="-2" pref="89" max="-2" attributes="0"/>
+                                  <Component id="labelNrSlotsInFrame" alignment="0" min="-2" max="-2" attributes="1"/>
                               </Group>
                               <EmptySpace max="-2" attributes="0"/>
-                              <Group type="103" groupAlignment="0" max="-2" attributes="0">
-                                  <Group type="102" attributes="1">
-                                      <EmptySpace min="-2" pref="68" max="-2" attributes="0"/>
-                                      <Component id="labelNrSlotsInFrame" min="-2" max="-2" attributes="1"/>
+                              <Group type="103" groupAlignment="0" attributes="0">
+                                  <Group type="102" attributes="0">
+                                      <Component id="inputNrSlotsInFrame" pref="741" max="32767" attributes="1"/>
                                       <EmptySpace max="-2" attributes="0"/>
-                                      <Component id="inputNrSlotsInFrame" max="32767" attributes="1"/>
                                   </Group>
-                                  <Component id="inputMSNameMask" alignment="0" pref="743" max="32767" attributes="1"/>
-                                  <Component id="inputReceiverList" alignment="0" max="32767" attributes="1"/>
+                                  <Group type="103" alignment="0" groupAlignment="0" max="-2" attributes="0">
+                                      <Component id="inputMSNameMask" alignment="0" pref="743" max="32767" attributes="1"/>
+                                      <Component id="inputReceiverList" alignment="0" max="32767" attributes="1"/>
+                                  </Group>
                               </Group>
                           </Group>
                       </Group>
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 002380d0aa9..3bc8d3fe70b 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
@@ -1110,16 +1110,16 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
                 .addContainerGap()
                 .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                     .add(labelMSNameMask, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 103, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-                    .add(labelReceiverList, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                    .add(labelReceiverList, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 89, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(labelNrSlotsInFrame))
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                     .add(jPanel10Layout.createSequentialGroup()
-                        .add(68, 68, 68)
-                        .add(labelNrSlotsInFrame)
-                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-                        .add(inputNrSlotsInFrame))
-                    .add(inputMSNameMask, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
-                    .add(inputReceiverList)))
+                        .add(inputNrSlotsInFrame, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 741, Short.MAX_VALUE)
+                        .addContainerGap())
+                    .add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+                        .add(inputMSNameMask, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
+                        .add(inputReceiverList))))
         );
         jPanel10Layout.setVerticalGroup(
             jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -1332,7 +1332,7 @@ public class ObservationPanel extends javax.swing.JPanel implements IViewPanel{
             jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
             .add(jPanel2Layout.createSequentialGroup()
                 .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-                    .add(jPanel10, 0, 884, Short.MAX_VALUE)
+                    .add(jPanel10, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                     .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                         .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel2Layout.createSequentialGroup()
                             .add(jPanel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 632, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-- 
GitLab