From 0531dbba9ff156415165c6810550e25d9ab0d25c Mon Sep 17 00:00:00 2001 From: Arthur Coolen <coolen@astron.nl> Date: Wed, 7 May 2008 07:22:42 +0000 Subject: [PATCH] Bug1164: Added changes and improvements after remarks from Arno during MAC-SAS teaching session. --- .../lofar/lofarutils/DateTimeChooser.form | 77 ++++++++----------- .../lofar/lofarutils/DateTimeChooser.java | 77 ++++++++----------- 2 files changed, 64 insertions(+), 90 deletions(-) diff --git a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.form b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.form index 18c4ae51eee..ec2fb8785af 100644 --- a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.form +++ b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.form @@ -14,65 +14,61 @@ <Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> - <Group type="102" alignment="0" attributes="0"> - <EmptySpace max="-2" attributes="0"/> - <Group type="103" groupAlignment="1" attributes="0"> - <Component id="calendar" alignment="0" pref="176" max="32767" attributes="1"/> - <Group type="102" alignment="1" attributes="0"> - <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" max="32767" attributes="0"/> + <EmptySpace min="-2" pref="89" max="-2" attributes="0"/> + </Group> + <Component id="now" alignment="0" min="-2" pref="102" max="-2" attributes="0"/> <Group type="102" alignment="0" attributes="0"> - <Component id="now" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> - <Component id="zero" min="-2" max="-2" attributes="0"/> + <Component id="hours" min="-2" pref="88" max="-2" attributes="0"/> </Group> - <Group type="102" alignment="1" attributes="0"> - <Group type="103" groupAlignment="0" attributes="0"> - <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> - <Component id="hours" alignment="0" min="-2" pref="37" max="-2" attributes="0"/> - </Group> - <EmptySpace pref="26" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="1"/> + <EmptySpace min="-2" pref="38" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> - <Group type="102" attributes="0"> - <Component id="mins" alignment="0" pref="50" max="32767" attributes="1"/> - <EmptySpace min="-2" max="-2" attributes="0"/> - </Group> - <Component id="jLabel2" min="-2" max="-2" attributes="1"/> - </Group> - <EmptySpace min="-2" pref="19" max="-2" attributes="0"/> - <Group type="103" groupAlignment="1" max="-2" attributes="0"> - <Component id="secs" alignment="0" max="32767" attributes="1"/> - <Component id="jLabel3" alignment="0" max="32767" attributes="1"/> + <Component id="zero" alignment="0" min="-2" max="-2" attributes="1"/> + <Component id="mins" alignment="0" min="-2" pref="84" max="-2" attributes="1"/> </Group> </Group> </Group> - <EmptySpace min="-2" max="-2" attributes="0"/> </Group> + <Component id="calendar" alignment="0" pref="210" max="32767" attributes="1"/> </Group> - <EmptySpace min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0"> - <EmptySpace max="32767" attributes="0"/> - <Component id="calendar" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> + <Component id="calendar" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> - <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> - <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="1" attributes="0"> - <Component id="hours" min="-2" max="-2" attributes="0"/> <Component id="mins" min="-2" max="-2" attributes="0"/> - <Component id="secs" min="-2" max="-2" attributes="0"/> + <Component id="hours" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" pref="20" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> - <Component id="now" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="zero" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="now" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" pref="24" max="-2" attributes="0"/> </Group> @@ -81,6 +77,10 @@ </Layout> <SubComponents> <Component class="com.toedter.calendar.JCalendar" name="calendar"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new com.toedter.calendar.JCalendar(local)"/> + <AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value="Locale local = new Locale("en");"/> + </AuxValues> </Component> <Component class="com.toedter.components.JSpinField" name="hours"> <AuxValues> @@ -98,23 +98,12 @@ <Property name="text" type="java.lang.String" value="Minutes:"/> </Properties> </Component> - <Component class="javax.swing.JLabel" name="jLabel3"> - <Properties> - <Property name="text" type="java.lang.String" value="Seconds:"/> - </Properties> - </Component> <Component class="com.toedter.components.JSpinField" name="mins"> <AuxValues> <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JSpinField(0,59);"/> <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="mins.adjustWidthToMaximumValue();"/> </AuxValues> </Component> - <Component class="com.toedter.components.JSpinField" name="secs"> - <AuxValues> - <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new JSpinField(0,59);"/> - <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="secs.adjustWidthToMaximumValue();"/> - </AuxValues> - </Component> <Component class="javax.swing.JButton" name="now"> <Properties> <Property name="text" type="java.lang.String" value="Set to now"/> diff --git a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.java b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.java index 7c1021a1544..a6b9b278fe5 100644 --- a/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.java +++ b/JAVA/LofarUtils/src/nl/astron/lofar/lofarutils/DateTimeChooser.java @@ -13,6 +13,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Locale; import java.util.TimeZone; import javax.swing.JOptionPane; import javax.swing.event.ChangeEvent; @@ -69,12 +70,11 @@ public class DateTimeChooser protected void createItself() { hours.addPropertyChangeListener(this); mins.addPropertyChangeListener(this); - secs.addPropertyChangeListener(this); calendar.setWeekOfYearVisible(false); calendar.addPropertyChangeListener(this); calendar.getYearChooser().addPropertyChangeListener(this); - + setDate (initialDate == null ? new Date() : initialDate,true); } @@ -84,7 +84,7 @@ public class DateTimeChooser cal.setTime(calendar.getDate()); cal.set(Calendar.HOUR_OF_DAY,hours.getValue()); cal.set(Calendar.MINUTE,mins.getValue()); - cal.set(Calendar.SECOND,secs.getValue()); + return cal.getTime(); } @@ -100,11 +100,6 @@ public class DateTimeChooser calendar.setDate(newDate); hours.setValue(cal.get(Calendar.HOUR_OF_DAY)); mins.setValue(cal.get(Calendar.MINUTE)); - if (!isOld) { - secs.setValue(0); - } else { - secs.setValue(cal.get(Calendar.SECOND)); - } } @@ -195,18 +190,17 @@ public class DateTimeChooser * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ - // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { - calendar = new com.toedter.calendar.JCalendar(); + + Locale local = new Locale("en"); + calendar = new com.toedter.calendar.JCalendar(local); hours = new JSpinField(0,23); hours.adjustWidthToMaximumValue(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); - jLabel3 = new javax.swing.JLabel(); mins = new JSpinField(0,59); mins.adjustWidthToMaximumValue(); - secs = new JSpinField(0,59); - secs.adjustWidthToMaximumValue(); now = new javax.swing.JButton(); zero = new javax.swing.JButton(); @@ -214,8 +208,6 @@ public class DateTimeChooser jLabel2.setText("Minutes:"); - jLabel3.setText("Seconds:"); - now.setText("Set to now"); now.setToolTipText("Set Date & Time to now"); now.addActionListener(new java.awt.event.ActionListener() { @@ -237,59 +229,54 @@ public class DateTimeChooser layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(calendar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(89, 89, 89)) + .addComponent(now, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(hours, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addComponent(jLabel2) + .addGap(38, 38, 38)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() - .addComponent(now) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(zero)) - .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel1) - .addComponent(hours, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(mins, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) - .addComponent(jLabel2)) - .addGap(19, 19, 19) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addComponent(secs, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) + .addComponent(zero) + .addComponent(mins, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(calendar, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap() .addComponent(calendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) .addComponent(jLabel2) - .addComponent(jLabel3)) + .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(hours, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(mins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(secs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(hours, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(20, 20, 20) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(now) - .addComponent(zero)) + .addComponent(zero) + .addComponent(now)) .addGap(24, 24, 24)) ); }// </editor-fold>//GEN-END:initComponents private void zeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zeroActionPerformed hours.setValue(0); - mins.setValue(0); - secs.setValue(0); + mins.setValue(0); }//GEN-LAST:event_zeroActionPerformed private void nowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nowActionPerformed @@ -314,10 +301,8 @@ public class DateTimeChooser private com.toedter.components.JSpinField hours; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; - private javax.swing.JLabel jLabel3; private com.toedter.components.JSpinField mins; private javax.swing.JButton now; - private com.toedter.components.JSpinField secs; private javax.swing.JButton zero; // End of variables declaration//GEN-END:variables -- GitLab