Skip to content

Commit

Permalink
Replaced resource name column with site path in project files view.
Browse files Browse the repository at this point in the history
  • Loading branch information
tHerrmann committed Nov 30, 2016
1 parent a30e4c8 commit abe7e86
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 39 deletions.
36 changes: 36 additions & 0 deletions src/org/opencms/ui/apps/projects/CmsProjectFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,20 @@
import org.opencms.file.CmsObject;
import org.opencms.file.CmsResource;
import org.opencms.main.CmsException;
import org.opencms.main.OpenCms;
import org.opencms.ui.A_CmsUI;
import org.opencms.ui.CmsVaadinUtils;
import org.opencms.ui.I_CmsDialogContext;
import org.opencms.ui.I_CmsDialogContext.ContextType;
import org.opencms.ui.apps.CmsFileExplorer;
import org.opencms.ui.apps.CmsFileExplorerSettings;
import org.opencms.ui.apps.CmsProjectManagerConfiguration;
import org.opencms.ui.apps.I_CmsContextProvider;
import org.opencms.ui.apps.Messages;
import org.opencms.ui.components.CmsErrorDialog;
import org.opencms.ui.components.CmsFileTable;
import org.opencms.ui.components.CmsFileTableDialogContext;
import org.opencms.ui.components.CmsResourceTableProperty;
import org.opencms.ui.contextmenu.CmsResourceContextMenuBuilder;
import org.opencms.util.CmsUUID;

Expand All @@ -61,7 +64,40 @@ public class CmsProjectFiles extends CmsFileTable implements I_CmsContextProvide
*/
public CmsProjectFiles(CmsUUID projectId) {
super(null);

// add site path property to container
m_container.addContainerProperty(
CmsResourceTableProperty.PROPERTY_SITE_PATH,
CmsResourceTableProperty.PROPERTY_SITE_PATH.getColumnType(),
CmsResourceTableProperty.PROPERTY_SITE_PATH.getDefaultValue());

// replace the resource name column with the path column
Object[] visibleCols = m_fileTable.getVisibleColumns();
for (int i = 0; i < visibleCols.length; i++) {
if (CmsResourceTableProperty.PROPERTY_RESOURCE_NAME.equals(visibleCols[i])) {
visibleCols[i] = CmsResourceTableProperty.PROPERTY_SITE_PATH;
}
}
m_fileTable.setVisibleColumns(visibleCols);
m_fileTable.setColumnCollapsible(CmsResourceTableProperty.PROPERTY_SITE_PATH, false);
m_fileTable.setColumnHeader(
CmsResourceTableProperty.PROPERTY_SITE_PATH,
CmsVaadinUtils.getMessageText(CmsResourceTableProperty.PROPERTY_SITE_PATH.getHeaderKey()));

// update column visibility according to the latest file explorer settings
CmsFileExplorerSettings settings;
try {
settings = OpenCms.getWorkplaceAppManager().getAppSettings(
A_CmsUI.getCmsObject(),
CmsFileExplorerSettings.class);

setTableState(settings);
} catch (Exception e) {
// LOG.error("Error while reading file explorer settings from user.", e);
}
m_fileTable.setSortContainerPropertyId(CmsResourceTableProperty.PROPERTY_SITE_PATH);
setContextProvider(this);
setActionColumnProperty(CmsResourceTableProperty.PROPERTY_SITE_PATH);
setMenuBuilder(new CmsResourceContextMenuBuilder());
CmsObject cms = A_CmsUI.getCmsObject();
List<CmsResource> childResources;
Expand Down
97 changes: 59 additions & 38 deletions src/org/opencms/ui/components/CmsFileTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -263,6 +266,9 @@ public interface I_FolderSelectHandler {
/** The logger instance for this class. */
static final Log LOG = CmsLog.getLog(CmsFileTable.class);

/** The default file table columns. */
private static final Map<CmsResourceTableProperty, Integer> DEFAULT_TABLE_PROPERTIES = new LinkedHashMap<CmsResourceTableProperty, Integer>();

/** The serial version id. */
private static final long serialVersionUID = 5460048685141699277L;

Expand All @@ -281,29 +287,59 @@ public interface I_FolderSelectHandler {
/** The context menu builder. */
I_CmsContextMenuBuilder m_menuBuilder;

/** The dialog context provider. */
private I_CmsContextProvider m_contextProvider;

/** The edited item id. */
private CmsUUID m_editItemId;

/** The edited property id. */
private CmsResourceTableProperty m_editProperty;

/** The folder select handler. */
private I_FolderSelectHandler m_folderSelectHandler;

/** The original edit value. */
private String m_originalEditValue;

/** The dialog context provider. */
private I_CmsContextProvider m_contextProvider;

/** The folder select handler. */
private I_FolderSelectHandler m_folderSelectHandler;
/** The default action column property. */
CmsResourceTableProperty m_actionColumnProperty;

{
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_TYPE_ICON, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_PROJECT, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_RESOURCE_NAME, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_TITLE, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_NAVIGATION_TEXT, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_NAVIGATION_POSITION, Integer.valueOf(INVISIBLE));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_IN_NAVIGATION, Integer.valueOf(INVISIBLE));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_COPYRIGHT, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_CACHE, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_RESOURCE_TYPE, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_SIZE, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_PERMISSIONS, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_DATE_MODIFIED, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_USER_MODIFIED, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_DATE_CREATED, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_USER_CREATED, Integer.valueOf(COLLAPSED));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_DATE_RELEASED, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_DATE_EXPIRED, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_STATE_NAME, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_USER_LOCKED, Integer.valueOf(0));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_IS_FOLDER, Integer.valueOf(INVISIBLE));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_STATE, Integer.valueOf(INVISIBLE));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_INSIDE_PROJECT, Integer.valueOf(INVISIBLE));
DEFAULT_TABLE_PROPERTIES.put(PROPERTY_RELEASED_NOT_EXPIRED, Integer.valueOf(INVISIBLE));
}

/**
* Default constructor.<p>
*
* @param contextProvider the dialog context provider
*/
public CmsFileTable(I_CmsContextProvider contextProvider) {

super();
m_actionColumnProperty = PROPERTY_RESOURCE_NAME;
m_contextProvider = contextProvider;
m_container.setItemSorter(new FileSorter());
m_fileTable.addStyleName(ValoTheme.TABLE_BORDERLESS);
Expand All @@ -314,36 +350,11 @@ public CmsFileTable(I_CmsContextProvider contextProvider) {
m_fileTable.setMultiSelect(true);

m_fileTable.setTableFieldFactory(new FileFieldFactory());
new ColumnBuilder() {

{
column(PROPERTY_TYPE_ICON);
column(PROPERTY_PROJECT, COLLAPSED);
column(PROPERTY_RESOURCE_NAME);
column(PROPERTY_TITLE);
column(PROPERTY_NAVIGATION_TEXT, COLLAPSED);
column(PROPERTY_NAVIGATION_POSITION, INVISIBLE);
column(PROPERTY_IN_NAVIGATION, INVISIBLE);
column(PROPERTY_COPYRIGHT, COLLAPSED);
column(PROPERTY_CACHE, COLLAPSED);
column(PROPERTY_RESOURCE_TYPE);
column(PROPERTY_SIZE);
column(PROPERTY_PERMISSIONS, COLLAPSED);
column(PROPERTY_DATE_MODIFIED);
column(PROPERTY_USER_MODIFIED, COLLAPSED);
column(PROPERTY_DATE_CREATED, COLLAPSED);
column(PROPERTY_USER_CREATED, COLLAPSED);
column(PROPERTY_DATE_RELEASED);
column(PROPERTY_DATE_EXPIRED);
column(PROPERTY_STATE_NAME);
column(PROPERTY_USER_LOCKED);
column(PROPERTY_IS_FOLDER, INVISIBLE);
column(PROPERTY_STATE, INVISIBLE);
column(PROPERTY_INSIDE_PROJECT, INVISIBLE);
column(PROPERTY_RELEASED_NOT_EXPIRED, INVISIBLE);
}

}.buildColumns();
ColumnBuilder builder = new ColumnBuilder();
for (Entry<CmsResourceTableProperty, Integer> entry : DEFAULT_TABLE_PROPERTIES.entrySet()) {
builder.column(entry.getKey(), entry.getValue().intValue());
}
builder.buildColumns();

m_fileTable.setSortContainerPropertyId(CmsResourceTableProperty.PROPERTY_RESOURCE_NAME);
m_menu = new CmsContextMenu();
Expand Down Expand Up @@ -392,7 +403,7 @@ public String getStyle(Table source, Object itemId, Object propertyId) {

Item item = m_container.getItem(itemId);
String style = getStateStyle(item);
if (CmsResourceTableProperty.PROPERTY_RESOURCE_NAME == propertyId) {
if (m_actionColumnProperty == propertyId) {
style += " " + OpenCmsTheme.HOVER_COLUMN;
} else if ((CmsResourceTableProperty.PROPERTY_NAVIGATION_TEXT == propertyId)
|| (CmsResourceTableProperty.PROPERTY_TITLE == propertyId)) {
Expand Down Expand Up @@ -560,6 +571,16 @@ public void openContextMenu(ItemClickEvent event) {
m_menu.openForTable(event, m_fileTable);
}

/**
* Sets the default action column property.<p>
*
* @param actionColumnProperty the default action column property
*/
public void setActionColumnProperty(CmsResourceTableProperty actionColumnProperty) {

m_actionColumnProperty = actionColumnProperty;
}

/**
* Sets the first visible item index.<p>
*
Expand Down Expand Up @@ -773,7 +794,7 @@ void handleFileItemClick(ItemClickEvent event) {
|| CmsResourceTableProperty.PROPERTY_TYPE_ICON.equals(event.getPropertyId())) {
openContextMenu(event);
} else {
if (CmsResourceTableProperty.PROPERTY_RESOURCE_NAME.equals(event.getPropertyId())) {
if (m_actionColumnProperty.equals(event.getPropertyId())) {
Boolean isFolder = (Boolean)event.getItem().getItemProperty(
CmsResourceTableProperty.PROPERTY_IS_FOLDER).getValue();
if ((isFolder != null) && isFolder.booleanValue()) {
Expand Down
5 changes: 5 additions & 0 deletions src/org/opencms/ui/components/CmsResourceTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_RELEASED_NOT_EXPIRED;
import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_RESOURCE_NAME;
import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_RESOURCE_TYPE;
import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_SITE_PATH;
import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_SIZE;
import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_STATE;
import static org.opencms.ui.components.CmsResourceTableProperty.PROPERTY_STATE_NAME;
Expand Down Expand Up @@ -384,6 +385,10 @@ public static void fillItemDefault(
resourceItem.getItemProperty(PROPERTY_RESOURCE_NAME).setValue(resource.getName());
}

if (resourceItem.getItemProperty(PROPERTY_SITE_PATH) != null) {
resourceItem.getItemProperty(PROPERTY_SITE_PATH).setValue(cms.getSitePath(resource));
}

if ((resourceItem.getItemProperty(PROPERTY_TITLE) != null) && (resourceProps != null)) {
resourceItem.getItemProperty(PROPERTY_TITLE).setValue(
resourceProps.containsKey(CmsPropertyDefinition.PROPERTY_TITLE)
Expand Down
3 changes: 2 additions & 1 deletion src/org/opencms/ui/components/CmsResourceTableProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import static org.opencms.workplace.explorer.Messages.GUI_INPUT_LOCKEDBY_0;
import static org.opencms.workplace.explorer.Messages.GUI_INPUT_NAME_0;
import static org.opencms.workplace.explorer.Messages.GUI_INPUT_NAVTEXT_0;
import static org.opencms.workplace.explorer.Messages.GUI_INPUT_PATH_0;
import static org.opencms.workplace.explorer.Messages.GUI_INPUT_PERMISSIONS_0;
import static org.opencms.workplace.explorer.Messages.GUI_INPUT_SIZE_0;
import static org.opencms.workplace.explorer.Messages.GUI_INPUT_STATE_0;
Expand Down Expand Up @@ -296,7 +297,7 @@ public Class<String> getPresentationType() {
"PROPERTY_SITE_PATH",
String.class,
null,
null,
GUI_INPUT_PATH_0,
true,
0,
0);
Expand Down

0 comments on commit abe7e86

Please sign in to comment.