TimeWidget angepaßt, so daß es sich
* der eingestellten Locale anpaßt (12-Stunden vs. 24-Stunden-Format) * Event angepaßt, so daß die Anzeige sich ebenfalls anpaßt (AttributeFormatter angepaßt). Diese Anpassung muß evt. bei allen PropertiesStep gemacht werden, die Datumsangaben verwenden oder es wir finden eine bessere Lösung, so daß man den AttributeFormatter nicht jedesmal neu schreiben muß. git-svn-id: https://svn.libreccm.org/ccm/trunk@705 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
6eaabaf7fa
commit
8f2246aba2
|
|
@ -34,6 +34,7 @@ import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
// replaced by AgendaGlobalizationUtil
|
// replaced by AgendaGlobalizationUtil
|
||||||
// import com.arsdigita.cms.util.GlobalizationUtil;
|
// import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
||||||
|
|
@ -91,7 +92,7 @@ public class AgendaPropertiesStep extends SimpleEditStep {
|
||||||
PageState state) {
|
PageState state) {
|
||||||
ContentPage page = (ContentPage) item;
|
ContentPage page = (ContentPage) item;
|
||||||
if(page.getLaunchDate() != null) {
|
if(page.getLaunchDate() != null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale())
|
||||||
.format(page.getLaunchDate());
|
.format(page.getLaunchDate());
|
||||||
} else {
|
} else {
|
||||||
return (String)AgendaGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
return (String)AgendaGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
|
|
@ -120,7 +121,7 @@ public class AgendaPropertiesStep extends SimpleEditStep {
|
||||||
PageState state) {
|
PageState state) {
|
||||||
Agenda agenda = (Agenda) item;
|
Agenda agenda = (Agenda) item;
|
||||||
if(agenda.getCreationDate() != null) {
|
if(agenda.getCreationDate() != null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale())
|
||||||
.format(agenda.getCreationDate());
|
.format(agenda.getCreationDate());
|
||||||
} else {
|
} else {
|
||||||
return (String)AgendaGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
return (String)AgendaGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
|
@ -32,8 +31,13 @@ import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
import com.arsdigita.cms.contenttypes.util.EventGlobalizationUtil;
|
import com.arsdigita.cms.contenttypes.util.EventGlobalizationUtil;
|
||||||
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authoring step to view/edit the simple attributes of the Event content type (and
|
* Authoring step to view/edit the simple attributes of the Event content type (and
|
||||||
|
|
@ -71,101 +75,91 @@ public class EventPropertiesStep extends SimpleEditStep {
|
||||||
* @return A component to display the state of the basic properties
|
* @return A component to display the state of the basic properties
|
||||||
* of the release
|
* of the release
|
||||||
**/
|
**/
|
||||||
public static Component getEventPropertySheet(ItemSelectionModel
|
public static Component getEventPropertySheet(ItemSelectionModel itemModel) {
|
||||||
itemModel) {
|
|
||||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.name").localize(), Event.NAME);
|
||||||
("cms.contenttypes.ui.event.name").localize(), Event.NAME);
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.title").localize(), Event.TITLE);
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.lead").localize(), Event.LEAD);
|
||||||
("cms.contenttypes.ui.event.title").localize(), Event.TITLE);
|
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
|
||||||
("cms.contenttypes.ui.event.lead").localize(), Event.LEAD);
|
|
||||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
sheet.add(EventGlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
|
sheet.add(EventGlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
|
||||||
ContentPage.LAUNCH_DATE,
|
ContentPage.LAUNCH_DATE,
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
public String format(DomainObject item,
|
public String format(DomainObject item,
|
||||||
String attribute,
|
String attribute,
|
||||||
PageState state) {
|
PageState state) {
|
||||||
ContentPage page = (ContentPage) item;
|
ContentPage page = (ContentPage) item;
|
||||||
if (page.getLaunchDate() != null) {
|
if (page.getLaunchDate() != null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(page.getLaunchDate());
|
||||||
.format(page.getLaunchDate());
|
|
||||||
} else {
|
} else {
|
||||||
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.start_time").localize(), Event.START_DATE,
|
||||||
("cms.contenttypes.ui.event.start_time").localize(), Event.START_DATE,
|
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
public String format(DomainObject item,
|
public String format(DomainObject item,
|
||||||
String attribute,
|
String attribute,
|
||||||
PageState state) {
|
PageState state) {
|
||||||
Event e = (Event) item;
|
Event e = (Event) item;
|
||||||
|
|
||||||
if (e.getStartDate() != null) {
|
if (e.getStartDate() != null) {
|
||||||
StringBuffer buf = new StringBuffer();
|
|
||||||
buf.append(DateFormat.getDateInstance(DateFormat.LONG)
|
|
||||||
.format(e.getStartDate()));
|
|
||||||
|
|
||||||
if (e.getStartTime() != null) {
|
if (e.getStartTime() == null) {
|
||||||
buf.append(". " + e.getDisplayStartTime());
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(e.getStartDate());
|
||||||
|
} else {
|
||||||
|
Date startDateTime = new Date(e.getStartDate().getTime() + e.getStartTime().getTime());
|
||||||
|
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, DispatcherHelper.getNegotiatedLocale()).format(startDateTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.toString();
|
|
||||||
} else {
|
} else {
|
||||||
return "<i>unknown</i>";
|
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.end_time").localize(), Event.END_DATE,
|
||||||
("cms.contenttypes.ui.event.end_time").localize(), Event.END_DATE,
|
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
public String format(DomainObject item,
|
public String format(DomainObject item,
|
||||||
String attribute,
|
String attribute,
|
||||||
PageState state) {
|
PageState state) {
|
||||||
Event e = (Event) item;
|
Event e = (Event) item;
|
||||||
if (e.getEndDate() != null) {
|
if (e.getEndDate() != null) {
|
||||||
StringBuffer buf = new StringBuffer();
|
|
||||||
buf.append(DateFormat.getDateInstance(DateFormat.LONG)
|
|
||||||
.format(e.getEndDate()));
|
|
||||||
|
|
||||||
if (e.getEndTime() != null) {
|
if (e.getEndTime() == null) {
|
||||||
buf.append(". " + e.getDisplayEndTime());
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(e.getEndDate());
|
||||||
|
} else {
|
||||||
|
Date endDateTime = new Date(e.getEndDate().getTime() + e.getEndTime().getTime());
|
||||||
|
return DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, DispatcherHelper.getNegotiatedLocale()).format(endDateTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.toString();
|
|
||||||
} else {
|
} else {
|
||||||
return "<i>unknown</i>";
|
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!Event.getConfig().getHideDateDescription()) {
|
if (!Event.getConfig().getHideDateDescription()) {
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.date_description").localize(), Event.EVENT_DATE);
|
||||||
("cms.contenttypes.ui.event.date_description").localize(), Event.EVENT_DATE);
|
|
||||||
}
|
}
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.location").localize(), Event.LOCATION);
|
||||||
("cms.contenttypes.ui.event.location").localize(), Event.LOCATION);
|
|
||||||
|
|
||||||
if (!Event.getConfig().getHideMainContributor()) {
|
if (!Event.getConfig().getHideMainContributor()) {
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.main_contributor").localize(), Event.MAIN_CONTRIBUTOR);
|
||||||
("cms.contenttypes.ui.event.main_contributor").localize(), Event.MAIN_CONTRIBUTOR);
|
|
||||||
}
|
}
|
||||||
if (!Event.getConfig().getHideEventType()) {
|
if (!Event.getConfig().getHideEventType()) {
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.event_type").localize(), Event.EVENT_TYPE);
|
||||||
("cms.contenttypes.ui.event.event_type").localize(), Event.EVENT_TYPE);
|
|
||||||
}
|
}
|
||||||
if (!Event.getConfig().getHideLinkToMap()) {
|
if (!Event.getConfig().getHideLinkToMap()) {
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.link_to_map").localize(), Event.MAP_LINK);
|
||||||
("cms.contenttypes.ui.event.link_to_map").localize(), Event.MAP_LINK);
|
|
||||||
}
|
}
|
||||||
if (!Event.getConfig().getHideCost()) {
|
if (!Event.getConfig().getHideCost()) {
|
||||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.cost").localize(), Event.COST);
|
||||||
("cms.contenttypes.ui.event.cost").localize(), Event.COST);
|
|
||||||
}
|
}
|
||||||
return sheet;
|
return sheet;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.contenttypes.ui;
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.cms.ContentPage;
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
|
@ -32,6 +31,7 @@ import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
import com.arsdigita.cms.contenttypes.util.NewsItemGlobalizationUtil;
|
import com.arsdigita.cms.contenttypes.util.NewsItemGlobalizationUtil;
|
||||||
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
||||||
|
|
@ -71,30 +71,25 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
|
||||||
* @return A component to display the state of the basic properties
|
* @return A component to display the state of the basic properties
|
||||||
* of the item
|
* of the item
|
||||||
**/
|
**/
|
||||||
public static Component getNewsDomainObjectPropertySheet(ItemSelectionModel
|
public static Component getNewsDomainObjectPropertySheet(ItemSelectionModel itemModel) {
|
||||||
itemModel) {
|
|
||||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
sheet.add((String) NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.title").localize(), NewsItem.TITLE);
|
||||||
("cms.contenttypes.ui.title").localize(), NewsItem.TITLE);
|
sheet.add((String) NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.newsitem.name").localize(), NewsItem.NAME);
|
||||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
sheet.add((String) NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.newsitem.lead").localize(), NewsItem.LEAD);
|
||||||
("cms.contenttypes.ui.newsitem.name").localize(), NewsItem.NAME);
|
|
||||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
|
||||||
("cms.contenttypes.ui.newsitem.lead").localize(), NewsItem.LEAD);
|
|
||||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||||
sheet.add(NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
|
sheet.add(NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
|
||||||
ContentPage.LAUNCH_DATE,
|
ContentPage.LAUNCH_DATE,
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
public String format(DomainObject item,
|
public String format(DomainObject item,
|
||||||
String attribute,
|
String attribute,
|
||||||
PageState state) {
|
PageState state) {
|
||||||
ContentPage page = (ContentPage) item;
|
ContentPage page = (ContentPage) item;
|
||||||
if (page.getLaunchDate() != null) {
|
if (page.getLaunchDate() != null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(page.getLaunchDate());
|
||||||
.format(page.getLaunchDate());
|
|
||||||
} else {
|
} else {
|
||||||
return (String)NewsItemGlobalizationUtil.globalize
|
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
("cms.ui.unknown").localize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -102,29 +97,25 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
// Show news item on homepage?
|
// Show news item on homepage?
|
||||||
if (!NewsItem.getConfig().getHideHomepageField()) {
|
if (!NewsItem.getConfig().getHideHomepageField()) {
|
||||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
sheet.add((String) NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.newsitem.homepage").localize(),
|
||||||
("cms.contenttypes.ui.newsitem.homepage").localize(),
|
|
||||||
NewsItem.IS_HOMEPAGE,
|
NewsItem.IS_HOMEPAGE,
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
public String format(DomainObject item,
|
public String format(DomainObject item,
|
||||||
String attribute,
|
String attribute,
|
||||||
PageState state) {
|
PageState state) {
|
||||||
NewsItem pr = (NewsItem) item;
|
NewsItem pr = (NewsItem) item;
|
||||||
|
|
||||||
if (pr.isHomepage().booleanValue()) {
|
if (pr.isHomepage().booleanValue()) {
|
||||||
return (String) NewsItemGlobalizationUtil.globalize
|
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.yes").localize();
|
||||||
("cms.ui.yes").localize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (String) NewsItemGlobalizationUtil.globalize
|
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.no").localize();
|
||||||
("cms.ui.no").localize();
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
sheet.add((String) NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.newsitem.news_date").localize(), NewsItem.NEWS_DATE,
|
||||||
("cms.contenttypes.ui.newsitem.news_date").localize(), NewsItem.NEWS_DATE,
|
|
||||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||||
|
|
||||||
public String format(DomainObject item,
|
public String format(DomainObject item,
|
||||||
|
|
@ -132,11 +123,9 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
|
||||||
PageState state) {
|
PageState state) {
|
||||||
NewsItem pr = (NewsItem) item;
|
NewsItem pr = (NewsItem) item;
|
||||||
if (pr.getNewsDate() != null) {
|
if (pr.getNewsDate() != null) {
|
||||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(pr.getNewsDate());
|
||||||
.format(pr.getNewsDate());
|
|
||||||
} else {
|
} else {
|
||||||
return (String)NewsItemGlobalizationUtil.globalize
|
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||||
("cms.ui.unknown").localize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,15 @@ import com.arsdigita.bebop.parameters.NumberInRangeValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.ParameterData;
|
import com.arsdigita.bebop.parameters.ParameterData;
|
||||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
import com.arsdigita.bebop.util.BebopConstants;
|
import com.arsdigita.bebop.util.BebopConstants;
|
||||||
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import com.arsdigita.xml.Element;
|
import com.arsdigita.xml.Element;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
|
||||||
import java.text.DateFormatSymbols;
|
import java.text.DateFormatSymbols;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing a time field in an HTML form.
|
* A class representing a time field in an HTML form.
|
||||||
|
|
@ -57,7 +61,11 @@ public class Time extends Widget implements BebopConstants {
|
||||||
public HourFragment(String name, Time parent) {
|
public HourFragment(String name, Time parent) {
|
||||||
super(name);
|
super(name);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
if (has12HourClock()) {
|
||||||
this.addValidationListener(new NumberInRangeValidationListener(1, 12));
|
this.addValidationListener(new NumberInRangeValidationListener(1, 12));
|
||||||
|
} else {
|
||||||
|
this.addValidationListener(new NumberInRangeValidationListener(1, 24));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -71,11 +79,13 @@ public class Time extends Widget implements BebopConstants {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(PageState ps) {
|
public Object getValue(PageState ps) {
|
||||||
// Depending on locale we need to differ between 12 hour and 24 hout format
|
if (has12HourClock()) {
|
||||||
// return parent.getFragmentValue(ps, Calendar.HOUR);
|
return parent.getFragmentValue(ps, Calendar.HOUR);
|
||||||
|
} else {
|
||||||
return parent.getFragmentValue(ps, Calendar.HOUR_OF_DAY);
|
return parent.getFragmentValue(ps, Calendar.HOUR_OF_DAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class MinuteFragment extends TextField {
|
private class MinuteFragment extends TextField {
|
||||||
|
|
||||||
|
|
@ -178,11 +188,10 @@ public class Time extends Widget implements BebopConstants {
|
||||||
|
|
||||||
if (!(model instanceof TimeParameter)) {
|
if (!(model instanceof TimeParameter)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"The Time widget " + model.getName() +
|
"The Time widget " + model.getName()
|
||||||
" must be backed by a TimeParameter parameter model");
|
+ " must be backed by a TimeParameter parameter model");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String name = model.getName();
|
String name = model.getName();
|
||||||
String nameHour = name + ".hour";
|
String nameHour = name + ".hour";
|
||||||
String nameMinute = name + ".minute";
|
String nameMinute = name + ".minute";
|
||||||
|
|
@ -267,8 +276,10 @@ public class Time extends Widget implements BebopConstants {
|
||||||
if (m_showSeconds) {
|
if (m_showSeconds) {
|
||||||
m_second.generateXML(ps, time);
|
m_second.generateXML(ps, time);
|
||||||
}
|
}
|
||||||
|
if (has12HourClock()) {
|
||||||
m_amOrPm.generateXML(ps, time);
|
m_amOrPm.generateXML(ps, time);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDisabled() {
|
public void setDisabled() {
|
||||||
|
|
@ -277,8 +288,10 @@ public class Time extends Widget implements BebopConstants {
|
||||||
if (m_showSeconds) {
|
if (m_showSeconds) {
|
||||||
m_second.setDisabled();
|
m_second.setDisabled();
|
||||||
}
|
}
|
||||||
|
if (has12HourClock()) {
|
||||||
m_amOrPm.setDisabled();
|
m_amOrPm.setDisabled();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setReadOnly() {
|
public void setReadOnly() {
|
||||||
|
|
@ -287,8 +300,10 @@ public class Time extends Widget implements BebopConstants {
|
||||||
if (m_showSeconds) {
|
if (m_showSeconds) {
|
||||||
m_second.setReadOnly();
|
m_second.setReadOnly();
|
||||||
}
|
}
|
||||||
|
if (has12HourClock()) {
|
||||||
m_amOrPm.setReadOnly();
|
m_amOrPm.setReadOnly();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Form Object for this Widget. This method will throw an
|
* Sets the Form Object for this Widget. This method will throw an
|
||||||
|
|
@ -319,7 +334,7 @@ public class Time extends Widget implements BebopConstants {
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
c.setTime(value);
|
c.setTime(value);
|
||||||
int intVal = c.get(field);
|
int intVal = c.get(field);
|
||||||
if (field == Calendar.HOUR && intVal == 0) {
|
if (field == Calendar.HOUR && intVal == 0 && has12HourClock()) {
|
||||||
intVal = 12;
|
intVal = 12;
|
||||||
}
|
}
|
||||||
return new Integer(intVal);
|
return new Integer(intVal);
|
||||||
|
|
@ -327,4 +342,18 @@ public class Time extends Widget implements BebopConstants {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean has12HourClock() {
|
||||||
|
Locale locale = DispatcherHelper.getNegotiatedLocale();
|
||||||
|
DateFormat format_12Hour = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US);
|
||||||
|
DateFormat format_locale = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
|
||||||
|
|
||||||
|
String midnight = "";
|
||||||
|
try {
|
||||||
|
midnight = format_locale.format(format_12Hour.parse("12:00 AM"));
|
||||||
|
} catch (ParseException ignore) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return midnight.contains("12");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue