Update UI last access
[gpl/argeo-suite.git] / swt / org.argeo.app.swt / src / org / argeo / app / swt / ux / SwtArgeoApp.java
index b092e777727f7d6df0e78591d42e74a90e311939..a81c33ef83f17fce709099e4fe52dc4293a563bf 100644 (file)
@@ -36,7 +36,6 @@ import org.argeo.app.ux.AppUi;
 import org.argeo.app.ux.SuiteUxEvent;
 import org.argeo.cms.LocaleUtils;
 import org.argeo.cms.Localized;
-import org.argeo.cms.acr.ContentUtils;
 import org.argeo.cms.swt.CmsSwtUtils;
 import org.argeo.cms.swt.acr.SwtUiProvider;
 import org.argeo.cms.swt.dialogs.CmsFeedback;
@@ -124,7 +123,7 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
                                pidPrefix = appPid.substring(0, lastDotIndex);
                        }
                } else {
-                       // TODO doe it make sense to accept that?
+                       // TODO does it make sense to accept that?
                        appPid = "<unknown>";
                }
 
@@ -138,6 +137,7 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
 //             leadPanePid = pidPrefix + "leadPane";
 //             adminLeadPanePid = pidPrefix + "adminLeadPane";
 //             loginScreenPid = pidPrefix + "loginScreen";
+
        }
 
        public void stop(Map<String, Object> properties) {
@@ -174,18 +174,6 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
                String uid = cmsView.getUid();
                managedUis.put(uid, argeoSuiteUi);
                argeoSuiteUi.addDisposeListener(new CleanUpUi(uid));
-//             argeoSuiteUi.addDisposeListener((e) -> {
-//                     managedUis.remove(uid);
-//                     if (log.isDebugEnabled())
-//                             log.debug("Suite UI " + uid + " has been disposed.");
-//             });
-//             Display.getCurrent().disposeExec(() -> {
-//                     if (managedUis.containsKey(uid)) {
-//                             managedUis.remove(uid);
-//                             if (log.isDebugEnabled())
-//                                     log.debug("Suite UI " + uid + " has been disposed from Display#disposeExec().");
-//                     }
-//             });
                return argeoSuiteUi;
        }
 
@@ -202,6 +190,7 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
                try {
                        Content context = null;
                        SwtAppUi ui = (SwtAppUi) cmsUi;
+                       ui.updateLastAccess();
 
                        String uiName = Objects.toString(ui.getParent().getData(UI_NAME_PROPERTY), null);
                        if (uiName == null)
@@ -249,10 +238,10 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
                                        if (cmsSession == null || cmsView.isAnonymous()) {
                                                assert publicBasePath != null;
                                                Content userDir = contentSession
-                                                               .get(ContentUtils.SLASH + CmsConstants.SYS_WORKSPACE + publicBasePath);
+                                                               .get(Content.ROOT_PATH + CmsConstants.SYS_WORKSPACE + publicBasePath);
                                                ui.setUserDir(userDir);
                                        } else {
-                                               Content userDir = appUserState.getOrCreateSessionDir(contentSession, cmsSession);
+                                               Content userDir = appUserState.getOrCreateSessionDir(cmsSession);
                                                ui.setUserDir(userDir);
 //                                             Node userDirNode = jcrContentProvider.doInAdminSession((adminSession) -> {
 //                                                     Node node = SuiteUtils.getOrCreateCmsSessionNode(adminSession, cmsSession);
@@ -469,7 +458,7 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
        }
 
        // TODO move it to an internal package?
-       public static String nodeToState(Content node) {
+       private static String nodeToState(Content node) {
                return node.getPath();
        }
 
@@ -497,6 +486,7 @@ public class SwtArgeoApp extends AbstractArgeoApp implements CmsEventSubscriber
                SwtAppUi ui = getRelatedUi(event);
                if (ui == null)
                        return;
+               ui.updateLastAccess();
                ui.getCmsView().runAs(() -> {
                        try {
                                String appTitle = "";