1 package org
.argeo
.suite
.web
;
3 import java
.nio
.file
.spi
.FileSystemProvider
;
4 import java
.util
.Locale
;
8 import javax
.jcr
.RepositoryException
;
9 import javax
.jcr
.Session
;
10 import javax
.jcr
.nodetype
.NodeType
;
12 import org
.argeo
.cms
.CmsMsg
;
13 import org
.argeo
.cms
.auth
.CurrentUser
;
14 import org
.argeo
.cms
.text
.TextStyles
;
15 import org
.argeo
.cms
.ui
.CmsUiProvider
;
16 import org
.argeo
.cms
.ui
.CmsView
;
17 import org
.argeo
.cms
.ui
.LifeCycleUiProvider
;
18 import org
.argeo
.cms
.util
.CmsUtils
;
19 import org
.argeo
.cms
.widgets
.auth
.CmsLogin
;
20 import org
.argeo
.connect
.people
.PeopleService
;
21 import org
.argeo
.connect
.people
.PeopleTypes
;
22 import org
.argeo
.connect
.people
.web
.pages
.PeopleDefaultPage
;
23 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
24 import org
.argeo
.suite
.web
.fs
.MyFilesBrowserPage
;
25 import org
.eclipse
.swt
.SWT
;
26 import org
.eclipse
.swt
.events
.SelectionListener
;
27 import org
.eclipse
.swt
.layout
.GridData
;
28 import org
.eclipse
.swt
.layout
.GridLayout
;
29 import org
.eclipse
.swt
.widgets
.Button
;
30 import org
.eclipse
.swt
.widgets
.Composite
;
31 import org
.eclipse
.swt
.widgets
.Control
;
32 import org
.eclipse
.swt
.widgets
.Label
;
35 * Default entry point for the Argeo Suite CMS. Forwards the request to the relevant
38 public class DefaultMainPage
implements LifeCycleUiProvider
{
40 private CmsUiProvider dashboardPage
;
41 private CmsUiProvider peoplePage
;
42 private CmsUiProvider fsBrowserPage
;
44 /* DEPENDENCY INJECTION */
45 private PeopleService peopleService
;
46 private FileSystemProvider nodeFileSystemProvider
;
47 private Map
<String
, String
> peopleIconPaths
;
49 public DefaultMainPage() {
53 public void init(Session adminSession
) throws RepositoryException
{
54 dashboardPage
= new DefaultDashboard(peopleService
, peopleIconPaths
);
55 peoplePage
= new PeopleDefaultPage(peopleService
, peopleIconPaths
);
56 fsBrowserPage
= new MyFilesBrowserPage(nodeFileSystemProvider
);
60 public Control
createUi(Composite parent
, Node context
) throws RepositoryException
{
61 if (CurrentUser
.isAnonymous())
62 return createAnonymousUi(parent
, context
);
64 if (context
.isNodeType(PeopleTypes
.PEOPLE_ENTITY
))
65 return peoplePage
.createUi(parent
, context
);
66 else if (peopleService
.getBasePath(null).equals(context
.getPath()))
67 return peoplePage
.createUi(parent
, context
);
68 else if (context
.isNodeType(NodeType
.NT_FOLDER
) || context
.isNodeType(NodeType
.NT_FILE
))
69 return fsBrowserPage
.createUi(parent
, context
);
71 return dashboardPage
.createUi(parent
, context
);
74 public Control
createAnonymousUi(Composite parent
, Node context
) throws RepositoryException
{
75 parent
.setLayout(new GridLayout());
76 Composite body
= new Composite(parent
, SWT
.NO_FOCUS
);
77 body
.setLayoutData(new GridData(SWT
.CENTER
, SWT
.CENTER
, true, true));
78 body
.setLayout(new GridLayout());
80 Composite loginCmp
= new Composite(body
, SWT
.NO_FOCUS
);
81 loginCmp
.setLayout(EclipseUiUtils
.noSpaceGridLayout());
82 loginCmp
.setLayoutData(new GridData(SWT
.CENTER
, SWT
.CENTER
, true, true));
84 CmsLogin login
= new MyCmsLogin(CmsUtils
.getCmsView());
85 // Composite credBlockCmp =
86 login
.createCredentialsBlock(loginCmp
);
87 // Use a custom style that has no border, among other
88 // CmsUtils.style(loginCmp, ArgeoStyles.LOGIN_INLINE_CREDBLOCK);
90 Label anonymousLbl
= new Label(body
, SWT
.WRAP
);
91 anonymousLbl
.setText("You should login or register to access your private dashboard");
97 private class MyCmsLogin
extends CmsLogin
{
99 public MyCmsLogin(CmsView cmsView
) {
104 protected boolean login() {
105 boolean result
= super.login();
110 protected void extendsCredentialsBlock(Composite credentialsBlock
, Locale selectedLocale
,
111 SelectionListener loginSelectionListener
) {
112 Button loginBtn
= new Button(credentialsBlock
, SWT
.PUSH
);
113 loginBtn
.setText(CmsMsg
.login
.lead(selectedLocale
));
114 loginBtn
.setLayoutData(CmsUtils
.fillWidth());
115 loginBtn
.addSelectionListener(loginSelectionListener
);
116 // CmsUtils.style(loginBtn, ArgeoStyles.LOGIN_SIGNIN_BTN);
121 public void destroy() {
124 /* DEPENDENCY INJECTION */
125 public void setPeopleService(PeopleService peopleService
) {
126 this.peopleService
= peopleService
;
129 public void setNodeFileSystemProvider(FileSystemProvider nodeFileSystemProvider
) {
130 this.nodeFileSystemProvider
= nodeFileSystemProvider
;
133 public void setPeopleIconPaths(Map
<String
, String
> peopleIconPaths
) {
134 this.peopleIconPaths
= peopleIconPaths
;