View Javadoc
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  		CmsUiUtils.style(shell, CMS_USER_MENU);
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  		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  }