From 416b3cb01d7d05627f1f94029af130b2fbfd3949 Mon Sep 17 00:00:00 2001 From: jensp Date: Mon, 8 Jul 2013 10:27:26 +0000 Subject: [PATCH] =?UTF-8?q?ccm-cms-types-bookmark=20springt=20jetzt=20vom?= =?UTF-8?q?=20PropertiesStep=20zum=20n=C3=A4chsten=20Schritt=20weiter.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@2250 8810af33-2d31-482b-a856-94f89814c4df --- .../ui/BookmarkPropertiesStep.java | 59 ++++----- .../contenttypes/ui/BookmarkPropertyForm.java | 123 +++++++++--------- 2 files changed, 89 insertions(+), 93 deletions(-) diff --git a/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java b/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java index 2e8f6dc7b..8b0add686 100755 --- a/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java +++ b/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertiesStep.java @@ -18,7 +18,6 @@ */ package com.arsdigita.cms.contenttypes.ui; - import com.arsdigita.bebop.Component; import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentSection; @@ -32,65 +31,57 @@ import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; - /** - * Authoring step to edit the simple attributes of the Bookmark content - * type (and its subclasses). + * Authoring step to edit the simple attributes of the Bookmark content type (and its subclasses). */ public class BookmarkPropertiesStep extends SimpleEditStep { - /** The name of the editing sheet added to this step */ + /** + * The name of the editing sheet added to this step + */ public static final String EDIT_SHEET_NAME = "edit"; - public BookmarkPropertiesStep( ItemSelectionModel itemModel, - AuthoringKitWizard parent ) { - super( itemModel, parent ); + public BookmarkPropertiesStep(final ItemSelectionModel itemModel, + final AuthoringKitWizard parent) { + super(itemModel, parent); BasicPageForm editSheet; - editSheet = new BookmarkPropertyForm( itemModel ); - add( EDIT_SHEET_NAME, - GlobalizationUtil.globalize("cms.ui.edit"), - new WorkflowLockedComponentAccess(editSheet, itemModel), - editSheet.getSaveCancelSection().getCancelButton() ); + editSheet = new BookmarkPropertyForm(itemModel, this); + add(EDIT_SHEET_NAME, + GlobalizationUtil.globalize("cms.ui.edit"), + new WorkflowLockedComponentAccess(editSheet, itemModel), + editSheet.getSaveCancelSection().getCancelButton()); setDefaultEditKey(EDIT_SHEET_NAME); - setDisplayComponent( getBookmarkPropertySheet( itemModel ) ); + setDisplayComponent(getBookmarkPropertySheet(itemModel)); } /** - * Returns a component that displays the properties of the - * Bookmark specified by the ItemSelectionModel passed in. + * Returns a component that displays the properties of the Bookmark specified by the ItemSelectionModel passed in. + * * @param itemModel The ItemSelectionModel to use * @pre itemModel != null - * @return A component to display the state of the basic properties - * of the release + * @return A component to display the state of the basic properties of the release */ - public static Component getBookmarkPropertySheet( ItemSelectionModel - itemModel ) { - DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( itemModel ); + public static Component getBookmarkPropertySheet(final ItemSelectionModel itemModel) { + final DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel); sheet.add(GlobalizationUtil - .globalize("cms.contenttypes.ui.title"), Bookmark.TITLE ); + .globalize("cms.contenttypes.ui.title"), Bookmark.TITLE); sheet.add(GlobalizationUtil - .globalize("cms.contenttypes.ui.name"), Bookmark.NAME ); + .globalize("cms.contenttypes.ui.name"), Bookmark.NAME); if (!ContentSection.getConfig().getHideLaunchDate()) { sheet.add(GlobalizationUtil - .globalize("cms.contenttypes.ui.launch_date"), + .globalize("cms.contenttypes.ui.launch_date"), ContentPage.LAUNCH_DATE, - new LaunchDateAttributeFormatter() ); + new LaunchDateAttributeFormatter()); } sheet.add(GlobalizationUtil - .globalize("cms.contenttypes.ui.summary"), Bookmark.DESCRIPTION ); - sheet.add(new GlobalizedMessage - ("cms.contenttypes.ui.bookmark.url",Bookmark.RESOURCES), - Bookmark.URL ); + .globalize("cms.contenttypes.ui.summary"), Bookmark.DESCRIPTION); + sheet.add(new GlobalizedMessage("cms.contenttypes.ui.bookmark.url", Bookmark.RESOURCES), + Bookmark.URL); return sheet; } } - - - - - diff --git a/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertyForm.java b/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertyForm.java index 3d433944c..d037a8a9f 100755 --- a/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertyForm.java +++ b/ccm-cms-types-bookmark/src/com/arsdigita/cms/contenttypes/ui/BookmarkPropertyForm.java @@ -28,90 +28,95 @@ import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextField; import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringParameter; +import com.arsdigita.cms.AuthoringStep; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.globalization.GlobalizedMessage; - /** - * to edit BasicPageForm the basic properties of an Bookmark. This form can be - * extended to create forms for Bookmark subclasses. + * to edit BasicPageForm the basic properties of an Bookmark. This form can be extended to create forms for Bookmark + * subclasses. */ -public class BookmarkPropertyForm - extends BasicPageForm - implements FormProcessListener, FormInitListener { - - /** parameter names */ - public static final String DESCRIPTION = "description"; - public static final String URL = "url"; - - /** Name of this form */ - public static final String ID = "Bookmark_edit"; +public class BookmarkPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener { /** - * Creates a new form to edit the Bookmark object specified - * by the item selection model passed in. - * @param itemModel The ItemSelectionModel to use to obtain the - * Bookmark to work on + * parameter names */ - public BookmarkPropertyForm( ItemSelectionModel itemModel ) { - super( ID, itemModel ); + public static final String DESCRIPTION = "description"; + public static final String URL = "url"; + /** + * Name of this form + */ + public static final String ID = "Bookmark_edit"; + + /** + * AuthoringKit step managing this form + */ + private final BookmarkPropertiesStep step; + + /** + * Creates a new form to edit the Bookmark object specified by the item selection model passed in. + * + * @param itemModel The ItemSelectionModel to use to obtain the Bookmark to work on + */ + public BookmarkPropertyForm(final ItemSelectionModel itemModel, final BookmarkPropertiesStep step) { + super(ID, itemModel); + this.step = step; } /** * Adds widgets to the form. */ + @Override protected void addWidgets() { super.addWidgets(); - - add( new Label( GlobalizationUtil.globalize( - "cms.contenttypes.ui.summary") ) ); - ParameterModel descriptionParam - = new StringParameter( DESCRIPTION ); - TextArea description = new TextArea( descriptionParam ); + + add(new Label(GlobalizationUtil.globalize( + "cms.contenttypes.ui.summary"))); + final ParameterModel descriptionParam = new StringParameter(DESCRIPTION); + final TextArea description = new TextArea(descriptionParam); description.setCols(40); description.setRows(5); description.setHint(GlobalizationUtil.globalize( - "cms.contenttypes.ui.summary_hint")); - add( description ); - - add( new Label( new GlobalizedMessage - ("cms.contenttypes.ui.bookmark.url",Bookmark.RESOURCES) ) ); - ParameterModel urlParam - = new StringParameter( URL ); - TextField url = new TextField( urlParam ); - url.setSize( 40 ); - add( url ); - + "cms.contenttypes.ui.summary_hint")); + add(description); + + add(new Label(new GlobalizedMessage("cms.contenttypes.ui.bookmark.url", Bookmark.RESOURCES))); + final ParameterModel urlParam = new StringParameter(URL); + final TextField url = new TextField(urlParam); + url.setSize(40); + add(url); + } - /** Form initialisation hook. Fills widgets with data. */ - public void init( FormSectionEvent fse ) { - FormData data = fse.getFormData(); - Bookmark item - = (Bookmark) super.initBasicWidgets( fse ); - - data.put( DESCRIPTION, item.getDescription() ); - data.put( URL, item.getURL() ); + /** + * Form initialisation hook. Fills widgets with data. + */ + public void init(final FormSectionEvent fse) { + final FormData data = fse.getFormData(); + final Bookmark item = (Bookmark) super.initBasicWidgets(fse); + + data.put(DESCRIPTION, item.getDescription()); + data.put(URL, item.getURL()); } - - /** Form processing hook. Saves Bookmark object. */ - public void process( FormSectionEvent fse ) { - FormData data = fse.getFormData(); - - Bookmark item - = (Bookmark) super.processBasicWidgets( fse ); - + + /** + * Form processing hook. Saves Bookmark object. + */ + public void process(final FormSectionEvent fse) { + final FormData data = fse.getFormData(); + + final Bookmark item = (Bookmark) super.processBasicWidgets(fse); + // save only if save button was pressed - if ( item != null - && getSaveCancelSection().getSaveButton() - .isSelected( fse.getPageState() ) ) { - item.setDescription( (String) - data.get( DESCRIPTION ) ); - item.setURL( (String) - data.get( URL ) ); + if (item != null + && getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) { + item.setDescription((String) data.get(DESCRIPTION)); + item.setURL((String) data.get(URL)); item.save(); + step.maybeForwardToNextStep(fse.getPageState()); } } }