diff --git a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java index b7d99e2f8542b9bba5fe5a3f2523f3355269e078..556660b6de288c2952a5cbffa9ed9033142c7d47 100644 --- a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java +++ b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/LofarUtils.java @@ -375,6 +375,25 @@ public abstract class LofarUtils { return aV; } + /** Function to return nr of elements in an stringArray + * + */ + static public int nrArrayStringElements(String orgStr) { + int nr = -1; + // destroyable copy, containing expanded String to avoid allready available x..y constructions + String baseStr=LofarUtils.expandedArrayString(orgStr); + + // strip the brackets, space and tab + baseStr =LofarUtils.ltrim(baseStr," \\["); + baseStr =LofarUtils.rtrim(baseStr," \\]"); + + + //split the baseString into individual numbers + String[] splitted = baseStr.split("[,]"); + + return splitted.length; + } + /** Function compactedArrayString(string) * * 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 c29df69f9d85c3bf8dc16811c4737b7246bf7d72..c0c37c6b1ed9cc339e9dc6bc1de58614c6220dbd 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 @@ -110,6 +110,15 @@ public class BeamDialog extends javax.swing.JDialog { } 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() { @@ -329,6 +338,16 @@ public class BeamDialog extends javax.swing.JDialog { isChanged=false; setVisible(false); dispose(); + } else { + return; + } + + } else if (hasChanged() && !checkNrOfBeamletsAndSubbands() ) { + if (JOptionPane.showConfirmDialog(this,"The number of beamlets and subbands differ. Continueing discards all changes. Continue?","Beamlet-subband amount differ 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; diff --git a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/TreeInfoDialog.java b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/TreeInfoDialog.java index 7514916a6b91235c8c3ce4c213304f84b27d558a..f8990a4c127394b3d6d2850d6b44194d8cb58c45 100644 --- a/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/TreeInfoDialog.java +++ b/SAS/OTB/OTB/src/nl/astron/lofar/sas/otbcomponents/TreeInfoDialog.java @@ -311,6 +311,10 @@ public class TreeInfoDialog extends javax.swing.JDialog { } private boolean checkTimes() { + + // for now return true because Arno needs to do some testing. + return true; +/* // start the checking. Both dates need to be set. // the startdate needs to be at least 4 minutes away from NOW // the enddate needs to be further in the future then the starttime/. @@ -325,27 +329,35 @@ public class TreeInfoDialog extends javax.swing.JDialog { anErrorMsg = "Stop time BEFORE start time"; } - // check if date is further away then now(in GMT) + 4 minutes + // check if date is further away then now(in GMT) + 1 minutes Date now = getGMTTime(new Date()); Calendar cal = Calendar.getInstance(); cal.setTime(now); cal.set(Calendar.MINUTE,cal.get(Calendar.MINUTE)+1); Date minTime = getGMTTime(cal.getTime()); - if (itsStartDate.before(minTime)) { - anErrorMsg = "Start time needs to be minimal 1 minutes away from now (GMT)"; - // create an Info popup. - JOptionPane.showMessageDialog(this,anErrorMsg,"Warning",JOptionPane.WARNING_MESSAGE); - return true; } + if (itsStartDate.after(now)) { + anErrorMsg = "That date allready passed I'm afraid."; + } else if (itsStartDate.before(minTime)) { + anErrorMsg = "Start time needs to be minimal 1 minutes away from now (GMT)"; + // create an Info popup. + JOptionPane.showMessageDialog(this,anErrorMsg,"Warning",JOptionPane.WARNING_MESSAGE); + return true; } if (itsStopDate.before(itsStartDate)) { if (anErrorMsg.length() > 0) { anErrorMsg+=", and "; } anErrorMsg = "Stop time BEFORE start time"; - // create an Info popup. - JOptionPane.showMessageDialog(this,anErrorMsg,"Error",JOptionPane.WARNING_MESSAGE); - return false; } + } } - return true; + if (!anErrorMsg.equals("") ) { + // create an Error popup. + JOptionPane.showMessageDialog(this,anErrorMsg,"Error",JOptionPane.ERROR_MESSAGE); + return false; + } else { + return true; + } + * + */ } private void initFocus() {