From 1e6abe269d535da29a6372f7a6571d12d7095496 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 26 Oct 2011 12:42:26 +0000 Subject: [PATCH] =?UTF-8?q?SciProject:=20F=C3=BCr=20Anfangs-=20und=20Endda?= =?UTF-8?q?tum=20eines=20Projektes=20jetzt=20auch=20unvollst=C3=A4ndige=20?= =?UTF-8?q?Datumsangaben=20(z.B.=20nur=20das=20Jahr=20oder=20nur=20Jahr=20?= =?UTF-8?q?und=20Monat)=20verwendet=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@1206 8810af33-2d31-482b-a856-94f89814c4df --- .../arsdigita/content-types/SciProject.pdl | 8 ++- .../cms/contenttypes/SciProject.java | 60 ++++++++++++++++++- .../ui/SciProjectPropertiesStep.java | 56 +++++++++++++++-- .../ui/SciProjectPropertyForm.java | 54 +++++++++++++++-- .../ui/SciProjectResources.properties | 1 + .../ui/SciProjectResources_de.properties | 1 + 6 files changed, 166 insertions(+), 14 deletions(-) diff --git a/ccm-sci-types-project/pdl/com/arsdigita/content-types/SciProject.pdl b/ccm-sci-types-project/pdl/com/arsdigita/content-types/SciProject.pdl index ea6d97d2a..4d20c749f 100644 --- a/ccm-sci-types-project/pdl/com/arsdigita/content-types/SciProject.pdl +++ b/ccm-sci-types-project/pdl/com/arsdigita/content-types/SciProject.pdl @@ -5,8 +5,12 @@ import com.arsdigita.cms.*; object type SciProject extends GenericOrganizationalUnit { - Date[0..1] projectbegin = ct_sci_projects.projectbegin DATE; - Date[0..1] projectend = ct_sci_projects.projectend DATE; + Date[0..1] projectBegin = ct_sci_projects.projectbegin DATE; + Boolean[0..1] projectBeginSkipMonth = ct_sci_projects.projectbegin_skip_month; + Boolean[0..1] projectBeginSkipDay = ct_sci_projects.projectbegin_skip_day; + Date[0..1] projectEnd = ct_sci_projects.projectend DATE; + Boolean[0..1] projectEndSkipMonth = ct_sci_projects.projectend_skip_month; + Boolean[0..1] projectEndSkipDay = ct_sci_projects.projectend_skip_day; String[0..1] projectShortDesc = ct_sci_projects.shortdesc VARCHAR(5000); String[0..1] projectDescription = ct_sci_projects.description CLOB; String[0..1] funding = ct_sci_projects.funding CLOB; diff --git a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/SciProject.java b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/SciProject.java index b5b58c4fc..7d242583e 100644 --- a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/SciProject.java +++ b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/SciProject.java @@ -41,8 +41,12 @@ import java.util.List; */ public class SciProject extends GenericOrganizationalUnit { - public static final String BEGIN = "projectbegin"; - public static final String END = "projectend"; + public static final String BEGIN = "projectBegin"; + public static final String BEGIN_SKIP_MONTH = "projectBeginSkipMonth"; + public static final String BEGIN_SKIP_DAY = "projectBeginSkipDay"; + public static final String END = "projectEnd"; + public static final String END_SKIP_MONTH = "projectEndSkipMonth"; + public static final String END_SKIP_DAY = "projectEndSkipDay"; public static final String PROJECT_SHORT_DESCRIPTION = "projectShortDesc"; public static final String PROJECT_DESCRIPTION = "projectDescription"; public static final String FUNDING = "funding"; @@ -87,6 +91,32 @@ public class SciProject extends GenericOrganizationalUnit { public void setBegin(Date begin) { set(BEGIN, begin); } + + public Boolean getBeginSkipMonth() { + final Object value = get(BEGIN_SKIP_MONTH); + if (value == null) { + return false; + } else { + return (Boolean) value; + } + } + + public void setBeginSkipMonth(final Boolean skipMonth) { + set(BEGIN_SKIP_MONTH, skipMonth); + } + + public Boolean getBeginSkipDay() { + final Object value = get(BEGIN_SKIP_DAY); + if (value == null) { + return false; + } else { + return (Boolean) value; + } + } + + public void setBeginSkipDay(final Boolean skipDay) { + set(BEGIN_SKIP_DAY, skipDay); + } public Date getEnd() { return (Date) get(END); @@ -95,6 +125,32 @@ public class SciProject extends GenericOrganizationalUnit { public void setEnd(Date end) { set(END, end); } + + public Boolean getEndSkipMonth() { + final Object value = get(END_SKIP_MONTH); + if (value == null) { + return false; + } else { + return (Boolean) value; + } + } + + public void setEndSkipMonth(final Boolean skipMonth) { + set(END_SKIP_MONTH, skipMonth); + } + + public Boolean getEndSkipDay() { + final Object value = get(END_SKIP_DAY); + if (value == null) { + return false; + } else { + return (Boolean) value; + } + } + + public void setEndSkipDay(final Boolean skipDay) { + set(END_SKIP_DAY, skipDay); + } public String getProjectShortDescription() { return (String) get(PROJECT_SHORT_DESCRIPTION); diff --git a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertiesStep.java b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertiesStep.java index c5c3de3db..dc50fa6ea 100644 --- a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertiesStep.java +++ b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertiesStep.java @@ -11,8 +11,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.domain.DomainObject; +import com.arsdigita.globalization.GlobalizationHelper; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import java.text.DateFormat; +import java.text.DateFormatSymbols; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Locale; /** * @@ -44,6 +49,27 @@ public class SciProjectPropertiesStep if (project.getBegin() == null) { return (String) ContenttypesGlobalizationUtil.globalize( "cms.ui.unknown").localize(); + } else if (project.getBeginSkipMonth() + || project.getBeginSkipDay()) { + String month = ""; + final Calendar begin = new GregorianCalendar(); + begin.setTime(project.getBegin()); + if (!project.getBeginSkipMonth()) { + final Locale locale = GlobalizationHelper. + getNegotiatedLocale(); + if (locale != null) { + final DateFormatSymbols dfs = new DateFormatSymbols( + locale); + String[] months = dfs.getMonths(); + month = String.format("%s ", + months[begin.get( + Calendar.MONTH)]); + } + } + return String.format("%s %s", + month, + Integer.toString(begin.get( + Calendar.YEAR))); } else { return DateFormat.getDateInstance(DateFormat.LONG).format( project.getBegin()); @@ -61,6 +87,27 @@ public class SciProjectPropertiesStep if (project.getEnd() == null) { return (String) ContenttypesGlobalizationUtil.globalize( "cms.ui.unknown").localize(); + } else if (project.getEndSkipMonth() + || project.getEndSkipDay()) { + String month = ""; + final Calendar end = new GregorianCalendar(); + end.setTime(project.getEnd()); + if (!project.getEndSkipMonth()) { + final Locale locale = GlobalizationHelper. + getNegotiatedLocale(); + if (locale != null) { + final DateFormatSymbols dfs = new DateFormatSymbols( + locale); + String[] months = dfs.getMonths(); + month = String.format("%s ", + months[end.get( + Calendar.MONTH)]); + } + } + return String.format("%s %s", + month, + Integer.toString(end.get( + Calendar.YEAR))); } else { return DateFormat.getDateInstance(DateFormat.LONG).format(project. getEnd()); @@ -82,8 +129,9 @@ public class SciProjectPropertiesStep parent, EDIT_SHEET_NAME); - final BasicPageForm editBasicSheet = new SciProjectPropertyForm(itemModel, - this); + final BasicPageForm editBasicSheet = new SciProjectPropertyForm( + itemModel, + this); basicProperties.add(EDIT_SHEET_NAME, (String) SciProjectGlobalizationUtil.globalize( @@ -109,7 +157,7 @@ public class SciProjectPropertiesStep addStep(new GenericOrganizationalUnitContactPropertiesStep(itemModel, parent), SciProjectGlobalizationUtil.globalize("sciproject.ui.contacts")); - - + + } } diff --git a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java index 7551a08e4..29ae24735 100644 --- a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java +++ b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java @@ -9,7 +9,9 @@ import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; import com.arsdigita.bebop.event.FormSubmissionListener; import com.arsdigita.bebop.form.Date; +import com.arsdigita.bebop.form.Hidden; import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.parameters.BooleanParameter; import com.arsdigita.bebop.parameters.IncompleteDateParameter; import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringInRangeValidationListener; @@ -48,17 +50,42 @@ public class SciProjectPropertyForm public void addWidgets() { super.addWidgets(); + final ParameterModel beginSkipMonthParam = + new BooleanParameter(SciProject.BEGIN_SKIP_MONTH); + final Hidden beginSkipMonth = new Hidden(beginSkipMonthParam); + add(beginSkipMonth); + + final ParameterModel beginSkipDayParam = + new BooleanParameter(SciProject.BEGIN_SKIP_DAY); + final Hidden beginSkipDay = new Hidden(beginSkipDayParam); + add(beginSkipDay); + add(new Label(SciProjectGlobalizationUtil.globalize( "sciproject.ui.begin"))); - ParameterModel beginParam = new IncompleteDateParameter(SciProject.BEGIN); - Calendar today = new GregorianCalendar(); - Date begin = new Date(beginParam); + final IncompleteDateParameter beginParam = + new IncompleteDateParameter(SciProject.BEGIN); + beginParam.allowSkipMonth(true); + beginParam.allowSkipDay(true); + final Calendar today = new GregorianCalendar(); + final Date begin = new Date(beginParam); begin.setYearRange(1970, (today.get(Calendar.YEAR) + 2)); add(begin); + final ParameterModel endSkipMonthParam = + new BooleanParameter(SciProject.END_SKIP_MONTH); + final Hidden endSkipMonth = new Hidden(endSkipMonthParam); + add(endSkipMonth); + + final ParameterModel endSkipDayParam = new BooleanParameter( + SciProject.END_SKIP_DAY); + final Hidden endSkipDay = new Hidden(endSkipDayParam); + add(endSkipDay); + add(new Label(SciProjectGlobalizationUtil.globalize( "sciproject.ui.end"))); - ParameterModel endParam = new IncompleteDateParameter(SciProject.END); + final IncompleteDateParameter endParam = new IncompleteDateParameter(SciProject.END); + endParam.allowSkipMonth(true); + endParam.allowSkipDay(true); Date end = new Date(endParam); end.setYearRange(1970, (today.get(Calendar.YEAR) + 8)); add(end); @@ -84,7 +111,11 @@ public class SciProjectPropertyForm final SciProject project = (SciProject) super.initBasicWidgets(fse); data.put(SciProject.BEGIN, project.getBegin()); + data.put(SciProject.BEGIN_SKIP_MONTH, project.getBeginSkipMonth()); + data.put(SciProject.BEGIN_SKIP_DAY, project.getBeginSkipDay()); data.put(SciProject.END, project.getEnd()); + data.put(SciProject.END_SKIP_MONTH, project.getEndSkipMonth()); + data.put(SciProject.END_SKIP_DAY, project.getEndSkipDay()); data.put(SciProject.PROJECT_SHORT_DESCRIPTION, project.getProjectShortDescription()); } @@ -99,8 +130,19 @@ public class SciProjectPropertyForm if ((project != null) && getSaveCancelSection().getSaveButton().isSelected(state)) { - project.setBegin((java.util.Date) data.get(SciProject.BEGIN)); - project.setEnd((java.util.Date) data.get(SciProject.END)); + project.setBeginSkipMonth(((IncompleteDateParameter) data. + getParameter(SciProject.BEGIN). + getModel()).isMonthSkipped()); + project.setBeginSkipDay( + ((IncompleteDateParameter) data.getParameter( + SciProject.BEGIN).getModel()).isDaySkipped()); + project.setBegin((java.util.Date) data.get(SciProject.BEGIN)); + project.setEndSkipMonth( + ((IncompleteDateParameter) data.getParameter( + SciProject.END).getModel()).isMonthSkipped()); + project.setEndSkipDay(((IncompleteDateParameter) data.getParameter( + SciProject.END).getModel()).isDaySkipped()); + project.setEnd((java.util.Date) data.get(SciProject.END)); project.setProjectShortDescription((String) data.get( SciProject.PROJECT_SHORT_DESCRIPTION)); diff --git a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources.properties b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources.properties index b87218b24..7b4b7b5da 100644 --- a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources.properties +++ b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources.properties @@ -84,3 +84,4 @@ sciproject.ui.involved_orgas.delete.confirm=Are you sure to remove the selected sciproject.ui.involved_orgas.title=Involved Organizations sciproject.ui.involved_orgas.description=Managed involved organizations scidepartment.ui.superdepartment.add=Add superior department +sciproject.ui.edit_basic_properties=Basic properties diff --git a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources_de.properties b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources_de.properties index 5db843809..4cf28813a 100644 --- a/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources_de.properties +++ b/ccm-sci-types-project/src/com/arsdigita/cms/contenttypes/ui/SciProjectResources_de.properties @@ -85,3 +85,4 @@ sciproject.ui.involved_orgas.delete.confirm=Sind Sie sicher, dass die die ausgew sciproject.ui.involved_orgas.title=Beteiligte Organisationen sciproject.ui.involved_orgas.description=Verwalten von am Projekt beteiligten Organisationen scidepartment.ui.superdepartment.add=\u00dcbergeordnete Abteilung hinzuf\u00fcgen +sciproject.ui.edit_basic_properties=Basiseigenschaften