Fixed another wrong label

git-svn-id: https://svn.libreccm.org/ccm/trunk@2880 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-09-26 10:15:50 +00:00
parent 33a0ee169b
commit 18c47d2f9f
1 changed files with 71 additions and 68 deletions

View File

@ -18,6 +18,7 @@
*/ */
package com.arsdigita.cms.contenttypes.ui; package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.Completable;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink; import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
@ -50,8 +51,8 @@ import org.apache.log4j.Logger;
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class PublicationSeriesTable public class PublicationSeriesTable
extends Table extends Table
implements TableActionListener { implements TableActionListener {
private static final Logger LOGGER = Logger.getLogger(PublicationSeriesTable.class); private static final Logger LOGGER = Logger.getLogger(PublicationSeriesTable.class);
private final static String TABLE_COL_EDIT = "table_col_edit"; private final static String TABLE_COL_EDIT = "table_col_edit";
@ -63,27 +64,28 @@ public class PublicationSeriesTable
super(); super();
m_itemModel = itemModel; m_itemModel = itemModel;
setEmptyView(new Label(PublicationGlobalizationUtil.globalize("publications.ui.series.none"))); setEmptyView(
new Label(PublicationGlobalizationUtil.globalize("publications.ui.series.none")));
final TableColumnModel colModel = getColumnModel(); final TableColumnModel colModel = getColumnModel();
colModel.add(new TableColumn( colModel.add(new TableColumn(
0, 0,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.title")), "publications.ui.series.title")),
TABLE_COL_EDIT)); TABLE_COL_EDIT));
colModel.add(new TableColumn( colModel.add(new TableColumn(
1, 1,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.number")), "publications.ui.series.number")),
TABLE_COL_NUMBER)); TABLE_COL_NUMBER));
colModel.add(new TableColumn( colModel.add(new TableColumn(
2, 2,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.remove")), "publications.ui.series.remove")),
TABLE_COL_DEL)); TABLE_COL_DEL));
setModelBuilder( setModelBuilder(
new PublicationSeriesTableModelBuilder(itemModel)); new PublicationSeriesTableModelBuilder(itemModel));
colModel.get(0).setCellRenderer(new EditCellRenderer()); colModel.get(0).setCellRenderer(new EditCellRenderer());
colModel.get(1).setCellRenderer(new NumberCellRenderer()); colModel.get(1).setCellRenderer(new NumberCellRenderer());
@ -94,13 +96,13 @@ public class PublicationSeriesTable
} }
private class PublicationSeriesTableModelBuilder private class PublicationSeriesTableModelBuilder
extends LockableImpl extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private final ItemSelectionModel m_itemModel; private final ItemSelectionModel m_itemModel;
public PublicationSeriesTableModelBuilder( public PublicationSeriesTableModelBuilder(
ItemSelectionModel itemModel) { ItemSelectionModel itemModel) {
m_itemModel = itemModel; m_itemModel = itemModel;
} }
@ -108,7 +110,7 @@ public class PublicationSeriesTable
public TableModel makeModel(Table table, PageState state) { public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
Publication publication = (Publication) m_itemModel. Publication publication = (Publication) m_itemModel.
getSelectedObject(state); getSelectedObject(state);
return new PublicationSeriesTableModel(table, state, publication); return new PublicationSeriesTableModel(table, state, publication);
} }
@ -137,7 +139,7 @@ public class PublicationSeriesTable
boolean ret; boolean ret;
if ((m_seriesCollection != null) if ((m_seriesCollection != null)
&& m_seriesCollection.next()) { && m_seriesCollection.next()) {
m_series = m_seriesCollection.getSeries(); m_series = m_seriesCollection.getSeries();
ret = true; ret = true;
} else { } else {
@ -156,7 +158,7 @@ public class PublicationSeriesTable
return m_series.getTitle(); return m_series.getTitle();
case 2: case 2:
return new Label(PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.remove")); "publications.ui.series.remove"));
default: default:
return null; return null;
} }
@ -170,8 +172,8 @@ public class PublicationSeriesTable
} }
private class EditCellRenderer private class EditCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent(Table table, public Component getComponent(Table table,
@ -181,15 +183,14 @@ public class PublicationSeriesTable
Object key, Object key,
int row, int row,
int col) { int col) {
SecurityManager securityManager = SecurityManager securityManager = Utilities.getSecurityManager(state);
Utilities.getSecurityManager(state);
Publication publication = (Publication) m_itemModel. Publication publication = (Publication) m_itemModel.
getSelectedObject(state); getSelectedObject(state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.EDIT_ITEM, SecurityManager.EDIT_ITEM,
publication); publication);
if (canEdit) { if (canEdit) {
Series series; Series series;
@ -204,14 +205,13 @@ public class PublicationSeriesTable
ContentSection section = series.getContentSection();//CMS.getContext().getContentSection(); ContentSection section = series.getContentSection();//CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver(); ItemResolver resolver = section.getItemResolver();
Link link = Link link = new Link(String.format("%s (%s)",
new Link(String.format("%s (%s)", value.toString(),
value.toString(), series.getLanguage()),
series.getLanguage()), resolver.generateItemURL(state,
resolver.generateItemURL(state, series,
series, section,
section, series.getVersion()));
series.getVersion()));
return link; return link;
} else { } else {
@ -231,6 +231,7 @@ public class PublicationSeriesTable
return label; return label;
} }
} }
} }
private class NumberCellRenderer extends LockableImpl implements TableCellRenderer { private class NumberCellRenderer extends LockableImpl implements TableCellRenderer {
@ -249,7 +250,7 @@ public class PublicationSeriesTable
final SeriesCollection seriesCol = publication.getSeries(); final SeriesCollection seriesCol = publication.getSeries();
String volumeOfSeries = null; String volumeOfSeries = null;
while(seriesCol.next()) { while (seriesCol.next()) {
if (seriesId.equals(seriesCol.getSeries().getID())) { if (seriesId.equals(seriesCol.getSeries().getID())) {
volumeOfSeries = seriesCol.getVolumeOfSeries(); volumeOfSeries = seriesCol.getVolumeOfSeries();
break; break;
@ -267,8 +268,8 @@ public class PublicationSeriesTable
} }
private class DeleteCellRenderer private class DeleteCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent(Table table, public Component getComponent(Table table,
@ -278,24 +279,27 @@ public class PublicationSeriesTable
Object key, Object key,
int row, int row,
int col) { int col) {
SecurityManager securityManager = SecurityManager securityManager = Utilities.getSecurityManager(state);
Utilities.getSecurityManager(state);
Publication publication = (Publication) m_itemModel. Publication publication = (Publication) m_itemModel.
getSelectedObject(state); getSelectedObject(state);
boolean canDelete = securityManager.canAccess( boolean canDelete = securityManager.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.DELETE_ITEM, SecurityManager.DELETE_ITEM,
publication); publication);
if (canDelete) { if (canDelete) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink(value.toString());
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.series.confirm_remove")); "publications.ui.series.confirm_remove"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); if (value instanceof Component) {
return label; return (Component) value;
} else {
final Label label = new Label(value.toString());
return label;
}
} }
} }
@ -307,12 +311,11 @@ public class PublicationSeriesTable
LOGGER.info("cellSelected!"); LOGGER.info("cellSelected!");
Series series = Series series = new Series(new BigDecimal(event.getRowKey().
new Series(new BigDecimal(event.getRowKey(). toString()));
toString()));
Publication publication = (Publication) m_itemModel.getSelectedObject( Publication publication = (Publication) m_itemModel.getSelectedObject(
state); state);
SeriesCollection seriesCollection = publication.getSeries(); SeriesCollection seriesCollection = publication.getSeries();