Naechster Satz von UI Klassen fuer das Publikationen-Modul.
git-svn-id: https://svn.libreccm.org/ccm/trunk@512 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
92e63ef562
commit
80791e4adf
|
|
@ -30,7 +30,7 @@ import java.math.BigDecimal;
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
*/
|
*/
|
||||||
public abstract class Publication extends ContentPage {
|
public class Publication extends ContentPage {
|
||||||
|
|
||||||
public final static String YEAR_OF_PUBLICATION = "yearOfPublication";
|
public final static String YEAR_OF_PUBLICATION = "yearOfPublication";
|
||||||
public final static String ABSTRACT = "abstract";
|
public final static String ABSTRACT = "abstract";
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,7 @@ public class VolumeInSeriesCollection extends DomainCollection {
|
||||||
*
|
*
|
||||||
* @return The current data object.
|
* @return The current data object.
|
||||||
*/
|
*/
|
||||||
public DataObject getPublication() {
|
public Publication getPublication() {
|
||||||
return m_dataCollection.getDataObject();
|
return new Publication(m_dataCollection.getDataObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ public class PublicationAuthorsPropertyStep extends SimpleEditStep {
|
||||||
private static final String ADD_AUTHOR_SHEET_NAME = "addAuthor";
|
private static final String ADD_AUTHOR_SHEET_NAME = "addAuthor";
|
||||||
|
|
||||||
public PublicationAuthorsPropertyStep(
|
public PublicationAuthorsPropertyStep(
|
||||||
ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
this(itemModel, parent, null);
|
this(itemModel, parent, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ public class PublicationAuthorsTable
|
||||||
Logger.getLogger(PublicationAuthorsTable.class);
|
Logger.getLogger(PublicationAuthorsTable.class);
|
||||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
private final String TABLE_COL_DEL = "table_col_del";
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
private final static String TABLE_COL_UP = "table_col_up";
|
private final String TABLE_COL_UP = "table_col_up";
|
||||||
private final static String TABLE_COL_DOWN = "table_col_down";
|
private final String TABLE_COL_DOWN = "table_col_down";
|
||||||
private ItemSelectionModel m_itemModel;
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
public PublicationAuthorsTable(ItemSelectionModel itemModel) {
|
public PublicationAuthorsTable(ItemSelectionModel itemModel) {
|
||||||
|
|
@ -115,10 +115,12 @@ public class PublicationAuthorsTable
|
||||||
m_authorshipCollection = publication.getAuthors();
|
m_authorshipCollection = publication.getAuthors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return m_table.getColumnModel().size();
|
return m_table.getColumnModel().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean nextRow() {
|
public boolean nextRow() {
|
||||||
boolean ret;
|
boolean ret;
|
||||||
|
|
||||||
|
|
@ -133,6 +135,7 @@ public class PublicationAuthorsTable
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object getElementAt(int columnIndex) {
|
public Object getElementAt(int columnIndex) {
|
||||||
switch (columnIndex) {
|
switch (columnIndex) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,11 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* @author Jens Pelzetter
|
* @author Jens Pelzetter
|
||||||
*/
|
*/
|
||||||
public class PublicationPropertyForm extends BasicPageForm implements
|
public class PublicationPropertyForm
|
||||||
FormProcessListener, FormInitListener, FormSubmissionListener {
|
extends BasicPageForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(
|
private static final Logger s_log = Logger.getLogger(
|
||||||
PublicationPropertyForm.class);
|
PublicationPropertyForm.class);
|
||||||
|
|
@ -92,9 +95,11 @@ public class PublicationPropertyForm extends BasicPageForm implements
|
||||||
FormData data = fse.getFormData();
|
FormData data = fse.getFormData();
|
||||||
Publication publication = (Publication) super.processBasicWidgets(fse);
|
Publication publication = (Publication) super.processBasicWidgets(fse);
|
||||||
|
|
||||||
if((publication != null) && getSaveCancelSection().getSaveButton().isSelected(fse.getPageState())) {
|
if ((publication != null) && getSaveCancelSection().getSaveButton().
|
||||||
|
isSelected(fse.getPageState())) {
|
||||||
publication.setTitle((String) data.get(Publication.NAME));
|
publication.setTitle((String) data.get(Publication.NAME));
|
||||||
publication.setYearOfPublication((Integer) data.get(Publication.YEAR_OF_PUBLICATION));
|
publication.setYearOfPublication((Integer) data.get(
|
||||||
|
Publication.YEAR_OF_PUBLICATION));
|
||||||
publication.setAbstract((String) data.get(Publication.ABSTRACT));
|
publication.setAbstract((String) data.get(Publication.ABSTRACT));
|
||||||
publication.setMisc((String) data.get(Publication.MISC));
|
publication.setMisc((String) data.get(Publication.MISC));
|
||||||
|
|
||||||
|
|
@ -106,6 +111,7 @@ public class PublicationPropertyForm extends BasicPageForm implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
||||||
if ((m_step != null) && getSaveCancelSection().getCancelButton().
|
if ((m_step != null) && getSaveCancelSection().getCancelButton().
|
||||||
isSelected(fse.getPageState())) {
|
isSelected(fse.getPageState())) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
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.parameters.DateParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.EditshipCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
|
import com.arsdigita.cms.contenttypes.Series;
|
||||||
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class SeriesEditshipAddForm extends BasicItemForm {
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(SeriesEditshipAddForm.class);
|
||||||
|
private SeriesPropertiesStep m_step;
|
||||||
|
private ItemSearchWidget m_itemSearch;
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
private final String ITEM_SEARCH = "editors";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public SeriesEditshipAddForm(ItemSelectionModel itemModel) {
|
||||||
|
super("EditorsEntryForm", itemModel);
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editorship.selectEditors").localize()));
|
||||||
|
m_itemSearch = new ItemSearchWidget(
|
||||||
|
ITEM_SEARCH,
|
||||||
|
ContentType.findByAssociatedObjectType(GenericPerson.class.
|
||||||
|
getName()));
|
||||||
|
add(m_itemSearch);
|
||||||
|
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editorship.from").localize()));
|
||||||
|
ParameterModel fromParam = new DateParameter(EditshipCollection.FROM);
|
||||||
|
com.arsdigita.bebop.form.Date from = new com.arsdigita.bebop.form.Date(
|
||||||
|
fromParam);
|
||||||
|
Calendar today = new GregorianCalendar();
|
||||||
|
from.setYearRange(1900, today.get(Calendar.YEAR));
|
||||||
|
add(from);
|
||||||
|
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editorship.to").localize()));
|
||||||
|
ParameterModel toParam = new DateParameter(EditshipCollection.TO);
|
||||||
|
com.arsdigita.bebop.form.Date to = new com.arsdigita.bebop.form.Date(
|
||||||
|
toParam);
|
||||||
|
to.setYearRange(1900, today.get(Calendar.YEAR));
|
||||||
|
add(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
Series series =
|
||||||
|
(Series) getItemSelectionModel().getSelectedObject(state);
|
||||||
|
|
||||||
|
if (!(this.getSaveCancelSection().
|
||||||
|
getCancelButton().isSelected(state))) {
|
||||||
|
series.addEditor((GenericPerson) data.get(ITEM_SEARCH),
|
||||||
|
(Date) data.get(EditshipCollection.FROM),
|
||||||
|
(Date) data.get(EditshipCollection.TO));
|
||||||
|
}
|
||||||
|
|
||||||
|
init(fse);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.authoring.WorkflowLockedComponentAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class SeriesEditshipStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String ADD_EDITOR_SHEET_NAME = "addEditor";
|
||||||
|
|
||||||
|
public SeriesEditshipStep(
|
||||||
|
ItemSelectionModel itemModel, AuthoringKitWizard parent) {
|
||||||
|
this(itemModel, parent, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeriesEditshipStep(
|
||||||
|
ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent,
|
||||||
|
String prefix) {
|
||||||
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
|
BasicItemForm addEditorSheet = new SeriesEditshipAddForm(itemModel);
|
||||||
|
add(ADD_EDITOR_SHEET_NAME,
|
||||||
|
(String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.add_editship").localize(),
|
||||||
|
new WorkflowLockedComponentAccess(addEditorSheet, itemModel),
|
||||||
|
addEditorSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
SeriesEditshipTable editorsTable = new SeriesEditshipTable(itemModel);
|
||||||
|
setDisplayComponent(editorsTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,317 @@
|
||||||
|
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.EditshipCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.GenericPerson;
|
||||||
|
import com.arsdigita.cms.contenttypes.Series;
|
||||||
|
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 SeriesEditshipTable extends Table implements TableActionListener {
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(SeriesEditshipTable.class);
|
||||||
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
//private final String TABLE_COL_UP = "table_col_up";
|
||||||
|
//private final String TABLE_COL_DOWN = "table_col_down";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public SeriesEditshipTable(ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(
|
||||||
|
new Label(PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editship.none")));
|
||||||
|
|
||||||
|
TableColumnModel colModel = getColumnModel();
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
0,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editship.name").localize(),
|
||||||
|
TABLE_COL_EDIT));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
1,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editship.from").localize()));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
2,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editship.to").localize()));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
3,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editship.remove").localize(),
|
||||||
|
TABLE_COL_DEL));
|
||||||
|
/* Just in the case someone want's to sort editships manually..." */
|
||||||
|
/* colModel.add(new TableColumn(
|
||||||
|
4,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.edithship.up").localize(),
|
||||||
|
TABLE_COL_UP));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
5,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editship.down").localize(),
|
||||||
|
TABLE_COL_DOWN));*/
|
||||||
|
|
||||||
|
setModelBuilder(new SeriesEditshipTableModelBuilder(itemModel));
|
||||||
|
|
||||||
|
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
colModel.get(3).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
//colModel.get(4).setCellRenderer(new UpCellRenderer());
|
||||||
|
//colModel.get(5).setCellRenderer(new DownCellRenderer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SeriesEditshipTableModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public SeriesEditshipTableModelBuilder(
|
||||||
|
ItemSelectionModel itemModel) {
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
Series series =
|
||||||
|
(Series) m_itemModel.getSelectedObject(state);
|
||||||
|
return new SeriesEditshipTableModel(table, state, series);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SeriesEditshipTableModel implements TableModel {
|
||||||
|
|
||||||
|
private final int MAX_DESC_LENGTH = 25;
|
||||||
|
private Table m_table;
|
||||||
|
private EditshipCollection m_editshipCollection;
|
||||||
|
private GenericPerson m_editor;
|
||||||
|
|
||||||
|
private SeriesEditshipTableModel(
|
||||||
|
Table table,
|
||||||
|
PageState state,
|
||||||
|
Series series) {
|
||||||
|
m_table = table;
|
||||||
|
m_editshipCollection = series.getEditors();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return m_table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if ((m_editshipCollection != null) && m_editshipCollection.next()) {
|
||||||
|
m_editor = m_editshipCollection.getEditor();
|
||||||
|
ret = true;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return m_editor.getFullName();
|
||||||
|
case 1:
|
||||||
|
return m_editshipCollection.getFrom();
|
||||||
|
case 2:
|
||||||
|
return m_editshipCollection.getTo();
|
||||||
|
case 3:
|
||||||
|
return PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.editship.remove").
|
||||||
|
localize();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_editor.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);
|
||||||
|
Series series = (Series) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canEdit = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.EDIT_ITEM,
|
||||||
|
series);
|
||||||
|
|
||||||
|
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);
|
||||||
|
Series series = (Series) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canDelete = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.DELETE_ITEM,
|
||||||
|
series);
|
||||||
|
|
||||||
|
if (canDelete) {
|
||||||
|
ControlLink link = new ControlLink(value.toString());
|
||||||
|
link.setConfirmation((String) PublicationGlobalizationUtil.
|
||||||
|
globalize("publications.ui.editship.remove.confirm").
|
||||||
|
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) {
|
||||||
|
|
||||||
|
Series = (Series) m_itemModel.
|
||||||
|
getSelectedObject(state);
|
||||||
|
EditshipCollection editors = series.getEditors();
|
||||||
|
|
||||||
|
if ((editors.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 editor =
|
||||||
|
new GenericPerson(new BigDecimal(event.getRowKey().toString()));
|
||||||
|
|
||||||
|
Series series = (Series) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
//EditshipCollection editors = series.getEditors();
|
||||||
|
|
||||||
|
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||||
|
|
||||||
|
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||||
|
|
||||||
|
} else if(TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||||
|
series.removeEditor(editor);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
else if(TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
|
||||||
|
editors.swapWithPrevious(editor);
|
||||||
|
} else if(TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) {
|
||||||
|
authors.swapWithNext(editor);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(TableActionEvent event) {
|
||||||
|
//Nothing to do here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,112 @@
|
||||||
|
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.contenttypes.Series;
|
||||||
|
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||||
|
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.authoring.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class SeriesPropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
public static final String EDIT_SHEET_NAME = "edit";
|
||||||
|
private SegmentedPanel segmentedPanel;
|
||||||
|
|
||||||
|
public SeriesPropertiesStep(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 getSeriesPropertySheet(
|
||||||
|
ItemSelectionModel itemModel) {
|
||||||
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(
|
||||||
|
itemModel);
|
||||||
|
|
||||||
|
sheet.add(PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.title"),
|
||||||
|
Series.NAME);
|
||||||
|
|
||||||
|
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 SeriesPropertyForm(itemModel, this);
|
||||||
|
|
||||||
|
basicProperties.add(
|
||||||
|
EDIT_SHEET_NAME,
|
||||||
|
(String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.edit_basic_sheet").localize(),
|
||||||
|
new WorkflowLockedComponentAccess(editBasicSheet,
|
||||||
|
itemModel),
|
||||||
|
editBasicSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
basicProperties.setDisplayComponent(getSeriesPropertySheet(itemModel));
|
||||||
|
|
||||||
|
segmentedPanel.addSegment(new Label((String) PublicationGlobalizationUtil.
|
||||||
|
globalize("publications.ui.series.basic_properties").localize()),
|
||||||
|
basicProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addSteps(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
addStep(new SeriesEditshipStep(itemModel, parent),
|
||||||
|
"publications.ui.series.editors");
|
||||||
|
addStep(new SeriesVolumesStep(itemModel, parent),
|
||||||
|
"publications.ui.series.volumes");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addStep(SimpleEditStep step, String labelKey) {
|
||||||
|
segmentedPanel.addSegment(
|
||||||
|
new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
labelKey).localize()),
|
||||||
|
step);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
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.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.Series;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class SeriesPropertyForm
|
||||||
|
extends BasicPageForm
|
||||||
|
implements FormProcessListener,
|
||||||
|
FormInitListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(SeriesPropertyForm.class);
|
||||||
|
private SeriesPropertiesStep m_step;
|
||||||
|
public static final String ID = "Series_edit";
|
||||||
|
|
||||||
|
public SeriesPropertyForm(ItemSelectionModel itemModel) {
|
||||||
|
this(itemModel, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeriesPropertyForm(ItemSelectionModel itemModel,
|
||||||
|
SeriesPropertiesStep step) {
|
||||||
|
super(ID, itemModel);
|
||||||
|
m_step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.title").localize()));
|
||||||
|
ParameterModel titleParam = new StringParameter(Series.NAME);
|
||||||
|
TextField title = new TextField(titleParam);
|
||||||
|
add(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
Series series = (Series) super.initBasicWidgets(fse);
|
||||||
|
|
||||||
|
data.put(Series.NAME, series.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
Series series = (Series) super.processBasicWidgets(fse);
|
||||||
|
|
||||||
|
if ((series != null) && getSaveCancelSection().getSaveButton().
|
||||||
|
isSelected(fse.getPageState())) {
|
||||||
|
series.setTitle((String) data.get(Series.NAME));
|
||||||
|
|
||||||
|
series.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_step != null) {
|
||||||
|
m_step.maybeForwardToNextStep(fse.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void submitted(FormSectionEvent fse) throws FormProcessException {
|
||||||
|
if ((m_step != null) && getSaveCancelSection().getCancelButton().
|
||||||
|
isSelected(fse.getPageState())) {
|
||||||
|
m_step.cancelStreamlinedCreation(fse.getPageState());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,84 @@
|
||||||
|
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.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.IntegerParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterModel;
|
||||||
|
import com.arsdigita.cms.ContentType;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.contenttypes.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.Series;
|
||||||
|
import com.arsdigita.cms.contenttypes.VolumeInSeriesCollection;
|
||||||
|
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jens Pelzetter
|
||||||
|
*/
|
||||||
|
public class SeriesVolumeAddForm extends BasicItemForm {
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
SeriesVolumeAddForm.class);
|
||||||
|
private SeriesPropertiesStep m_step;
|
||||||
|
private ItemSearchWidget m_itemSearch;
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
private final String ITEM_SEARCH = "volumes";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public SeriesVolumeAddForm(ItemSelectionModel itemModel) {
|
||||||
|
super("VolumesEntryForm", itemModel);
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.volumes.select_publication").
|
||||||
|
localize()));
|
||||||
|
m_itemSearch = new ItemSearchWidget(
|
||||||
|
ITEM_SEARCH,
|
||||||
|
ContentType.findByAssociatedObjectType(
|
||||||
|
Publication.class.getName()));
|
||||||
|
add(m_itemSearch);
|
||||||
|
|
||||||
|
add(new Label((String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.volume_of_series").localize()));
|
||||||
|
ParameterModel volumeOfSeriesParam = new IntegerParameter(
|
||||||
|
VolumeInSeriesCollection.VOLUME_OF_SERIES);
|
||||||
|
TextField volumeOfSeries = new TextField(volumeOfSeriesParam);
|
||||||
|
add(volumeOfSeries);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
Series series = (Series) getItemSelectionModel().
|
||||||
|
getSelectedObject(state);
|
||||||
|
|
||||||
|
if (!(this.getSaveCancelSection().getCancelButton().
|
||||||
|
isSelected(state))) {
|
||||||
|
series.addVolume(
|
||||||
|
(Publication) data.get(ITEM_SEARCH),
|
||||||
|
(Integer) data.get(
|
||||||
|
VolumeInSeriesCollection.VOLUME_OF_SERIES));
|
||||||
|
}
|
||||||
|
|
||||||
|
init(fse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
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 SeriesVolumesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
private static final String ADD_VOLUME_SHEET_NAME = "addVolume";
|
||||||
|
|
||||||
|
public SeriesVolumesStep(
|
||||||
|
ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
this(itemModel, parent, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SeriesVolumesStep(
|
||||||
|
ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent,
|
||||||
|
String prefix) {
|
||||||
|
super(itemModel, parent, prefix);
|
||||||
|
|
||||||
|
BasicItemForm addVolumeSheet =
|
||||||
|
new SeriesVolumeAddForm(itemModel);
|
||||||
|
add(ADD_VOLUME_SHEET_NAME,
|
||||||
|
(String) PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.add_volume").localize(),
|
||||||
|
new WorkflowLockedComponentAccess(addVolumeSheet, itemModel),
|
||||||
|
addVolumeSheet.getSaveCancelSection().getCancelButton());
|
||||||
|
|
||||||
|
SeriesVolumesTable volumesTable = new SeriesVolumesTable(
|
||||||
|
itemModel);
|
||||||
|
setDisplayComponent(volumesTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,231 @@
|
||||||
|
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.Publication;
|
||||||
|
import com.arsdigita.cms.contenttypes.Series;
|
||||||
|
import com.arsdigita.cms.contenttypes.VolumeInSeriesCollection;
|
||||||
|
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 SeriesVolumesTable extends Table implements TableActionListener {
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(SeriesVolumesTable.class);
|
||||||
|
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||||
|
private final String TABLE_COL_DEL = "table_col_del";
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public SeriesVolumesTable(ItemSelectionModel itemModel) {
|
||||||
|
super();
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
|
||||||
|
setEmptyView(
|
||||||
|
new Label(PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.volumes.none")));
|
||||||
|
|
||||||
|
TableColumnModel colModel = getColumnModel();
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
0,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.volumes.name").localize(),
|
||||||
|
TABLE_COL_EDIT));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
1,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.volumes.volumeOfSeries").localize()));
|
||||||
|
colModel.add(new TableColumn(
|
||||||
|
2,
|
||||||
|
PublicationGlobalizationUtil.globalize(
|
||||||
|
"publications.ui.series.volumes.remove").localize(),
|
||||||
|
TABLE_COL_DEL));
|
||||||
|
|
||||||
|
setModelBuilder(new SeriesVolumesTableModelBuilder(itemModel));
|
||||||
|
|
||||||
|
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||||
|
colModel.get(2).setCellRenderer(new DeleteCellRenderer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SeriesVolumesTableModelBuilder
|
||||||
|
extends LockableImpl
|
||||||
|
implements TableModelBuilder {
|
||||||
|
|
||||||
|
private ItemSelectionModel m_itemModel;
|
||||||
|
|
||||||
|
public SeriesVolumesTableModelBuilder(
|
||||||
|
ItemSelectionModel itemModel) {
|
||||||
|
m_itemModel = itemModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
Series series =
|
||||||
|
(Series) m_itemModel.getSelectedObject(state);
|
||||||
|
return new SeriesVolumesTableModel(table, state, series);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SeriesVolumesTableModel implements TableModel {
|
||||||
|
|
||||||
|
private final int MAX_DESC_LENGTH = 25;
|
||||||
|
private Table m_table;
|
||||||
|
private VolumeInSeriesCollection m_volumesCollection;
|
||||||
|
private Publication m_publication;
|
||||||
|
|
||||||
|
private SeriesVolumesTableModel(
|
||||||
|
Table table,
|
||||||
|
PageState state,
|
||||||
|
Series series) {
|
||||||
|
m_table = table;
|
||||||
|
m_volumesCollection = series.getVolumes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return m_table.getColumnModel().size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean nextRow() {
|
||||||
|
boolean ret;
|
||||||
|
|
||||||
|
if ((m_volumesCollection != null) && m_volumesCollection.next()) {
|
||||||
|
m_publication = m_volumesCollection.getPublication();
|
||||||
|
ret = true;
|
||||||
|
} else {
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return m_publication.getTitle();
|
||||||
|
case 1:
|
||||||
|
return m_volumesCollection.getVolumeOfSeries();
|
||||||
|
case 2:
|
||||||
|
return PublicationGlobalizationUtil.globalize(
|
||||||
|
"publication.ui.series.volumes.remove").localize();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_publication.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);
|
||||||
|
Series series = (Series) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canEdit = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.EDIT_ITEM,
|
||||||
|
series);
|
||||||
|
|
||||||
|
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);
|
||||||
|
Series series = (Series) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean canDelete = securityManager.canAccess(
|
||||||
|
state.getRequest(),
|
||||||
|
SecurityManager.DELETE_ITEM,
|
||||||
|
series);
|
||||||
|
|
||||||
|
if (canDelete) {
|
||||||
|
ControlLink link = new ControlLink(value.toString());
|
||||||
|
link.setConfirmation((String) PublicationGlobalizationUtil.
|
||||||
|
globalize("publications.ui.volumes.remove.confirm").
|
||||||
|
localize());
|
||||||
|
return link;
|
||||||
|
} else {
|
||||||
|
Label label = new Label(value.toString());
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cellSelected(TableActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
Publication publication =
|
||||||
|
new Publication(new BigDecimal(event.getRowKey().
|
||||||
|
toString()));
|
||||||
|
|
||||||
|
Series series = (Series) m_itemModel.getSelectedObject(state);
|
||||||
|
|
||||||
|
//VolumeInSeriesCollection volumes = series.getVolumes();
|
||||||
|
|
||||||
|
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||||
|
|
||||||
|
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
|
||||||
|
} else if (TABLE_COL_DEL.equals(column.getHeaderKey().toString())) {
|
||||||
|
series.removeVolume(publication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void headSelected(TableActionEvent event) {
|
||||||
|
//Nothing to do.
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue