X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.suite.ui%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fui%2FSuiteUi.java;h=b245762cc7d8f27220d7ee6bfef5f5eff82246d8;hp=1231d9262efda834e893a75f6a4dd81b670f79af;hb=f709e4a3ae06e51f767eee8152b393eb1df97df4;hpb=d21b6765434d473fe04de867e2c3e773a6da8030 diff --git a/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java b/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java index 1231d92..b245762 100644 --- a/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java +++ b/org.argeo.suite.ui/src/org/argeo/suite/ui/SuiteUi.java @@ -11,7 +11,6 @@ import javax.jcr.Session; 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; @@ -29,8 +28,8 @@ class SuiteUi extends Composite { private Composite dynamicArea; private Session sysSession; - private Session homeSession; - private Node userHome; +// private Session homeSession; + private Node userDir; private Map layers = new HashMap<>(); private Map workAreas = new HashMap<>(); @@ -44,6 +43,7 @@ class SuiteUi extends Composite { this.setLayout(CmsUiUtils.noSpaceGridLayout()); header = new Composite(this, SWT.NONE); + header.setLayout(CmsUiUtils.noSpaceGridLayout()); CmsUiUtils.style(header, SuiteStyle.header); header.setLayoutData(CmsUiUtils.fillWidth()); @@ -65,9 +65,10 @@ class SuiteUi extends Composite { dynamicArea = new Composite(belowHeader, SWT.NONE); } leadPane.setLayoutData(CmsUiUtils.fillHeight()); + leadPane.setLayout(CmsUiUtils.noSpaceGridLayout()); CmsUiUtils.style(leadPane, SuiteStyle.leadPane); - dynamicArea.setLayoutData(CmsUiUtils.fillAll()); + dynamicArea.setLayoutData(CmsUiUtils.fillAll()); dynamicArea.setLayout(new FormLayout()); } else { @@ -91,33 +92,42 @@ class SuiteUi extends Composite { 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()) + if (toShow != null) { + currentLayerId = layerId; + if (!isDisposed()) { +// getDisplay().syncExec(() -> { + if (!toShow.isDisposed()) { toShow.moveAbove(null); - else + } else { log.warn("Cannot show work area because it is disposed."); + toShow = initLayer(layerId, layers.get(layerId), context); + toShow.moveAbove(null); + } dynamicArea.layout(true, true); - }); - return toShow; +// }); + } + return toShow; + } else { + return current; + } } Composite switchToLayer(SuiteLayer layer, Node context) { @@ -146,15 +156,16 @@ class SuiteUi extends Composite { protected Composite initLayer(String id, SuiteLayer layer, Node context) { Composite workArea = cmsView.doAs(() -> (Composite) layer.createUiPart(dynamicArea, context)); + CmsUiUtils.style(workArea, SuiteStyle.workArea); workArea.setLayoutData(CmsUiUtils.coverAll()); workAreas.put(id, workArea); return workArea; } synchronized void logout() { - userHome = null; + userDir = null; Jcr.logout(sysSession); - Jcr.logout(homeSession); +// Jcr.logout(homeSession); currentLayerId = null; workAreas.clear(); } @@ -179,18 +190,18 @@ class SuiteUi extends Composite { // 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() { @@ -202,8 +213,8 @@ class SuiteUi extends Composite { 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); }