X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.app.ui%2Fsrc%2Forg%2Fargeo%2Fapp%2Fui%2FSuiteUi.java;h=02ff38e73a2b969759b493466609bc04c24d6e8b;hb=f1b87af2e0de38f1f49ab8fe68f9988018914811;hp=b2e43852bed2441ac2d47e8a37adde5bc18229fb;hpb=942fd932e1f6ed3319575c4c1d944912dfca9fa5;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUi.java b/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUi.java index b2e4385..02ff38e 100644 --- a/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUi.java +++ b/org.argeo.app.ui/src/org/argeo/app/ui/SuiteUi.java @@ -3,24 +3,17 @@ package org.argeo.app.ui; import java.util.HashMap; import java.util.Map; -import javax.jcr.Node; -import javax.jcr.Repository; -import javax.jcr.RepositoryException; -import javax.jcr.Session; - -import org.argeo.api.cms.CmsUi; -import org.argeo.api.cms.CmsView; +import org.argeo.api.acr.Content; import org.argeo.api.cms.CmsLog; -import org.argeo.api.cms.CmsConstants; import org.argeo.cms.Localized; +import org.argeo.cms.swt.CmsSwtUi; import org.argeo.cms.swt.CmsSwtUtils; -import org.argeo.jcr.Jcr; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Composite; /** The view for the default ergonomics of Argeo Suite. */ -class SuiteUi extends Composite implements CmsUi { +class SuiteUi extends CmsSwtUi { private static final long serialVersionUID = 6207018859086689108L; private final static CmsLog log = CmsLog.getLog(SuiteUi.class); @@ -32,19 +25,19 @@ class SuiteUi extends Composite implements CmsUi { private Composite sidePane; private Composite dynamicArea; - private Session sysSession; - private Session homeSession; - private Node userDir; +// private Session sysSession; +// private Session homeSession; + private Content userDir; private Map layers = new HashMap<>(); private Map workAreas = new HashMap<>(); private String currentLayerId = null; - private CmsView cmsView; + private boolean loginScreen = false; +// private String postLoginState; public SuiteUi(Composite parent, int style) { super(parent, style); - cmsView = CmsSwtUtils.getCmsView(parent); this.setLayout(CmsSwtUtils.noSpaceGridLayout()); header = new Composite(this, SWT.NONE); @@ -106,7 +99,7 @@ class SuiteUi extends Composite implements CmsUi { return currentLayerId; } - private Composite getLayer(String id, Node context) { + private Composite getLayer(String id, Content context) { if (!layers.containsKey(id)) return null; if (!workAreas.containsKey(id)) @@ -114,7 +107,7 @@ class SuiteUi extends Composite implements CmsUi { return workAreas.get(id); } - Composite switchToLayer(String layerId, Node context) { + Composite switchToLayer(String layerId, Content context) { Composite current = null; if (currentLayerId != null) { current = getCurrentWorkArea(); @@ -122,8 +115,8 @@ class SuiteUi extends Composite implements CmsUi { return current; } if (context == null) { - if (!cmsView.isAnonymous()) - context = userDir; + if (!getCmsView().isAnonymous()) + context = getUserDirNode(); } Composite toShow = getLayer(layerId, context); if (toShow != null) { @@ -146,12 +139,13 @@ class SuiteUi extends Composite implements CmsUi { } } - Composite switchToLayer(SuiteLayer layer, Node context) { + void switchToLayer(SuiteLayer layer, Content context) { // TODO make it more robust for (String layerId : layers.keySet()) { SuiteLayer l = layers.get(layerId); - if (layer == l) { - return switchToLayer(layerId, context); + if (layer.getId().equals(l.getId())) { + switchToLayer(layerId, context); + return; } } throw new IllegalArgumentException("Layer is not registered."); @@ -170,8 +164,8 @@ class SuiteUi extends Composite implements CmsUi { } } - protected Composite initLayer(String id, SuiteLayer layer, Node context) { - Composite workArea = cmsView.doAs(() -> (Composite) layer.createUiPart(dynamicArea, context)); + protected Composite initLayer(String id, SuiteLayer layer, Content context) { + Composite workArea = getCmsView().doAs(() -> (Composite) layer.createUiPart(dynamicArea, context)); CmsSwtUtils.style(workArea, SuiteStyle.workArea); workArea.setLayoutData(CmsSwtUtils.coverAll()); workAreas.put(id, workArea); @@ -180,8 +174,8 @@ class SuiteUi extends Composite implements CmsUi { synchronized void logout() { userDir = null; - Jcr.logout(sysSession); - Jcr.logout(homeSession); +// Jcr.logout(sysSession); +// Jcr.logout(homeSession); currentLayerId = null; workAreas.clear(); } @@ -214,38 +208,45 @@ class SuiteUi extends Composite implements CmsUi { // return sysSession; // } // - synchronized void initSessions(Repository repository, String userDirPath) throws RepositoryException { - this.sysSession = repository.login(); - this.homeSession = repository.login(CmsConstants.HOME_WORKSPACE); - userDir = sysSession.getNode(userDirPath); - addDisposeListener((e) -> { - Jcr.logout(sysSession); - Jcr.logout(homeSession); - }); - } +// synchronized void initSessions(Repository repository, String userDirPath) throws RepositoryException { +// this.sysSession = repository.login(); +// this.homeSession = repository.login(CmsConstants.HOME_WORKSPACE); +// userDir = sysSession.getNode(userDirPath); +// addDisposeListener((e) -> { +// Jcr.logout(sysSession); +// Jcr.logout(homeSession); +// }); +// } - Node getUserDir() { + @Deprecated + Content getUserDirNode() { + if (userDir == null) + return null; return userDir; } - Session getSysSession() { - return sysSession; + Content getUserDir() { + return userDir; } - Session getSession(String workspaceName) { - if (workspaceName == null) - return sysSession; - if (CmsConstants.SYS_WORKSPACE.equals(workspaceName)) - return sysSession; - else if (CmsConstants.HOME_WORKSPACE.equals(workspaceName)) - return homeSession; - else - throw new IllegalArgumentException("Unknown workspace " + workspaceName); + void setUserDir(Content userDir) { + this.userDir = userDir; } - public CmsView getCmsView() { - return cmsView; - } +// Session getSysSession() { +// return sysSession; +// } + +// Session getSession(String workspaceName) { +// if (workspaceName == null) +// return sysSession; +// if (CmsConstants.SYS_WORKSPACE.equals(workspaceName)) +// return sysSession; +// else if (CmsConstants.HOME_WORKSPACE.equals(workspaceName)) +// return homeSession; +// else +// throw new IllegalArgumentException("Unknown workspace " + workspaceName); +// } public Localized getTitle() { return title; @@ -255,4 +256,20 @@ class SuiteUi extends Composite implements CmsUi { this.title = title; } + public boolean isLoginScreen() { + return loginScreen; + } + + public void setLoginScreen(boolean loginScreen) { + this.loginScreen = loginScreen; + } + +// public String getPostLoginState() { +// return postLoginState; +// } +// +// public void setPostLoginState(String postLoginState) { +// this.postLoginState = postLoginState; +// } + }