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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -141,8 +141,8 @@ public class SciPublicationsAboutDiscussesTable extends Table implements TableAc
case 0:
return discussed.getTitle();
case 1:
return SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discusses.publication.remove");
return new Label(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discusses.publication.remove"));
default:
return null;
}
@ -215,12 +215,12 @@ public class SciPublicationsAboutDiscussesTable extends Table implements TableAc
discussing);
if (canEdit) {
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value));
final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discusses.publication.remove.confirm"));
return link;
} 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(
0,
SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication")));
"com.arsdigita.cms.contentassets.about.discussing.publication")));
colModel.add(new TableColumn(
1,
SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication.remove"),
"com.arsdigita.cms.contentassets.about.discussing.publication.remove"),
TABLE_COL_DEL));
setModelBuilder(new SciPublicationsAboutTableModelBuilder(itemModel));
@ -134,15 +134,15 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
return ret;
}
@Override
public Object getElementAt(final int columnIndex) {
switch (columnIndex) {
case 0:
return discussing.getTitle();
case 1:
return SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication.remove");
return new Label(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication.remove"));
default:
return null;
}
@ -152,10 +152,11 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
public Object getKeyAt(final int columnIndex) {
return discussing.getID();
}
}
private class PublicationCellRenderer extends LockableImpl implements TableCellRenderer {
@Override
public Component getComponent(final Table table,
final PageState state,
@ -192,10 +193,10 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
return new Label(value.toString());
}
}
}
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer {
@Override
public Component getComponent(final Table table,
@ -207,19 +208,19 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
final int column) {
final com.arsdigita.cms.SecurityManager securityManager = CMS.getSecurityManager(state);
final Publication discussed = (Publication) itemModel.getSelectedObject(state);
final boolean canEdit = securityManager.canAccess(
state.getRequest(),
state.getRequest(),
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
discussed);
if (canEdit) {
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value));
final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(SciPublicationsAboutGlobalizationUtil.globalize(
"com.arsdigita.cms.contentassets.about.discussing.publication.remove.confirm"));
return link;
} else {
return new Label(value.toString());
return new Label("");
}
}
@ -227,15 +228,15 @@ public class SciPublicationsAboutDiscussingTable extends Table implements TableA
@Override
public void cellSelected(final TableActionEvent event) {
final PageState state = event.getPageState();
final Publication discussing = new Publication(new BigDecimal(event.getRowKey().toString()));
final Publication discussed = (Publication) itemModel.getSelectedObject(state);
final SciPublicationsAboutService service = new SciPublicationsAboutService();
final TableColumn column = getColumn(event.getColumn().intValue());
if (TABLE_COL_DEL.equals(column.getHeaderKey())) {
service.removeDiscussingPublication(discussed, discussing);
}

View File

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

View File

@ -161,8 +161,8 @@ public class SciPublicationsPersonsPersonTable extends Table implements TableAct
case 1:
return relation;
case 2:
return globalisationUtil.globalize(
"com.arsdigita.cms.contentassets.publication_persons.person.remove");
return new Label(globalisationUtil.globalize(
"com.arsdigita.cms.contentassets.publication_persons.person.remove"));
default:
return null;
}
@ -230,28 +230,12 @@ public class SciPublicationsPersonsPersonTable extends Table implements TableAct
final int row,
final int column) {
final GlobalizedMessage relation = new GlobalizedMessage((String) value,
SciPublicationsPersonsService.RELATION_ATTRIBUTE,
new RelationAttributeResourceBundleControl());
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);
// }
final GlobalizedMessage relation = new GlobalizedMessage(
(String) value,
SciPublicationsPersonsService.RELATION_ATTRIBUTE,
new RelationAttributeResourceBundleControl());
//return new Label(value.toString());
return new Label(relation);
}
}
@ -275,12 +259,12 @@ public class SciPublicationsPersonsPersonTable extends Table implements TableAct
publication);
if (canEdit) {
final ControlLink link = new ControlLink(new Label((GlobalizedMessage) value));
final ControlLink link = new ControlLink((Label) value);
link.setConfirmation(globalisationUtil.globalize(
"com.arsdigita.cms.contentassets.publications_persons.person.remove.confirm"));
return link;
} else {
return new Label((GlobalizedMessage) value);
return new Label("");
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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