2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\r
6 * GSS is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * GSS is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
\r
19 package gr.ebs.gss.client;
\r
21 import com.google.gwt.user.client.Command;
\r
22 import com.google.gwt.user.client.Window;
\r
23 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
24 import com.google.gwt.user.client.ui.ClickListener;
\r
25 import com.google.gwt.user.client.ui.ImageBundle;
\r
26 import com.google.gwt.user.client.ui.MenuBar;
\r
27 import com.google.gwt.user.client.ui.PopupPanel;
\r
28 import com.google.gwt.user.client.ui.Widget;
\r
31 * The 'settings' menu implementation.
\r
33 public class SettingsMenu extends PopupPanel implements ClickListener {
\r
36 * The widget's images.
\r
38 private Images images;
\r
39 private final MenuBar contextMenu;
\r
41 * An image bundle for this widgets images.
\r
43 public interface Images extends ImageBundle {
\r
46 * Will bundle the file 'advancedsettings.png' residing in the package
\r
47 * 'gr.ebs.gss.resources'.
\r
49 * @return the image prototype
\r
51 @Resource("gr/ebs/gss/resources/advancedsettings.png")
\r
52 AbstractImagePrototype preferences();
\r
54 @Resource("gr/ebs/gss/resources/lock.png")
\r
55 AbstractImagePrototype credentials();
\r
60 * The widget's constructor.
\r
62 * @param newImages the image bundle passed on by the parent object
\r
64 public SettingsMenu(final Images newImages) {
\r
65 // The popup's constructor's argument is a boolean specifying that it
\r
66 // auto-close itself when the user clicks outside of it.
\r
68 setAnimationEnabled(true);
\r
71 // Make a command that we will execute from all leaves.
\r
72 final Command cmd = new Command() {
\r
74 public void execute() {
\r
76 Window.alert("You selected a menu item!");
\r
79 Command userCredentialsCommand = new Command(){
\r
81 * @see com.google.gwt.user.client.Command#execute()
\r
83 public void execute() {
\r
84 CredentialsDialog dlg = new CredentialsDialog();
\r
88 contextMenu = new MenuBar(true);
\r
89 // contextMenu.addItem("<span>" + newImages.preferences().getHTML() + " Preferences</span>", true, cmd);
\r
90 contextMenu.addItem("<span>" + newImages.credentials().getHTML() + " Show Credentials</span>", true, userCredentialsCommand);
\r
93 // setStyleName("toolbarPopup");
\r
99 * @see com.google.gwt.user.client.ui.ClickListener#onClick(com.google.gwt.user.client.ui.Widget)
\r
101 public void onClick(final Widget sender) {
\r
102 final SettingsMenu menu = new SettingsMenu(images);
\r
103 final int left = sender.getAbsoluteLeft();
\r
104 final int top = sender.getAbsoluteTop() + sender.getOffsetHeight();
\r
105 menu.setPopupPosition(left, top);
\r
112 * Retrieve the contextMenu.
\r
114 * @return the contextMenu
\r
116 public MenuBar getContextMenu() {
\r
117 contextMenu.setAutoOpen(false);
\r
118 return contextMenu;
\r