X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=inline;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FUserMenu.java;h=a654dddd4054f7aa27b318352afe65d892a0ec29;hb=c873a0359345503b8e3ca07828bd99d525ec7cc0;hp=95c7b21597a8b1aed1a9ce8b42132c5ecdad18f1;hpb=94114b7d025df8452c96a23554ec96c32e6c459b;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/util/UserMenu.java b/org.argeo.cms/src/org/argeo/cms/util/UserMenu.java index 95c7b2159..a654dddd4 100644 --- a/org.argeo.cms/src/org/argeo/cms/util/UserMenu.java +++ b/org.argeo.cms/src/org/argeo/cms/util/UserMenu.java @@ -1,84 +1,48 @@ package org.argeo.cms.util; -import org.argeo.cms.widgets.auth.CmsLogin; -import org.eclipse.rap.rwt.RWT; +import org.argeo.cms.CmsException; +import org.argeo.cms.widgets.auth.CmsLoginShell; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ShellAdapter; import org.eclipse.swt.events.ShellEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; /** The site-related user menu */ -public class UserMenu extends CmsLogin { - private final Shell shell; +public class UserMenu extends CmsLoginShell { + private final Control source; - public UserMenu(Control source, boolean autoclose) { + public UserMenu(Control source) { super(CmsUtils.getCmsView()); - if (source != null) { - shell = new Shell(Display.getCurrent(), SWT.NO_TRIM | SWT.BORDER - | SWT.ON_TOP); - } else { - shell = new Shell(Display.getCurrent(), SWT.NO_TRIM); - shell.setMaximized(true); - shell.setLayout(CmsUtils.noSpaceGridLayout()); - } - shell.setData(RWT.CUSTOM_VARIANT, CMS_USER_MENU); - - if (isAnonymous()) { - anonymousUi(shell); - } else { - userUi(shell); - } - - if (source != null) {// popup - shell.pack(); - shell.layout(); - shell.setLocation(source.toDisplay( - source.getSize().x - shell.getSize().x, source.getSize().y)); - } else { // centered - Composite parent = getCredentialsBlock(); - parent.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, - true)); - // Rectangle shellBounds = shell.getBounds();// RAP - // Point dialogSize = parent.getSize(); - // int x = shellBounds.x + (shellBounds.width - dialogSize.x) / 2; - // int y = shellBounds.y + (shellBounds.height - dialogSize.y) / 2; - // parent.setLocation(x, y); - } - if (autoclose) - shell.addShellListener(new ShellAdapter() { - private static final long serialVersionUID = 5178980294808435833L; - - @Override - public void shellDeactivated(ShellEvent e) { - closeShell(); - } - }); - shell.open(); - + if (source == null) + throw new CmsException("Source control cannot be null."); + this.source = source; + open(); } @Override - protected void login() { - super.login(); - closeShell(); + protected Shell createShell() { + return new Shell(Display.getCurrent(), SWT.NO_TRIM | SWT.BORDER + | SWT.ON_TOP); } @Override - protected void logout() { - closeShell(); - super.logout(); + public void open() { + Shell shell = getShell(); + shell.pack(); + shell.layout(); + shell.setLocation(source.toDisplay(source.getSize().x + - shell.getSize().x, source.getSize().y)); + shell.addShellListener(new ShellAdapter() { + private static final long serialVersionUID = 5178980294808435833L; + + @Override + public void shellDeactivated(ShellEvent e) { + closeShell(); + } + }); + super.open(); } - protected void closeShell() { - shell.close(); - shell.dispose(); - } - - public Shell getShell() { - return shell; - } }