2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
4 * This file is part of GSS.
6 * GSS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
19 package gr.ebs.gss.client;
21 import com.google.gwt.core.client.GWT;
22 import com.google.gwt.resources.client.ClientBundle;
23 import com.google.gwt.resources.client.ImageResource;
24 import com.google.gwt.user.client.Command;
25 import com.google.gwt.user.client.ui.AbstractImagePrototype;
26 import com.google.gwt.user.client.ui.Composite;
27 import com.google.gwt.user.client.ui.HTML;
28 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
29 import com.google.gwt.user.client.ui.HasVerticalAlignment;
30 import com.google.gwt.user.client.ui.HorizontalPanel;
31 import com.google.gwt.user.client.ui.MenuBar;
32 import com.google.gwt.user.client.ui.MenuItem;
35 * The top panel, which contains the menu bar icons and the user name.
37 public class TopPanel extends Composite {
40 * A constant that denotes the completion of an IncrementalCommand.
42 public static final boolean DONE = false;
45 * An image bundle for this widgets images.
47 public interface Images extends ClientBundle, FileMenu.Images, EditMenu.Images,
48 SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images,
49 HelpMenu.Images, LoadingIndicator.Images {
51 @Source("gr/ebs/gss/resources/exit.png")
54 @Source("gr/ebs/gss/resources/folder_blue.png")
55 ImageResource folder();
57 @Source("gr/ebs/gss/resources/edit.png")
60 @Source("gr/ebs/gss/resources/edit_group.png")
61 ImageResource group();
63 @Source("gr/ebs/gss/resources/configure.png")
64 ImageResource configure();
66 @Source("gr/ebs/gss/resources/help.png")
69 @Source("gr/ebs/gss/resources/pithos-logo.png")
70 ImageResource gssLogo();
72 @Source("gr/ebs/gss/resources/grnet-logo.png")
73 ImageResource grnetLogo();
77 * The menu bar widget.
82 * The file menu widget.
84 private FileMenu fileMenu;
87 * The edit menu widget.
89 private EditMenu editMenu;
92 * The group menu widget.
94 private GroupMenu groupMenu;
97 * The settings menu widget.
99 private SettingsMenu settingsMenu;
102 * The help menu widget.
104 private HelpMenu helpMenu;
107 * A widget that displays a message indicating that communication with the
108 * server is underway.
110 private LoadingIndicator loading;
113 * The constructor for the top panel.
115 * @param images the supplied images
117 public TopPanel(Images images) {
118 fileMenu = new FileMenu(images);
119 editMenu = new EditMenu(images);
120 groupMenu = new GroupMenu(images);
121 settingsMenu = new SettingsMenu(images);
122 helpMenu = new HelpMenu(images);
123 loading = new LoadingIndicator(images);
124 HorizontalPanel outer = new HorizontalPanel();
126 outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
128 menu = new MenuBar();
129 menu.setWidth("100%");
130 menu.setAutoOpen(false);
131 menu.setAnimationEnabled(true);
132 menu.setStyleName("toolbarmenu");
134 Command quitCommand = new Command(){
136 public void execute() {
137 QuitDialog dlg = new QuitDialog();
141 MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
142 AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand);
143 quitItem.getElement().setId("topMenu.quit");
145 MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
146 AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
148 public MenuBar getSubMenu() {
149 return fileMenu.createMenu();
152 fileItem.getElement().setId("topMenu.file");
154 MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
155 AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
157 public MenuBar getSubMenu() {
158 return editMenu.createMenu();
161 editItem.getElement().setId("topMenu.edit");
163 MenuItem groupItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
164 AbstractImagePrototype.create(images.group()).getHTML() + "</td><td>Group</td></tr></table>", true,
165 groupMenu.getContextMenu());
166 groupItem.getElement().setId("topMenu.group");
168 MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
169 AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>",
170 true,settingsMenu.getContextMenu());
171 configureItem.getElement().setId("topMenu.settings");
173 MenuItem helpItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
174 AbstractImagePrototype.create(images.help()).getHTML() + "</td><td>Help</td></tr></table>", true, new MenuBar(true)){
176 public MenuBar getSubMenu() {
177 return helpMenu.createMenu();
180 helpItem.getElement().setId("topMenu.help");
182 menu.addItem(quitItem);
183 menu.addItem(fileItem);
184 menu.addItem(editItem);
185 menu.addItem(groupItem);
186 menu.addItem(configureItem);
187 menu.addItem(helpItem);
190 outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
191 outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
193 outer.setStyleName("toolbar");
197 Configuration conf = (Configuration) GWT.create(Configuration.class);
198 HTML logos = new HTML("<table><tr><td><a href='" + conf.serviceHome() +
199 "' target='gss'>" + AbstractImagePrototype.create(images.gssLogo()).getHTML() +
200 "</a><a href='http://www.grnet.gr/' " + "target='grnet'>" +
201 AbstractImagePrototype.create(images.grnetLogo()).getHTML()+"</a></td></tr></table>");
204 outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT);
211 * Retrieve the loading.
213 * @return the loading
215 public LoadingIndicator getLoading() {
220 * Retrieve the fileMenu.
222 * @return the fileMenu
224 FileMenu getFileMenu() {
229 * Retrieve the editMenu.
231 * @return the editMenu
233 EditMenu getEditMenu() {