From 2e5d6ef588da8658360e42c9f5f77c4a61483e04 Mon Sep 17 00:00:00 2001 From: jensp Date: Thu, 14 Jul 2011 11:41:26 +0000 Subject: [PATCH] SciPublicPersonalProfile: Mock fertiggestellt. git-svn-id: https://svn.libreccm.org/ccm/trunk@1004 8810af33-2d31-482b-a856-94f89814c4df --- .../arsdigita/bebop/page/PageTransformer.java | 2 +- ccm-core/web/packages/ui/xsl/user-banner.xsl | 4 +- .../heirloom/packages/ui/xsl/user-banner.xsl | 2 +- .../ui/SciPublicPersonalProfileCreate.java | 143 ------------------ ...ublicPersonalProfileNavigationAddForm.java | 4 +- ...iPublicPersonalProfileNavigationTable.java | 2 +- ...ciPublicPersonalProfilePropertiesStep.java | 37 ++++- .../SciPublicPersonalProfilePropertyForm.java | 52 ++++--- ...iPublicPersonalProfileResources.properties | 9 ++ ...blicPersonalProfileResources_de.properties | 12 ++ ...icationPersonalProfileResources.properties | 2 - ...tionPersonalProfileResources_de.properties | 5 - 12 files changed, 87 insertions(+), 187 deletions(-) delete mode 100644 ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileCreate.java create mode 100644 ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources.properties create mode 100644 ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources_de.properties delete mode 100644 ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources.properties delete mode 100644 ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources_de.properties diff --git a/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java b/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java index d08c65ba4..c52d74671 100755 --- a/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java +++ b/ccm-core/src/com/arsdigita/bebop/page/PageTransformer.java @@ -327,7 +327,7 @@ public class PageTransformer implements PresentationManager { while (entries.hasNext()) { final Map.Entry entry = (Map.Entry) entries.next(); - + xf.setParameter((String) entry.getKey(), entry.getValue()); } diff --git a/ccm-core/web/packages/ui/xsl/user-banner.xsl b/ccm-core/web/packages/ui/xsl/user-banner.xsl index 2c71985f5..478643d30 100755 --- a/ccm-core/web/packages/ui/xsl/user-banner.xsl +++ b/ccm-core/web/packages/ui/xsl/user-banner.xsl @@ -15,7 +15,7 @@ - +
       @@ -87,7 +87,7 @@
- +
       diff --git a/ccm-core/web/themes/heirloom/packages/ui/xsl/user-banner.xsl b/ccm-core/web/themes/heirloom/packages/ui/xsl/user-banner.xsl index 2c71985f5..3628ca5c9 100644 --- a/ccm-core/web/themes/heirloom/packages/ui/xsl/user-banner.xsl +++ b/ccm-core/web/themes/heirloom/packages/ui/xsl/user-banner.xsl @@ -87,7 +87,7 @@
- +
       diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileCreate.java b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileCreate.java deleted file mode 100644 index d09db7916..000000000 --- a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileCreate.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.arsdigita.cms.contenttypes.ui; - -import com.arsdigita.bebop.ColumnPanel; -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.parameters.DateParameter; -import com.arsdigita.bebop.parameters.ParameterModel; -import com.arsdigita.bebop.util.GlobalizationUtil; -import com.arsdigita.cms.ContentBundle; -import com.arsdigita.cms.ContentPage; -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.ui.ItemSearchWidget; -import com.arsdigita.cms.ui.authoring.CreationSelector; -import com.arsdigita.cms.ui.authoring.PageCreate; -import com.arsdigita.cms.ContentSection; -import com.arsdigita.cms.ContentType; -import com.arsdigita.cms.Folder; -import com.arsdigita.cms.ui.authoring.ApplyWorkflowFormSection; -import com.arsdigita.cms.ui.authoring.LanguageWidget; -import com.arsdigita.cms.contenttypes.SciMember; -import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile; -import com.arsdigita.util.Assert; -import java.math.BigDecimal; -import java.util.Date; - -/** - * - * @author Jens Pelzetter - * @version $Id$ - */ -public class SciPublicPersonalProfileCreate extends PageCreate { - - private ItemSearchWidget itemSearch; - private final String ITEM_SEARCH = "owner"; - - public SciPublicPersonalProfileCreate(final ItemSelectionModel itemModel, - final CreationSelector parent) { - super(itemModel, parent); - } - - @Override - public void addWidgets() { - ContentType type = getItemSelectionModel().getContentType(); - m_workflowSection = new ApplyWorkflowFormSection(type); - add(m_workflowSection, ColumnPanel.INSERT); - add(new Label(GlobalizationUtil.globalize( - "cms.ui.authoring.content_type"))); - add(new Label(type.getLabel())); - add(new Label(GlobalizationUtil.globalize("cms.ui.language.field"))); - add(new LanguageWidget(LANGUAGE)); - - itemSearch = new ItemSearchWidget(ITEM_SEARCH, - ContentType.findByAssociatedObjectType( - SciMember.class.getName())); - add(itemSearch); - - if (!ContentSection.getConfig().getHideLaunchDate()) { - add(new Label(GlobalizationUtil.globalize( - "cms.ui.authoring.page_launch_date"))); - ParameterModel launchDateParam = new DateParameter(LAUNCH_DATE); - com.arsdigita.bebop.form.Date launchDate = - new com.arsdigita.bebop.form.Date( - launchDateParam); - if (ContentSection.getConfig().getRequireLaunchDate()) { - launchDate.addValidationListener( - new LaunchDateValidationListener()); - // if launch date is required, help user by suggesting today's date - launchDateParam.setDefaultValue(new Date()); - } - add(launchDate); - } - } - - @Override - public void validate(FormSectionEvent fse) throws FormProcessException { - final Folder folder = m_parent.getFolder(fse.getPageState()); - Assert.exists(folder); - validateNameUniqueness(folder, fse, getProfileName(fse)); - } - - @Override - public void process(FormSectionEvent fse) throws FormProcessException { - final FormData data = fse.getFormData(); - final PageState state = fse.getPageState(); - final ContentSection section = m_parent.getContentSection(state); - final Folder folder = m_parent.getFolder(state); - - final String profileName = getProfileName(fse); - final SciMember owner = (SciMember) data.get(ITEM_SEARCH); - - Assert.exists(section, ContentSection.class); - - final ContentPage item = createContentPage(state); - item.setLanguage((String) data.get(LANGUAGE)); - item.setName(profileName); - item.setTitle(getProfileTitle(fse)); - if (!ContentSection.getConfig().getHideLaunchDate()) { - item.setLaunchDate((Date) data.get(LAUNCH_DATE)); - } - - final ContentBundle bundle = new ContentBundle(item); - bundle.setParent(folder); - bundle.setContentSection(m_parent.getContentSection(state)); - bundle.save(); - - m_workflowSection.applyWorkflow(state, item); - - SciPublicPersonalProfile profile = new SciPublicPersonalProfile(item.getID()); - profile.setOwner(owner); - profile.save(); - - m_parent.editItem(state, item); - } - - private String getProfileName(FormSectionEvent fse) { - final FormData data = fse.getFormData(); - - SciMember owner = (SciMember) data.get(ITEM_SEARCH); - if (owner == null) { - return null; - } else { - return String.format("profile_%s_%s", - owner.getGivenName(), - owner.getSurname()); - } - } - - private String getProfileTitle(FormSectionEvent fse) { - final FormData data = fse.getFormData(); - - SciMember owner = (SciMember) data.get(ITEM_SEARCH); - if (owner == null) { - return null; - } else { - return String.format("Profile %s %s", - owner.getGivenName(), - owner.getSurname()); - } - } -} diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationAddForm.java b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationAddForm.java index fba99bca9..740383a18 100644 --- a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationAddForm.java +++ b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationAddForm.java @@ -70,9 +70,7 @@ public class SciPublicPersonalProfileNavigationAddForm add(new Label((String) SciPublicPersonalProfileGlobalizationUtil. globalize("scipublicpersonalprofile.ui.nav.select_target"). localize())); - itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. - findByAssociatedObjectType( - "com.arsdigita.cms.contenttypes.ContentItem")); + itemSearch = new ItemSearchWidget(ITEM_SEARCH); add(this.itemSearch); } diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationTable.java b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationTable.java index 20acb0b2a..1098692b9 100644 --- a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationTable.java +++ b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileNavigationTable.java @@ -103,7 +103,7 @@ public class SciPublicPersonalProfileNavigationTable @Override public boolean nextRow() { - if (index < mockNav.length) { + if (index < (mockNav.length - 1)) { index++; return true; } else { diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertiesStep.java b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertiesStep.java index a87144130..7508c2215 100644 --- a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertiesStep.java +++ b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertiesStep.java @@ -2,14 +2,18 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SegmentedPanel; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile; +import com.arsdigita.cms.ui.ItemSearchWidget; +import com.arsdigita.domain.DomainObject; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; 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.SciMember; /** * @@ -53,18 +57,39 @@ public class SciPublicPersonalProfilePropertiesStep extends SimpleEditStep { segmentedPanel.addSegment(new Label((String) SciPublicPersonalProfileGlobalizationUtil. globalize("scipublicpersonalprofile.ui.profile.basic_properties"). localize()), basicProperties); - + setDisplayComponent(segmentedPanel); } - + public static Component getSciPublicPersonalProfilePropertySheet( ItemSelectionModel itemModel) { DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel); - - sheet.add(SciPublicPersonalProfileGlobalizationUtil.globalize("scipublicpersonalprofile.ui.profile_url"), - SciPublicPersonalProfile.PROFILE_URL); - + + sheet.add(SciPublicPersonalProfileGlobalizationUtil.globalize( + "scipublicpersonalprofile.ui.owner"), + SciPublicPersonalProfile.OWNER, new OwnerFormatter()); + + sheet.add(SciPublicPersonalProfileGlobalizationUtil.globalize( + "scipublicpersonalprofile.ui.profile_url"), + SciPublicPersonalProfile.PROFILE_URL); + return sheet; } + + private static class OwnerFormatter implements + DomainObjectPropertySheet.AttributeFormatter { + + public String format(DomainObject obj, String attribute, PageState state) { + SciPublicPersonalProfile profile = (SciPublicPersonalProfile) obj; + + SciMember owner = profile.getOwner(); + + if (owner == null) { + return ""; + } else { + return owner.getFullName(); + } + } + } } diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertyForm.java b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertyForm.java index 2b277fe07..f21670e62 100644 --- a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertyForm.java +++ b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfilePropertyForm.java @@ -2,32 +2,20 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.FormSection; import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.event.FormInitListener; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.event.FormSubmissionListener; -import com.arsdigita.bebop.form.CheckboxGroup; -import com.arsdigita.bebop.form.Option; -import com.arsdigita.bebop.form.SingleSelect; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.bebop.parameters.DateParameter; -import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.contenttypes.GenericPerson; +import com.arsdigita.cms.contenttypes.SciMember; import com.arsdigita.cms.contenttypes.SciPublicPersonalProfile; -import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; +import com.arsdigita.cms.ui.ItemSearchWidget; import com.arsdigita.cms.ui.authoring.BasicPageForm; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import javax.swing.text.StyledEditorKit.BoldAction; -import org.apache.log4j.Logger; /** * @@ -40,10 +28,8 @@ public class SciPublicPersonalProfilePropertyForm FormInitListener { private SciPublicPersonalProfilePropertiesStep step; - private CheckboxGroup showPublicationList; - private CheckboxGroup showProjectList; - private String SHOW_PUBLICATION_LIST = "showPublicationList"; - private String SHOW_PROJECT_LIST = "showProjectList"; + private ItemSearchWidget itemSearch; + private final String ITEM_SEARCH = "owner"; public static final String ID = "SciPublicPersonalProfile_edit"; public SciPublicPersonalProfilePropertyForm(ItemSelectionModel itemModel) { @@ -61,12 +47,18 @@ public class SciPublicPersonalProfilePropertyForm public void addWidgets() { super.addWidgets(); + add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize( + "scipublicpersonalprofile.ui.profile.owner"))); + itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType. + findByAssociatedObjectType(SciMember.class.getName())); + add(itemSearch); + add(new Label(SciPublicPersonalProfileGlobalizationUtil.globalize( "scipublicpersonalprofile.ui.profile.url"))); ParameterModel profileUrlParam = new StringParameter(SciPublicPersonalProfile.PROFILE_URL); TextField profileUrl = new TextField(profileUrlParam); - add(profileUrl); + add(profileUrl); } @Override @@ -77,7 +69,7 @@ public class SciPublicPersonalProfilePropertyForm (SciPublicPersonalProfile) super. initBasicWidgets(fse); - data.put(SciPublicPersonalProfile.PROFILE_URL, profile.getProfileUrl()); + data.put(SciPublicPersonalProfile.PROFILE_URL, profile.getProfileUrl()); } @Override @@ -90,10 +82,24 @@ public class SciPublicPersonalProfilePropertyForm if ((profile != null) && getSaveCancelSection().getSaveButton().isSelected(state)) { + SciMember owner = (SciMember) data.get(ITEM_SEARCH); + profile.setOwner(owner); + profile.setProfileUrl((String) data.get( SciPublicPersonalProfile.PROFILE_URL)); - + profile.save(); } } + + @Override + public void validate(FormSectionEvent fse) throws FormProcessException { + final PageState state = fse.getPageState(); + final FormData data = fse.getFormData(); + + if (data.get(ITEM_SEARCH) == null) { + data.addError(SciPublicPersonalProfileGlobalizationUtil.globalize( + "scipublicpersonalprofile.ui.profile.missing_owner")); + } + } } diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources.properties b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources.properties new file mode 100644 index 000000000..aed672e01 --- /dev/null +++ b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources.properties @@ -0,0 +1,9 @@ +scipublicpersonalprofile.ui.profile.basic_properties=Basic properties +scipublicpersonalprofile.ui.profile.edit_basic_properties=Edit basic properties +scipublicpersonalprofile.ui.owner=Profile of +scipublicpersonalprofile.ui.profile_url=URL fragement +scipublicpersonalprofile.ui.nav.target=Navigation item +scipublicpersonalprofile.ui.nav.remove=Remove +scipublicpersonalprofile.ui.profile_properties.title=Basic properties +scipublicpersonalprofile.ui.profile_nav.title=Navigation +scipublicpersonalprofile.ui.profile.nav_add=Add item diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources_de.properties b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources_de.properties new file mode 100644 index 000000000..a6df56c3a --- /dev/null +++ b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicPersonalProfileResources_de.properties @@ -0,0 +1,12 @@ +# To change this template, choose Tools | Templates +# and open the template in the editor. + +scipublicpersonalprofile.ui.profile.basic_properties=Basiseigenschaften +scipublicpersonalprofile.ui.profile.edit_basic_properties=Basiseigenschaften bearbeiten +scipublicpersonalprofile.ui.owner=Profil von +scipublicpersonalprofile.ui.profile_url=URL Fragment +scipublicpersonalprofile.ui.nav.target=Navigationspunkt +scipublicpersonalprofile.ui.nav.remove=Entfernen +scipublicpersonalprofile.ui.profile_properties.title=Basiseigenschaften +scipublicpersonalprofile.ui.profile_nav.title=Navigation +scipublicpersonalprofile.ui.profile.nav_add=Navigationspunkt hinzuf\u00fcgen diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources.properties b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources.properties deleted file mode 100644 index 37b58c1b4..000000000 --- a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources.properties +++ /dev/null @@ -1,2 +0,0 @@ -scipublicpersonalprofile.ui.profile.basic_properties=Basic properties -scipublicpersonalprofile.ui.profile.edit_basic_properties=Edit basic properties diff --git a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources_de.properties b/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources_de.properties deleted file mode 100644 index 7be40d125..000000000 --- a/ccm-sci-publicpersonalprofile/src/com/arsdigita/cms/contenttypes/ui/SciPublicationPersonalProfileResources_de.properties +++ /dev/null @@ -1,5 +0,0 @@ -# To change this template, choose Tools | Templates -# and open the template in the editor. - -scipublicpersonalprofile.ui.profile.basic_properties=Basiseigenschaften -scipublicpersonalprofile.ui.profile.edit_basic_properties=Basiseigenschaften bearbeiten