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 MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
144 AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
146 public MenuBar getSubMenu() {
147 return fileMenu.createMenu();
150 MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
151 AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
153 public MenuBar getSubMenu() {
154 return editMenu.createMenu();
157 MenuItem groupItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
158 AbstractImagePrototype.create(images.group()).getHTML() + "</td><td>Group</td></tr></table>", true,
159 groupMenu.getContextMenu());
160 MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
161 AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>",
162 true,settingsMenu.getContextMenu());
163 MenuItem helpItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
164 AbstractImagePrototype.create(images.help()).getHTML() + "</td><td>Help</td></tr></table>", true, new MenuBar(true)){
166 public MenuBar getSubMenu() {
167 return helpMenu.createMenu();
170 menu.addItem(quitItem);
171 menu.addItem(fileItem);
172 menu.addItem(editItem);
173 menu.addItem(groupItem);
174 menu.addItem(configureItem);
175 menu.addItem(helpItem);
178 outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
179 outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
181 outer.setStyleName("toolbar");
185 Configuration conf = (Configuration) GWT.create(Configuration.class);
186 HTML logos = new HTML("<table><tr><td><a href='" + conf.serviceHome() +
187 "' target='gss'>" + AbstractImagePrototype.create(images.gssLogo()).getHTML() +
188 "</a><a href='http://www.grnet.gr/' " + "target='grnet'>" +
189 AbstractImagePrototype.create(images.grnetLogo()).getHTML()+"</a></td></tr></table>");
192 outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT);
199 * Retrieve the loading.
201 * @return the loading
203 public LoadingIndicator getLoading() {
208 * Retrieve the fileMenu.
210 * @return the fileMenu
212 FileMenu getFileMenu() {
217 * Retrieve the editMenu.
219 * @return the editMenu
221 EditMenu getEditMenu() {