import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.api.NodeConstants;
-import org.argeo.api.NodeUtils;
import org.argeo.cms.ui.CmsView;
import org.argeo.cms.ui.util.CmsUiUtils;
import org.argeo.jcr.Jcr;
private Composite dynamicArea;
private Session sysSession;
- private Session homeSession;
- private Node userHome;
+// private Session homeSession;
+ private Node userDir;
private Map<String, SuiteLayer> layers = new HashMap<>();
private Map<String, Composite> workAreas = new HashMap<>();
private Composite getLayer(String id, Node context) {
if (!layers.containsKey(id))
- throw new IllegalArgumentException("No layer " + id + " is available.");
+ return null;
if (!workAreas.containsKey(id))
initLayer(id, layers.get(id), context);
return workAreas.get(id);
}
Composite switchToLayer(String layerId, Node context) {
+ Composite current = null;
if (currentLayerId != null) {
- Composite current = getCurrentWorkArea();
+ current = getCurrentWorkArea();
if (currentLayerId.equals(layerId))
return current;
}
if (context == null) {
if (!cmsView.isAnonymous())
- context = userHome;
+ context = userDir;
}
Composite toShow = getLayer(layerId, context);
- currentLayerId = layerId;
- if (!isDisposed())
- getDisplay().syncExec(() -> {
- if (!toShow.isDisposed())
- toShow.moveAbove(null);
- else
- log.warn("Cannot show work area because it is disposed.");
- dynamicArea.layout(true, true);
- });
- return toShow;
+ if (toShow != null) {
+ currentLayerId = layerId;
+ if (!isDisposed())
+ getDisplay().syncExec(() -> {
+ if (!toShow.isDisposed())
+ toShow.moveAbove(null);
+ else
+ log.warn("Cannot show work area because it is disposed.");
+ dynamicArea.layout(true, true);
+ });
+ return toShow;
+ } else {
+ return current;
+ }
}
Composite switchToLayer(SuiteLayer layer, Node context) {
}
synchronized void logout() {
- userHome = null;
+ userDir = null;
Jcr.logout(sysSession);
- Jcr.logout(homeSession);
+// Jcr.logout(homeSession);
currentLayerId = null;
workAreas.clear();
}
// return sysSession;
// }
//
- synchronized void initSessions(Repository repository) throws RepositoryException {
+ synchronized void initSessions(Repository repository, String userDirPath) throws RepositoryException {
this.sysSession = repository.login();
- this.homeSession = repository.login(NodeConstants.HOME_WORKSPACE);
- userHome = NodeUtils.getUserHome(homeSession);
+// this.homeSession = repository.login(NodeConstants.HOME_WORKSPACE);
+ userDir = sysSession.getNode(userDirPath);
addDisposeListener((e) -> {
Jcr.logout(sysSession);
- Jcr.logout(homeSession);
+// Jcr.logout(homeSession);
});
}
- Node getUserHome() {
- return userHome;
+ Node getUserDir() {
+ return userDir;
}
Session getSysSession() {
return sysSession;
if (NodeConstants.SYS_WORKSPACE.equals(workspaceName))
return sysSession;
- else if (NodeConstants.HOME_WORKSPACE.equals(workspaceName))
- return homeSession;
+// else if (NodeConstants.HOME_WORKSPACE.equals(workspaceName))
+// return homeSession;
else
throw new IllegalArgumentException("Unknown workspace " + workspaceName);
}