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