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;
|
||||
// replaced by AgendaGlobalizationUtil
|
||||
// import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ public class AgendaPropertiesStep extends SimpleEditStep {
|
|||
PageState state) {
|
||||
ContentPage page = (ContentPage) item;
|
||||
if(page.getLaunchDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
||||
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale())
|
||||
.format(page.getLaunchDate());
|
||||
} else {
|
||||
return (String)AgendaGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
|
|
@ -120,7 +121,7 @@ public class AgendaPropertiesStep extends SimpleEditStep {
|
|||
PageState state) {
|
||||
Agenda agenda = (Agenda) item;
|
||||
if(agenda.getCreationDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
||||
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale())
|
||||
.format(agenda.getCreationDate());
|
||||
} else {
|
||||
return (String)AgendaGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
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.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.cms.contenttypes.util.EventGlobalizationUtil;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
|
||||
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
|
||||
|
|
@ -49,7 +53,7 @@ public class EventPropertiesStep extends SimpleEditStep {
|
|||
public static String EDIT_SHEET_NAME = "edit";
|
||||
|
||||
public EventPropertiesStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
AuthoringKitWizard parent) {
|
||||
super(itemModel, parent);
|
||||
|
||||
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||
|
|
@ -57,7 +61,7 @@ public class EventPropertiesStep extends SimpleEditStep {
|
|||
|
||||
editSheet = new EventPropertyForm(itemModel, this);
|
||||
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel),
|
||||
editSheet.getSaveCancelSection().getCancelButton());
|
||||
editSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
setDisplayComponent(getEventPropertySheet(itemModel));
|
||||
}
|
||||
|
|
@ -71,102 +75,92 @@ public class EventPropertiesStep extends SimpleEditStep {
|
|||
* @return A component to display the state of the basic properties
|
||||
* of the release
|
||||
**/
|
||||
public static Component getEventPropertySheet(ItemSelectionModel
|
||||
itemModel) {
|
||||
public static Component getEventPropertySheet(ItemSelectionModel itemModel) {
|
||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("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
|
||||
("cms.contenttypes.ui.event.lead").localize(), Event.LEAD);
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("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("cms.contenttypes.ui.event.lead").localize(), Event.LEAD);
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
sheet.add(EventGlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
|
||||
ContentPage.LAUNCH_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
ContentPage page = (ContentPage) item;
|
||||
if(page.getLaunchDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
||||
.format(page.getLaunchDate());
|
||||
} else {
|
||||
return (String)EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
ContentPage.LAUNCH_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
ContentPage page = (ContentPage) item;
|
||||
if (page.getLaunchDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(page.getLaunchDate());
|
||||
} else {
|
||||
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.start_time").localize(), Event.START_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
Event e = (Event) item;
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.start_time").localize(), Event.START_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
if (e.getStartDate() != null) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(DateFormat.getDateInstance(DateFormat.LONG)
|
||||
.format(e.getStartDate()));
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
Event e = (Event) item;
|
||||
|
||||
if (e.getStartTime() != null) {
|
||||
buf.append(". " + e.getDisplayStartTime());
|
||||
}
|
||||
if (e.getStartDate() != null) {
|
||||
|
||||
return buf.toString();
|
||||
} else {
|
||||
return "<i>unknown</i>";
|
||||
}
|
||||
}
|
||||
});
|
||||
if (e.getStartTime() == null) {
|
||||
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);
|
||||
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.end_time").localize(), Event.END_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
Event e = (Event) item;
|
||||
if (e.getEndDate() != null) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(DateFormat.getDateInstance(DateFormat.LONG)
|
||||
.format(e.getEndDate()));
|
||||
}
|
||||
|
||||
if (e.getEndTime() != null) {
|
||||
buf.append(". " + e.getDisplayEndTime());
|
||||
}
|
||||
} else {
|
||||
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return buf.toString();
|
||||
} else {
|
||||
return "<i>unknown</i>";
|
||||
}
|
||||
}
|
||||
});
|
||||
if(!Event.getConfig().getHideDateDescription()) {
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.date_description").localize(), Event.EVENT_DATE);
|
||||
}
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.location").localize(), Event.LOCATION);
|
||||
|
||||
if(!Event.getConfig().getHideMainContributor()) {
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.main_contributor").localize(), Event.MAIN_CONTRIBUTOR);
|
||||
}
|
||||
if(!Event.getConfig().getHideEventType()) {
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.event_type").localize(), Event.EVENT_TYPE);
|
||||
}
|
||||
if(!Event.getConfig().getHideLinkToMap()) {
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.link_to_map").localize(), Event.MAP_LINK);
|
||||
}
|
||||
if(!Event.getConfig().getHideCost()) {
|
||||
sheet.add( (String)EventGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.event.cost").localize(), Event.COST);
|
||||
}
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.end_time").localize(), Event.END_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
Event e = (Event) item;
|
||||
if (e.getEndDate() != null) {
|
||||
|
||||
if (e.getEndTime() == null) {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
return (String) EventGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!Event.getConfig().getHideDateDescription()) {
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.date_description").localize(), Event.EVENT_DATE);
|
||||
}
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.location").localize(), Event.LOCATION);
|
||||
|
||||
if (!Event.getConfig().getHideMainContributor()) {
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.main_contributor").localize(), Event.MAIN_CONTRIBUTOR);
|
||||
}
|
||||
if (!Event.getConfig().getHideEventType()) {
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.event_type").localize(), Event.EVENT_TYPE);
|
||||
}
|
||||
if (!Event.getConfig().getHideLinkToMap()) {
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.link_to_map").localize(), Event.MAP_LINK);
|
||||
}
|
||||
if (!Event.getConfig().getHideCost()) {
|
||||
sheet.add((String) EventGlobalizationUtil.globalize("cms.contenttypes.ui.event.cost").localize(), Event.COST);
|
||||
}
|
||||
return sheet;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
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.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.cms.contenttypes.util.NewsItemGlobalizationUtil;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
|
|
@ -49,15 +49,15 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
|
|||
public static String EDIT_SHEET_NAME = "edit";
|
||||
|
||||
public NewsItemPropertiesStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
AuthoringKitWizard parent) {
|
||||
super(itemModel, parent);
|
||||
|
||||
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||
BasicPageForm editSheet;
|
||||
|
||||
editSheet = new NewsItemPropertyForm(itemModel,this);
|
||||
editSheet = new NewsItemPropertyForm(itemModel, this);
|
||||
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel),
|
||||
editSheet.getSaveCancelSection().getCancelButton());
|
||||
editSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
setDisplayComponent(getNewsDomainObjectPropertySheet(itemModel));
|
||||
}
|
||||
|
|
@ -71,75 +71,64 @@ public class NewsItemPropertiesStep extends SimpleEditStep {
|
|||
* @return A component to display the state of the basic properties
|
||||
* of the item
|
||||
**/
|
||||
public static Component getNewsDomainObjectPropertySheet(ItemSelectionModel
|
||||
itemModel) {
|
||||
public static Component getNewsDomainObjectPropertySheet(ItemSelectionModel itemModel) {
|
||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||
|
||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
||||
("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
|
||||
("cms.contenttypes.ui.newsitem.lead").localize(), NewsItem.LEAD);
|
||||
sheet.add((String) NewsItemGlobalizationUtil.globalize("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("cms.contenttypes.ui.newsitem.lead").localize(), NewsItem.LEAD);
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
sheet.add(NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.launch_date"),
|
||||
ContentPage.LAUNCH_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
ContentPage page = (ContentPage) item;
|
||||
if(page.getLaunchDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
||||
.format(page.getLaunchDate());
|
||||
} else {
|
||||
return (String)NewsItemGlobalizationUtil.globalize
|
||||
("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
ContentPage.LAUNCH_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
ContentPage page = (ContentPage) item;
|
||||
if (page.getLaunchDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(page.getLaunchDate());
|
||||
} else {
|
||||
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Show news item on homepage?
|
||||
// Show news item on homepage?
|
||||
if (!NewsItem.getConfig().getHideHomepageField()) {
|
||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.newsitem.homepage").localize(),
|
||||
NewsItem.IS_HOMEPAGE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
NewsItem pr = (NewsItem) item;
|
||||
|
||||
if ( pr.isHomepage().booleanValue()) {
|
||||
return (String) NewsItemGlobalizationUtil.globalize
|
||||
("cms.ui.yes").localize();
|
||||
}
|
||||
|
||||
return (String) NewsItemGlobalizationUtil.globalize
|
||||
("cms.ui.no").localize();
|
||||
}
|
||||
}
|
||||
);
|
||||
sheet.add((String) NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.newsitem.homepage").localize(),
|
||||
NewsItem.IS_HOMEPAGE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
NewsItem pr = (NewsItem) item;
|
||||
|
||||
if (pr.isHomepage().booleanValue()) {
|
||||
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.yes").localize();
|
||||
}
|
||||
|
||||
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.no").localize();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
sheet.add( (String)NewsItemGlobalizationUtil.globalize
|
||||
("cms.contenttypes.ui.newsitem.news_date").localize(), NewsItem.NEWS_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
sheet.add((String) NewsItemGlobalizationUtil.globalize("cms.contenttypes.ui.newsitem.news_date").localize(), NewsItem.NEWS_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
NewsItem pr = (NewsItem) item;
|
||||
if (pr.getNewsDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG)
|
||||
.format(pr.getNewsDate());
|
||||
} else {
|
||||
return (String)NewsItemGlobalizationUtil.globalize
|
||||
("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
NewsItem pr = (NewsItem) item;
|
||||
if (pr.getNewsDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG, DispatcherHelper.getNegotiatedLocale()).format(pr.getNewsDate());
|
||||
} else {
|
||||
return (String) NewsItemGlobalizationUtil.globalize("cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,15 @@ import com.arsdigita.bebop.parameters.NumberInRangeValidationListener;
|
|||
import com.arsdigita.bebop.parameters.ParameterData;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.util.BebopConstants;
|
||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.text.DateFormat;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
super(name);
|
||||
this.parent = parent;
|
||||
this.addValidationListener(new NumberInRangeValidationListener(1, 12));
|
||||
if (has12HourClock()) {
|
||||
this.addValidationListener(new NumberInRangeValidationListener(1, 12));
|
||||
} else {
|
||||
this.addValidationListener(new NumberInRangeValidationListener(1, 24));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -71,9 +79,11 @@ public class Time extends Widget implements BebopConstants {
|
|||
|
||||
@Override
|
||||
public Object getValue(PageState ps) {
|
||||
// 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);
|
||||
if (has12HourClock()) {
|
||||
return parent.getFragmentValue(ps, Calendar.HOUR);
|
||||
} else {
|
||||
return parent.getFragmentValue(ps, Calendar.HOUR_OF_DAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -178,11 +188,10 @@ public class Time extends Widget implements BebopConstants {
|
|||
|
||||
if (!(model instanceof TimeParameter)) {
|
||||
throw new IllegalArgumentException(
|
||||
"The Time widget " + model.getName() +
|
||||
" must be backed by a TimeParameter parameter model");
|
||||
"The Time widget " + model.getName()
|
||||
+ " must be backed by a TimeParameter parameter model");
|
||||
}
|
||||
|
||||
|
||||
String name = model.getName();
|
||||
String nameHour = name + ".hour";
|
||||
String nameMinute = name + ".minute";
|
||||
|
|
@ -267,7 +276,9 @@ public class Time extends Widget implements BebopConstants {
|
|||
if (m_showSeconds) {
|
||||
m_second.generateXML(ps, time);
|
||||
}
|
||||
m_amOrPm.generateXML(ps, time);
|
||||
if (has12HourClock()) {
|
||||
m_amOrPm.generateXML(ps, time);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -277,7 +288,9 @@ public class Time extends Widget implements BebopConstants {
|
|||
if (m_showSeconds) {
|
||||
m_second.setDisabled();
|
||||
}
|
||||
m_amOrPm.setDisabled();
|
||||
if (has12HourClock()) {
|
||||
m_amOrPm.setDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -287,7 +300,9 @@ public class Time extends Widget implements BebopConstants {
|
|||
if (m_showSeconds) {
|
||||
m_second.setReadOnly();
|
||||
}
|
||||
m_amOrPm.setReadOnly();
|
||||
if (has12HourClock()) {
|
||||
m_amOrPm.setReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -319,7 +334,7 @@ public class Time extends Widget implements BebopConstants {
|
|||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(value);
|
||||
int intVal = c.get(field);
|
||||
if (field == Calendar.HOUR && intVal == 0) {
|
||||
if (field == Calendar.HOUR && intVal == 0 && has12HourClock()) {
|
||||
intVal = 12;
|
||||
}
|
||||
return new Integer(intVal);
|
||||
|
|
@ -327,4 +342,18 @@ public class Time extends Widget implements BebopConstants {
|
|||
}
|
||||
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