ccm-cms-types-bookmark springt jetzt vom PropertiesStep zum nächsten Schritt weiter.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2250 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
cc6b96d27f
commit
416b3cb01d
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
public class BookmarkPropertyForm extends BasicPageForm implements FormProcessListener, FormInitListener {
|
||||
|
||||
/** parameter names */
|
||||
/**
|
||||
* parameter names
|
||||
*/
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String URL = "url";
|
||||
|
||||
/** Name of this form */
|
||||
/**
|
||||
* Name of this form
|
||||
*/
|
||||
public static final String ID = "Bookmark_edit";
|
||||
|
||||
/**
|
||||
* 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
|
||||
* AuthoringKit step managing this form
|
||||
*/
|
||||
public BookmarkPropertyForm( ItemSelectionModel itemModel ) {
|
||||
super( ID, itemModel );
|
||||
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 );
|
||||
"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 );
|
||||
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 );
|
||||
/**
|
||||
* 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() );
|
||||
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();
|
||||
/**
|
||||
* Form processing hook. Saves Bookmark object.
|
||||
*/
|
||||
public void process(final FormSectionEvent fse) {
|
||||
final FormData data = fse.getFormData();
|
||||
|
||||
Bookmark item
|
||||
= (Bookmark) super.processBasicWidgets( fse );
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue