]> git.argeo.org Git - lgpl/argeo-commons.git/blob - eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/auth/CmsLoginShell.java
Prepare next development cycle
[lgpl/argeo-commons.git] / eclipse / org.argeo.cms.swt / src / org / argeo / cms / swt / auth / CmsLoginShell.java
1 package org.argeo.cms.swt.auth;
2
3 import org.argeo.api.cms.CmsContext;
4 import org.argeo.api.cms.CmsView;
5 import org.argeo.cms.swt.CmsSwtUtils;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.widgets.Control;
8 import org.eclipse.swt.widgets.Display;
9 import org.eclipse.swt.widgets.Shell;
10
11 /** The site-related user menu */
12 public class CmsLoginShell extends CmsLogin {
13 private final Shell shell;
14
15 public CmsLoginShell(CmsView cmsView, CmsContext cmsContext) {
16 super(cmsView, cmsContext);
17 shell = createShell();
18 // createUi(shell);
19 }
20
21 /** To be overridden. */
22 protected Shell createShell() {
23 Shell shell = new Shell(Display.getCurrent(), SWT.NO_TRIM);
24 shell.setMaximized(true);
25 return shell;
26 }
27
28 /** To be overridden. */
29 public void open() {
30 CmsSwtUtils.style(shell, CMS_USER_MENU);
31 shell.open();
32 }
33
34 @Override
35 protected boolean login() {
36 boolean success = false;
37 try {
38 success = super.login();
39 return success;
40 } finally {
41 if (success)
42 closeShell();
43 else {
44 for (Control child : shell.getChildren())
45 child.dispose();
46 createUi(shell);
47 shell.layout();
48 // TODO error message
49 }
50 }
51 }
52
53 @Override
54 protected void logout() {
55 closeShell();
56 super.logout();
57 }
58
59 protected void closeShell() {
60 if (!shell.isDisposed()) {
61 shell.close();
62 shell.dispose();
63 }
64 }
65
66 public Shell getShell() {
67 return shell;
68 }
69
70 public void createUi() {
71 createUi(shell);
72 }
73 }