]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.ui/src/org/argeo/cms/util/UserMenu.java
[maven-release-plugin] prepare for next development iteration
[lgpl/argeo-commons.git] / org.argeo.cms.ui / src / org / argeo / cms / util / UserMenu.java
1 package org.argeo.cms.util;
2
3 import org.argeo.cms.CmsException;
4 import org.argeo.cms.widgets.auth.CmsLoginShell;
5 import org.eclipse.swt.SWT;
6 import org.eclipse.swt.events.ShellAdapter;
7 import org.eclipse.swt.events.ShellEvent;
8 import org.eclipse.swt.widgets.Control;
9 import org.eclipse.swt.widgets.Display;
10 import org.eclipse.swt.widgets.Shell;
11
12 /** The site-related user menu */
13 public class UserMenu extends CmsLoginShell {
14 private final Control source;
15
16 public UserMenu(Control source) {
17 super(CmsUtils.getCmsView());
18 createUi();
19 if (source == null)
20 throw new CmsException("Source control cannot be null.");
21 this.source = source;
22 open();
23 }
24
25 @Override
26 protected Shell createShell() {
27 return new Shell(Display.getCurrent(), SWT.NO_TRIM | SWT.BORDER
28 | SWT.ON_TOP);
29 }
30
31 @Override
32 public void open() {
33 Shell shell = getShell();
34 shell.pack();
35 shell.layout();
36 shell.setLocation(source.toDisplay(source.getSize().x
37 - shell.getSize().x, source.getSize().y));
38 shell.addShellListener(new ShellAdapter() {
39 private static final long serialVersionUID = 5178980294808435833L;
40
41 @Override
42 public void shellDeactivated(ShellEvent e) {
43 closeShell();
44 }
45 });
46 super.open();
47 }
48
49 }