Enhancements for localisation in several authoring step

git-svn-id: https://svn.libreccm.org/ccm/trunk@2763 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-07-17 13:47:03 +00:00
parent 4cdc5b3cd5
commit bca01fc9ee
32 changed files with 890 additions and 975 deletions

View File

@ -39,9 +39,9 @@ import javax.imageio.ImageIO;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* <p>An {@link com.arsdigita.cms.Asset asset} representing an image. An * <p>
* ImageAsset is deleted when its parent content item is deleted and is not * An {@link com.arsdigita.cms.Asset asset} representing an image. An ImageAsset is deleted when its
* intended to be reused between content items..</p> * parent content item is deleted and is not intended to be reused between content items..</p>
* *
* @see com.arsdigita.cms.ReusableImageAsset * @see com.arsdigita.cms.ReusableImageAsset
* @see com.arsdigita.cms.BinaryAsset * @see com.arsdigita.cms.BinaryAsset
@ -54,276 +54,277 @@ import org.apache.log4j.Logger;
*/ */
public class ImageAsset extends BinaryAsset { public class ImageAsset extends BinaryAsset {
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.ImageAsset";
"com.arsdigita.cms.ImageAsset"; public static final String CONTENT = "content";
public static final String CONTENT = "content"; public static final String HEIGHT = "height";
public static final String HEIGHT = "height"; public static final String WIDTH = "width";
public static final String WIDTH = "width"; public static final String MIME_JPEG = "image/jpeg";
public static final String MIME_JPEG = "image/jpeg"; public static final String MIME_GIF = "image/gif";
public static final String MIME_GIF = "image/gif"; private static final Logger s_log = Logger.getLogger(ImageAsset.class);
private static final Logger s_log = Logger.getLogger(ImageAsset.class);
/** /**
* Default constructor. This creates a new image asset. * Default constructor. This creates a new image asset.
*/ */
public ImageAsset() { public ImageAsset() {
super(BASE_DATA_OBJECT_TYPE); super(BASE_DATA_OBJECT_TYPE);
} }
/** /**
* Constructor. The contained * Constructor. The contained <code>DataObject</code> is retrieved from the persistent storage
* <code>DataObject</code> is retrieved from the persistent storage * mechanism with an <code>OID</code> specified by <i>oid</i>.
* mechanism with an *
* <code>OID</code> specified by <i>oid</i>. * @param oid The <code>OID</code> for the retrieved <code>DataObject</code>.
* */
* @param oid The <code>OID</code> for the retrieved public ImageAsset(OID oid) throws DataObjectNotFoundException {
* <code>DataObject</code>. super(oid);
*/ }
public ImageAsset(OID oid) throws DataObjectNotFoundException {
super(oid);
}
/** /**
* Constructor. The contained * Constructor. The contained <code>DataObject</code> is retrieved from the persistent storage
* <code>DataObject</code> is retrieved from the persistent storage * mechanism with an <code>OID</code> specified by <i>id</i> and
* mechanism with an * <code>ImageAsset.BASE_DATA_OBJECT_TYPE</code>.
* <code>OID</code> specified by <i>id</i> and *
* <code>ImageAsset.BASE_DATA_OBJECT_TYPE</code>. * @param id The <code>id</code> for the retrieved <code>DataObject</code>.
* *
* @param id The <code>id</code> for the retrieved <code>DataObject</code>. */
* public ImageAsset(BigDecimal id) throws DataObjectNotFoundException {
*/ this(new OID(BASE_DATA_OBJECT_TYPE, id));
public ImageAsset(BigDecimal id) throws DataObjectNotFoundException { }
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
public ImageAsset(DataObject obj) { public ImageAsset(DataObject obj) {
super(obj); super(obj);
} }
public ImageAsset(String type) { public ImageAsset(String type) {
super(type); super(type);
} }
/** /**
* @return the base PDL object type for this item. Child classes should * @return the base PDL object type for this item. Child classes should override this method to
* override this method to return the correct value * return the correct value
*/ */
@Override @Override
public String getBaseDataObjectType() { public String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE; return BASE_DATA_OBJECT_TYPE;
} }
public BigDecimal getWidth() { public BigDecimal getWidth() {
return (BigDecimal) get(WIDTH); return (BigDecimal) get(WIDTH);
} }
public void setWidth(BigDecimal width) { public void setWidth(BigDecimal width) {
set(WIDTH, width); set(WIDTH, width);
} }
public BigDecimal getHeight() { public BigDecimal getHeight() {
return (BigDecimal) get(HEIGHT); return (BigDecimal) get(HEIGHT);
} }
public void setHeight(BigDecimal height) { public void setHeight(BigDecimal height) {
set(HEIGHT, height); set(HEIGHT, height);
} }
/** /**
* Retrieves the Blob content. * Retrieves the Blob content.
* *
* @return the Blob content * @return the Blob content
*/ */
@Override @Override
protected byte[] getContent() { protected byte[] getContent() {
return (byte[]) get(CONTENT); return (byte[]) get(CONTENT);
} }
/** /**
* Sets the Blob content. * Sets the Blob content.
*/ */
@Override @Override
protected void setContent(byte[] content) { protected void setContent(byte[] content) {
set(CONTENT, content); set(CONTENT, content);
} }
/** /**
* Load the image asset from the specified file. Automatically guesses the * Load the image asset from the specified file. Automatically guesses the mime type of the
* mime type of the file. If the file is a jpeg, tries to automatically * file. If the file is a jpeg, tries to automatically determine width and height, as well.
* determine width and height, as well. *
* * @param fileName The original name of the file
* @param fileName The original name of the file * @param file The actual file on the server
* @param file The actual file on the server * @param defaultMimeType The default mime type for the file (ignored)
* @param defaultMimeType The default mime type for the file (ignored) */
*/ public void loadFromFile(String fileName, File file, String defaultMimeType)
public void loadFromFile(String fileName, File file, String defaultMimeType) throws IOException, IllegalArgumentException {
throws IOException, IllegalArgumentException {
BufferedImage image; BufferedImage image;
if (file == null) { if (file == null) {
throw new IllegalArgumentException("Parameter file must not be null."); throw new IllegalArgumentException("Parameter file must not be null.");
} }
try { try {
image = ImageIO.read(file); image = ImageIO.read(file);
} catch (IOException ex) { } catch (IOException ex) {
throw new IOException("Can't read image format."); throw new IOException("Can't read image format.");
} }
// Guess mime type // Guess mime type
MimeType mime = MimeType.guessMimeTypeFromFile(fileName); MimeType mime = MimeType.guessMimeTypeFromFile(fileName);
if (mime == null && !(mime instanceof ImageMimeType)) { if (mime == null && !(mime instanceof ImageMimeType)) {
throw new IOException("Unsupported image format."); throw new IOException("Unsupported image format.");
} }
setMimeType(mime); setMimeType(mime);
// Image size // Image size
readImageSize(image); readImageSize(image);
// Extract filename // Extract filename
setName(extractFilename(fileName)); setName(extractFilename(fileName));
// Create InputStream // Create InputStream
FileInputStream in = new FileInputStream(file); FileInputStream in = new FileInputStream(file);
// Save image data // Save image data
readBytes(in); readBytes(in);
} }
/** /**
* Write the image asset content to a file. * Write the image asset content to a file.
* *
* @param file The file on the server to write to. * @param file The file on the server to write to.
*/ */
@Override @Override
public void writeToFile(File file) public void writeToFile(File file)
throws IOException { throws IOException {
FileOutputStream fs = new FileOutputStream(file); FileOutputStream fs = new FileOutputStream(file);
try { try {
fs.write(getContent()); fs.write(getContent());
} finally { } finally {
if (null != fs) { if (null != fs) {
fs.close(); fs.close();
} }
} }
} }
/** /**
* Retrieve all images in the database. Extremely expensive ! * Retrieve all images in the database. Extremely expensive !
* *
* @return a collection of ImageAssets * @return a collection of ImageAssets
*/ */
public static ImageAssetCollection getAllImages() { public static ImageAssetCollection getAllImages() {
DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE); DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
da.addEqualsFilter(VersionedACSObject.IS_DELETED, new Integer(0)); da.addEqualsFilter(VersionedACSObject.IS_DELETED, new Integer(0));
return new ImageAssetCollection(da); return new ImageAssetCollection(da);
} }
/** /**
* Find all images whose name matches the specified keyword * Find all images whose name matches the specified keyword
* *
* @param keyword a String keyword * @param keyword a String keyword
* @param context the context for the retrieved items. Should be * @param context the context for the retrieved items. Should be {@link ContentItem#DRAFT} or
* {@link ContentItem#DRAFT} or {@link ContentItem#LIVE} * {@link ContentItem#LIVE}
* @return a collection of images whose name matches the keyword *
*/ * @return a collection of images whose name matches the keyword
public static ImageAssetCollection getImagesByKeyword( */
String keyword, String context) { public static ImageAssetCollection getImagesByKeyword(
ImageAssetCollection c = getAllImages(); String keyword, String context) {
c.addOrder(Asset.NAME); ImageAssetCollection c = getAllImages();
Filter f; c.addOrder(Asset.NAME);
f = c.addFilter("name like (\'%\' || :keyword || \'%\')"); Filter f;
f.set("keyword", keyword); f = c.addFilter("name like (\'%\' || :keyword || \'%\')");
f = c.addFilter("version = :version"); f.set("keyword", keyword);
f.set("version", context); f = c.addFilter("version = :version");
return c; f.set("version", context);
} return c;
}
/** /**
* Find all images whose name matches the specified keyword * Find all images whose name matches the specified keyword
* *
* @param keyword a String keyword * @param keyword a String keyword
* @return a collection of images whose name matches the keyword *
*/ * @return a collection of images whose name matches the keyword
public static ImageAssetCollection getImagesByKeyword(String keyword) { */
return getImagesByKeyword(keyword, ContentItem.DRAFT); public static ImageAssetCollection getImagesByKeyword(String keyword) {
} return getImagesByKeyword(keyword, ContentItem.DRAFT);
}
/** /**
* Resize this ImageAsset proportional to maxThumbnailWidth, if this * Resize this ImageAsset proportional to maxThumbnailWidth, if this ImageAsset is wider then
* ImageAsset is wider then maxThumbnailWidth. Else just return this * maxThumbnailWidth. Else just return this ImageAsset.
* ImageAsset. *
* * @param maxThumbnailWidth max image width
* @param maxThumbnailWidth max image width *
* @return * @return
*/ */
public ImageAsset proportionalResizeToWidth(int maxThumbnailWidth) { public ImageAsset proportionalResizeToWidth(int maxThumbnailWidth) {
if (this.getWidth().intValue() <= maxThumbnailWidth) { if (this.getWidth().intValue() <= maxThumbnailWidth) {
return this; return this;
} else { } else {
ImageAsset imageAsset = new ImageAsset(); ImageAsset imageAsset = new ImageAsset();
imageAsset.setMimeType(this.getMimeType()); imageAsset.setMimeType(this.getMimeType());
imageAsset.setName("Scaled" + this.getName()); imageAsset.setName("Scaled" + this.getName());
ByteArrayInputStream in = new ByteArrayInputStream(this.getContent()); ByteArrayInputStream in = new ByteArrayInputStream(this.getContent());
try { try {
BufferedImage origImage = ImageIO.read(in); BufferedImage origImage = ImageIO.read(in);
ByteArrayOutputStream scaledImageBuffer = new ByteArrayOutputStream(); ByteArrayOutputStream scaledImageBuffer = new ByteArrayOutputStream();
java.awt.Image scaledImage = origImage.getScaledInstance(maxThumbnailWidth, -1, java.awt.Image.SCALE_SMOOTH); java.awt.Image scaledImage = origImage.getScaledInstance(maxThumbnailWidth, -1,
java.awt.Image.SCALE_SMOOTH);
BufferedImage scaledBufImage = new BufferedImage(scaledImage.getWidth(null), scaledImage.getHeight(null), origImage.getType()); BufferedImage scaledBufImage = new BufferedImage(scaledImage.getWidth(null),
scaledBufImage.getGraphics().drawImage(scaledImage, 0, 0, null); scaledImage.getHeight(null),
origImage.getType());
scaledBufImage.getGraphics().drawImage(scaledImage, 0, 0, null);
ImageIO.write(scaledBufImage, this.getMimeType().getFileExtension(), scaledImageBuffer); ImageIO.write(scaledBufImage, this.getMimeType().getFileExtension(),
scaledImageBuffer);
imageAsset.setContent(scaledImageBuffer.toByteArray()); imageAsset.setContent(scaledImageBuffer.toByteArray());
imageAsset.setWidth(new BigDecimal(scaledImage.getWidth(null))); imageAsset.setWidth(new BigDecimal(scaledImage.getWidth(null)));
imageAsset.setHeight(new BigDecimal(scaledImage.getHeight(null))); imageAsset.setHeight(new BigDecimal(scaledImage.getHeight(null)));
} catch (IOException e) { } catch (IOException e) {
imageAsset.setContent(this.getContent()); imageAsset.setContent(this.getContent());
imageAsset.setWidth(this.getWidth()); imageAsset.setWidth(this.getWidth());
imageAsset.setHeight(this.getHeight()); imageAsset.setHeight(this.getHeight());
} }
return imageAsset; return imageAsset;
} }
} }
/** /**
* Extract filename from path * Extract filename from path
* *
* @param fileName * @param fileName
* @return filename *
*/ * @return filename
protected String extractFilename(String fileName) { */
// protected String extractFilename(String fileName) {
// Extract the filename //
int i = fileName.lastIndexOf("/"); // Extract the filename
if (i > 0) { int i = fileName.lastIndexOf("/");
fileName = fileName.substring(i + 1); if (i > 0) {
} fileName = fileName.substring(i + 1);
i = fileName.lastIndexOf("\\"); // DOS-style }
if (i > 0) { i = fileName.lastIndexOf("\\"); // DOS-style
fileName = fileName.substring(i + 1); if (i > 0) {
} fileName = fileName.substring(i + 1);
return fileName; }
} return fileName;
}
/**
* Read image size from file.
*/
private void readImageSize(BufferedImage image) {
setWidth(new BigDecimal(image.getWidth()));
setHeight(new BigDecimal(image.getHeight()));
}
/**
* Read image size from file.
*/
private void readImageSize(BufferedImage image) {
setWidth(new BigDecimal(image.getWidth()));
setHeight(new BigDecimal(image.getHeight()));
}
} }

View File

@ -128,8 +128,8 @@ public class GenericContactAddressSheet extends Table implements TableActionList
case 0: case 0:
return address.getTitle(); return address.getTitle();
case 1: case 1:
return ContenttypesGlobalizationUtil.globalize( return new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.contact.delete_address.button_label"); "cms.contenttypes.ui.contact.delete_address.button_label"));
default: default:
return null; return null;
} }
@ -208,7 +208,7 @@ public class GenericContactAddressSheet extends Table implements TableActionList
contact); contact);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value)); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(ContenttypesGlobalizationUtil.globalize( link.setConfirmation(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.contact.person.confirm_remove")); "cms.contenttypes.ui.contact.person.confirm_remove"));
return link; return link;

View File

@ -156,8 +156,8 @@ public class GenericContactPersonSheet extends Table implements TableActionListe
case 0: case 0:
return m_person.getFullName(); return m_person.getFullName();
case 1: case 1:
return ContenttypesGlobalizationUtil.globalize( return new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.genericcontact.delete_person").localize(); "cms.contenttypes.ui.genericcontact.delete_person"));
default: default:
return null; return null;
} }
@ -238,14 +238,13 @@ public class GenericContactPersonSheet extends Table implements TableActionListe
contact); contact);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label)value);
link.setConfirmation(ContenttypesGlobalizationUtil.globalize( link.setConfirmation(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.contact.person" "cms.contenttypes.ui.contact.person"
+ ".confirm_remove")); + ".confirm_remove"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return (Label) value;
return label;
} }
} }

View File

@ -61,25 +61,25 @@ public class GenericContactTypeTable extends Table implements TableActionListene
// if table is empty: // if table is empty:
setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize( setEmptyView(new Label(ContenttypesGlobalizationUtil.globalize(
"cms.contenttypes.ui.contacttypes.none"))); "cms.contenttypes.ui.contacttypes.none")));
TableColumnModel tab_model = getColumnModel(); TableColumnModel tab_model = getColumnModel();
// define columns // define columns
tab_model.add(new TableColumn( tab_model.add(new TableColumn(
0, 0,
ContenttypesGlobalizationUtil ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.key"), .globalize("cms.contenttypes.ui.contacttypes.key"),
TABLE_COL_EDIT)); TABLE_COL_EDIT));
tab_model.add(new TableColumn( tab_model.add(new TableColumn(
1, 1,
ContenttypesGlobalizationUtil ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.title") .globalize("cms.contenttypes.ui.contacttypes.title")
)); ));
tab_model.add(new TableColumn( tab_model.add(new TableColumn(
2, 2,
ContenttypesGlobalizationUtil ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.contacttypes.action"), .globalize("cms.contenttypes.ui.contacttypes.action"),
TABLE_COL_DEL)); TABLE_COL_DEL));
setModelBuilder(new GenericContactTypeTableModelBuilder(itemModel)); setModelBuilder(new GenericContactTypeTableModelBuilder(itemModel));
@ -95,7 +95,7 @@ public class GenericContactTypeTable extends Table implements TableActionListene
* *
*/ */
private class GenericContactTypeTableModelBuilder extends LockableImpl private class GenericContactTypeTableModelBuilder extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
@ -106,9 +106,10 @@ public class GenericContactTypeTable extends Table implements TableActionListene
public TableModel makeModel(Table table, PageState state) { public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
RelationAttribute contacttype = (RelationAttribute) m_itemModel RelationAttribute contacttype = (RelationAttribute) m_itemModel
.getSelectedObject(state); .getSelectedObject(state);
return new GenericContactTypeTableModel(table, state, contacttype); return new GenericContactTypeTableModel(table, state, contacttype);
} }
} }
/** /**
@ -120,8 +121,8 @@ public class GenericContactTypeTable extends Table implements TableActionListene
final private int MAX_DESC_LENGTH = 25; final private int MAX_DESC_LENGTH = 25;
private Table m_table; private Table m_table;
private RelationAttribute m_contacttype; private RelationAttribute m_contacttype;
private GenericContactTypeCollection m_contacttypeCollection = new private GenericContactTypeCollection m_contacttypeCollection
GenericContactTypeCollection(); = new GenericContactTypeCollection();
private GenericContactTypeTableModel(Table t, private GenericContactTypeTableModel(Table t,
PageState ps, PageState ps,
@ -139,8 +140,8 @@ public class GenericContactTypeTable extends Table implements TableActionListene
/** /**
* Check collection for the existence of another row. * Check collection for the existence of another row.
* *
* If exists, fetch the value of current GenericPersonEntryCollection object * If exists, fetch the value of current GenericPersonEntryCollection object into m_comntact
* into m_comntact class variable. * class variable.
*/ */
public boolean nextRow() { public boolean nextRow() {
@ -157,6 +158,7 @@ public class GenericContactTypeTable extends Table implements TableActionListene
/** /**
* Return the * Return the
*
* @see com.arsdigita.bebop.table.TableModel#getElementAt(int) * @see com.arsdigita.bebop.table.TableModel#getElementAt(int)
*/ */
public Object getElementAt(int columnIndex) { public Object getElementAt(int columnIndex) {
@ -166,8 +168,7 @@ public class GenericContactTypeTable extends Table implements TableActionListene
case 1: case 1:
return m_contacttypeCollection.getName(); return m_contacttypeCollection.getName();
case 2: case 2:
return new Label(GlobalizationUtil.globalize("cms.ui.delete") return new Label(GlobalizationUtil.globalize("cms.ui.delete"));
);
default: default:
return null; return null;
} }
@ -180,21 +181,20 @@ public class GenericContactTypeTable extends Table implements TableActionListene
public Object getKeyAt(int columnIndex) { public Object getKeyAt(int columnIndex) {
return m_contacttype.getKey(); return m_contacttype.getKey();
} }
} }
/** /**
* Check for the permissions to edit item and put either a Label or * Check for the permissions to edit item and put either a Label or a ControlLink accordingly.
* a ControlLink accordingly.
*/ */
private class EditCellRenderer extends LockableImpl implements TableCellRenderer { private class EditCellRenderer extends LockableImpl implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value, public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, boolean isSelected, Object key,
int row, int column) { int row, int column) {
SecurityManager sm = Utilities.getSecurityManager(state); SecurityManager sm = Utilities.getSecurityManager(state);
RelationAttribute contacttype = (RelationAttribute) RelationAttribute contacttype = (RelationAttribute) m_itemModel.getSelectedObject(state);
m_itemModel.getSelectedObject(state);
// boolean canEdit = sm.canAccess(state.getRequest(), // boolean canEdit = sm.canAccess(state.getRequest(),
// SecurityManager.EDIT_ITEM, // SecurityManager.EDIT_ITEM,
@ -206,50 +206,49 @@ public class GenericContactTypeTable extends Table implements TableActionListene
// return new Label(value.toString()); // return new Label(value.toString());
// } // }
} }
} }
/** /**
* Check for the permissions to delete item and put either a Label or * Check for the permissions to delete item and put either a Label or a ControlLink accordingly.
* a ControlLink accordingly.
*/ */
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer { private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
public Component getComponent(Table table, PageState state, Object value, public Component getComponent(Table table, PageState state, Object value,
boolean isSelected, Object key, boolean isSelected, Object key,
int row, int column) { int row, int column) {
SecurityManager sm = Utilities.getSecurityManager(state); SecurityManager sm = Utilities.getSecurityManager(state);
RelationAttribute contacttype = (RelationAttribute) RelationAttribute contacttype = (RelationAttribute) m_itemModel.getSelectedObject(state);
m_itemModel.getSelectedObject(state);
// boolean canDelete = sm.canAccess(state.getRequest(), // boolean canDelete = sm.canAccess(state.getRequest(),
// SecurityManager.DELETE_ITEM, // SecurityManager.DELETE_ITEM,
// contacttype); // contacttype);
// if (canDelete) { // if (canDelete) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label)value);
link.setConfirmation(ContenttypesGlobalizationUtil link.setConfirmation(ContenttypesGlobalizationUtil
.globalize( .globalize(
"cms.contenttypes.ui.contacttype.confirm_delete") "cms.contenttypes.ui.contacttype.confirm_delete")
); );
return link; return link;
// } else { // } else {
// return new Label(value.toString()); // return new Label(value.toString());
// } // }
} }
} }
/** /**
* Provide implementation to TableActionListener method. * Provide implementation to TableActionListener method. Code that comes into picture when a
* Code that comes into picture when a link on the table is clicked. * link on the table is clicked. Handles edit and delete event.
* Handles edit and delete event.
*/ */
public void cellSelected(TableActionEvent evt) { public void cellSelected(TableActionEvent evt) {
PageState state = evt.getPageState(); PageState state = evt.getPageState();
// Get selected GenericContactType // Get selected GenericContactType
RelationAttribute contacttype = new RelationAttribute(new RelationAttribute contacttype = new RelationAttribute(new BigDecimal(evt.getRowKey()
BigDecimal(evt.getRowKey().toString())); .toString()));
// Get selected column // Get selected column
TableColumn col = getColumnModel().get(evt.getColumn().intValue()); TableColumn col = getColumnModel().get(evt.getColumn().intValue());
@ -266,10 +265,10 @@ public class GenericContactTypeTable extends Table implements TableActionListene
} }
/** /**
* provide Implementation to TableActionListener method. * provide Implementation to TableActionListener method. Does nothing in our case.
* Does nothing in our case.
*/ */
public void headSelected(TableActionEvent e) { public void headSelected(TableActionEvent e) {
throw new UnsupportedOperationException("Not Implemented"); throw new UnsupportedOperationException("Not Implemented");
} }
} }

View File

@ -313,10 +313,10 @@ public class GenericOrganizationalUnitContactTable extends Table implements
SecurityManager.EDIT_ITEM, SecurityManager.EDIT_ITEM,
orgaunit); orgaunit);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
return link; return link;
} else { } else {
return new Label(value.toString()); return new Label("");
} }
} }
} }
@ -344,14 +344,14 @@ public class GenericOrganizationalUnitContactTable extends Table implements
SecurityManager.DELETE_ITEM, SecurityManager.DELETE_ITEM,
orgaunit); orgaunit);
if (canDelete) { if (canDelete) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(ContenttypesGlobalizationUtil. link.setConfirmation(ContenttypesGlobalizationUtil.
globalize( globalize(
"cms.contenttypes.ui.genericorgaunit.confirm_delete") "cms.contenttypes.ui.genericorgaunit.confirm_delete")
); );
return link; return link;
} else { } else {
return new Label(value.toString()); return new Label("");
} }
} }
} }

View File

@ -174,7 +174,7 @@ public class GenericOrganizationalUnitSubordinateOrgaUnitsTable
GlobalizationHelper.getNegotiatedLocale(). GlobalizationHelper.getNegotiatedLocale().
getLanguage()).getTitle(); getLanguage()).getTitle();
case 1: case 1:
return customizer.getDeleteLabel(); return new Label(customizer.getDeleteLabel());
case 2: case 2:
return customizer.getUpLabel(); return customizer.getUpLabel();
case 3: case 3:
@ -254,7 +254,7 @@ public class GenericOrganizationalUnitSubordinateOrgaUnitsTable
orgaunit); orgaunit);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(value.toString()); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(customizer.getConfirmRemoveLabel()); link.setConfirmation(customizer.getConfirmRemoveLabel());
return link; return link;
} else { } else {

View File

@ -160,7 +160,7 @@ public class GenericOrganizationalUnitSuperiorOrgaUnitsTable extends Table {
case 0: case 0:
return superiorOrgaUnits.getTitle(); return superiorOrgaUnits.getTitle();
case 1: case 1:
return customizer.getDeleteLabel(); return new Label(customizer.getDeleteLabel());
case 2: case 2:
return customizer.getUpLabel(); return customizer.getUpLabel();
case 3: case 3:
@ -236,12 +236,11 @@ public class GenericOrganizationalUnitSuperiorOrgaUnitsTable extends Table {
orgaunit); orgaunit);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(value.toString()); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(customizer.getConfirmRemoveLabel()); link.setConfirmation(customizer.getConfirmRemoveLabel());
return link; return link;
} else { } else {
final Label label = new Label(""); return new Label("");
return label;
} }
} }

View File

@ -314,12 +314,12 @@ public class GenericPersonContactTable extends Table implements
SecurityManager.DELETE_ITEM, SecurityManager.DELETE_ITEM,
person); person);
if (canDelete) { if (canDelete) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(ContenttypesGlobalizationUtil. link.setConfirmation(ContenttypesGlobalizationUtil.
globalize("cms.contenttypes.ui.person.confirm_delete")); globalize("cms.contenttypes.ui.person.confirm_delete"));
return link; return link;
} else { } else {
return new Label((GlobalizedMessage) value); return new Label("");
} }
} }
} }

View File

@ -141,8 +141,8 @@ public class SciPublicationsAboutDiscussesTable extends Table implements TableAc
case 0: case 0:
return discussed.getTitle(); return discussed.getTitle();
case 1: case 1:
return SciPublicationsAboutGlobalizationUtil.globalize( return new Label(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discusses.publication.remove"); "com.arsdigita.cms.contentassets.about.discusses.publication.remove"));
default: default:
return null; return null;
} }
@ -215,12 +215,12 @@ public class SciPublicationsAboutDiscussesTable extends Table implements TableAc
discussing); discussing);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value)); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(SciPublicationsAboutGlobalizationUtil.globalize( link.setConfirmation(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discusses.publication.remove.confirm")); "com.arsdigita.cms.contentassets.about.discusses.publication.remove.confirm"));
return link; return link;
} else { } else {
return new Label(value.toString()); return new Label("");
} }
} }

View File

@ -67,11 +67,11 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
colModel.add(new TableColumn( colModel.add(new TableColumn(
0, 0,
SciPublicationsAboutGlobalizationUtil.globalize( SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication"))); "com.arsdigita.cms.contentassets.about.discussing.publication")));
colModel.add(new TableColumn( colModel.add(new TableColumn(
1, 1,
SciPublicationsAboutGlobalizationUtil.globalize( SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication.remove"), "com.arsdigita.cms.contentassets.about.discussing.publication.remove"),
TABLE_COL_DEL)); TABLE_COL_DEL));
setModelBuilder(new SciPublicationsAboutTableModelBuilder(itemModel)); setModelBuilder(new SciPublicationsAboutTableModelBuilder(itemModel));
@ -141,8 +141,8 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
case 0: case 0:
return discussing.getTitle(); return discussing.getTitle();
case 1: case 1:
return SciPublicationsAboutGlobalizationUtil.globalize( return new Label(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication.remove"); "com.arsdigita.cms.contentassets.about.discussing.publication.remove"));
default: default:
return null; return null;
} }
@ -152,6 +152,7 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
public Object getKeyAt(final int columnIndex) { public Object getKeyAt(final int columnIndex) {
return discussing.getID(); return discussing.getID();
} }
} }
private class PublicationCellRenderer extends LockableImpl implements TableCellRenderer { private class PublicationCellRenderer extends LockableImpl implements TableCellRenderer {
@ -195,7 +196,7 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
} }
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer { private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
@Override @Override
public Component getComponent(final Table table, public Component getComponent(final Table table,
@ -209,17 +210,17 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
final Publication discussed = (Publication) itemModel.getSelectedObject(state); final Publication discussed = (Publication) itemModel.getSelectedObject(state);
final boolean canEdit = securityManager.canAccess( final boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.DELETE_ITEM, com.arsdigita.cms.SecurityManager.DELETE_ITEM,
discussed); discussed);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value)); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(SciPublicationsAboutGlobalizationUtil.globalize( link.setConfirmation(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication.remove.confirm")); "com.arsdigita.cms.contentassets.about.discussing.publication.remove.confirm"));
return link; return link;
} else { } else {
return new Label(value.toString()); return new Label("");
} }
} }

View File

@ -156,9 +156,9 @@ public class LibrarySignaturesTable extends Table {
case 2: case 2:
return librarySignatures.get(LibrarySignature.LIBRARY_LINK); return librarySignatures.get(LibrarySignature.LIBRARY_LINK);
case 3: case 3:
return LibrarySignaturesGlobalizationUtil.globalize("scipublications.librarysignatures.edit"); return new Label(LibrarySignaturesGlobalizationUtil.globalize("scipublications.librarysignatures.edit"));
case 4: case 4:
return LibrarySignaturesGlobalizationUtil.globalize("scipublications.librarysignatures.delete"); return new Label(LibrarySignaturesGlobalizationUtil.globalize("scipublications.librarysignatures.delete"));
default: default:
return null; return null;
} }
@ -193,25 +193,10 @@ public class LibrarySignaturesTable extends Table {
publication); publication);
if (canEdit) { if (canEdit) {
final ControlLink link; final ControlLink link= new ControlLink((Label) value);
if (value instanceof GlobalizedMessage) {
link = new ControlLink(new Label((GlobalizedMessage) value));
} else if (value == null) {
return new Label("???");
} else {
link = new ControlLink(value.toString());
}
return link; return link;
} else { } else {
final Label label; return new Label("");
if (value instanceof GlobalizedMessage) {
label = new Label((GlobalizedMessage) value);
} else if (value == null) {
return new Label("???");
} else {
label = new Label(value.toString());
}
return label;
} }
} }
@ -239,23 +224,12 @@ public class LibrarySignaturesTable extends Table {
publication); publication);
if (canEdit) { if (canEdit) {
final ControlLink link; final ControlLink link = new ControlLink((Label) value);
if (value instanceof GlobalizedMessage) {
link = new ControlLink(new Label((GlobalizedMessage) value));
} else {
link = new ControlLink(value.toString());
}
link.setConfirmation(LibrarySignaturesGlobalizationUtil.globalize( link.setConfirmation(LibrarySignaturesGlobalizationUtil.globalize(
"scipublications.librarysignatures.delete.confirm")); "scipublications.librarysignatures.delete.confirm"));
return link; return link;
} else { } else {
final Label label; return new Label("");
if (value instanceof GlobalizedMessage) {
label = new Label((GlobalizedMessage) value);
} else {
label = new Label(value.toString());
}
return label;
} }
} }

View File

@ -161,8 +161,8 @@ public class SciPublicationsPersonsPersonTable extends Table implements TableAct
case 1: case 1:
return relation; return relation;
case 2: case 2:
return globalisationUtil.globalize( return new Label(globalisationUtil.globalize(
"com.arsdigita.cms.contentassets.publication_persons.person.remove"); "com.arsdigita.cms.contentassets.publication_persons.person.remove"));
default: default:
return null; return null;
} }
@ -230,28 +230,12 @@ public class SciPublicationsPersonsPersonTable extends Table implements TableAct
final int row, final int row,
final int column) { final int column) {
final GlobalizedMessage relation = new GlobalizedMessage((String) value, final GlobalizedMessage relation = new GlobalizedMessage(
SciPublicationsPersonsService.RELATION_ATTRIBUTE, (String) value,
new RelationAttributeResourceBundleControl()); SciPublicationsPersonsService.RELATION_ATTRIBUTE,
new RelationAttributeResourceBundleControl());
return new Label(relation); return new Label(relation);
// final String relation = (String) value;
//
// final RelationAttributeCollection relations = new RelationAttributeCollection(
// SciPublicationsPersonsService.RELATION_ATTRIBUTE,
// relation);
// relations.addLanguageFilter(GlobalizationHelper.getNegotiatedLocale().getLanguage());
// if (relations.isEmpty()) {
// return new Label(relation);
// } else {
// relations.next();
// final String label = relations.getName();
// relations.close();
// return new Label(label);
// }
//return new Label(value.toString());
} }
} }
@ -275,12 +259,12 @@ public class SciPublicationsPersonsPersonTable extends Table implements TableAct
publication); publication);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value)); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(globalisationUtil.globalize( link.setConfirmation(globalisationUtil.globalize(
"com.arsdigita.cms.contentassets.publications_persons.person.remove.confirm")); "com.arsdigita.cms.contentassets.publications_persons.person.remove.confirm"));
return link; return link;
} else { } else {
return new Label((GlobalizedMessage) value); return new Label("");
} }
} }

View File

@ -67,30 +67,35 @@ public class PublicationTypeAssetTable extends Table {
this.typeModel = typeModel; this.typeModel = typeModel;
setEmptyView(new Label(PublicationTypeAssetGlobalizationUtil.globalize( setEmptyView(new Label(PublicationTypeAssetGlobalizationUtil.globalize(
"scipublications.publication_type_asset.none"))); "scipublications.publication_type_asset.none")));
final TableColumnModel columnModel = getColumnModel(); final TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
0, 0,
PublicationTypeAssetGlobalizationUtil.globalize("scipublications.publication_type_asset.type"), PublicationTypeAssetGlobalizationUtil.globalize(
TABLE_COL_TYPE)); "scipublications.publication_type_asset.type"),
TABLE_COL_TYPE));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
1, 1,
PublicationTypeAssetGlobalizationUtil.globalize("scipublications.publication_type_asset.isbn"), PublicationTypeAssetGlobalizationUtil.globalize(
TABLE_COL_ISBN)); "scipublications.publication_type_asset.isbn"),
TABLE_COL_ISBN));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
2, 2,
PublicationTypeAssetGlobalizationUtil.globalize("scipublications.publication_type_asset.misc"), PublicationTypeAssetGlobalizationUtil.globalize(
TABLE_COL_MISC)); "scipublications.publication_type_asset.misc"),
TABLE_COL_MISC));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
3, 3,
PublicationTypeAssetGlobalizationUtil.globalize("scipublications.publication_type_asset.edit"), PublicationTypeAssetGlobalizationUtil.globalize(
TABLE_COL_EDIT)); "scipublications.publication_type_asset.edit"),
TABLE_COL_EDIT));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
4, 4,
PublicationTypeAssetGlobalizationUtil.globalize("scipublications.publication_type_asset.delete"), PublicationTypeAssetGlobalizationUtil.globalize(
TABLE_COL_DEL)); "scipublications.publication_type_asset.delete"),
TABLE_COL_DEL));
setModelBuilder(new ModelBuilder(itemModel)); setModelBuilder(new ModelBuilder(itemModel));
@ -150,11 +155,11 @@ public class PublicationTypeAssetTable extends Table {
case 2: case 2:
return typeAssets.get(PublicationTypeAsset.MISC); return typeAssets.get(PublicationTypeAsset.MISC);
case 3: case 3:
return PublicationTypeAssetGlobalizationUtil.globalize( return new Label(PublicationTypeAssetGlobalizationUtil.globalize(
"scipublications.publication_type_asset.edit"); "scipublications.publication_type_asset.edit"));
case 4: case 4:
return PublicationTypeAssetGlobalizationUtil.globalize( return new Label(PublicationTypeAssetGlobalizationUtil.globalize(
"scipublications.publication_type_asset.delete"); "scipublications.publication_type_asset.delete"));
default: default:
return null; return null;
} }
@ -189,25 +194,11 @@ public class PublicationTypeAssetTable extends Table {
publication); publication);
if (canEdit) { if (canEdit) {
final ControlLink link; final ControlLink link = new ControlLink((Label) value);
if (value instanceof GlobalizedMessage) {
link = new ControlLink(new Label((GlobalizedMessage) value));
} else if (value == null) {
return new Label("???");
} else {
link = new ControlLink(value.toString());
}
return link; return link;
} else { } else {
final Label label; final Label label;
if (value instanceof GlobalizedMessage) { return new Label("");
label = new Label((GlobalizedMessage) value);
} else if (value == null) {
return new Label("???");
} else {
label = new Label(value.toString());
}
return label;
} }
} }
@ -235,23 +226,12 @@ public class PublicationTypeAssetTable extends Table {
publication); publication);
if (canEdit) { if (canEdit) {
final ControlLink link; final ControlLink link = new ControlLink((Label) value);
if (value instanceof GlobalizedMessage) {
link = new ControlLink(new Label((GlobalizedMessage) value));
} else {
link = new ControlLink(value.toString());
}
link.setConfirmation(PublicationTypeAssetGlobalizationUtil.globalize( link.setConfirmation(PublicationTypeAssetGlobalizationUtil.globalize(
"scipublications.publication_type_asset.delete.confirm")); "scipublications.publication_type_asset.delete.confirm"));
return link; return link;
} else { } else {
final Label label; return new Label("");
if (value instanceof GlobalizedMessage) {
label = new Label((GlobalizedMessage) value);
} else {
label = new Label(value.toString());
}
return label;
} }
} }
@ -268,7 +248,8 @@ public class PublicationTypeAssetTable extends Table {
public void cellSelected(final TableActionEvent event) { public void cellSelected(final TableActionEvent event) {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
final PublicationTypeAsset asset = new PublicationTypeAsset(new BigDecimal(event.getRowKey().toString())); final PublicationTypeAsset asset = new PublicationTypeAsset(new BigDecimal(event
.getRowKey().toString()));
final TableColumn column = getColumnModel().get(event.getColumn().intValue()); final TableColumn column = getColumnModel().get(event.getColumn().intValue());
@ -286,4 +267,5 @@ public class PublicationTypeAssetTable extends Table {
} }
} }
} }

View File

@ -234,7 +234,7 @@ public class SciPublicationsMovieDirectorSheet
movie); movie);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink((Label)value); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(globalisationUtil.globalize( link.setConfirmation(globalisationUtil.globalize(
"publications.dramaticarts.ui.movie.director.remove.confirm")); "publications.dramaticarts.ui.movie.director.remove.confirm"));
return link; return link;

View File

@ -152,9 +152,8 @@ public class ArticleInCollectedVolumeCollectedVolumeSheet
case 0: case 0:
return collectedVolume.getTitle(); return collectedVolume.getTitle();
case 1: case 1:
return PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.articleInCollectedVolume.collectedVolume.remove"). "publications.ui.articleInCollectedVolume.collectedVolume.remove"));
localize();
default: default:
return null; return null;
} }
@ -244,15 +243,14 @@ public class ArticleInCollectedVolumeCollectedVolumeSheet
article); article);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation( link.setConfirmation(
PublicationGlobalizationUtil.globalize( PublicationGlobalizationUtil.globalize(
"publications.ui.articleInCollectedVolume.collectedVolume." "publications.ui.articleInCollectedVolume.collectedVolume."
+ "confirm_remove")); + "confirm_remove"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }

View File

@ -142,9 +142,8 @@ public class ArticleInJournalJournalSheet
case 0: case 0:
return journal.getTitle(); return journal.getTitle();
case 1: case 1:
return PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.articleInCollectedVolume.collectedVolume.remove"). "publications.ui.articleInCollectedVolume.collectedVolume.remove"));
localize();
default: default:
return null; return null;
} }
@ -227,15 +226,13 @@ public class ArticleInJournalJournalSheet
article); article);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation( link.setConfirmation(
(String) PublicationGlobalizationUtil.globalize( PublicationGlobalizationUtil.globalize(
"publication.ui.articleInJournal.journal.confirm_remove"). "publication.ui.articleInJournal.journal.confirm_remove"));
localize());
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -50,12 +50,11 @@ import org.apache.log4j.Logger;
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class CollectedVolumeArticlesTable public class CollectedVolumeArticlesTable
extends Table extends Table
implements TableActionListener { implements TableActionListener {
private static final Logger s_log = private static final Logger s_log = Logger.getLogger(
Logger.getLogger( CollectedVolumeArticlesTable.class);
CollectedVolumeArticlesTable.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 String TABLE_COL_UP = "table_col_up"; private final String TABLE_COL_UP = "table_col_up";
@ -67,33 +66,33 @@ public class CollectedVolumeArticlesTable
m_itemModel = itemModel; m_itemModel = itemModel;
setEmptyView( setEmptyView(
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.collected_volume.no_articles"))); "publications.ui.collected_volume.no_articles")));
TableColumnModel colModel = getColumnModel(); TableColumnModel colModel = getColumnModel();
colModel.add(new TableColumn( colModel.add(new TableColumn(
0, 0,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.collected_volume.article")), "publications.ui.collected_volume.article")),
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.collected_volume.article.remove")), "publications.ui.collected_volume.article.remove")),
TABLE_COL_DEL)); TABLE_COL_DEL));
colModel.add(new TableColumn( colModel.add(new TableColumn(
2, 2,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.collected_volume.article.up")), "publications.ui.collected_volume.article.up")),
TABLE_COL_UP)); TABLE_COL_UP));
colModel.add(new TableColumn( colModel.add(new TableColumn(
3, 3,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.collected_volume.article.down")), "publications.ui.collected_volume.article.down")),
TABLE_COL_DOWN)); TABLE_COL_DOWN));
setModelBuilder( setModelBuilder(
new CollectedVolumeArticlesTableModelBuilder(itemModel)); new CollectedVolumeArticlesTableModelBuilder(itemModel));
colModel.get(0).setCellRenderer(new EditCellRenderer()); colModel.get(0).setCellRenderer(new EditCellRenderer());
colModel.get(1).setCellRenderer(new DeleteCellRenderer()); colModel.get(1).setCellRenderer(new DeleteCellRenderer());
@ -104,26 +103,26 @@ public class CollectedVolumeArticlesTable
} }
private class CollectedVolumeArticlesTableModelBuilder private class CollectedVolumeArticlesTableModelBuilder
extends LockableImpl extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
public CollectedVolumeArticlesTableModelBuilder( public CollectedVolumeArticlesTableModelBuilder(
ItemSelectionModel itemModel) { ItemSelectionModel itemModel) {
m_itemModel = itemModel; m_itemModel = itemModel;
} }
@Override @Override
public TableModel makeModel(Table table, PageState state) { public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
CollectedVolume collectedVolume = CollectedVolume collectedVolume = (CollectedVolume) m_itemModel.getSelectedObject(
(CollectedVolume) m_itemModel.getSelectedObject( state);
state);
return new CollectedVolumeArticlesTableModel(table, return new CollectedVolumeArticlesTableModel(table,
state, state,
collectedVolume); collectedVolume);
} }
} }
private class CollectedVolumeArticlesTableModel implements TableModel { private class CollectedVolumeArticlesTableModel implements TableModel {
@ -133,9 +132,9 @@ public class CollectedVolumeArticlesTable
private ArticleInCollectedVolume m_article; private ArticleInCollectedVolume m_article;
private CollectedVolumeArticlesTableModel( private CollectedVolumeArticlesTableModel(
Table table, Table table,
PageState state, PageState state,
CollectedVolume collectedVolume) { CollectedVolume collectedVolume) {
m_table = table; m_table = table;
m_articles = collectedVolume.getArticles(); m_articles = collectedVolume.getArticles();
} }
@ -166,7 +165,7 @@ public class CollectedVolumeArticlesTable
return m_article.getTitle(); return m_article.getTitle();
case 1: case 1:
return new Label(PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.collected_volume.article.remove")); "publications.ui.collected_volume.article.remove"));
default: default:
return null; return null;
} }
@ -176,11 +175,12 @@ public class CollectedVolumeArticlesTable
public Object getKeyAt(int columnIndex) { public Object getKeyAt(int columnIndex) {
return m_article.getID(); return m_article.getID();
} }
} }
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,
@ -190,15 +190,14 @@ public class CollectedVolumeArticlesTable
Object key, Object key,
int row, int row,
int col) { int col) {
SecurityManager securityManager = SecurityManager securityManager = Utilities.getSecurityManager(state);
Utilities.getSecurityManager(state);
CollectedVolume collectedVolume = (CollectedVolume) m_itemModel. CollectedVolume collectedVolume = (CollectedVolume) m_itemModel.
getSelectedObject(state); getSelectedObject(state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.EDIT_ITEM, SecurityManager.EDIT_ITEM,
collectedVolume); collectedVolume);
if (canEdit) { if (canEdit) {
ArticleInCollectedVolume article; ArticleInCollectedVolume article;
@ -213,12 +212,11 @@ public class CollectedVolumeArticlesTable
ContentSection section = article.getContentSection();//CMS.getContext().getContentSection(); ContentSection section = article.getContentSection();//CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver(); ItemResolver resolver = section.getItemResolver();
Link link = Link link = new Link(value.toString(),
new Link(value.toString(), resolver.generateItemURL(state,
resolver.generateItemURL(state, article,
article, section,
section, article.getVersion()));
article.getVersion()));
return link; return link;
} else { } else {
@ -236,11 +234,12 @@ public class CollectedVolumeArticlesTable
return label; return label;
} }
} }
} }
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,
@ -250,42 +249,40 @@ public class CollectedVolumeArticlesTable
Object key, Object key,
int row, int row,
int col) { int col) {
SecurityManager securityManager = SecurityManager securityManager = Utilities.getSecurityManager(state);
Utilities.getSecurityManager(state); CollectedVolume collectedVolume = (CollectedVolume) m_itemModel.getSelectedObject(
CollectedVolume collectedVolume = state);
(CollectedVolume) m_itemModel.getSelectedObject(
state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.DELETE_ITEM, SecurityManager.DELETE_ITEM,
collectedVolume); collectedVolume);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.collected_volume.articles.confirm_remove")); "publications.ui.collected_volume.articles.confirm_remove"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }
private class UpCellRenderer private class UpCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
if (0 == row) { if (0 == row) {
s_log.debug("Row is first row in table, don't show up link"); s_log.debug("Row is first row in table, don't show up link");
@ -296,27 +293,26 @@ public class CollectedVolumeArticlesTable
return link; return link;
} }
} }
} }
private class DownCellRenderer private class DownCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
CollectedVolume collectedVolume = CollectedVolume collectedVolume = (CollectedVolume) m_itemModel.getSelectedObject(
(CollectedVolume) m_itemModel.getSelectedObject( state);
state); ArticleInCollectedVolumeCollection articles = collectedVolume.getArticles();
ArticleInCollectedVolumeCollection articles =
collectedVolume.getArticles();
if ((articles.size() - 1) == row) { if ((articles.size() - 1) == row) {
s_log.debug("Row is last row in table, don't show down link"); s_log.debug("Row is last row in table, don't show down link");
@ -327,21 +323,19 @@ public class CollectedVolumeArticlesTable
return link; return link;
} }
} }
} }
@Override @Override
public void cellSelected(TableActionEvent event) { public void cellSelected(TableActionEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
ArticleInCollectedVolume article = ArticleInCollectedVolume article = new ArticleInCollectedVolume(
new ArticleInCollectedVolume( new BigDecimal(event.getRowKey().toString()));
new BigDecimal(event.getRowKey().toString()));
CollectedVolume collectedVolume = CollectedVolume collectedVolume = (CollectedVolume) m_itemModel.getSelectedObject(state);
(CollectedVolume) m_itemModel.getSelectedObject(state);
ArticleInCollectedVolumeCollection articles = ArticleInCollectedVolumeCollection articles = collectedVolume.getArticles();
collectedVolume.getArticles();
TableColumn column = getColumnModel().get(event.getColumn().intValue()); TableColumn column = getColumnModel().get(event.getColumn().intValue());
@ -359,4 +353,5 @@ public class CollectedVolumeArticlesTable
public void headSelected(TableActionEvent event) { public void headSelected(TableActionEvent event) {
//Nothing to do. //Nothing to do.
} }
} }

View File

@ -231,13 +231,12 @@ public class ExpertiseOrdererSheet
expertise); expertise);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publication.ui.expertise.orderer.remove.confirm")); "publication.ui.expertise.orderer.remove.confirm"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -231,13 +231,12 @@ public class ExpertiseOrganizationSheet
expertise); expertise);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publication.ui.expertise.organization.remove.confirm")); "publication.ui.expertise.organization.remove.confirm"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -142,9 +142,8 @@ public class GenericOrganizationalUnitPublicationsTable
case 0: case 0:
return publications.getPublication().getTitle(); return publications.getPublication().getTitle();
case 1: case 1:
return PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"genericorganizationalunit.ui.publications.remove"). "genericorganizationalunit.ui.publications.remove"));
localize();
default: default:
return null; return null;
} }
@ -219,13 +218,12 @@ public class GenericOrganizationalUnitPublicationsTable
orgaunit); orgaunit);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(value.toString()); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"genericorganizationalunit.ui.publications.remove.confirm")); "genericorganizationalunit.ui.publications.remove.confirm"));
return link; return link;
} else { } else {
final Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }

View File

@ -242,13 +242,12 @@ public class InProceedingsProceedingsSheet
inProceedings); inProceedings);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.inProceedings.proceedings.confirm_remove")); "publications.ui.inProceedings.proceedings.confirm_remove"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -242,13 +242,12 @@ public class InternetArticleOrganizationSheet
article); article);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.internetarticle.organization.remove.confirm")); "publications.ui.internetarticle.organization.remove.confirm"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -48,11 +48,11 @@ import org.apache.log4j.Logger;
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class JournalArticlesTable public class JournalArticlesTable
extends Table extends Table
implements TableActionListener { implements TableActionListener {
private static final Logger s_log = Logger.getLogger( private static final Logger s_log = Logger.getLogger(
JournalArticlesTable.class); JournalArticlesTable.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 String TABLE_COL_UP = "table_col_up"; private final String TABLE_COL_UP = "table_col_up";
@ -64,29 +64,29 @@ public class JournalArticlesTable
m_itemModel = itemModel; m_itemModel = itemModel;
setEmptyView(new Label(PublicationGlobalizationUtil.globalize( setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.journal.no_articles"))); "publications.ui.journal.no_articles")));
TableColumnModel columnModel = getColumnModel(); TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
0, 0,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.journal.article")), "publications.ui.journal.article")),
TABLE_COL_EDIT)); TABLE_COL_EDIT));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
1, 1,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.journal.article.remove")), "publications.ui.journal.article.remove")),
TABLE_COL_DEL)); TABLE_COL_DEL));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
2, 2,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.journal.article.up")), "publications.ui.journal.article.up")),
TABLE_COL_UP)); TABLE_COL_UP));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
3, 3,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.journal.article.down")), "publications.ui.journal.article.down")),
TABLE_COL_DOWN)); TABLE_COL_DOWN));
setModelBuilder(new JournalArticlesTableModelBuilder(itemModel)); setModelBuilder(new JournalArticlesTableModelBuilder(itemModel));
@ -99,26 +99,26 @@ public class JournalArticlesTable
} }
private class JournalArticlesTableModelBuilder private class JournalArticlesTableModelBuilder
extends LockableImpl extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
public JournalArticlesTableModelBuilder( public JournalArticlesTableModelBuilder(
ItemSelectionModel itemModel) { ItemSelectionModel itemModel) {
m_itemModel = itemModel; m_itemModel = itemModel;
} }
@Override @Override
public TableModel makeModel(Table table, PageState state) { public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
Journal collectedVolume = Journal collectedVolume = (Journal) m_itemModel.getSelectedObject(
(Journal) m_itemModel.getSelectedObject( state);
state);
return new JournalArticlesTableModel(table, return new JournalArticlesTableModel(table,
state, state,
collectedVolume); collectedVolume);
} }
} }
private class JournalArticlesTableModel implements TableModel { private class JournalArticlesTableModel implements TableModel {
@ -160,7 +160,7 @@ public class JournalArticlesTable
return m_article.getTitle(); return m_article.getTitle();
case 1: case 1:
return new Label(PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.journal.article.remove")); "publications.ui.journal.article.remove"));
default: default:
return null; return null;
} }
@ -170,11 +170,12 @@ public class JournalArticlesTable
public Object getKeyAt(int columnIndex) { public Object getKeyAt(int columnIndex) {
return m_article.getID(); return m_article.getID();
} }
} }
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,
@ -184,14 +185,13 @@ public class JournalArticlesTable
Object key, Object key,
int row, int row,
int col) { int col) {
com.arsdigita.cms.SecurityManager securityManager = com.arsdigita.cms.SecurityManager securityManager = Utilities.getSecurityManager(state);
Utilities.getSecurityManager(state);
Journal journal = (Journal) m_itemModel.getSelectedObject(state); Journal journal = (Journal) m_itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM, com.arsdigita.cms.SecurityManager.EDIT_ITEM,
journal); journal);
if (canEdit) { if (canEdit) {
ArticleInJournal article; ArticleInJournal article;
@ -205,14 +205,13 @@ public class JournalArticlesTable
} }
ContentSection section = article.getContentSection();//CMS.getContext().getContentSection(); ContentSection section = article.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(), article.getLanguage()),
article.getLanguage()), resolver.generateItemURL(state,
resolver.generateItemURL(state, article,
article, section,
section, article.getVersion()));
article.getVersion()));
return link; return link;
} else { } else {
ArticleInJournal article; ArticleInJournal article;
@ -231,79 +230,82 @@ public class JournalArticlesTable
return label; return label;
} }
} }
} }
private class DeleteCellRenderer extends LockableImpl implements private class DeleteCellRenderer extends LockableImpl implements
TableCellRenderer { TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
com.arsdigita.cms.SecurityManager securityManager = Utilities. com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state); getSecurityManager(state);
Journal journal = (Journal) m_itemModel.getSelectedObject( Journal journal = (Journal) m_itemModel.getSelectedObject(
state); state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.DELETE_ITEM, com.arsdigita.cms.SecurityManager.DELETE_ITEM,
journal); journal);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"cms.contenttypes.ui.journal.articles.confirm_delete")); "cms.contenttypes.ui.journal.articles.confirm_delete"));
return link; return link;
} else { } else {
return new Label(value.toString()); return new Label("");
} }
} }
} }
private class UpCellRenderer private class UpCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
if (0 == row) { if (0 == row) {
Label label = new Label(); Label label = new Label();
return label; return label;
} else { } else {
ControlLink link = new ControlLink( ControlLink link = new ControlLink(
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"cms.contenttypes.ui.journal.articles.up"))); "cms.contenttypes.ui.journal.articles.up")));
return link; return link;
} }
} }
} }
private class DownCellRenderer private class DownCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
Journal journal = (Journal) m_itemModel.getSelectedObject(state); Journal journal = (Journal) m_itemModel.getSelectedObject(state);
ArticleInJournalCollection articles = journal.getArticles(); ArticleInJournalCollection articles = journal.getArticles();
@ -313,11 +315,12 @@ public class JournalArticlesTable
return label; return label;
} else { } else {
ControlLink link = new ControlLink( ControlLink link = new ControlLink(
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"cms.contenttypes.ui.journal.articles.down"))); "cms.contenttypes.ui.journal.articles.down")));
return link; return link;
} }
} }
} }
@Override @Override
@ -326,11 +329,11 @@ public class JournalArticlesTable
PageState state = event.getPageState(); PageState state = event.getPageState();
s_log.debug(String.format("RowKey = %s", event.getRowKey().toString())); s_log.debug(String.format("RowKey = %s", event.getRowKey().toString()));
s_log.debug(String.format("Selected column: %d", event.getColumn(). s_log.debug(String.format("Selected column: %d", event.getColumn().
intValue())); intValue()));
ArticleInJournal article = new ArticleInJournal(new BigDecimal(event. ArticleInJournal article = new ArticleInJournal(new BigDecimal(event.
getRowKey(). getRowKey().
toString())); toString()));
Journal journal = (Journal) m_itemModel.getSelectedObject(state); Journal journal = (Journal) m_itemModel.getSelectedObject(state);
@ -353,4 +356,5 @@ public class JournalArticlesTable
public void headSelected(TableActionEvent event) { public void headSelected(TableActionEvent event) {
//Nothing to do //Nothing to do
} }
} }

View File

@ -234,13 +234,12 @@ public class ProceedingsOrganizerSheet
proceedings); proceedings);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.proceedings.organizer.remove.confirm")); "publications.ui.proceedings.organizer.remove.confirm"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -269,13 +269,12 @@ public class ProceedingsPapersTable
proceedings); proceedings);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.proceedings.paper.confirm_remove")); "publications.ui.proceedings.paper.confirm_remove"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -309,7 +309,7 @@ public class PublicationAuthorsTable
ControlLink link = new ControlLink((Label) value); ControlLink link = new ControlLink((Label) value);
return link; return link;
} else { } else {
return (Label) value; return new Label("");
} }
} }
@ -342,7 +342,7 @@ public class PublicationAuthorsTable
"publications.ui.authors.author.confirm_remove")); "publications.ui.authors.author.confirm_remove"));
return link; return link;
} else { } else {
return (Label) value; return new Label("");
} }
} }

View File

@ -55,24 +55,24 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
private ItemSelectionModel itemModel; private ItemSelectionModel itemModel;
public PublicationGenericOrganizationalUnitsTable( public PublicationGenericOrganizationalUnitsTable(
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel) {
super(); super();
this.itemModel = itemModel; this.itemModel = itemModel;
setEmptyView(new Label(PublicationGlobalizationUtil.globalize( setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.orgaunits.none"))); "publications.ui.orgaunits.none")));
final TableColumnModel columnModel = getColumnModel(); final TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
0, 0,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.orgaunits.columns.name")), "publications.ui.orgaunits.columns.name")),
TABLE_COL_EDIT)); TABLE_COL_EDIT));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
1, 1,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.orgaunits.columns.remove")), "publications.ui.orgaunits.columns.remove")),
TABLE_COL_DEL)); TABLE_COL_DEL));
setModelBuilder(new ModelBuilder(itemModel)); setModelBuilder(new ModelBuilder(itemModel));
@ -83,8 +83,8 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
} }
private class ModelBuilder private class ModelBuilder
extends LockableImpl extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private final ItemSelectionModel itemModel; private final ItemSelectionModel itemModel;
@ -97,7 +97,7 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
final PageState state) { final PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
final Publication publication = (Publication) itemModel. final Publication publication = (Publication) itemModel.
getSelectedObject(state); getSelectedObject(state);
return new Model(table, state, publication); return new Model(table, state, publication);
} }
@ -141,7 +141,7 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
return orgaunits.getTitle(); return orgaunits.getTitle();
case 1: case 1:
return new Label(PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.orgaunits.remove")); "publications.ui.orgaunits.remove"));
default: default:
return null; return null;
} }
@ -155,8 +155,8 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
} }
private class EditCellRenderer private class EditCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent(final Table table, public Component getComponent(final Table table,
@ -167,31 +167,30 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
final int row, final int row,
final int column) { final int column) {
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state); final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
final GenericOrganizationalUnit orgaunit = final GenericOrganizationalUnit orgaunit = new GenericOrganizationalUnit(
new GenericOrganizationalUnit( (BigDecimal) key);
(BigDecimal) key);
final boolean canEdit = securityManager.canAccess( final boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM, com.arsdigita.cms.SecurityManager.EDIT_ITEM,
orgaunit); orgaunit);
if (canEdit) { if (canEdit) {
final ContentSection section = orgaunit.getContentSection(); final ContentSection section = orgaunit.getContentSection();
final ItemResolver resolver = section.getItemResolver(); final ItemResolver resolver = section.getItemResolver();
final Link link = new Link( final Link link = new Link(
String.format("%s (%s)", String.format("%s (%s)",
value.toString(), value.toString(),
orgaunit.getLanguage()), orgaunit.getLanguage()),
resolver.generateItemURL(state, resolver.generateItemURL(state,
orgaunit, orgaunit,
section, section,
orgaunit.getVersion())); orgaunit.getVersion()));
return link; return link;
} else { } else {
final Label label = new Label(String.format( final Label label = new Label(String.format(
"%s (%s)", "%s (%s)",
value.toString(), value.toString(),
orgaunit.getLanguage())); orgaunit.getLanguage()));
return label; return label;
} }
} }
@ -199,8 +198,8 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
} }
private class DeleteCellRenderer private class DeleteCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent(final Table table, public Component getComponent(final Table table,
@ -211,23 +210,20 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
final int row, final int row,
final int column) { final int column) {
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state); final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
final Publication publication = final Publication publication = (Publication) itemModel.getSelectedObject(state);
(Publication) itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM, com.arsdigita.cms.SecurityManager.EDIT_ITEM,
publication); publication);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(value.toString()); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.orgaunits.remove.confirm")); "publications.ui.orgaunits.remove.confirm"));
return link; return link;
} else { } else {
final Label label = new Label(""); return new Label("");
return label;
} }
} }
@ -239,14 +235,13 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
public void cellSelected(final TableActionEvent event) { public void cellSelected(final TableActionEvent event) {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
final GenericOrganizationalUnit orgaunit = final GenericOrganizationalUnit orgaunit = new GenericOrganizationalUnit(
new GenericOrganizationalUnit( new BigDecimal(event.getRowKey().toString()));
new BigDecimal(event.getRowKey().toString()));
final Publication publication = (Publication) itemModel. final Publication publication = (Publication) itemModel.
getSelectedObject(state); getSelectedObject(state);
final TableColumn column = getColumnModel().get(event.getColumn(). final TableColumn column = getColumnModel().get(event.getColumn().
intValue()); intValue());
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
//Nothing yet //Nothing yet
@ -264,4 +259,5 @@ public class PublicationGenericOrganizationalUnitsTable extends Table {
} }
} }
} }

View File

@ -46,35 +46,35 @@ import java.math.BigDecimal;
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class PublicationWithPublisherSetPublisherSheet public class PublicationWithPublisherSetPublisherSheet
extends Table extends Table
implements TableActionListener { implements TableActionListener {
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 ItemSelectionModel itemModel; private ItemSelectionModel itemModel;
public PublicationWithPublisherSetPublisherSheet( public PublicationWithPublisherSetPublisherSheet(
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel) {
super(); super();
this.itemModel = itemModel; this.itemModel = itemModel;
setEmptyView(new Label(PublicationGlobalizationUtil.globalize( setEmptyView(new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.with_publisher.publisher.none"))); "publications.ui.with_publisher.publisher.none")));
TableColumnModel columnModel = getColumnModel(); TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
0, 0,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.with_publisher.publisher")), "publications.ui.with_publisher.publisher")),
TABLE_COL_EDIT)); TABLE_COL_EDIT));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
1, 1,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.with_publisher.publisher.remove")), "publications.ui.with_publisher.publisher.remove")),
TABLE_COL_DEL)); TABLE_COL_DEL));
setModelBuilder(new PublicationWithPublisherSetPublisherSheetModelBuilder( setModelBuilder(new PublicationWithPublisherSetPublisherSheetModelBuilder(
itemModel)); itemModel));
columnModel.get(0).setCellRenderer(new EditCellRenderer()); columnModel.get(0).setCellRenderer(new EditCellRenderer());
columnModel.get(1).setCellRenderer((new DeleteCellRenderer())); columnModel.get(1).setCellRenderer((new DeleteCellRenderer()));
@ -82,30 +82,30 @@ public class PublicationWithPublisherSetPublisherSheet
} }
private class PublicationWithPublisherSetPublisherSheetModelBuilder private class PublicationWithPublisherSetPublisherSheetModelBuilder
extends LockableImpl extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private ItemSelectionModel itemModel; private ItemSelectionModel itemModel;
public PublicationWithPublisherSetPublisherSheetModelBuilder( public PublicationWithPublisherSetPublisherSheetModelBuilder(
final ItemSelectionModel itemModel) { final ItemSelectionModel itemModel) {
this.itemModel = itemModel; this.itemModel = itemModel;
} }
@Override @Override
public TableModel makeModel(final Table table, final PageState state) { public TableModel makeModel(final Table table, final PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
PublicationWithPublisher publication = PublicationWithPublisher publication = (PublicationWithPublisher) itemModel.
(PublicationWithPublisher) itemModel. getSelectedObject(state);
getSelectedObject(state);
return new PublicationWithPublisherSetPublisherSheetModel(table, return new PublicationWithPublisherSetPublisherSheetModel(table,
state, state,
publication); publication);
} }
} }
private class PublicationWithPublisherSetPublisherSheetModel private class PublicationWithPublisherSetPublisherSheetModel
implements TableModel { implements TableModel {
private final Table table; private final Table table;
private final Publisher publisher; private final Publisher publisher;
@ -149,7 +149,7 @@ public class PublicationWithPublisherSetPublisherSheet
return publisher.getTitle(); return publisher.getTitle();
case 1: case 1:
return new Label(PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.with_publisher.publisher.remove")); "publications.ui.with_publisher.publisher.remove"));
default: default:
return null; return null;
} }
@ -159,11 +159,12 @@ public class PublicationWithPublisherSetPublisherSheet
public Object getKeyAt(final int columnIndex) { public Object getKeyAt(final int columnIndex) {
return publisher.getID(); return publisher.getID();
} }
} }
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,
@ -173,11 +174,9 @@ public class PublicationWithPublisherSetPublisherSheet
Object key, Object key,
int row, int row,
int column) { int column) {
com.arsdigita.cms.SecurityManager securityManager = com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
CMS.getSecurityManager(state); PublicationWithPublisher publication = (PublicationWithPublisher) itemModel.
PublicationWithPublisher publication = getSelectedObject(state);
(PublicationWithPublisher) itemModel.
getSelectedObject(state);
boolean canEdit = securityManager.canAccess(state.getRequest(), boolean canEdit = securityManager.canAccess(state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM, com.arsdigita.cms.SecurityManager.EDIT_ITEM,
@ -186,26 +185,25 @@ public class PublicationWithPublisherSetPublisherSheet
Publisher publisher; Publisher publisher;
try { try {
publisher = new Publisher( publisher = new Publisher(
(BigDecimal) key); (BigDecimal) key);
} catch (ObjectNotFoundException ex) { } catch (ObjectNotFoundException ex) {
return new Label(value.toString()); return new Label(value.toString());
} }
ContentSection section = publisher.getContentSection();//CMS.getContext().getContentSection(); ContentSection section = publisher.getContentSection();//CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver(); ItemResolver resolver = section.getItemResolver();
Link link = Link link = new Link(value.toString(),
new Link(value.toString(), resolver.generateItemURL(state,
resolver.generateItemURL(state, publisher,
publisher, section,
section, publisher.getVersion()));
publisher.getVersion()));
return link; return link;
} else { } else {
Publisher publisher; Publisher publisher;
try { try {
publisher = new Publisher( publisher = new Publisher(
(BigDecimal) key); (BigDecimal) key);
} catch (ObjectNotFoundException ex) { } catch (ObjectNotFoundException ex) {
return new Label(value.toString()); return new Label(value.toString());
} }
@ -214,11 +212,12 @@ public class PublicationWithPublisherSetPublisherSheet
return label; return label;
} }
} }
} }
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,
@ -228,37 +227,34 @@ public class PublicationWithPublisherSetPublisherSheet
Object key, Object key,
int row, int row,
int col) { int col) {
com.arsdigita.cms.SecurityManager securityManager = com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
CMS.getSecurityManager(state); PublicationWithPublisher publication = (PublicationWithPublisher) itemModel.
PublicationWithPublisher publication = getSelectedObject(
(PublicationWithPublisher) itemModel.
getSelectedObject(
state); state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.DELETE_ITEM, com.arsdigita.cms.SecurityManager.DELETE_ITEM,
publication); publication);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.with_publisher.publisher.remove.confirm")); "publications.ui.with_publisher.publisher.remove.confirm"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }
@Override @Override
public void cellSelected(final TableActionEvent event) { public void cellSelected(final TableActionEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
PublicationWithPublisher publication = PublicationWithPublisher publication = (PublicationWithPublisher) itemModel.
(PublicationWithPublisher) itemModel. getSelectedObject(state);
getSelectedObject(state);
TableColumn column = getColumnModel().get(event.getColumn().intValue()); TableColumn column = getColumnModel().get(event.getColumn().intValue());
@ -273,4 +269,5 @@ public class PublicationWithPublisherSetPublisherSheet
public void headSelected(final TableActionEvent event) { public void headSelected(final TableActionEvent event) {
//Nothing to do //Nothing to do
} }
} }

View File

@ -52,10 +52,11 @@ import org.apache.log4j.Logger;
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class SeriesEditshipTable extends Table implements TableActionListener { public class SeriesEditshipTable extends Table implements TableActionListener {
private static final Logger s_log = private static final Logger s_log = Logger.getLogger(SeriesEditshipTable.class);
Logger.getLogger(SeriesEditshipTable.class);
private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_EDIT_EDITSHIP = "table_col_edit_editship"; private final String TABLE_COL_EDIT_EDITSHIP = "table_col_edit_editship";
private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_DEL = "table_col_del";
@ -71,44 +72,44 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
this.editStep = (SeriesEditshipStep) editStep; this.editStep = (SeriesEditshipStep) editStep;
setEmptyView( setEmptyView(
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.none"))); "publications.ui.series.editship.none")));
TableColumnModel colModel = getColumnModel(); TableColumnModel colModel = getColumnModel();
colModel.add(new TableColumn( colModel.add(new TableColumn(
0, 0,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.name")), "publications.ui.series.editship.name")),
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.editship.from")))); "publications.ui.series.editship.from"))));
colModel.add(new TableColumn( colModel.add(new TableColumn(
2, 2,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.to")))); "publications.ui.series.editship.to"))));
colModel.add(new TableColumn( colModel.add(new TableColumn(
3, 3,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.edit")), "publications.ui.series.editship.edit")),
TABLE_COL_EDIT_EDITSHIP)); TABLE_COL_EDIT_EDITSHIP));
colModel.add(new TableColumn( colModel.add(new TableColumn(
4, 4,
new Label(PublicationGlobalizationUtil.globalize( new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.remove")), "publications.ui.series.editship.remove")),
TABLE_COL_DEL)); TABLE_COL_DEL));
/* Just in the case someone want's to sort editships manually..." */ /* Just in the case someone want's to sort editships manually..." */
/* colModel.add(new TableColumn( /* colModel.add(new TableColumn(
5, 5,
PublicationGlobalizationUtil.globalize( PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.up").localize(), "publications.ui.series.editship.up").localize(),
TABLE_COL_UP)); TABLE_COL_UP));
colModel.add(new TableColumn( colModel.add(new TableColumn(
6, 6,
PublicationGlobalizationUtil.globalize( PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.down").localize(), "publications.ui.series.editship.down").localize(),
TABLE_COL_DOWN));*/ TABLE_COL_DOWN));*/
setModelBuilder(new SeriesEditshipTableModelBuilder(itemModel)); setModelBuilder(new SeriesEditshipTableModelBuilder(itemModel));
@ -122,22 +123,22 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
} }
private class SeriesEditshipTableModelBuilder private class SeriesEditshipTableModelBuilder
extends LockableImpl extends LockableImpl
implements TableModelBuilder { implements TableModelBuilder {
private ItemSelectionModel m_itemModel; private ItemSelectionModel m_itemModel;
public SeriesEditshipTableModelBuilder( public SeriesEditshipTableModelBuilder(
ItemSelectionModel itemModel) { ItemSelectionModel itemModel) {
m_itemModel = itemModel; m_itemModel = itemModel;
} }
public TableModel makeModel(Table table, PageState state) { public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state); table.getRowSelectionModel().clearSelection(state);
Series series = Series series = (Series) m_itemModel.getSelectedObject(state);
(Series) m_itemModel.getSelectedObject(state);
return new SeriesEditshipTableModel(table, state, series); return new SeriesEditshipTableModel(table, state, series);
} }
} }
private class SeriesEditshipTableModel implements TableModel { private class SeriesEditshipTableModel implements TableModel {
@ -148,9 +149,9 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
private GenericPerson m_editor; private GenericPerson m_editor;
private SeriesEditshipTableModel( private SeriesEditshipTableModel(
Table table, Table table,
PageState state, PageState state,
Series series) { Series series) {
m_table = table; m_table = table;
m_editshipCollection = series.getEditors(); m_editshipCollection = series.getEditors();
} }
@ -182,27 +183,27 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
case 1: case 1:
if (m_editshipCollection.getFrom() == null) { if (m_editshipCollection.getFrom() == null) {
return ContenttypesGlobalizationUtil.globalize( return ContenttypesGlobalizationUtil.globalize(
"cms.ui.unknown").localize(); "cms.ui.unknown").localize();
} else { } else {
return DateFormat.getDateInstance(DateFormat.LONG). return DateFormat.getDateInstance(DateFormat.LONG).
format( format(
m_editshipCollection.getFrom()); m_editshipCollection.getFrom());
} }
case 2: case 2:
if (m_editshipCollection.getTo() == null) { if (m_editshipCollection.getTo() == null) {
return ContenttypesGlobalizationUtil.globalize( return ContenttypesGlobalizationUtil.globalize(
"cms.ui.unknown").localize(); "cms.ui.unknown").localize();
} else { } else {
return DateFormat.getDateInstance(DateFormat.LONG). return DateFormat.getDateInstance(DateFormat.LONG).
format( format(
m_editshipCollection.getTo()); m_editshipCollection.getTo());
} }
case 3: case 3:
return new Label(PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.edit")); "publications.ui.series.editship.edit"));
case 4: case 4:
return new Label(PublicationGlobalizationUtil.globalize( return new Label(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.remove")); "publications.ui.series.editship.remove"));
default: default:
return null; return null;
} }
@ -211,29 +212,29 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
public Object getKeyAt(int columnIndex) { public Object getKeyAt(int columnIndex) {
return m_editor.getID(); return m_editor.getID();
} }
} }
private class EditCellRenderer private class EditCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
SecurityManager securityManager = SecurityManager securityManager = CMS.getSecurityManager(state);
CMS.getSecurityManager(state);
Series series = (Series) m_itemModel.getSelectedObject(state); Series series = (Series) m_itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.EDIT_ITEM, SecurityManager.EDIT_ITEM,
series); series);
if (canEdit) { if (canEdit) {
GenericPerson editor; GenericPerson editor;
@ -247,14 +248,13 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
} }
ContentSection section = editor.getContentSection();//CMS.getContext().getContentSection(); ContentSection section = editor.getContentSection();//CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver(); ItemResolver resolver = section.getItemResolver();
Link link = Link link = new Link(String.format("%s",
new Link(String.format("%s", value.toString(),
value.toString(), editor.getLanguage()),
editor.getLanguage()), resolver.generateItemURL(state,
resolver.generateItemURL(state, editor,
editor, section,
section, editor.getVersion()));
editor.getVersion()));
return link; return link;
} else { } else {
@ -273,11 +273,12 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
return label; return label;
} }
} }
} }
private class EditEditshipCellRenderer private class EditEditshipCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent(Table table, public Component getComponent(Table table,
@ -287,122 +288,119 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
Object key, Object key,
int row, int row,
int col) { int col) {
SecurityManager securityManager = SecurityManager securityManager = CMS.getSecurityManager(state);
CMS.getSecurityManager(state);
Series series = (Series) m_itemModel.getSelectedObject(state); Series series = (Series) m_itemModel.getSelectedObject(state);
boolean canEdit = securityManager.canAccess( boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.EDIT_ITEM, SecurityManager.EDIT_ITEM,
series); series);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }
private class DeleteCellRenderer private class DeleteCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
SecurityManager securityManager = SecurityManager securityManager = Utilities.getSecurityManager(state);
Utilities.getSecurityManager(state);
Series series = (Series) m_itemModel.getSelectedObject(state); Series series = (Series) m_itemModel.getSelectedObject(state);
boolean canDelete = securityManager.canAccess( boolean canDelete = securityManager.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.DELETE_ITEM, SecurityManager.DELETE_ITEM,
series); series);
if (canDelete) { if (canDelete) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.series.editship.remove.confirm")); "publications.ui.series.editship.remove.confirm"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }
/* /*
private class UpCellRenderer private class UpCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
if (0 == row) { if (0 == row) {
s_log.debug("Row is first row in table, don't show up link"); s_log.debug("Row is first row in table, don't show up link");
Label label = new Label(""); Label label = new Label("");
return label; return label;
} else { } else {
ControlLink link = new ControlLink("up"); ControlLink link = new ControlLink("up");
return link; return link;
} }
} }
}*/ }*/
/* /*
private class DownCellRenderer private class DownCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
Series = (Series) m_itemModel. Series = (Series) m_itemModel.
getSelectedObject(state); getSelectedObject(state);
EditshipCollection editors = series.getEditors(); EditshipCollection editors = series.getEditors();
if ((editors.size() - 1) if ((editors.size() - 1)
== row) { == row) {
s_log.debug("Row is last row in table, don't show down link"); s_log.debug("Row is last row in table, don't show down link");
Label label = new Label(""); Label label = new Label("");
return label; return label;
} else { } else {
ControlLink link = new ControlLink("down"); ControlLink link = new ControlLink("down");
return link; return link;
} }
} }
}*/ }*/
@Override @Override
public void cellSelected(TableActionEvent event) { public void cellSelected(TableActionEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
GenericPerson editor = GenericPerson editor = new GenericPerson(new BigDecimal(event.getRowKey().
new GenericPerson(new BigDecimal(event.getRowKey(). toString()));
toString()));
Series series = (Series) m_itemModel.getSelectedObject(state); Series series = (Series) m_itemModel.getSelectedObject(state);
@ -412,7 +410,7 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) {
} else if (TABLE_COL_EDIT_EDITSHIP.equals(column.getHeaderKey(). } else if (TABLE_COL_EDIT_EDITSHIP.equals(column.getHeaderKey().
toString())) { toString())) {
while (editors.next()) { while (editors.next()) {
if (editors.getEditor().equals(editor)) { if (editors.getEditor().equals(editor)) {
break; break;
@ -431,11 +429,11 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
series.removeEditor(editor); series.removeEditor(editor);
} }
/* /*
else if(TABLE_COL_UP.equals(column.getHeaderKey().toString())) { else if(TABLE_COL_UP.equals(column.getHeaderKey().toString())) {
editors.swapWithPrevious(editor); editors.swapWithPrevious(editor);
} else if(TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) { } else if(TABLE_COL_DOWN.equals(column.getHeaderKey().toString())) {
authors.swapWithNext(editor); authors.swapWithNext(editor);
} }
*/ */
} }
@ -443,4 +441,5 @@ public class SeriesEditshipTable extends Table implements TableActionListener {
public void headSelected(TableActionEvent event) { public void headSelected(TableActionEvent event) {
//Nothing to do here. //Nothing to do here.
} }
} }

View File

@ -257,9 +257,9 @@ public class SeriesVolumesTable extends Table {
series); series);
if (canEdit) { if (canEdit) {
return new ControlLink(value.toString()); return new ControlLink((Label)value);
} else { } else {
return new Label(value.toString()); return new Label("");
} }
} }
@ -284,13 +284,12 @@ public class SeriesVolumesTable extends Table {
series); series);
if (canDelete) { if (canDelete) {
final ControlLink link = new ControlLink(value.toString()); final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.series.volumes.remove.confirm")); "publications.ui.series.volumes.remove.confirm"));
return link; return link;
} else { } else {
final Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }

View File

@ -234,13 +234,12 @@ public class UnPublishedOrganizationSheet
unPublished); unPublished);
if (canEdit) { if (canEdit) {
ControlLink link = new ControlLink(value.toString()); ControlLink link = new ControlLink((Label)value);
link.setConfirmation(PublicationGlobalizationUtil.globalize( link.setConfirmation(PublicationGlobalizationUtil.globalize(
"publications.ui.unpublished.organization.confirm_remove")); "publications.ui.unpublished.organization.confirm_remove"));
return link; return link;
} else { } else {
Label label = new Label(value.toString()); return new Label("");
return label;
} }
} }
} }

View File

@ -49,34 +49,34 @@ public class SciProjectSponsorSheet extends Table {
this.editStep = editStep; this.editStep = editStep;
setEmptyView(new Label(SciProjectGlobalizationUtil.globalize( setEmptyView(new Label(SciProjectGlobalizationUtil.globalize(
"sciproject.ui.sponsor_none"))); "sciproject.ui.sponsor_none")));
final TableColumnModel columnModel = getColumnModel(); final TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
0, 0,
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_name"), SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_name"),
TABLE_COL_EDIT)); TABLE_COL_EDIT));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
1, 1,
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_fundingcode"))); SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_fundingcode")));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
2, 2,
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_edit_assoc"), SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_edit_assoc"),
TABLE_COL_EDIT_ASSOC)); TABLE_COL_EDIT_ASSOC));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
3, 3,
SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_remove"), SciProjectGlobalizationUtil.globalize("sciproject.ui.sponsor_remove"),
TABLE_COL_DEL)); TABLE_COL_DEL));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
4, 4,
SciProjectGlobalizationUtil.globalize( SciProjectGlobalizationUtil.globalize(
"sciproject.ui.sponsor.up"), "sciproject.ui.sponsor.up"),
TABLE_COL_UP)); TABLE_COL_UP));
columnModel.add(new TableColumn( columnModel.add(new TableColumn(
5, 5,
SciProjectGlobalizationUtil.globalize( SciProjectGlobalizationUtil.globalize(
"sciproject.ui.sponsor.down"), "sciproject.ui.sponsor.down"),
TABLE_COL_DOWN)); TABLE_COL_DOWN));
setModelBuilder(new ModelBuilder(itemModel)); setModelBuilder(new ModelBuilder(itemModel));
@ -144,10 +144,10 @@ public class SciProjectSponsorSheet extends Table {
return sponsors.getFundingCode(); return sponsors.getFundingCode();
case 2: case 2:
return new Label(SciProjectGlobalizationUtil.globalize( return new Label(SciProjectGlobalizationUtil.globalize(
"sciproject.ui.sponsor.edit_assoc")); "sciproject.ui.sponsor.edit_assoc"));
case 3: case 3:
return new Label(SciProjectGlobalizationUtil.globalize( return new Label(SciProjectGlobalizationUtil.globalize(
"sciproject.ui.sponsor.remove")); "sciproject.ui.sponsor.remove"));
default: default:
return null; return null;
} }
@ -171,13 +171,13 @@ public class SciProjectSponsorSheet extends Table {
final int row, final int row,
final int column) { final int column) {
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state); final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
final GenericOrganizationalUnit sponsor = final GenericOrganizationalUnit sponsor
new GenericOrganizationalUnit((BigDecimal) key); = new GenericOrganizationalUnit((BigDecimal) key);
final boolean canEdit = securityManager.canAccess( final boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM, com.arsdigita.cms.SecurityManager.EDIT_ITEM,
sponsor); sponsor);
if (canEdit) { if (canEdit) {
final ContentSection section = sponsor.getContentSection(); final ContentSection section = sponsor.getContentSection();
final ItemResolver resolver = section.getItemResolver(); final ItemResolver resolver = section.getItemResolver();
@ -200,8 +200,8 @@ public class SciProjectSponsorSheet extends Table {
} }
private class EditAssocCellRenderer private class EditAssocCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent(final Table table, public Component getComponent(final Table table,
@ -215,16 +215,15 @@ public class SciProjectSponsorSheet extends Table {
final SciProject project = (SciProject) itemModel.getSelectedObject(state); final SciProject project = (SciProject) itemModel.getSelectedObject(state);
final boolean canEdit = securityManager.canAccess( final boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM, com.arsdigita.cms.SecurityManager.EDIT_ITEM,
project); project);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(value.toString()); final ControlLink link = new ControlLink((Label) value);
return link; return link;
} else { } else {
final Label label = new Label(value.toString()); return (Label) value;
return label;
} }
} }
@ -242,17 +241,17 @@ public class SciProjectSponsorSheet extends Table {
final int row, final int row,
final int column) { final int column) {
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state); final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
final GenericOrganizationalUnit sponsor = final GenericOrganizationalUnit sponsor
new GenericOrganizationalUnit((BigDecimal) key); = new GenericOrganizationalUnit((BigDecimal) key);
final boolean canEdit = securityManager.canAccess( final boolean canEdit = securityManager.canAccess(
state.getRequest(), state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM, com.arsdigita.cms.SecurityManager.EDIT_ITEM,
sponsor); sponsor);
if (canEdit) { if (canEdit) {
final ControlLink link = new ControlLink(value.toString()); final ControlLink link = new ControlLink((Label)value);
link.setConfirmation(SciProjectGlobalizationUtil.globalize( link.setConfirmation(SciProjectGlobalizationUtil.globalize(
"sciproject.ui.sponsor.remove.confirm")); "sciproject.ui.sponsor.remove.confirm"));
return link; return link;
} else { } else {
return new Label(""); return new Label("");
@ -265,13 +264,13 @@ public class SciProjectSponsorSheet extends Table {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
if (0 == row) { if (0 == row) {
final Label label = new Label(); final Label label = new Label();
return label; return label;
@ -284,18 +283,18 @@ public class SciProjectSponsorSheet extends Table {
} }
private class DownCellRenderer private class DownCellRenderer
extends LockableImpl extends LockableImpl
implements TableCellRenderer { implements TableCellRenderer {
@Override @Override
public Component getComponent( public Component getComponent(
Table table, Table table,
PageState state, PageState state,
Object value, Object value,
boolean isSelected, boolean isSelected,
Object key, Object key,
int row, int row,
int col) { int col) {
final SciProject project = (SciProject) itemModel.getSelectedObject(state); final SciProject project = (SciProject) itemModel.getSelectedObject(state);
final SciProjectSponsorCollection sponsors = project.getSponsors(); final SciProjectSponsorCollection sponsors = project.getSponsors();
@ -318,7 +317,7 @@ public class SciProjectSponsorSheet extends Table {
final PageState state = event.getPageState(); final PageState state = event.getPageState();
final GenericOrganizationalUnit sponsor = new GenericOrganizationalUnit(new BigDecimal( final GenericOrganizationalUnit sponsor = new GenericOrganizationalUnit(new BigDecimal(
event.getRowKey().toString())); event.getRowKey().toString()));
final SciProject project = (SciProject) itemModel.getSelectedObject(state); final SciProject project = (SciProject) itemModel.getSelectedObject(state);
final SciProjectSponsorCollection sponsors = project.getSponsors(); final SciProjectSponsorCollection sponsors = project.getSponsors();
@ -336,7 +335,7 @@ public class SciProjectSponsorSheet extends Table {
((SciProjectSponsorStep) editStep).setSelectedSponsor(sponsor); ((SciProjectSponsorStep) editStep).setSelectedSponsor(sponsor);
((SciProjectSponsorStep) editStep).setSelectedSponsorFundingCode(sponsors. ((SciProjectSponsorStep) editStep).setSelectedSponsorFundingCode(sponsors.
getFundingCode()); getFundingCode());
editStep.showComponent(state, editStep.showComponent(state,
SciProjectSponsorStep.SCIPROJECT_SPONSOR_STEP); SciProjectSponsorStep.SCIPROJECT_SPONSOR_STEP);
@ -360,4 +359,5 @@ public class SciProjectSponsorSheet extends Table {
} }
} }
} }