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.core.client.GWT;
\r
22 import com.google.gwt.resources.client.ClientBundle;
\r
23 import com.google.gwt.resources.client.ImageResource;
\r
24 import com.google.gwt.user.client.Command;
\r
25 import com.google.gwt.user.client.ui.AbstractImagePrototype;
\r
26 import com.google.gwt.user.client.ui.Composite;
\r
27 import com.google.gwt.user.client.ui.HTML;
\r
28 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
\r
29 import com.google.gwt.user.client.ui.HasVerticalAlignment;
\r
30 import com.google.gwt.user.client.ui.HorizontalPanel;
\r
31 import com.google.gwt.user.client.ui.MenuBar;
\r
32 import com.google.gwt.user.client.ui.MenuItem;
\r
35 * The top panel, which contains the menu bar icons and the user name.
\r
37 public class TopPanel extends Composite {
\r
40 * A constant that denotes the completion of an IncrementalCommand.
\r
42 public static final boolean DONE = false;
\r
45 * An image bundle for this widgets images.
\r
47 public interface Images extends ClientBundle, FileMenu.Images, EditMenu.Images,
\r
48 SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images,
\r
49 HelpMenu.Images, LoadingIndicator.Images {
\r
51 @Source("gr/ebs/gss/resources/exit.png")
\r
52 ImageResource exit();
\r
54 @Source("gr/ebs/gss/resources/folder_blue.png")
\r
55 ImageResource folder();
\r
57 @Source("gr/ebs/gss/resources/edit.png")
\r
58 ImageResource edit();
\r
60 @Source("gr/ebs/gss/resources/edit_group.png")
\r
61 ImageResource group();
\r
63 @Source("gr/ebs/gss/resources/configure.png")
\r
64 ImageResource configure();
\r
66 @Source("gr/ebs/gss/resources/help.png")
\r
67 ImageResource help();
\r
69 @Source("gr/ebs/gss/resources/pithos-logo.png")
\r
70 ImageResource gssLogo();
\r
72 @Source("gr/ebs/gss/resources/grnet-logo.png")
\r
73 ImageResource grnetLogo();
\r
77 * The menu bar widget.
\r
79 private MenuBar menu;
\r
82 * The file menu widget.
\r
84 private FileMenu fileMenu;
\r
87 * The edit menu widget.
\r
89 private EditMenu editMenu;
\r
92 * The group menu widget.
\r
94 private GroupMenu groupMenu;
\r
97 * The settings menu widget.
\r
99 private SettingsMenu settingsMenu;
\r
102 * The help menu widget.
\r
104 private HelpMenu helpMenu;
\r
107 * A widget that displays a message indicating that communication with the
\r
108 * server is underway.
\r
110 private LoadingIndicator loading;
\r
113 * The constructor for the top panel.
\r
115 * @param images the supplied images
\r
117 public TopPanel(Images images) {
\r
118 fileMenu = new FileMenu(images);
\r
119 editMenu = new EditMenu(images);
\r
120 groupMenu = new GroupMenu(images);
\r
121 settingsMenu = new SettingsMenu(images);
\r
122 helpMenu = new HelpMenu(images);
\r
123 loading = new LoadingIndicator(images);
\r
124 HorizontalPanel outer = new HorizontalPanel();
\r
126 outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
\r
128 menu = new MenuBar();
\r
129 menu.setWidth("100%");
\r
130 menu.setAutoOpen(false);
\r
131 menu.setAnimationEnabled(true);
\r
132 menu.setStyleName("toolbarmenu");
\r
134 Command quitCommand = new Command(){
\r
135 public void execute() {
\r
136 QuitDialog dlg = new QuitDialog();
\r
140 MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
\r
141 AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand);
\r
142 MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
\r
143 AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
\r
145 public MenuBar getSubMenu() {
\r
146 return fileMenu.createMenu();
\r
149 MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
\r
150 AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
\r
152 public MenuBar getSubMenu() {
\r
153 return editMenu.createMenu();
\r
156 MenuItem groupItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
\r
157 AbstractImagePrototype.create(images.group()).getHTML() + "</td><td>Group</td></tr></table>", true,
\r
158 groupMenu.getContextMenu());
\r
159 MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
\r
160 AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>",
\r
161 true,settingsMenu.getContextMenu());
\r
162 MenuItem helpItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
\r
163 AbstractImagePrototype.create(images.help()).getHTML() + "</td><td>Help</td></tr></table>", true, new MenuBar(true)){
\r
165 public MenuBar getSubMenu() {
\r
166 return helpMenu.createMenu();
\r
169 menu.addItem(quitItem);
\r
170 menu.addItem(fileItem);
\r
171 menu.addItem(editItem);
\r
172 menu.addItem(groupItem);
\r
173 menu.addItem(configureItem);
\r
174 menu.addItem(helpItem);
\r
176 outer.setSpacing(2);
\r
177 outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
\r
178 outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
\r
180 outer.setStyleName("toolbar");
\r
182 outer.add(loading);
\r
184 Configuration conf = (Configuration) GWT.create(Configuration.class);
\r
185 HTML logos = new HTML("<table><tr><td><a href='" + conf.serviceHome() +
\r
186 "' target='gss'>" + AbstractImagePrototype.create(images.gssLogo()).getHTML() +
\r
187 "</a><a href='http://www.grnet.gr/' " + "target='grnet'>" +
\r
188 AbstractImagePrototype.create(images.grnetLogo()).getHTML()+"</a></td></tr></table>");
\r
191 outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT);
\r
198 * Retrieve the loading.
\r
200 * @return the loading
\r
202 public LoadingIndicator getLoading() {
\r
207 * Retrieve the fileMenu.
\r
209 * @return the fileMenu
\r
211 FileMenu getFileMenu() {
\r
216 * Retrieve the editMenu.
\r
218 * @return the editMenu
\r
220 EditMenu getEditMenu() {
\r