First part of UI classes for the publication contenttypes.
git-svn-id: https://svn.libreccm.org/ccm/trunk@511 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
98a99771b3
commit
92e63ef562
|
|
@ -48,9 +48,9 @@ public class GenericPerson extends ContentPage implements RelationAttribute {
|
|||
public static final String CONTACT_TYPE = "contact_type";
|
||||
public static final String CONTACT_ORDER = "contact_order";
|
||||
private static final String RELATION_ATTRIBUTES = "GenericContactType";
|
||||
|
||||
/** Data object type for this domain object */
|
||||
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.GenericPerson";
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.contenttypes.GenericPerson";
|
||||
|
||||
/**
|
||||
* Default constructor. This creates a new (empty) GenericPerson.
|
||||
|
|
@ -102,12 +102,14 @@ public class GenericPerson extends ContentPage implements RelationAttribute {
|
|||
public String getTitlePre() {
|
||||
return (String) get(TITLEPRE);
|
||||
}
|
||||
public Date getBirthdate() {
|
||||
return (Date)get(BIRTHDATE);
|
||||
}
|
||||
public void setBirthdate(Date birthdate) {
|
||||
set(BIRTHDATE, birthdate);
|
||||
}
|
||||
|
||||
public Date getBirthdate() {
|
||||
return (Date) get(BIRTHDATE);
|
||||
}
|
||||
|
||||
public void setBirthdate(Date birthdate) {
|
||||
set(BIRTHDATE, birthdate);
|
||||
}
|
||||
|
||||
public void setTitlePre(String titlePre) {
|
||||
set(TITLEPRE, titlePre);
|
||||
|
|
@ -121,6 +123,17 @@ public class GenericPerson extends ContentPage implements RelationAttribute {
|
|||
set(TITLEPOST, titlePost);
|
||||
}
|
||||
|
||||
/**
|
||||
* A convinient method which combines {@code titlePre}, {@code givenName),
|
||||
* {@code surname} and {@code titlePost}.
|
||||
*
|
||||
* @return {@code titlePre} {@code givenName) {@code surnameName} {@code titlePost}
|
||||
*/
|
||||
public String getFullName() {
|
||||
return String.format("%s %s %s %s", getTitlePre(), getGivenName(),
|
||||
getSurname(), getTitlePost()).trim();
|
||||
}
|
||||
|
||||
// Get all contacts for this person
|
||||
public GenericPersonContactCollection getContacts() {
|
||||
return new GenericPersonContactCollection((DataCollection) get(CONTACTS));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,97 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.RadioGroup;
|
||||
import com.arsdigita.bebop.parameters.BooleanParameter;
|
||||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class PublicationAuthorAddForm extends BasicItemForm {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
PublicationAuthorAddForm.class);
|
||||
private PublicationPropertiesStep m_step;
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private SaveCancelSection m_saveCancelSection;
|
||||
private final String ITEM_SEARCH = "authors";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public PublicationAuthorAddForm(ItemSelectionModel itemModel) {
|
||||
super("AuthorsEntryForm", itemModel);
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.selectAuthor").localize()));
|
||||
m_itemSearch = new ItemSearchWidget(
|
||||
ITEM_SEARCH,
|
||||
ContentType.findByAssociatedObjectType(GenericPerson.class.
|
||||
getName()));
|
||||
add(m_itemSearch);
|
||||
|
||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.is_editor").localize()));
|
||||
ParameterModel isEditorModel = new BooleanParameter(
|
||||
AuthorshipCollection.EDITOR);
|
||||
RadioGroup isEditorGroup = new RadioGroup(isEditorModel);
|
||||
isEditorGroup.addValidationListener(new NotNullValidationListener());
|
||||
isEditorGroup.setMetaDataAttribute(
|
||||
"label",
|
||||
(String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.is_editor_label").
|
||||
localize());
|
||||
isEditorGroup.addOption(
|
||||
new Option(Boolean.FALSE.toString(),
|
||||
(String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.is_editor_false").localize()));
|
||||
isEditorGroup.addOption(
|
||||
new Option(Boolean.TRUE.toString(),
|
||||
(String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.is_editor_true").localize()));
|
||||
add(isEditorGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
Publication publication = (Publication) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!(this.getSaveCancelSection().getCancelButton().isSelected(state))) {
|
||||
publication.addAuthor(
|
||||
(GenericPerson) data.get(ITEM_SEARCH),
|
||||
(Boolean) data.get(AuthorshipCollection.EDITOR));
|
||||
}
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class PublicationAuthorsPropertyStep extends SimpleEditStep {
|
||||
|
||||
private static final String ADD_AUTHOR_SHEET_NAME = "addAuthor";
|
||||
|
||||
public PublicationAuthorsPropertyStep(
|
||||
ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public PublicationAuthorsPropertyStep(
|
||||
ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
BasicItemForm addAuthorSheet =
|
||||
new PublicationAuthorAddForm(itemModel);
|
||||
add(ADD_AUTHOR_SHEET_NAME,
|
||||
(String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.add_author").localize(),
|
||||
new WorkflowLockedComponentAccess(addAuthorSheet, itemModel),
|
||||
addAuthorSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
PublicationAuthorsTable authorsTable = new PublicationAuthorsTable(
|
||||
itemModel);
|
||||
setDisplayComponent(authorsTable);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,319 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
|
||||
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class PublicationAuthorsTable
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(PublicationAuthorsTable.class);
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private final static String TABLE_COL_UP = "table_col_up";
|
||||
private final static String TABLE_COL_DOWN = "table_col_down";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public PublicationAuthorsTable(ItemSelectionModel itemModel) {
|
||||
super();
|
||||
m_itemModel = itemModel;
|
||||
|
||||
setEmptyView(
|
||||
new Label(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.none")));
|
||||
|
||||
TableColumnModel colModel = getColumnModel();
|
||||
colModel.add(new TableColumn(
|
||||
0,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.name").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
colModel.add(new TableColumn(
|
||||
1,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.isEditor").localize()));
|
||||
colModel.add(new TableColumn(
|
||||
2,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.delete").localize(),
|
||||
TABLE_COL_DEL));
|
||||
colModel.add(new TableColumn(
|
||||
3,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.up").localize(),
|
||||
TABLE_COL_UP));
|
||||
colModel.add(new TableColumn(
|
||||
4,
|
||||
PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.down").localize(),
|
||||
TABLE_COL_DOWN));
|
||||
|
||||
setModelBuilder(
|
||||
new PublicationAuthorsTableModelBuilder(itemModel));
|
||||
|
||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
colModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
||||
colModel.get(3).setCellRenderer(new UpCellRenderer());
|
||||
colModel.get(4).setCellRenderer(new DownCellRenderer());
|
||||
}
|
||||
|
||||
private class PublicationAuthorsTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public PublicationAuthorsTableModelBuilder(
|
||||
ItemSelectionModel itemModel) {
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
Publication publication =
|
||||
(Publication) m_itemModel.getSelectedObject(state);
|
||||
return new PublicationAuthorsTableModel(table, state, publication);
|
||||
}
|
||||
}
|
||||
|
||||
private class PublicationAuthorsTableModel implements TableModel {
|
||||
|
||||
private final int MAX_DESC_LENGTH = 25;
|
||||
private Table m_table;
|
||||
private AuthorshipCollection m_authorshipCollection;
|
||||
private GenericPerson m_author;
|
||||
|
||||
private PublicationAuthorsTableModel(
|
||||
Table table,
|
||||
PageState state,
|
||||
Publication publication) {
|
||||
m_table = table;
|
||||
m_authorshipCollection = publication.getAuthors();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
if ((m_authorshipCollection != null)
|
||||
&& m_authorshipCollection.next()) {
|
||||
m_author = m_authorshipCollection.getAuthor();
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return m_author.getFullName();
|
||||
case 1:
|
||||
if (m_authorshipCollection.isEditor()) {
|
||||
return (String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.isEditor").
|
||||
localize();
|
||||
} else {
|
||||
return PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.isNotEditor").
|
||||
localize();
|
||||
}
|
||||
case 2:
|
||||
return PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.authors.author.remove").
|
||||
localize();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getKeyAt(int columnIndex) {
|
||||
return m_author.getID();
|
||||
}
|
||||
}
|
||||
|
||||
private class EditCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
Publication publication = (Publication) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.EDIT_ITEM,
|
||||
publication);
|
||||
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
} else {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
Publication publication = (Publication) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
|
||||
boolean canDelete = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
publication);
|
||||
|
||||
if (canDelete) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) PublicationGlobalizationUtil.
|
||||
globalize(
|
||||
"publications.ui.authors.author.confirm_remove").
|
||||
localize());
|
||||
return link;
|
||||
} else {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class UpCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
if (0 == row) {
|
||||
s_log.debug("Row is first row in table, don't show up link");
|
||||
Label label = new Label("");
|
||||
return label;
|
||||
} else {
|
||||
ControlLink link = new ControlLink("up");
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DownCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
Publication publication = (Publication) m_itemModel.
|
||||
getSelectedObject(state);
|
||||
AuthorshipCollection authors = publication.getAuthors();
|
||||
|
||||
if ((authors.size() - 1)
|
||||
== row) {
|
||||
s_log.debug("Row is last row in table, don't show down link");
|
||||
Label label = new Label("");
|
||||
return label;
|
||||
} else {
|
||||
ControlLink link = new ControlLink("down");
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
GenericPerson author =
|
||||
new GenericPerson(new BigDecimal(event.getRowKey().
|
||||
toString()));
|
||||
|
||||
Publication publication = (Publication) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
AuthorshipCollection authors = publication.getAuthors();
|
||||
|
||||
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
publication.removeAuthor(author);
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
|
||||
authors.swapWithPrevious(author);
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
|
||||
authors.swapWithNext(author);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(TableActionEvent event) {
|
||||
//Nothing to do here.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class PublicationGlobalizationUtil {
|
||||
|
||||
public static final String BUNDLE_NAME =
|
||||
"com.arsdigita.cms.contenttypes.PublicationBundle";
|
||||
|
||||
public static GlobalizedMessage globalize(String key) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||
}
|
||||
|
||||
public static GlobalizedMessage globalize(String key, Object[] args) {
|
||||
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
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.ContentPage;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import java.text.DateFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class PublicationPropertiesStep extends SimpleEditStep {
|
||||
|
||||
public static final String EDIT_SHEET_NAME = "edit";
|
||||
private SegmentedPanel segmentedPanel;
|
||||
|
||||
public PublicationPropertiesStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
super(itemModel, parent);
|
||||
|
||||
segmentedPanel = new SegmentedPanel();
|
||||
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||
|
||||
addBasicProperties(itemModel, parent);
|
||||
addSteps(itemModel, parent);
|
||||
|
||||
setDisplayComponent(segmentedPanel);
|
||||
}
|
||||
|
||||
public static Component getPublicationPropertySheet(
|
||||
ItemSelectionModel itemModel) {
|
||||
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
|
||||
itemModel);
|
||||
|
||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.title"),
|
||||
Publication.NAME);
|
||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.year_of_publication"),
|
||||
Publication.YEAR_OF_PUBLICATION);
|
||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.abstract"),
|
||||
Publication.ABSTRACT);
|
||||
sheet.add(PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.misc"),
|
||||
Publication.MISC);
|
||||
|
||||
if (!ContentSection.getConfig().getHideLaunchDate()) {
|
||||
sheet.add(ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.ui.authoring.page_launch_date"),
|
||||
ContentPage.LAUNCH_DATE,
|
||||
new DomainObjectPropertySheet.AttributeFormatter() {
|
||||
|
||||
public String format(DomainObject item,
|
||||
String attribute,
|
||||
PageState state) {
|
||||
ContentPage page = (ContentPage) item;
|
||||
if (page.getLaunchDate() != null) {
|
||||
return DateFormat.getDateInstance(DateFormat.LONG).
|
||||
format(page.getLaunchDate());
|
||||
} else {
|
||||
return (String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.ui.unknown").localize();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return sheet;
|
||||
}
|
||||
|
||||
protected void addBasicProperties(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
SimpleEditStep basicProperties = new SimpleEditStep(itemModel,
|
||||
parent,
|
||||
EDIT_SHEET_NAME);
|
||||
|
||||
BasicPageForm editBasicSheet = new PublicationPropertyForm(itemModel,
|
||||
this);
|
||||
basicProperties.add(EDIT_SHEET_NAME, (String) PublicationGlobalizationUtil.
|
||||
globalize("publications.ui.publication.edit_basic_sheet").
|
||||
localize(), new WorkflowLockedComponentAccess(editBasicSheet,
|
||||
itemModel), editBasicSheet.
|
||||
getSaveCancelSection().getCancelButton());
|
||||
|
||||
basicProperties.setDisplayComponent(getPublicationPropertySheet(
|
||||
itemModel));
|
||||
|
||||
segmentedPanel.addSegment(new Label((String) PublicationGlobalizationUtil.
|
||||
globalize("publications.ui.publication.basic_properties").
|
||||
localize()), basicProperties);
|
||||
}
|
||||
|
||||
protected void addSteps(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
addStep(new PublicationAuthorsPropertyStep(itemModel, parent),
|
||||
"publications.ui.publication.authors");
|
||||
}
|
||||
|
||||
protected void addStep(SimpleEditStep step, String labelKey) {
|
||||
segmentedPanel.addSegment(
|
||||
new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
labelKey).localize()),
|
||||
step);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.bebop.FormData;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
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.TextArea;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.Publication;
|
||||
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class PublicationPropertyForm extends BasicPageForm implements
|
||||
FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
PublicationPropertyForm.class);
|
||||
private PublicationPropertiesStep m_step;
|
||||
public static final String ID = "Publication_edit";
|
||||
|
||||
public PublicationPropertyForm(ItemSelectionModel itemModel) {
|
||||
this(itemModel, null);
|
||||
}
|
||||
|
||||
public PublicationPropertyForm(ItemSelectionModel itemModel,
|
||||
PublicationPropertiesStep step) {
|
||||
super(ID, itemModel);
|
||||
m_step = step;
|
||||
addSubmissionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
super.addWidgets();
|
||||
|
||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.title").localize()));
|
||||
ParameterModel titleParam = new StringParameter(Publication.NAME);
|
||||
TextField title = new TextField(titleParam);
|
||||
add(title);
|
||||
|
||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.yearOfPublication").localize()));
|
||||
ParameterModel yearOfPublicationParam = new IntegerParameter(
|
||||
Publication.YEAR_OF_PUBLICATION);
|
||||
TextField yearOfPublication = new TextField(yearOfPublicationParam);
|
||||
yearOfPublication.setMaxLength(4);
|
||||
add(yearOfPublication);
|
||||
|
||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.abstract").localize()));
|
||||
ParameterModel abstractParam = new StringParameter(Publication.ABSTRACT);
|
||||
TextArea abstractArea = new TextArea(abstractParam);
|
||||
abstractArea.setCols(60);
|
||||
abstractArea.setRows(18);
|
||||
add(abstractArea);
|
||||
|
||||
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||
"publications.ui.publication.misc").localize()));
|
||||
ParameterModel miscParam = new StringParameter(Publication.ABSTRACT);
|
||||
TextArea misc = new TextArea(miscParam);
|
||||
misc.setCols(60);
|
||||
misc.setRows(18);
|
||||
add(misc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
Publication publication = (Publication) super.initBasicWidgets(fse);
|
||||
|
||||
data.put(Publication.NAME, publication.getTitle());
|
||||
data.put(Publication.YEAR_OF_PUBLICATION, publication.
|
||||
getYearOfPublication());
|
||||
data.put(Publication.ABSTRACT, publication.getAbstract());
|
||||
data.put(Publication.MISC, publication.getMisc());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
Publication publication = (Publication) super.processBasicWidgets(fse);
|
||||
|
||||
if((publication != null) && getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
|
||||
publication.setTitle((String) data.get(Publication.NAME));
|
||||
publication.setYearOfPublication((Integer) data.get(Publication.YEAR_OF_PUBLICATION));
|
||||
publication.setAbstract((String) data.get(Publication.ABSTRACT));
|
||||
publication.setMisc((String) data.get(Publication.MISC));
|
||||
|
||||
publication.save();
|
||||
}
|
||||
|
||||
if (m_step != null) {
|
||||
m_step.maybeForwardToNextStep(fse.getPageState());
|
||||
}
|
||||
}
|
||||
|
||||
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
||||
if ((m_step != null) && getSaveCancelSection().getCancelButton().
|
||||
isSelected(fse.getPageState())) {
|
||||
m_step.cancelStreamlinedCreation(fse.getPageState());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue