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