CCM NG/ccm-cms: Some improvments for EventPropertiesStep and EventPropertyForm
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4839 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
f7b70287b4
commit
f00b3ef6aa
|
|
@ -31,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.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.toolbox.ToolboxConstants;
|
||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
|
|
@ -48,6 +49,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
|
|
@ -102,6 +104,7 @@ public class EventPropertiesStep extends SimpleEditStep {
|
|||
* by the ItemSelectionModel passed in.
|
||||
*
|
||||
* @param itemSelectionModel The ItemSelectionModel to use
|
||||
* @param selectedLanguageParam
|
||||
*
|
||||
* @return A component to display the state of the basic properties of the
|
||||
* release
|
||||
|
|
@ -210,13 +213,13 @@ public class EventPropertiesStep extends SimpleEditStep {
|
|||
* @return A String representation of the retrieved boolean attribute of
|
||||
* the domain object.
|
||||
*/
|
||||
@Override
|
||||
public String format(final Object obj,
|
||||
final String attribute,
|
||||
final PageState state) {
|
||||
|
||||
if (obj != null && obj instanceof Event) {
|
||||
|
||||
final Event event = (Event) obj;
|
||||
final BeanInfo beanInfo;
|
||||
try {
|
||||
beanInfo = Introspector.getBeanInfo(Event.class);
|
||||
|
|
@ -246,24 +249,38 @@ public class EventPropertiesStep extends SimpleEditStep {
|
|||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
return (String) new GlobalizedMessage(
|
||||
"toolbox.ui.na", ToolboxConstants.TOOLBOX_BUNDLE)
|
||||
.localize();
|
||||
} else if (result instanceof Date) {
|
||||
return DateFormat
|
||||
.getDateTimeInstance(
|
||||
DateFormat.LONG,
|
||||
DateFormat.SHORT,
|
||||
globalizationHelper.getNegotiatedLocale())
|
||||
.format(result);
|
||||
.format((Date) result);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String
|
||||
.format(
|
||||
"Value is not an instance of \"%s\" but is an "
|
||||
+ "instance of \"%s\".",
|
||||
Date.class.getName(),
|
||||
result.getClass().getName()));
|
||||
}
|
||||
|
||||
} else {
|
||||
return (String) new GlobalizedMessage(
|
||||
"cms.ui.unknown",
|
||||
CmsConstants.CMS_BUNDLE)
|
||||
"toolbox.ui.na",
|
||||
ToolboxConstants.TOOLBOX_BUNDLE)
|
||||
.localize();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return (String) new GlobalizedMessage("cms.ui.unknown",
|
||||
CmsConstants.CMS_BUNDLE)
|
||||
return (String) new GlobalizedMessage(
|
||||
"toolbox.ui.na",
|
||||
ToolboxConstants.TOOLBOX_BUNDLE)
|
||||
.localize();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -442,14 +442,14 @@ public class EventPropertyForm
|
|||
|
||||
data.put(LEAD, item.getDescription().getValue(selectedLocale));
|
||||
data.put(START_DATE, startDate);
|
||||
data.put(START_TIME, startDate.getTime());
|
||||
data.put(START_TIME, startDate);
|
||||
data.put(END_DATE, endDate);
|
||||
data.put(END_TIME, endDate.getTime());
|
||||
data.put(END_TIME, endDate);
|
||||
if (!eventConfig.isHideDateDescription()) {
|
||||
data.put(EVENT_DATE,
|
||||
item.getEventDate().getValue(selectedLocale));
|
||||
}
|
||||
data.put(LOCATION, item.getLocation());
|
||||
data.put(LOCATION, item.getLocation().getValue(selectedLocale));
|
||||
if (!eventConfig.isHideMainContributor()) {
|
||||
data.put(MAIN_CONTRIBUTOR,
|
||||
item.getMainContributor().getValue(selectedLocale));
|
||||
|
|
@ -489,7 +489,8 @@ public class EventPropertyForm
|
|||
*/
|
||||
@Override
|
||||
public void process(final FormSectionEvent event) {
|
||||
FormData data = event.getFormData();
|
||||
|
||||
final FormData data = event.getFormData();
|
||||
|
||||
final Event item = (Event) super.processBasicWidgets(event);
|
||||
|
||||
|
|
@ -498,12 +499,20 @@ public class EventPropertyForm
|
|||
.findBean(ConfigurationManager.class);
|
||||
final EventConfig eventConfig = confManager
|
||||
.findConfiguration(EventConfig.class);
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
// save only if save button was pressed
|
||||
if (item != null
|
||||
&& getSaveCancelSection()
|
||||
.getSaveButton()
|
||||
.isSelected(event.getPageState())) {
|
||||
&& getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
|
||||
final String selectedLanguage = (String) state
|
||||
.getValue(selectedLanguageParam);
|
||||
final Locale selectedLocale;
|
||||
if (selectedLanguage == null) {
|
||||
selectedLocale = KernelConfig.getConfig().getDefaultLocale();
|
||||
} else {
|
||||
selectedLocale = new Locale(selectedLanguage);
|
||||
}
|
||||
|
||||
final java.util.Date startDate = (java.util.Date) data
|
||||
.get(START_DATE);
|
||||
|
|
@ -516,38 +525,33 @@ public class EventPropertyForm
|
|||
item.setEndDate((java.util.Date) data.get(END_DATE));
|
||||
//date_description
|
||||
if (!eventConfig.isHideDateDescription()) {
|
||||
item.getEventDate().addValue(
|
||||
KernelConfig.getConfig().getDefaultLocale(),
|
||||
item.getEventDate().addValue(selectedLocale,
|
||||
(String) data.get(EVENT_DATE));
|
||||
}
|
||||
|
||||
if (!eventConfig.isHideMainContributor()) {
|
||||
item
|
||||
.getMainContributor()
|
||||
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||
.addValue(selectedLocale,
|
||||
(String) data.get(MAIN_CONTRIBUTOR));
|
||||
}
|
||||
if (!eventConfig.isHideEventType()) {
|
||||
item
|
||||
.getEventType()
|
||||
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||
.addValue(selectedLocale,
|
||||
(String) data.get(EVENT_TYPE));
|
||||
}
|
||||
if (!eventConfig.isHideLinkToMap()) {
|
||||
item.setMapLink((String) data.get(MAP_LINK));
|
||||
}
|
||||
item
|
||||
.getLocation()
|
||||
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||
.getLocation().addValue(selectedLocale,
|
||||
(String) data.get(LOCATION));
|
||||
item
|
||||
.getDescription()
|
||||
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||
.getDescription().addValue(selectedLocale,
|
||||
(String) data.get(LEAD));
|
||||
if (!eventConfig.isHideCost()) {
|
||||
item
|
||||
.getCost()
|
||||
.addValue(KernelConfig.getConfig().getDefaultLocale(),
|
||||
item.getCost().addValue(selectedLocale,
|
||||
(String) data.get(COST));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,20 +167,36 @@ public class Event extends ContentItem implements Serializable {
|
|||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
if (startDate == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Date(startDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public void setStartDate(final Date startDate) {
|
||||
if (startDate == null) {
|
||||
this.startDate = null;
|
||||
} else {
|
||||
this.startDate = new Date(startDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
if (endDate == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new Date(endDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public void setEndDate(final Date endDate) {
|
||||
if (endDate == null) {
|
||||
this.endDate = null;
|
||||
} else {
|
||||
this.endDate = new Date(endDate.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public LocalizedString getEventDate() {
|
||||
return eventDate;
|
||||
|
|
|
|||
|
|
@ -336,3 +336,13 @@ cms.ui.action=Action
|
|||
cms.ui.item.language.add=Add language
|
||||
cms.contenttypes.ui.newsitem.date=News date
|
||||
cms.contenttypes.ui.newsitem.lead=Description
|
||||
cms.contenttypes.ui.event.lead=Description
|
||||
cms.contenttypes.ui.event.start_time=Starts at
|
||||
cms.contenttypes.ui.event.end_date=End date
|
||||
cms.contenttypes.ui.event.end_time=Ends at
|
||||
cms.contenttypes.ui.event.date_description=More information
|
||||
cms.contenttypes.ui.event.location=Location
|
||||
cms.contenttypes.ui.event.main_contributor=Main contributor
|
||||
cms.contenttypes.ui.event.event_type=Event type
|
||||
cms.contenttypes.ui.event.link_to_map=Link to map
|
||||
cms.contenttypes.ui.event.cost=Cost
|
||||
|
|
|
|||
|
|
@ -333,3 +333,13 @@ cms.ui.action=Aktion
|
|||
cms.ui.item.language.add=Sprache hinzuf\u00fcgen
|
||||
cms.contenttypes.ui.newsitem.date=Datum
|
||||
cms.contenttypes.ui.newsitem.lead=Zusammenfassung
|
||||
cms.contenttypes.ui.event.lead=Zusammenfassung
|
||||
cms.contenttypes.ui.event.start_time=Beginnt um
|
||||
cms.contenttypes.ui.event.end_date=Enddatum
|
||||
cms.contenttypes.ui.event.end_time=Endet um
|
||||
cms.contenttypes.ui.event.date_description=Weitere Informationen
|
||||
cms.contenttypes.ui.event.location=Ort
|
||||
cms.contenttypes.ui.event.main_contributor=Ansprechpartner
|
||||
cms.contenttypes.ui.event.event_type=Art der Veranstaltung
|
||||
cms.contenttypes.ui.event.link_to_map=Link zur Karte
|
||||
cms.contenttypes.ui.event.cost=Kosten
|
||||
|
|
|
|||
|
|
@ -292,3 +292,13 @@ cms.ui.action=Action
|
|||
cms.ui.item.language.add=Add language
|
||||
cms.contenttypes.ui.newsitem.date=News date
|
||||
cms.contenttypes.ui.newsitem.lead=Description
|
||||
cms.contenttypes.ui.event.lead=Description
|
||||
cms.contenttypes.ui.event.start_time=Starts at
|
||||
cms.contenttypes.ui.event.end_date=End date
|
||||
cms.contenttypes.ui.event.end_time=Ends at
|
||||
cms.contenttypes.ui.event.date_description=More information
|
||||
cms.contenttypes.ui.event.location=Location
|
||||
cms.contenttypes.ui.event.main_contributor=Main contributor
|
||||
cms.contenttypes.ui.event.event_type=Event type
|
||||
cms.contenttypes.ui.event.link_to_map=Link to map
|
||||
cms.contenttypes.ui.event.cost=Cost
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ public class DomainObjectPropertySheet extends PropertySheet {
|
|||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
throw new UnexpectedErrorException(ex);
|
||||
}
|
||||
return Optional.of(value);
|
||||
return Optional.ofNullable(value);
|
||||
|
||||
} else {
|
||||
return Optional.empty();
|
||||
|
|
|
|||
Loading…
Reference in New Issue