Skip to content

Commit

Permalink
Fixing issue where table state was lost after editing resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
tHerrmann committed Mar 28, 2019
1 parent 5b2d5a7 commit cdd8a3e
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 34 deletions.
3 changes: 2 additions & 1 deletion src/org/opencms/ui/actions/CmsFormEditDialogAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.opencms.ui.apps.CmsAppView.CacheStatus;
import org.opencms.ui.apps.CmsAppWorkplaceUi;
import org.opencms.ui.apps.CmsEditor;
import org.opencms.ui.apps.CmsEditorConfiguration;
import org.opencms.ui.contextmenu.CmsMenuItemVisibilityMode;
import org.opencms.ui.contextmenu.CmsStandardVisibilityCheck;
import org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility;
Expand Down Expand Up @@ -67,7 +68,7 @@ public void executeAction(I_CmsDialogContext context) {
((CmsAppView)view).setCacheStatus(CacheStatus.cacheOnce);
}
CmsAppWorkplaceUi.get().showApp(
OpenCms.getWorkplaceAppManager().getAppConfiguration("editor"),
OpenCms.getWorkplaceAppManager().getAppConfiguration(CmsEditorConfiguration.APP_ID),
CmsEditor.getEditState(
context.getResources().get(0).getStructureId(),
false,
Expand Down
19 changes: 10 additions & 9 deletions src/org/opencms/ui/apps/CmsFileExplorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1273,15 +1273,11 @@ protected void readFolder(CmsUUID folderId, boolean clearFilter) throws CmsExcep
m_searchField.clear();
}
CmsResource folder = cms.readResource(folderId, FOLDERS);
String p = RandomStringUtils.randomAlphanumeric(5) + " readFolder ";
LOG.debug(p + "siteRoot = " + cms.getRequestContext().getSiteRoot());
LOG.debug(p + "folder = " + folder.getRootPath());
m_currentFolder = folderId;
String folderPath = cms.getSitePath(folder);
if (OpenCms.getSiteManager().isSharedFolder(cms.getRequestContext().getSiteRoot())) {
folderPath = folderPath.substring(cms.getRequestContext().getSiteRoot().length());
}
LOG.debug(p + "folderPath = " + folderPath);
setPathInfo(folderPath);
List<CmsResource> childResources = cms.readResources(folder, FILES_N_FOLDERS, false);
m_fileTable.fillTable(cms, childResources, clearFilter);
Expand All @@ -1294,15 +1290,20 @@ protected void readFolder(CmsUUID folderId, boolean clearFilter) throws CmsExcep
}
m_treeContainer.setChildrenAllowed(folderId, hasFolderChild);
String sitePath = folder.getRootPath().equals(cms.getRequestContext().getSiteRoot() + "/") ? "" : folderPath;
LOG.debug(p + "sitePath = " + sitePath);

String state = new StateBean(
cms.getRequestContext().getSiteRoot(),
sitePath,
cms.getRequestContext().getCurrentProject().getUuid().toString()).asString();
LOG.debug(p + "state = " + state);
LOG.debug(p + "m_currentState = " + m_currentState);
LOG.debug(p + "m_currentState.asString = " + StateBean.parse(m_currentState).asString());
if (LOG.isDebugEnabled()) {
String p = RandomStringUtils.randomAlphanumeric(5) + " readFolder ";
LOG.debug(p + "siteRoot = " + cms.getRequestContext().getSiteRoot());
LOG.debug(p + "folder = " + folder.getRootPath());
LOG.debug(p + "folderPath = " + folderPath);
LOG.debug(p + "sitePath = " + sitePath);
LOG.debug(p + "state = " + state);
LOG.debug(p + "m_currentState = " + m_currentState);
LOG.debug(p + "m_currentState.asString = " + StateBean.parse(m_currentState).asString());
}
if ((m_currentState == null) || !(state).equals(StateBean.parse(m_currentState).asString())) {
m_currentState = state;
CmsAppWorkplaceUi.get().changeCurrentAppState(m_currentState);
Expand Down
103 changes: 79 additions & 24 deletions src/org/opencms/ui/apps/lists/CmsListManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@
import org.opencms.ui.actions.CmsEditDialogAction;
import org.opencms.ui.actions.CmsResourceInfoAction;
import org.opencms.ui.apps.A_CmsWorkplaceApp;
import org.opencms.ui.apps.CmsAppView;
import org.opencms.ui.apps.CmsAppView.CacheStatus;
import org.opencms.ui.apps.CmsAppWorkplaceUi;
import org.opencms.ui.apps.CmsEditor;
import org.opencms.ui.apps.CmsEditorConfiguration;
import org.opencms.ui.apps.CmsFileExplorer;
import org.opencms.ui.apps.CmsFileExplorerSettings;
import org.opencms.ui.apps.I_CmsAppUIContext;
import org.opencms.ui.apps.I_CmsCachableApp;
import org.opencms.ui.apps.I_CmsContextProvider;
import org.opencms.ui.apps.Messages;
import org.opencms.ui.apps.lists.CmsOptionDialog.I_OptionHandler;
Expand Down Expand Up @@ -129,6 +134,7 @@

import org.apache.commons.logging.Log;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.server.Sizeable.Unit;
import com.vaadin.ui.Button;
Expand All @@ -155,7 +161,8 @@
*/
@SuppressWarnings("deprecation")
public class CmsListManager extends A_CmsWorkplaceApp
implements I_ResourcePropertyProvider, I_CmsContextProvider, ViewChangeListener, I_CmsWindowCloseListener {
implements I_ResourcePropertyProvider, I_CmsContextProvider, ViewChangeListener, I_CmsWindowCloseListener,
I_CmsCachableApp {

/**
* Enum representing how selected categories should be combined in a search.<p>
Expand All @@ -182,6 +189,12 @@ public static class ListConfigurationBean {
/** The categories. */
private List<String> m_categories;

/** The category mode. */
private CategoryMode m_categoryMode;

/** The date restriction. */
private I_CmsListDateRestriction m_dateRestriction;

/** The display types. */
private List<String> m_dislayTypes;

Expand All @@ -191,12 +204,6 @@ public static class ListConfigurationBean {
/** Search parameters by configuration node name. */
private Map<String, String> m_parameterFields;

/** The category mode. */
private CategoryMode m_categoryMode;

/** The date restriction. */
private I_CmsListDateRestriction m_dateRestriction;

/**
* Constructor.<p>
*/
Expand Down Expand Up @@ -456,7 +463,6 @@ public DialogContext(
List<CmsResource> resources) {

super(appId, contextType, fileTable, resources);

}

/**
Expand Down Expand Up @@ -566,7 +572,7 @@ void deleteForOption(
}

/**
* Overrides the standard delete action to enable use of edit handlers.<p>
* Overrides the standard edit action to enable use of edit handlers.<p>
*/
class EditAction extends CmsEditDialogAction {

Expand Down Expand Up @@ -652,15 +658,6 @@ void editForOption(
}
}

/** XML content node name. */
public static final String N_DATE_RESTRICTION = "DateRestriction";

/** Default backend pagination. */
private static final I_CmsSearchConfigurationPagination PAGINATION = new CmsSearchConfigurationPagination(
null,
Integer.valueOf(10000),
Integer.valueOf(1));

/** SOLR field name. */
public static final String FIELD_CATEGORIES = "category_exact";

Expand All @@ -682,6 +679,9 @@ void editForOption(
/** List configuration node name for the category mode. */
public static final String N_CATEGORY_MODE = "CategoryMode";

/** XML content node name. */
public static final String N_DATE_RESTRICTION = "DateRestriction";

/** List configuration node name and field key. */
public static final String N_DISPLAY_TYPE = "TypesToCollect";

Expand Down Expand Up @@ -783,9 +783,6 @@ void editForOption(
Messages.GUI_LISTMANAGER_SORT_ORDER_ASC_0,
Messages.GUI_LISTMANAGER_SORT_ORDER_DESC_0}};

/** The logger for this class. */
private static final Log LOG = CmsLog.getLog(CmsListManager.class.getName());

/** The month name abbreviations. */
static final String[] MONTHS = new String[] {
"JAN",
Expand All @@ -801,6 +798,15 @@ void editForOption(
"NOV",
"DEC"};

/** The logger for this class. */
private static final Log LOG = CmsLog.getLog(CmsListManager.class.getName());

/** Default backend pagination. */
private static final I_CmsSearchConfigurationPagination PAGINATION = new CmsSearchConfigurationPagination(
null,
Integer.valueOf(10000),
Integer.valueOf(1));

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

Expand All @@ -819,6 +825,9 @@ void editForOption(
/** The current search parser. */
private CmsSimpleSearchConfigurationParser m_currentConfigParser;

/** The current app state. */
private String m_currentState;

/** The current edit dialog window. */
private Window m_dialogWindow;

Expand Down Expand Up @@ -1038,11 +1047,12 @@ public boolean beforeViewChange(ViewChangeEvent event) {
public I_CmsDialogContext getDialogContext() {

CmsFileTable table = isOverView() ? m_overviewTable : m_resultTable;
List<CmsResource> resources = table.getSelectedResources();
DialogContext context = new DialogContext(
CmsProjectManagerConfiguration.APP_ID,
ContextType.fileTable,
table,
table.getSelectedResources());
resources);
if (!isOverView()) {
context.setSelectedItems(m_resultTable.getSelectedItems());
}
Expand Down Expand Up @@ -1419,6 +1429,41 @@ public void valueChange(ValueChangeEvent event) {
m_resultLayout.setSplitPosition(CmsFileExplorer.LAYOUT_SPLIT_POSITION, Unit.PIXELS);
}

/**
* @see org.opencms.ui.apps.I_CmsCachableApp#isCachable()
*/
public boolean isCachable() {

return true;
}

/**
* @see org.opencms.ui.apps.I_CmsCachableApp#onRestoreFromCache()
*/
public void onRestoreFromCache() {

if (isOverView()) {
CmsFileExplorerSettings state = m_overviewTable.getTableSettings();
displayListConfigs();
m_overviewTable.setTableState(state);
m_overviewTable.updateSorting();
} else {
refreshResult();
}
}

/**
* @see org.opencms.ui.apps.A_CmsWorkplaceApp#onStateChange(java.lang.String)
*/
@Override
public void onStateChange(String state) {

if ((m_currentState == null) || !m_currentState.equals(state)) {
m_currentState = state;
super.onStateChange(state);
}
}

/**
* @see org.opencms.ui.components.I_CmsWindowCloseListener#onWindowClose()
*/
Expand Down Expand Up @@ -1706,6 +1751,7 @@ void displayResult(CmsSolrResultList resultList) {
state,
PARAM_LOCALE,
m_currentConfigParser.getSearchLocale().toString());
m_currentState = state;
CmsAppWorkplaceUi.get().changeCurrentAppState(state);
if (m_isOverView) {
enableOverviewMode(false);
Expand All @@ -1716,7 +1762,7 @@ void displayResult(CmsSolrResultList resultList) {
/**
* Edits the given list configuration resource.<p>
*
* @param resource the cofiguration resource
* @param resource the configuration resource
*/
void editListConfiguration(CmsResource resource) {

Expand All @@ -1737,7 +1783,13 @@ void editListConfiguration(CmsResource resource) {
false,
UI.getCurrent().getPage().getLocation().toString());
}
CmsAppWorkplaceUi.get().showApp(OpenCms.getWorkplaceAppManager().getAppConfiguration("editor"), editState);
View view = CmsAppWorkplaceUi.get().getCurrentView();
if (view instanceof CmsAppView) {
((CmsAppView)view).setCacheStatus(CacheStatus.cacheOnce);
}
CmsAppWorkplaceUi.get().showApp(
OpenCms.getWorkplaceAppManager().getAppConfiguration(CmsEditorConfiguration.APP_ID),
editState);

} catch (CmsLoaderException e) {
CmsErrorDialog.showErrorDialog(e);
Expand Down Expand Up @@ -1925,10 +1977,13 @@ public void onUpdate(List<String> updatedItems) {
void refreshResult() {

String itemId = m_resultTable.getCurrentPageFirstItemId();
CmsFileExplorerSettings state = m_resultTable.getTableSettings();
search(
m_resultFacets.getSelectedFieldFacets(),
m_resultFacets.getSelectedRangeFactes(),
m_textSearch.getValue());
m_resultTable.setTableState(state);
m_resultTable.updateSorting();
m_resultTable.setCurrentPageFirstItemId(itemId);
}

Expand Down

0 comments on commit cdd8a3e

Please sign in to comment.