diff --git a/ccm-core/src/com/arsdigita/bebop/form/Date.java b/ccm-core/src/com/arsdigita/bebop/form/Date.java
index 5e53d7b93..58f767c5f 100755
--- a/ccm-core/src/com/arsdigita/bebop/form/Date.java
+++ b/ccm-core/src/com/arsdigita/bebop/form/Date.java
@@ -29,7 +29,6 @@ import com.arsdigita.util.Assert;
import com.arsdigita.bebop.parameters.ParameterModel;
import com.arsdigita.bebop.parameters.DateParameter;
import com.arsdigita.bebop.parameters.ParameterData;
-import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
@@ -40,6 +39,7 @@ import com.arsdigita.kernel.Kernel;
import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.xml.Element;
+import java.text.SimpleDateFormat;
import java.util.Locale;
/**
@@ -47,8 +47,9 @@ import java.util.Locale;
*
* @author Karl Goldstein
* @author Uday Mathur
- * @author Michael Pih
- * @version $Id: Date.java 287 2005-02-22 00:29:02Z sskracic $
+ * @author Michael Pih
+ * @author Sören Bernstein
+ * @version $Id: Date.java 288 2010-02-20 07:29:00Z sbernstein $
*/
public class Date extends Widget implements BebopConstants {
@@ -66,6 +67,7 @@ public class Date extends Widget implements BebopConstants {
this.parent = parent;
}
+ @Override
protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps);
if (value == null) {
@@ -74,6 +76,7 @@ public class Date extends Widget implements BebopConstants {
return new ParameterData(getParameterModel(), value);
}
+ @Override
public Object getValue(PageState ps) {
Object value = parent.getFragmentValue(ps, Calendar.YEAR);
if (value == null) {
@@ -95,6 +98,7 @@ public class Date extends Widget implements BebopConstants {
this.parent = parent;
}
+ @Override
protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps);
if (value == null) {
@@ -103,6 +107,7 @@ public class Date extends Widget implements BebopConstants {
return new ParameterData(getParameterModel(), value);
}
+ @Override
public Object getValue(PageState ps) {
return parent.getFragmentValue(ps, Calendar.MONTH);
}
@@ -118,6 +123,7 @@ public class Date extends Widget implements BebopConstants {
this.parent = parent;
}
+ @Override
protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps);
if (value == null) {
@@ -126,6 +132,7 @@ public class Date extends Widget implements BebopConstants {
return new ParameterData(getParameterModel(), value);
}
+ @Override
public Object getValue(PageState ps) {
return parent.getFragmentValue(ps, Calendar.DATE);
}
@@ -211,10 +218,12 @@ public class Date extends Widget implements BebopConstants {
/** The XML tag for this derived class of Widget.
*/
+ @Override
protected String getElementTag() {
return BEBOP_DATE;
}
+ @Override
public void generateWidget(PageState ps, Element parent) {
if ( ! isVisible(ps) ) {
@@ -222,24 +231,37 @@ public class Date extends Widget implements BebopConstants {
}
Element date = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
- // parent.addContent(date);
date.addAttribute("name", getParameterModel().getName());
exportAttributes(date);
- m_month.generateXML(ps, date);
- m_day .generateXML(ps, date);
- m_year .generateXML(ps, date);
+ generateLocalizedWidget(ps, date);
+ // If Element could be null insert an extra widget to clear entry
if (!hasValidationListener(new NotNullValidationListener())) {
date.newChildElement("NoDate");
}
}
+ // Resepct the localized
+ public void generateLocalizedWidget(PageState ps, Element date) {
+
+ // Get the current Pattern
+// String format = new SimpleDateFormat(SimpleDateFormat.SHORT, Kernel.getContext().getLocale()).toPattern();
+ String format = new SimpleDateFormat().toPattern();
+
+ m_month.generateXML(ps, date);
+ m_day.generateXML(ps, date);
+ m_year.generateXML(ps, date);
+
+ }
+
+ @Override
public void setDisabled() {
m_month.setDisabled();
m_day.setDisabled();
m_year.setDisabled();
}
+ @Override
public void setReadOnly() {
m_month.setReadOnly();
m_day.setReadOnly();
@@ -255,6 +277,7 @@ public class Date extends Widget implements BebopConstants {
* @param the Form Object for this Widget.
* @exception IllegalStateException if form already set.
*/
+ @Override
public void setForm(Form f) {
super .setForm(f);
m_year .setForm(f);
@@ -276,6 +299,7 @@ public class Date extends Widget implements BebopConstants {
return null;
}
+ @Override
public void setClassAttr(String at) {
m_month.setClassAttr(at);
m_year.setClassAttr(at);
@@ -284,5 +308,6 @@ public class Date extends Widget implements BebopConstants {
}
// Don't lock
+ @Override
public void lock() {}
}
diff --git a/ccm-core/src/com/arsdigita/bebop/form/DateTime.java b/ccm-core/src/com/arsdigita/bebop/form/DateTime.java
index a9d7749b4..2e804b758 100755
--- a/ccm-core/src/com/arsdigita/bebop/form/DateTime.java
+++ b/ccm-core/src/com/arsdigita/bebop/form/DateTime.java
@@ -19,221 +19,24 @@
package com.arsdigita.bebop.form;
import com.arsdigita.bebop.Form;
-import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.parameters.DateTimeParameter;
-import com.arsdigita.bebop.parameters.NumberInRangeValidationListener;
-import com.arsdigita.bebop.parameters.ParameterData;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.ParameterModel;
-import com.arsdigita.util.Assert;
-import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.bebop.util.BebopConstants;
import com.arsdigita.xml.Element;
-import java.text.DateFormatSymbols;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
/**
* A class representing a date and time field in an HTML form.
* (based on the code in Date.java)
*
- * @author Scott Seago
- * @version $Id: DateTime.java 287 2005-02-22 00:29:02Z sskracic $
+ * @author Sören Bernstein
+ * @version $Id: DateTime.java 288 2010-02-20 07:29:00Z ssbernstein $
*/
public class DateTime extends Widget implements BebopConstants {
- private OptionGroup m_year;
- private OptionGroup m_month;
- private TextField m_day;
- private TextField m_hour;
- private TextField m_minute;
- private TextField m_second;
- private OptionGroup m_amOrPm;
- private static final String ZERO = "0";
- private boolean m_showSeconds;
-
- // Inner classes for the fragment widgets
- private class YearFragment extends SingleSelect {
-
- private DateTime parent;
-
- public YearFragment(String name, DateTime parent) {
- super(name);
- this.parent = parent;
- }
-
- protected ParameterData getParameterData(PageState ps) {
- Object value = getValue(ps);
- if (value == null) {
- return null;
- }
- return new ParameterData(getParameterModel(), value);
- }
-
- public Object getValue(PageState ps) {
- Object value = parent.getFragmentValue(ps, Calendar.YEAR);
- if (value == null) {
- Calendar currentTime = GregorianCalendar.getInstance();
- int currentYear = currentTime.get(Calendar.YEAR);
- value = new Integer(currentYear);
- }
- return value;
- }
-
- }
-
- private class MonthFragment extends SingleSelect {
-
- private DateTime parent;
-
- public MonthFragment(String name, DateTime parent) {
- super(name);
- this.parent = parent;
- }
-
- protected ParameterData getParameterData(PageState ps) {
- Object value = getValue(ps);
- if (value == null) {
- return null;
- }
- return new ParameterData(getParameterModel(), value);
- }
-
- public Object getValue(PageState ps) {
- return parent.getFragmentValue(ps, Calendar.MONTH);
- }
-
- }
-
- private class DayFragment extends TextField {
-
- private DateTime parent;
-
- public DayFragment(String name, DateTime parent) {
- super(name);
- this.parent = parent;
- }
-
- protected ParameterData getParameterData(PageState ps) {
- Object value = getValue(ps);
- if (value == null) {
- return null;
- }
- return new ParameterData(getParameterModel(), value);
- }
-
- public Object getValue(PageState ps) {
- return parent.getFragmentValue(ps, Calendar.DATE);
- }
- }
-
- private class HourFragment extends TextField {
-
- private DateTime parent;
-
- public HourFragment(String name, DateTime parent) {
- super(name);
- this.parent = parent;
- this.addValidationListener(new NumberInRangeValidationListener(1,12));
- }
-
- protected ParameterData getParameterData(PageState ps) {
- Object value = getValue(ps);
- if (value == null) {
- return null;
- }
- return new ParameterData(getParameterModel(), value);
- }
-
- public Object getValue(PageState ps) {
- return parent.getFragmentValue(ps, Calendar.HOUR);
- }
- }
-
- private class MinuteFragment extends TextField {
-
- private DateTime parent;
-
- public MinuteFragment(String name, DateTime parent) {
- super(name);
- this.parent = parent;
- this.addValidationListener(new NumberInRangeValidationListener(0,59));
- }
-
- protected ParameterData getParameterData(PageState ps) {
- Object value = getValue(ps);
- if (value == null) {
- return null;
- }
- return new ParameterData(getParameterModel(), value);
- }
-
- public Object getValue(PageState ps) {
- Integer min = (Integer) parent.getFragmentValue(ps, Calendar.MINUTE);
- if (min == null) {
- return null;
- }
- if ( min.intValue() < 10 ) {
- return ZERO + min.toString();
- } else {
- return min.toString();
- }
- }
- }
-
- private class SecondFragment extends TextField {
-
- private DateTime parent;
-
- public SecondFragment(String name, DateTime parent) {
- super(name);
- this.parent = parent;
- this.addValidationListener(new NumberInRangeValidationListener(0,59));
- }
-
- protected ParameterData getParameterData(PageState ps) {
- Object value = getValue(ps);
- if (value == null) {
- return null;
- }
- return new ParameterData(getParameterModel(), value);
- }
-
- public Object getValue(PageState ps) {
- Integer sec = (Integer) parent.getFragmentValue(ps, Calendar.SECOND);
- if (sec == null) {
- return null;
- }
- if ( sec.intValue() < 10 ) {
- return ZERO + sec.toString();
- } else {
- return sec.toString();
- }
- }
- }
-
- private class AmPmFragment extends SingleSelect {
-
- private DateTime parent;
-
- public AmPmFragment(String name, DateTime parent) {
- super(name);
- this.parent = parent;
- }
-
- protected ParameterData getParameterData(PageState ps) {
- Object value = getValue(ps);
- if (value == null) {
- return null;
- }
- return new ParameterData(getParameterModel(), value);
- }
-
- public Object getValue(PageState ps) {
- return parent.getFragmentValue(ps, Calendar.AM_PM);
- }
-
- }
+ private Date m_date;
+ private Time m_time;
/**
* Construct a new DateTime. The model must be a DateTimeParameter
@@ -248,69 +51,14 @@ public class DateTime extends Widget implements BebopConstants {
public DateTime(ParameterModel model, boolean showSeconds) {
super(model);
- if ( ! (model instanceof DateTimeParameter)) {
+ if (!(model instanceof DateTimeParameter)) {
throw new IllegalArgumentException(
- "The DateTime widget " + model.getName() +
- " must be backed by a DateTimeParameter parmeter model");
- }
-
- String name = model.getName();
- String nameYear = name + ".year";
- String nameMonth = name + ".month";
- String nameDay = name + ".day";
- String nameHour = name + ".hour";
- String nameMinute = name + ".minute";
- String nameSecond = name + ".second";
- String nameAmOrPm = name + ".amOrPm";
-
-
- DateFormatSymbols dfs = new DateFormatSymbols();
- Calendar currentTime = GregorianCalendar.getInstance();
-
- m_year = new YearFragment(nameYear, this);
- m_month = new MonthFragment(nameMonth, this);
- m_day = new DayFragment(nameDay, this);
- m_hour = new HourFragment(nameHour, this);
- m_minute = new MinuteFragment(nameMinute, this);
- m_showSeconds = showSeconds;
- if (m_showSeconds) {
- m_second = new SecondFragment(nameSecond, this);
- } else {
- m_second = null;
- }
- m_amOrPm = new AmPmFragment(nameAmOrPm, this);
-
- m_day.setMaxLength(2);
- m_day.setSize(2);
- m_hour.setMaxLength(2);
- m_hour.setSize(2);
- m_minute.setMaxLength(2);
- m_minute.setSize(2);
- if (m_showSeconds) {
- m_second.setMaxLength(2);
- m_second.setSize(2);
- }
- String [] months = dfs.getMonths();
-
- for (int i=0; i 0 ) {
- m_month.addOption(new Option(String.valueOf(i),months[i]));
- }
- }
- int currentYear = currentTime.get(Calendar.YEAR);
- setYearRange(currentYear - 1, currentYear + 3);
-
-
- String [] amPmStrings = dfs.getAmPmStrings();
- for (int i=0; i 0 ) {
- m_amOrPm.addOption(new Option(String.valueOf(i),amPmStrings[i]));
- //}
+ "The DateTime widget " + model.getName() +
+ " must be backed by a DateTimeParameter parmeter model");
}
+ m_date = new Date(model);
+ m_time = new Time(model, showSeconds);
}
public DateTime(String name) {
@@ -318,11 +66,7 @@ public class DateTime extends Widget implements BebopConstants {
}
public void setYearRange(int startYear, int endYear) {
- Assert.isUnlocked(this);
- m_year.clearOptions();
- for (int j= startYear; j<=endYear; j+=1) {
- m_year.addOption(new Option(String.valueOf(j)));
- }
+ m_date.setYearRange(startYear, endYear);
}
/**
@@ -346,51 +90,39 @@ public class DateTime extends Widget implements BebopConstants {
/** The XML tag for this derived class of Widget.
*/
+ @Override
protected String getElementTag() {
return BEBOP_DATETIME;
}
+ @Override
public void generateWidget(PageState ps, Element parent) {
- if ( ! isVisible(ps) ) {
+ if (!isVisible(ps)) {
return;
}
- Element date = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
- date.addAttribute("name", getParameterModel().getName());
- m_month .generateXML(ps, date);
- m_day .generateXML(ps, date);
- m_year .generateXML(ps, date);
- m_hour .generateXML(ps, date);
- m_minute.generateXML(ps, date);
- if (m_showSeconds) {
- m_second.generateXML(ps, date);
+ Element datetime = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
+ datetime.addAttribute("name", getParameterModel().getName());
+ m_date.generateLocalizedWidget(ps, datetime);
+ m_time.generateLocalizedWidget(ps, datetime);
+
+ // If Element could be null insert a extra widget to clear entry
+ if (!hasValidationListener(new NotNullValidationListener())) {
+ datetime.newChildElement("NoDateTime");
}
- m_amOrPm.generateXML(ps, date);
}
+ @Override
public void setDisabled() {
- m_month.setDisabled();
- m_day.setDisabled();
- m_year.setDisabled();
- m_hour.setDisabled();
- m_minute.setDisabled();
- if (m_showSeconds) {
- m_second.setDisabled();
- }
- m_amOrPm.setDisabled();
+ m_date.setDisabled();
+ m_time.setDisabled();
}
+ @Override
public void setReadOnly() {
- m_month.setReadOnly();
- m_day.setReadOnly();
- m_year.setReadOnly();
- m_hour.setReadOnly();
- m_minute.setReadOnly();
- if (m_showSeconds) {
- m_second.setReadOnly();
- }
- m_amOrPm.setReadOnly();
+ m_date.setReadOnly();
+ m_time.setReadOnly();
}
/**
@@ -402,30 +134,10 @@ public class DateTime extends Widget implements BebopConstants {
* @param the Form Object for this Widget.
* @exception IllegalStateException if form already set.
*/
+ @Override
public void setForm(Form f) {
- super .setForm(f);
- m_year .setForm(f);
- m_month.setForm(f);
- m_day .setForm(f);
- m_hour.setForm(f);
- m_minute.setForm(f);
- if (m_showSeconds) {
- m_second.setForm(f);
- }
- m_amOrPm.setForm(f);
- }
-
- private Object getFragmentValue(PageState ps, int field) {
- Assert.exists(ps, "PageState");
- FormData f = getForm().getFormData(ps);
- if (f != null) {
- java.util.Date value = (java.util.Date)f.get(getName());
- if (value != null) {
- Calendar c = Calendar.getInstance();
- c.setTime(value);
- return new Integer(c.get(field));
- }
- }
- return null;
+ super.setForm(f);
+ m_date.setForm(f);
+ m_time.setForm(f);
}
}
diff --git a/ccm-core/src/com/arsdigita/bebop/form/Time.java b/ccm-core/src/com/arsdigita/bebop/form/Time.java
index 0909d3685..d901fa13e 100755
--- a/ccm-core/src/com/arsdigita/bebop/form/Time.java
+++ b/ccm-core/src/com/arsdigita/bebop/form/Time.java
@@ -21,6 +21,7 @@ package com.arsdigita.bebop.form;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.parameters.NotNullValidationListener;
import com.arsdigita.bebop.parameters.TimeParameter;
import com.arsdigita.bebop.parameters.NumberInRangeValidationListener;
import com.arsdigita.bebop.parameters.ParameterData;
@@ -32,16 +33,15 @@ import com.arsdigita.xml.Element;
import java.text.DateFormatSymbols;
import java.util.Calendar;
-
/**
* A class representing a time field in an HTML form.
*
* @see com.arsdigita.bebop.form.DateTime
* @author Dave Turner
- * @version $Id: Time.java 287 2005-02-22 00:29:02Z sskracic $
+ * @author Sören Bernstein
+ * @version $Id: Time.java 288 2010-02-20 07:29:00Z sbernstein $
*/
-public class Time extends Widget implements BebopConstants
-{
+public class Time extends Widget implements BebopConstants {
private TextField m_hour;
private TextField m_minute;
@@ -50,7 +50,6 @@ public class Time extends Widget implements BebopConstants
private boolean m_showSeconds;
private static final String ZERO = "0";
-
private class HourFragment extends TextField {
private Time parent;
@@ -58,8 +57,10 @@ public class Time extends Widget implements BebopConstants
public HourFragment(String name, Time parent) {
super(name);
this.parent = parent;
- this.addValidationListener(new NumberInRangeValidationListener(1,12)); }
+ this.addValidationListener(new NumberInRangeValidationListener(1, 12));
+ }
+ @Override
protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps);
if (value == null) {
@@ -68,8 +69,11 @@ public class Time extends Widget implements BebopConstants
return new ParameterData(getParameterModel(), value);
}
+ @Override
public Object getValue(PageState ps) {
- return parent.getFragmentValue(ps, Calendar.HOUR);
+ // Depending on locale we need to differ between 12 hour and 24 hout format
+// return parent.getFragmentValue(ps, Calendar.HOUR);
+ return parent.getFragmentValue(ps, Calendar.HOUR_OF_DAY);
}
}
@@ -80,8 +84,10 @@ public class Time extends Widget implements BebopConstants
public MinuteFragment(String name, Time parent) {
super(name);
this.parent = parent;
- this.addValidationListener(new NumberInRangeValidationListener(0,59)); }
+ this.addValidationListener(new NumberInRangeValidationListener(0, 59));
+ }
+ @Override
protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps);
if (value == null) {
@@ -90,12 +96,13 @@ public class Time extends Widget implements BebopConstants
return new ParameterData(getParameterModel(), value);
}
+ @Override
public Object getValue(PageState ps) {
Integer min = (Integer) parent.getFragmentValue(ps, Calendar.MINUTE);
if (min == null) {
return null;
}
- if ( min.intValue() < 10 ) {
+ if (min.intValue() < 10) {
return ZERO + min.toString();
} else {
return min.toString();
@@ -110,8 +117,10 @@ public class Time extends Widget implements BebopConstants
public SecondFragment(String name, Time parent) {
super(name);
this.parent = parent;
- this.addValidationListener(new NumberInRangeValidationListener(0,59)); }
+ this.addValidationListener(new NumberInRangeValidationListener(0, 59));
+ }
+ @Override
protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps);
if (value == null) {
@@ -120,12 +129,13 @@ public class Time extends Widget implements BebopConstants
return new ParameterData(getParameterModel(), value);
}
+ @Override
public Object getValue(PageState ps) {
Integer sec = (Integer) parent.getFragmentValue(ps, Calendar.SECOND);
if (sec == null) {
return null;
}
- if ( sec.intValue() < 10 ) {
+ if (sec.intValue() < 10) {
return ZERO + sec.toString();
} else {
return sec.toString();
@@ -142,6 +152,7 @@ public class Time extends Widget implements BebopConstants
this.parent = parent;
}
+ @Override
protected ParameterData getParameterData(PageState ps) {
Object value = getValue(ps);
if (value == null) {
@@ -150,26 +161,25 @@ public class Time extends Widget implements BebopConstants
return new ParameterData(getParameterModel(), value);
}
+ @Override
public Object getValue(PageState ps) {
return parent.getFragmentValue(ps, Calendar.AM_PM);
}
-
}
-
/** Constructor. */
- public Time ( ParameterModel model ) {
+ public Time(ParameterModel model) {
this(model, false);
}
/** Constructor. */
- public Time ( ParameterModel model, boolean showSeconds ) {
+ public Time(ParameterModel model, boolean showSeconds) {
super(model);
- if ( ! (model instanceof TimeParameter)) {
- throw new IllegalArgumentException (
- "The Time widget " + model.getName() +
- " must be backed by a TimeParameter parameter model");
+ if (!(model instanceof TimeParameter)) {
+ throw new IllegalArgumentException(
+ "The Time widget " + model.getName() +
+ " must be backed by a TimeParameter parameter model");
}
@@ -184,7 +194,7 @@ public class Time extends Widget implements BebopConstants
m_hour = new HourFragment(nameHour, this);
m_minute = new MinuteFragment(nameMinute, this);
m_showSeconds = showSeconds;
- if ( m_showSeconds ) {
+ if (m_showSeconds) {
m_second = new SecondFragment(nameSecond, this);
} else {
m_second = null;
@@ -200,20 +210,19 @@ public class Time extends Widget implements BebopConstants
m_second.setSize(2);
}
- String [] amPmStrings = dfs.getAmPmStrings();
- for ( int i = 0 ; i < amPmStrings.length ; i++ ) {
+ String[] amPmStrings = dfs.getAmPmStrings();
+ for (int i = 0; i < amPmStrings.length; i++) {
m_amOrPm.addOption(new Option(String.valueOf(i), amPmStrings[i]));
}
}
-
- public Time ( String name ) {
+ public Time(String name) {
this(new TimeParameter(name));
}
/** Returns a string naming the type of this widget. */
- public String getType () {
+ public String getType() {
return "time";
}
@@ -221,54 +230,66 @@ public class Time extends Widget implements BebopConstants
* Sets the MAXLENGTH attributes for the INPUT tag
* used to render this form element.
*/
- public void setMaxLength ( int length ) {
+ public void setMaxLength(int length) {
setAttribute("MAXLENGTH", String.valueOf(length));
}
- public boolean isCompound () {
+ public boolean isCompound() {
return true;
}
/** The XML tag for this derived class of Widget. */
- protected String getElementTag () {
- return "bebop:time";
+ @Override
+ protected String getElementTag() {
+ return "BEBOP_TIME";
}
- public void generateWidget ( PageState ps, Element parent ) {
+ @Override
+ public void generateWidget(PageState ps, Element parent) {
- if ( ! isVisible(ps) ) {
+ if (!isVisible(ps)) {
return;
}
Element time = parent.newChildElement(getElementTag(), BEBOP_XML_NS);
time.addAttribute("name", getParameterModel().getName());
- m_hour .generateXML(ps, time);
+ generateLocalizedWidget(ps, time);
+
+ // If Element could be null insert a extra widget to clear entry
+ if (!hasValidationListener(new NotNullValidationListener())) {
+ time.newChildElement("NoTime");
+ }
+ }
+
+ public void generateLocalizedWidget(PageState ps, Element time) {
+ m_hour.generateXML(ps, time);
m_minute.generateXML(ps, time);
- if ( m_showSeconds ) {
+ if (m_showSeconds) {
m_second.generateXML(ps, time);
}
m_amOrPm.generateXML(ps, time);
}
- public void setDisabled () {
+ @Override
+ public void setDisabled() {
m_hour.setDisabled();
m_minute.setDisabled();
- if ( m_showSeconds ) {
+ if (m_showSeconds) {
m_second.setDisabled();
}
m_amOrPm.setDisabled();
}
- public void setReadOnly () {
+ @Override
+ public void setReadOnly() {
m_hour.setReadOnly();
m_minute.setReadOnly();
- if ( m_showSeconds ) {
+ if (m_showSeconds) {
m_second.setReadOnly();
}
m_amOrPm.setReadOnly();
}
-
/**
* Sets the Form Object for this Widget. This method will throw an
* exception if the _form pointer is already set. To explicity
@@ -278,8 +299,9 @@ public class Time extends Widget implements BebopConstants
* @param the Form Object for this Widget.
* @exception IllegalStateException if form already set.
*/
+ @Override
public void setForm(Form f) {
- super .setForm(f);
+ super.setForm(f);
m_hour.setForm(f);
m_minute.setForm(f);
if (m_showSeconds) {
@@ -292,19 +314,17 @@ public class Time extends Widget implements BebopConstants
Assert.exists(ps, "PageState");
FormData f = getForm().getFormData(ps);
if (f != null) {
- java.util.Date value = (java.util.Date)f.get(getName());
+ java.util.Date value = (java.util.Date) f.get(getName());
if (value != null) {
Calendar c = Calendar.getInstance();
c.setTime(value);
- int intVal = c.get(field);
- if (field == Calendar.HOUR && intVal == 0) {
- intVal = 12;
- }
+ int intVal = c.get(field);
+ if (field == Calendar.HOUR && intVal == 0) {
+ intVal = 12;
+ }
return new Integer(intVal);
}
}
return null;
}
-
-
}