|
|
|
@ -32,8 +32,6 @@ import com.arsdigita.bebop.SimpleContainer;
|
|
|
|
import com.arsdigita.bebop.Table;
|
|
|
|
import com.arsdigita.bebop.Table;
|
|
|
|
import com.arsdigita.bebop.event.ActionEvent;
|
|
|
|
import com.arsdigita.bebop.event.ActionEvent;
|
|
|
|
import com.arsdigita.bebop.event.ActionListener;
|
|
|
|
import com.arsdigita.bebop.event.ActionListener;
|
|
|
|
import com.arsdigita.bebop.event.ChangeEvent;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.event.ChangeListener;
|
|
|
|
|
|
|
|
import com.arsdigita.bebop.event.TableActionAdapter;
|
|
|
|
import com.arsdigita.bebop.event.TableActionAdapter;
|
|
|
|
import com.arsdigita.bebop.event.TableActionEvent;
|
|
|
|
import com.arsdigita.bebop.event.TableActionEvent;
|
|
|
|
import com.arsdigita.bebop.event.TableActionListener;
|
|
|
|
import com.arsdigita.bebop.event.TableActionListener;
|
|
|
|
@ -45,12 +43,7 @@ import com.arsdigita.bebop.table.TableCellRenderer;
|
|
|
|
import com.arsdigita.bebop.table.TableColumn;
|
|
|
|
import com.arsdigita.bebop.table.TableColumn;
|
|
|
|
import com.arsdigita.bebop.table.TableHeader;
|
|
|
|
import com.arsdigita.bebop.table.TableHeader;
|
|
|
|
import com.arsdigita.bebop.table.TableModel;
|
|
|
|
import com.arsdigita.bebop.table.TableModel;
|
|
|
|
import com.arsdigita.cms.CMS;
|
|
|
|
import com.arsdigita.cms.*;
|
|
|
|
import com.arsdigita.cms.ContentBundle;
|
|
|
|
|
|
|
|
import com.arsdigita.cms.ContentItem;
|
|
|
|
|
|
|
|
import com.arsdigita.cms.ContentSection;
|
|
|
|
|
|
|
|
import com.arsdigita.cms.Folder;
|
|
|
|
|
|
|
|
import com.arsdigita.cms.ItemCollection;
|
|
|
|
|
|
|
|
import com.arsdigita.cms.SecurityManager;
|
|
|
|
import com.arsdigita.cms.SecurityManager;
|
|
|
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
|
|
|
import com.arsdigita.cms.dispatcher.ItemResolver;
|
|
|
|
import com.arsdigita.cms.dispatcher.Utilities;
|
|
|
|
import com.arsdigita.cms.dispatcher.Utilities;
|
|
|
|
@ -68,12 +61,13 @@ import com.arsdigita.util.Assert;
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Browse folders and items. If the user clicks on a folder, the folder
|
|
|
|
* Browse folders and items. If the user clicks on a folder, the folder
|
|
|
|
* selection model is updated. If the user clicks on any other item, an
|
|
|
|
* selection model is updated. If the user clicks on any other item, an separate
|
|
|
|
* separate item selection model is updated.
|
|
|
|
* item selection model is updated.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author <a href="mailto:lutter@arsdigita.com">David Lutterkort</a>
|
|
|
|
* @author <a href="mailto:lutter@arsdigita.com">David Lutterkort</a>
|
|
|
|
* @version $Id: FolderBrowser.java 2017 2009-10-04 09:03:45Z pboy $
|
|
|
|
* @version $Id: FolderBrowser.java 2017 2009-10-04 09:03:45Z pboy $
|
|
|
|
@ -82,18 +76,22 @@ public class FolderBrowser extends Table {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger s_log = Logger.getLogger(FolderBrowser.class);
|
|
|
|
private static final Logger s_log = Logger.getLogger(FolderBrowser.class);
|
|
|
|
private static GlobalizedMessage[] s_headers = {
|
|
|
|
private static GlobalizedMessage[] s_headers = {
|
|
|
|
globalize("cms.ui.folder.name"), globalize("cms.ui.folder.title"),
|
|
|
|
globalize("cms.ui.folder.name"),
|
|
|
|
|
|
|
|
globalize("cms.ui.folder.languages"),
|
|
|
|
|
|
|
|
globalize("cms.ui.folder.title"),
|
|
|
|
globalize("cms.ui.folder.type"),
|
|
|
|
globalize("cms.ui.folder.type"),
|
|
|
|
globalize("cms.ui.folder.creation_date"),
|
|
|
|
globalize("cms.ui.folder.creation_date"),
|
|
|
|
globalize("cms.ui.folder.last_modified"), globalize(
|
|
|
|
globalize("cms.ui.folder.last_modified"),
|
|
|
|
"cms.ui.folder.action"),
|
|
|
|
globalize("cms.ui.folder.action"),
|
|
|
|
globalize("cms.ui.folder.index")};
|
|
|
|
globalize("cms.ui.folder.index")};
|
|
|
|
private static GlobalizedMessage[] s_noIndexHeaders = {
|
|
|
|
private static GlobalizedMessage[] s_noIndexHeaders = {
|
|
|
|
globalize("cms.ui.folder.name"), globalize("cms.ui.folder.title"),
|
|
|
|
globalize("cms.ui.folder.name"),
|
|
|
|
|
|
|
|
globalize("cms.ui.folder.languages"),
|
|
|
|
|
|
|
|
globalize("cms.ui.folder.title"),
|
|
|
|
globalize("cms.ui.folder.type"),
|
|
|
|
globalize("cms.ui.folder.type"),
|
|
|
|
globalize("cms.ui.folder.creation_date"),
|
|
|
|
globalize("cms.ui.folder.creation_date"),
|
|
|
|
globalize("cms.ui.folder.last_modified"), globalize(
|
|
|
|
globalize("cms.ui.folder.last_modified"),
|
|
|
|
"cms.ui.folder.action")};
|
|
|
|
globalize("cms.ui.folder.action")};
|
|
|
|
private static final String SORT_ACTION_UP = "sortActionUp";
|
|
|
|
private static final String SORT_ACTION_UP = "sortActionUp";
|
|
|
|
private static final String SORT_ACTION_DOWN = "sortActionDown";
|
|
|
|
private static final String SORT_ACTION_DOWN = "sortActionDown";
|
|
|
|
private FolderSelectionModel m_currentFolder;
|
|
|
|
private FolderSelectionModel m_currentFolder;
|
|
|
|
@ -122,8 +120,8 @@ public class FolderBrowser extends Table {
|
|
|
|
|
|
|
|
|
|
|
|
setModelBuilder(new FolderTableModelBuilder(currentFolder));
|
|
|
|
setModelBuilder(new FolderTableModelBuilder(currentFolder));
|
|
|
|
setColumnModel(new DefaultTableColumnModel(hideIndexColumn()
|
|
|
|
setColumnModel(new DefaultTableColumnModel(hideIndexColumn()
|
|
|
|
? s_noIndexHeaders
|
|
|
|
? s_noIndexHeaders
|
|
|
|
: s_headers));
|
|
|
|
: s_headers));
|
|
|
|
setHeader(new TableHeader(getColumnModel()));
|
|
|
|
setHeader(new TableHeader(getColumnModel()));
|
|
|
|
// DEE 1/18/02: the folder table model builder needs to know about
|
|
|
|
// DEE 1/18/02: the folder table model builder needs to know about
|
|
|
|
// 'this' in order to set visibility, but 'this' isn't available
|
|
|
|
// 'this' in order to set visibility, but 'this' isn't available
|
|
|
|
@ -139,22 +137,22 @@ public class FolderBrowser extends Table {
|
|
|
|
m_currentFolder = currentFolder;
|
|
|
|
m_currentFolder = currentFolder;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
|
|
|
|
*
|
|
|
|
This code should be uncommented if the desired behaviour is for a change
|
|
|
|
* This code should be uncommented if the desired behaviour is for a
|
|
|
|
of folder to cause reversion to default ordering of contained items
|
|
|
|
* change of folder to cause reversion to default ordering of contained
|
|
|
|
(by name ascending). Our feeling is that the user selected ordering
|
|
|
|
* items (by name ascending). Our feeling is that the user selected
|
|
|
|
should be retained for the duration of the folder browsing session. If
|
|
|
|
* ordering should be retained for the duration of the folder browsing
|
|
|
|
anyone wants this alternative behaviour it should be brought in under
|
|
|
|
* session. If anyone wants this alternative behaviour it should be
|
|
|
|
the control of a config parameter.
|
|
|
|
* brought in under the control of a config parameter.
|
|
|
|
|
|
|
|
*
|
|
|
|
m_currentFolder.addChangeListener(new ChangeListener() {
|
|
|
|
* m_currentFolder.addChangeListener(new ChangeListener() {
|
|
|
|
|
|
|
|
*
|
|
|
|
public void stateChanged(ChangeEvent e) {
|
|
|
|
* public void stateChanged(ChangeEvent e) { PageState state =
|
|
|
|
PageState state = e.getPageState();
|
|
|
|
* e.getPageState(); state.setValue(m_sortType,
|
|
|
|
state.setValue(m_sortType, m_sortType.getDefaultValue());
|
|
|
|
* m_sortType.getDefaultValue()); state.setValue(m_sortDirection,
|
|
|
|
state.setValue(m_sortDirection, m_sortDirection.getDefaultValue());
|
|
|
|
* m_sortDirection.getDefaultValue());
|
|
|
|
|
|
|
|
*
|
|
|
|
}});
|
|
|
|
* }});
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
setClassAttr("dataTable");
|
|
|
|
setClassAttr("dataTable");
|
|
|
|
|
|
|
|
|
|
|
|
@ -164,16 +162,17 @@ public class FolderBrowser extends Table {
|
|
|
|
m_nameColumn = getColumn(0);
|
|
|
|
m_nameColumn = getColumn(0);
|
|
|
|
m_nameColumn.setCellRenderer(new NameCellRenderer());
|
|
|
|
m_nameColumn.setCellRenderer(new NameCellRenderer());
|
|
|
|
m_nameColumn.setHeaderRenderer(new HeaderCellRenderer(SORT_KEY_NAME));
|
|
|
|
m_nameColumn.setHeaderRenderer(new HeaderCellRenderer(SORT_KEY_NAME));
|
|
|
|
getColumn(1).setHeaderRenderer(new HeaderCellRenderer(SORT_KEY_TITLE));
|
|
|
|
getColumn(1).setCellRenderer(new LanguagesCellRenderer());
|
|
|
|
getColumn(3).setHeaderRenderer(new HeaderCellRenderer(
|
|
|
|
getColumn(2).setHeaderRenderer(new HeaderCellRenderer(SORT_KEY_TITLE));
|
|
|
|
SORT_KEY_CREATION_DATE));
|
|
|
|
|
|
|
|
getColumn(4).setHeaderRenderer(new HeaderCellRenderer(
|
|
|
|
getColumn(4).setHeaderRenderer(new HeaderCellRenderer(
|
|
|
|
|
|
|
|
SORT_KEY_CREATION_DATE));
|
|
|
|
|
|
|
|
getColumn(5).setHeaderRenderer(new HeaderCellRenderer(
|
|
|
|
SORT_KEY_LAST_MODIFIED_DATE));
|
|
|
|
SORT_KEY_LAST_MODIFIED_DATE));
|
|
|
|
m_deleteColumn = getColumn(5);
|
|
|
|
m_deleteColumn = getColumn(6);
|
|
|
|
m_deleteColumn.setCellRenderer(new ActionCellRenderer());
|
|
|
|
m_deleteColumn.setCellRenderer(new ActionCellRenderer());
|
|
|
|
m_deleteColumn.setAlign("center");
|
|
|
|
m_deleteColumn.setAlign("center");
|
|
|
|
if (!hideIndexColumn()) {
|
|
|
|
if (!hideIndexColumn()) {
|
|
|
|
m_indexColumn = getColumn(6);
|
|
|
|
m_indexColumn = getColumn(7);
|
|
|
|
m_indexColumn.setCellRenderer(new IndexToggleRenderer());
|
|
|
|
m_indexColumn.setCellRenderer(new IndexToggleRenderer());
|
|
|
|
m_indexColumn.setAlign("center");
|
|
|
|
m_indexColumn.setAlign("center");
|
|
|
|
|
|
|
|
|
|
|
|
@ -217,7 +216,7 @@ public class FolderBrowser extends Table {
|
|
|
|
|
|
|
|
|
|
|
|
boolean canDelete =
|
|
|
|
boolean canDelete =
|
|
|
|
sm.canAccess(state.getRequest(), SecurityManager.DELETE_ITEM,
|
|
|
|
sm.canAccess(state.getRequest(), SecurityManager.DELETE_ITEM,
|
|
|
|
folder);
|
|
|
|
folder);
|
|
|
|
|
|
|
|
|
|
|
|
m_deleteColumn.setVisible(state, canDelete);
|
|
|
|
m_deleteColumn.setVisible(state, canDelete);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -261,7 +260,7 @@ public class FolderBrowser extends Table {
|
|
|
|
private class FolderTableModelBuilder
|
|
|
|
private class FolderTableModelBuilder
|
|
|
|
extends AbstractTableModelBuilder
|
|
|
|
extends AbstractTableModelBuilder
|
|
|
|
implements PaginationModelBuilder,
|
|
|
|
implements PaginationModelBuilder,
|
|
|
|
FolderManipulator.FilterFormModelBuilder {
|
|
|
|
FolderManipulator.FilterFormModelBuilder {
|
|
|
|
|
|
|
|
|
|
|
|
private FolderSelectionModel m_folder;
|
|
|
|
private FolderSelectionModel m_folder;
|
|
|
|
private RequestLocal m_size;
|
|
|
|
private RequestLocal m_size;
|
|
|
|
@ -273,7 +272,7 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FolderTableModelBuilder(FolderSelectionModel sel,
|
|
|
|
public FolderTableModelBuilder(FolderSelectionModel sel,
|
|
|
|
FolderBrowser fb) {
|
|
|
|
FolderBrowser fb) {
|
|
|
|
super();
|
|
|
|
super();
|
|
|
|
m_folder = sel;
|
|
|
|
m_folder = sel;
|
|
|
|
m_size = new RequestLocal();
|
|
|
|
m_size = new RequestLocal();
|
|
|
|
@ -282,8 +281,7 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TableModel makeModel(Table t, PageState s) {
|
|
|
|
public TableModel makeModel(Table t, PageState s) {
|
|
|
|
FolderSelectionModel sel = ((FolderBrowser) t).
|
|
|
|
FolderSelectionModel sel = ((FolderBrowser) t).getFolderSelectionModel();
|
|
|
|
getFolderSelectionModel();
|
|
|
|
|
|
|
|
Folder f = (Folder) sel.getSelectedObject(s);
|
|
|
|
Folder f = (Folder) sel.getSelectedObject(s);
|
|
|
|
if (f == null) {
|
|
|
|
if (f == null) {
|
|
|
|
return Table.EMPTY_MODEL;
|
|
|
|
return Table.EMPTY_MODEL;
|
|
|
|
@ -291,7 +289,7 @@ public class FolderBrowser extends Table {
|
|
|
|
t.getRowSelectionModel().clearSelection(s);
|
|
|
|
t.getRowSelectionModel().clearSelection(s);
|
|
|
|
s_log.debug(String.format("filter = '%s'", s.getValue(m_filter)));
|
|
|
|
s_log.debug(String.format("filter = '%s'", s.getValue(m_filter)));
|
|
|
|
Folder.ItemCollection itemColl =
|
|
|
|
Folder.ItemCollection itemColl =
|
|
|
|
(Folder.ItemCollection) m_itemColl.get(s);
|
|
|
|
(Folder.ItemCollection) m_itemColl.get(s);
|
|
|
|
s_log.debug(String.format("itemColl.size = %d", itemColl.size()));
|
|
|
|
s_log.debug(String.format("itemColl.size = %d", itemColl.size()));
|
|
|
|
|
|
|
|
|
|
|
|
m_folderSize = itemColl.size();
|
|
|
|
m_folderSize = itemColl.size();
|
|
|
|
@ -363,7 +361,7 @@ public class FolderBrowser extends Table {
|
|
|
|
size = new Integer((int) itemColl.size());
|
|
|
|
size = new Integer((int) itemColl.size());
|
|
|
|
|
|
|
|
|
|
|
|
itemColl.setRange(new Integer(paginator.getFirst(state)),
|
|
|
|
itemColl.setRange(new Integer(paginator.getFirst(state)),
|
|
|
|
new Integer(paginator.getLast(state) + 1));
|
|
|
|
new Integer(paginator.getLast(state) + 1));
|
|
|
|
|
|
|
|
|
|
|
|
String sortKey = (String) state.getValue(m_sortType);
|
|
|
|
String sortKey = (String) state.getValue(m_sortType);
|
|
|
|
String direction = "asc";
|
|
|
|
String direction = "asc";
|
|
|
|
@ -374,13 +372,13 @@ public class FolderBrowser extends Table {
|
|
|
|
|
|
|
|
|
|
|
|
if (sortKey.equals(SORT_KEY_TITLE)) {
|
|
|
|
if (sortKey.equals(SORT_KEY_TITLE)) {
|
|
|
|
itemColl.setOrder("lower(item." + ContentItem.DISPLAY_NAME
|
|
|
|
itemColl.setOrder("lower(item." + ContentItem.DISPLAY_NAME
|
|
|
|
+ ") " + direction);
|
|
|
|
+ ") " + direction);
|
|
|
|
} else if (sortKey.equals(SORT_KEY_NAME)) {
|
|
|
|
} else if (sortKey.equals(SORT_KEY_NAME)) {
|
|
|
|
itemColl.setOrder("lower(item." + ContentItem.NAME + ") "
|
|
|
|
itemColl.setOrder("lower(item." + ContentItem.NAME + ") "
|
|
|
|
+ direction);
|
|
|
|
+ direction);
|
|
|
|
} else if (sortKey.equals(SORT_KEY_LAST_MODIFIED_DATE)) {
|
|
|
|
} else if (sortKey.equals(SORT_KEY_LAST_MODIFIED_DATE)) {
|
|
|
|
itemColl.setOrder("item.auditing.lastModifiedDate "
|
|
|
|
itemColl.setOrder("item.auditing.lastModifiedDate "
|
|
|
|
+ direction);
|
|
|
|
+ direction);
|
|
|
|
} else if (sortKey.equals(SORT_KEY_CREATION_DATE)) {
|
|
|
|
} else if (sortKey.equals(SORT_KEY_CREATION_DATE)) {
|
|
|
|
itemColl.setOrder("item.auditing.creationDate " + direction);
|
|
|
|
itemColl.setOrder("item.auditing.creationDate " + direction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -397,11 +395,11 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Indicates whether the paginator should be visible,
|
|
|
|
* Indicates whether the paginator should be visible, based on the
|
|
|
|
* based on the visibility of the folder browser itself.
|
|
|
|
* visibility of the folder browser itself.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return true if folder browser is visible, or if the
|
|
|
|
* @return true if folder browser is visible, or if the associated
|
|
|
|
* associated folder browser is unknown.
|
|
|
|
* folder browser is unknown.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public boolean isVisible(PageState state) {
|
|
|
|
public boolean isVisible(PageState state) {
|
|
|
|
return (m_fb != null) ? m_fb.isVisible(state) : true;
|
|
|
|
return (m_fb != null) ? m_fb.isVisible(state) : true;
|
|
|
|
@ -419,9 +417,9 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Component getComponent(final Table table, final PageState state,
|
|
|
|
public Component getComponent(final Table table, final PageState state,
|
|
|
|
Object value,
|
|
|
|
Object value,
|
|
|
|
boolean isSelected, Object key,
|
|
|
|
boolean isSelected, Object key,
|
|
|
|
int row, int column) {
|
|
|
|
int row, int column) {
|
|
|
|
String headerName = (String) ((GlobalizedMessage) value).localize();
|
|
|
|
String headerName = (String) ((GlobalizedMessage) value).localize();
|
|
|
|
String sortKey = (String) state.getValue(m_sortType);
|
|
|
|
String sortKey = (String) state.getValue(m_sortType);
|
|
|
|
final boolean isCurrentKey = sortKey.equals(m_key);
|
|
|
|
final boolean isCurrentKey = sortKey.equals(m_key);
|
|
|
|
@ -442,14 +440,14 @@ public class FolderBrowser extends Table {
|
|
|
|
// by default, everything sorts "up" unless it
|
|
|
|
// by default, everything sorts "up" unless it
|
|
|
|
// is the current key and it is already pointing up
|
|
|
|
// is the current key and it is already pointing up
|
|
|
|
if (SORT_ACTION_UP.equals(currentSortDirection)
|
|
|
|
if (SORT_ACTION_UP.equals(currentSortDirection)
|
|
|
|
&& isCurrentKey) {
|
|
|
|
&& isCurrentKey) {
|
|
|
|
sortDirectionAction = SORT_ACTION_DOWN;
|
|
|
|
sortDirectionAction = SORT_ACTION_DOWN;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
sortDirectionAction = SORT_ACTION_UP;
|
|
|
|
sortDirectionAction = SORT_ACTION_UP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ps.setControlEvent(table,
|
|
|
|
ps.setControlEvent(table,
|
|
|
|
sortDirectionAction,
|
|
|
|
sortDirectionAction,
|
|
|
|
m_key);
|
|
|
|
m_key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Label l = new Label();
|
|
|
|
Label l = new Label();
|
|
|
|
@ -470,8 +468,8 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Produce links to view an item or control links for folders
|
|
|
|
* Produce links to view an item or control links for folders to change into
|
|
|
|
* to change into the folder.
|
|
|
|
* the folder.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private class NameCellRenderer extends DefaultTableCellRenderer {
|
|
|
|
private class NameCellRenderer extends DefaultTableCellRenderer {
|
|
|
|
|
|
|
|
|
|
|
|
@ -481,14 +479,14 @@ public class FolderBrowser extends Table {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
|
|
Folder.ItemCollection coll = (Folder.ItemCollection) value;
|
|
|
|
Folder.ItemCollection coll = (Folder.ItemCollection) value;
|
|
|
|
String name = coll.getName();
|
|
|
|
String name = coll.getName();
|
|
|
|
if (coll.isFolder()) {
|
|
|
|
if (coll.isFolder()) {
|
|
|
|
return super.getComponent(table, state, name,
|
|
|
|
return super.getComponent(table, state, name,
|
|
|
|
isSelected, key, row, column);
|
|
|
|
isSelected, key, row, column);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ContentSection section = CMS.getContext().getContentSection();
|
|
|
|
ContentSection section = CMS.getContext().getContentSection();
|
|
|
|
BigDecimal id = coll.getID();
|
|
|
|
BigDecimal id = coll.getID();
|
|
|
|
@ -498,9 +496,101 @@ public class FolderBrowser extends Table {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ItemResolver resolver = section.getItemResolver();
|
|
|
|
ItemResolver resolver = section.getItemResolver();
|
|
|
|
return new Link(name, resolver.generateItemURL(state, id,
|
|
|
|
return new Link(name, resolver.generateItemURL(state, id,
|
|
|
|
name, section,
|
|
|
|
name, section, coll.getVersion()));
|
|
|
|
coll.
|
|
|
|
}
|
|
|
|
getVersion()));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Added by: Sören Bernstein <sbernstein@zes.uni-bremen.de>
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Produce links to view an item in a specific language and show all
|
|
|
|
|
|
|
|
* existing language version and the live status in the folder browser.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private class LanguagesCellRenderer extends DefaultTableCellRenderer {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LanguagesCellRenderer() {
|
|
|
|
|
|
|
|
super(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public Component getComponent(Table table, PageState state, Object value,
|
|
|
|
|
|
|
|
boolean isSelected, Object key,
|
|
|
|
|
|
|
|
int row, int column) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Folder.ItemCollection coll = (Folder.ItemCollection) value;
|
|
|
|
|
|
|
|
String name = coll.getName();
|
|
|
|
|
|
|
|
if (coll.isFolder()) {
|
|
|
|
|
|
|
|
// Nothing to show on folders
|
|
|
|
|
|
|
|
return new Label();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ContentPage cp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
cp = new ContentPage(coll.getID());
|
|
|
|
|
|
|
|
} catch (DataObjectNotFoundException ex) {
|
|
|
|
|
|
|
|
// Content item was not found, return nothing
|
|
|
|
|
|
|
|
return new Label();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ContentBundle bundle = cp.getContentBundle();
|
|
|
|
|
|
|
|
ContentSection section = CMS.getContext().getContentSection();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (bundle != null
|
|
|
|
|
|
|
|
&& !(cp instanceof LanguageInvariantContentItem
|
|
|
|
|
|
|
|
&& ((LanguageInvariantContentItem) cp).isLanguageInvariant())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Iterator<String> languages = bundle.getLanguages().iterator();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder temp = new StringBuilder(20);
|
|
|
|
|
|
|
|
SimpleContainer container = new SimpleContainer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (languages.hasNext()) {
|
|
|
|
|
|
|
|
String lang = languages.next();
|
|
|
|
|
|
|
|
ContentItem ci = bundle.getInstance(lang, false);
|
|
|
|
|
|
|
|
StringBuilder fontWeight = new StringBuilder(2);
|
|
|
|
|
|
|
|
StringBuilder classes = new StringBuilder(20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ci.isLive()) {
|
|
|
|
|
|
|
|
fontWeight.append(Label.BOLD);
|
|
|
|
|
|
|
|
classes.append("live ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bundle.getPrimaryInstance().equals(ci)) {
|
|
|
|
|
|
|
|
fontWeight.append(Label.ITALIC);
|
|
|
|
|
|
|
|
classes.append("primaryInstance");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Label langLabel = new Label(lang);
|
|
|
|
|
|
|
|
langLabel.setFontWeight(fontWeight.toString().trim());
|
|
|
|
|
|
|
|
langLabel.setClassAttr(classes.toString().trim());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (section == null) {
|
|
|
|
|
|
|
|
container.add(langLabel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ItemResolver resolver = section.getItemResolver();
|
|
|
|
|
|
|
|
container.add(
|
|
|
|
|
|
|
|
new Link(langLabel,
|
|
|
|
|
|
|
|
resolver.generateItemURL(state,
|
|
|
|
|
|
|
|
ci.getID(),
|
|
|
|
|
|
|
|
name,
|
|
|
|
|
|
|
|
section,
|
|
|
|
|
|
|
|
coll.getVersion())));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (languages.hasNext()) {
|
|
|
|
|
|
|
|
container.add(new Label(" ", false));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return container;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return new Label();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -527,8 +617,8 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
if (((Boolean) value).booleanValue()) {
|
|
|
|
if (((Boolean) value).booleanValue()) {
|
|
|
|
return s_link;
|
|
|
|
return s_link;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -540,8 +630,8 @@ public class FolderBrowser extends Table {
|
|
|
|
private final class IndexToggleRenderer implements TableCellRenderer {
|
|
|
|
private final class IndexToggleRenderer implements TableCellRenderer {
|
|
|
|
|
|
|
|
|
|
|
|
public Component getComponent(Table table, PageState state, Object value,
|
|
|
|
public Component getComponent(Table table, PageState state, Object value,
|
|
|
|
boolean isSelected, Object key, int row,
|
|
|
|
boolean isSelected, Object key, int row,
|
|
|
|
int column) {
|
|
|
|
int column) {
|
|
|
|
|
|
|
|
|
|
|
|
if (value == null) {
|
|
|
|
if (value == null) {
|
|
|
|
return new Label(GlobalizationUtil.globalize("cms.ui.folder.na"));
|
|
|
|
return new Label(GlobalizationUtil.globalize("cms.ui.folder.na"));
|
|
|
|
@ -558,7 +648,7 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Deletes an item
|
|
|
|
// Deletes an item
|
|
|
|
private class ItemDeleter extends TableActionAdapter {
|
|
|
|
private class ItemDeleter extends TableActionAdapter {
|
|
|
|
|
|
|
|
|
|
|
|
public void cellSelected(TableActionEvent e) {
|
|
|
|
public void cellSelected(TableActionEvent e) {
|
|
|
|
@ -596,12 +686,13 @@ public class FolderBrowser extends Table {
|
|
|
|
private static class FolderTableModel implements TableModel {
|
|
|
|
private static class FolderTableModel implements TableModel {
|
|
|
|
|
|
|
|
|
|
|
|
private static final int NAME = 0;
|
|
|
|
private static final int NAME = 0;
|
|
|
|
private static final int TITLE = 1;
|
|
|
|
private static final int LANGUAGES = 1;
|
|
|
|
private static final int TYPE = 2;
|
|
|
|
private static final int TITLE = 2;
|
|
|
|
private static final int CREATION_DATE = 3;
|
|
|
|
private static final int TYPE = 3;
|
|
|
|
private static final int LAST_MODIFIED = 4;
|
|
|
|
private static final int CREATION_DATE = 4;
|
|
|
|
private static final int DELETABLE = 5;
|
|
|
|
private static final int LAST_MODIFIED = 5;
|
|
|
|
private static final int IS_INDEX = 6;
|
|
|
|
private static final int DELETABLE = 6;
|
|
|
|
|
|
|
|
private static final int IS_INDEX = 7;
|
|
|
|
private PageState m_state;
|
|
|
|
private PageState m_state;
|
|
|
|
private FolderBrowser m_table;
|
|
|
|
private FolderBrowser m_table;
|
|
|
|
private Folder.ItemCollection m_itemColl;
|
|
|
|
private Folder.ItemCollection m_itemColl;
|
|
|
|
@ -613,7 +704,7 @@ public class FolderBrowser extends Table {
|
|
|
|
//m_itemColl = folder.getItems();
|
|
|
|
//m_itemColl = folder.getItems();
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
public FolderTableModel(FolderBrowser table, PageState state,
|
|
|
|
public FolderTableModel(FolderBrowser table, PageState state,
|
|
|
|
Folder.ItemCollection itemColl) {
|
|
|
|
Folder.ItemCollection itemColl) {
|
|
|
|
m_state = state;
|
|
|
|
m_state = state;
|
|
|
|
m_table = table;
|
|
|
|
m_table = table;
|
|
|
|
m_itemColl = itemColl;
|
|
|
|
m_itemColl = itemColl;
|
|
|
|
@ -631,7 +722,7 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getColumnCount() {
|
|
|
|
public int getColumnCount() {
|
|
|
|
return hideIndexColumn() ? 6 : 7;
|
|
|
|
return hideIndexColumn() ? 7 : 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean nextRow() {
|
|
|
|
public boolean nextRow() {
|
|
|
|
@ -642,6 +733,8 @@ public class FolderBrowser extends Table {
|
|
|
|
switch (columnIndex) {
|
|
|
|
switch (columnIndex) {
|
|
|
|
case NAME:
|
|
|
|
case NAME:
|
|
|
|
return m_itemColl;
|
|
|
|
return m_itemColl;
|
|
|
|
|
|
|
|
case LANGUAGES:
|
|
|
|
|
|
|
|
return m_itemColl;
|
|
|
|
case TITLE:
|
|
|
|
case TITLE:
|
|
|
|
return m_itemColl.getDisplayName();
|
|
|
|
return m_itemColl.getDisplayName();
|
|
|
|
case TYPE:
|
|
|
|
case TYPE:
|
|
|
|
@ -655,7 +748,7 @@ public class FolderBrowser extends Table {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case LAST_MODIFIED: {
|
|
|
|
case LAST_MODIFIED: {
|
|
|
|
java.util.Date lastModified =
|
|
|
|
java.util.Date lastModified =
|
|
|
|
m_itemColl.getLastModifiedDate();
|
|
|
|
m_itemColl.getLastModifiedDate();
|
|
|
|
if (lastModified == null) {
|
|
|
|
if (lastModified == null) {
|
|
|
|
return "--";
|
|
|
|
return "--";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -675,13 +768,12 @@ public class FolderBrowser extends Table {
|
|
|
|
if (m_folIndexID == null) {
|
|
|
|
if (m_folIndexID == null) {
|
|
|
|
return new Boolean(false);
|
|
|
|
return new Boolean(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new Boolean(m_folIndexID.compareTo(m_itemColl.
|
|
|
|
return new Boolean(m_folIndexID.compareTo(m_itemColl.getBundleID()) == 0);
|
|
|
|
getBundleID()) == 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new IndexOutOfBoundsException("Column index "
|
|
|
|
throw new IndexOutOfBoundsException("Column index "
|
|
|
|
+ columnIndex
|
|
|
|
+ columnIndex
|
|
|
|
+ " not in table model.");
|
|
|
|
+ " not in table model.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -702,13 +794,13 @@ public class FolderBrowser extends Table {
|
|
|
|
if (!m_itemColl.hasChildren()) {
|
|
|
|
if (!m_itemColl.hasChildren()) {
|
|
|
|
if (s_log.isDebugEnabled()) {
|
|
|
|
if (s_log.isDebugEnabled()) {
|
|
|
|
s_log.debug("The item is an empty folder; it may be "
|
|
|
|
s_log.debug("The item is an empty folder; it may be "
|
|
|
|
+ "deleted");
|
|
|
|
+ "deleted");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (s_log.isDebugEnabled()) {
|
|
|
|
if (s_log.isDebugEnabled()) {
|
|
|
|
s_log.debug("The folder is not empty; it cannot be "
|
|
|
|
s_log.debug("The folder is not empty; it cannot be "
|
|
|
|
+ "deleted");
|
|
|
|
+ "deleted");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -724,7 +816,7 @@ public class FolderBrowser extends Table {
|
|
|
|
public Object getKeyAt(int columnIndex) {
|
|
|
|
public Object getKeyAt(int columnIndex) {
|
|
|
|
// Mark folders by using their negative ID (dirty, dirty)
|
|
|
|
// Mark folders by using their negative ID (dirty, dirty)
|
|
|
|
return (m_itemColl.isFolder()) ? m_itemColl.getID().negate()
|
|
|
|
return (m_itemColl.isFolder()) ? m_itemColl.getID().negate()
|
|
|
|
: m_itemColl.getBundleID();
|
|
|
|
: m_itemColl.getBundleID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -767,11 +859,10 @@ public class FolderBrowser extends Table {
|
|
|
|
|
|
|
|
|
|
|
|
Folder folder = (Folder) m_fol.getSelectedObject(state);
|
|
|
|
Folder folder = (Folder) m_fol.getSelectedObject(state);
|
|
|
|
|
|
|
|
|
|
|
|
ContentBundle currentIndexItem = (ContentBundle) folder.
|
|
|
|
ContentBundle currentIndexItem = (ContentBundle) folder.getIndexItem();
|
|
|
|
getIndexItem();
|
|
|
|
|
|
|
|
if (currentIndexItem == null || (currentIndexItem.getID().
|
|
|
|
if (currentIndexItem == null || (currentIndexItem.getID().
|
|
|
|
compareTo(contentItem.getID())
|
|
|
|
compareTo(contentItem.getID())
|
|
|
|
!= 0)) {
|
|
|
|
!= 0)) {
|
|
|
|
folder.setIndexItem(contentItem);
|
|
|
|
folder.setIndexItem(contentItem);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
folder.removeIndexItem();
|
|
|
|
folder.removeIndexItem();
|
|
|
|
@ -786,8 +877,7 @@ public class FolderBrowser extends Table {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Getting the GlobalizedMessage using a CMS Class targetBundle.
|
|
|
|
* Getting the GlobalizedMessage using a CMS Class targetBundle.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param key The resource key
|
|
|
|
* @param key The resource key @pre ( key != null )
|
|
|
|
* @pre ( key != null )
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static GlobalizedMessage globalize(String key) {
|
|
|
|
private static GlobalizedMessage globalize(String key) {
|
|
|
|
return FolderManipulator.globalize(key);
|
|
|
|
return FolderManipulator.globalize(key);
|
|
|
|
|