root / src / gr / ebs / gss / web / client / TopPanel.java @ af6aa461
History | View | Annotate | Download (6.9 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
|
3 |
*
|
4 |
* This file is part of GSS.
|
5 |
*
|
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.
|
10 |
*
|
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.
|
15 |
*
|
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/>.
|
18 |
*/
|
19 |
package gr.ebs.gss.web.client; |
20 |
|
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.Window; |
26 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
27 |
import com.google.gwt.user.client.ui.Composite; |
28 |
import com.google.gwt.user.client.ui.HTML; |
29 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
30 |
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
31 |
import com.google.gwt.user.client.ui.HorizontalPanel; |
32 |
import com.google.gwt.user.client.ui.MenuBar; |
33 |
import com.google.gwt.user.client.ui.MenuItem; |
34 |
|
35 |
/**
|
36 |
* The top panel, which contains the menu bar icons and the user name.
|
37 |
*/
|
38 |
public class TopPanel extends Composite { |
39 |
|
40 |
/**
|
41 |
* A constant that denotes the completion of an IncrementalCommand.
|
42 |
*/
|
43 |
public static final boolean DONE = false; |
44 |
|
45 |
/**
|
46 |
* An image bundle for this widgets images.
|
47 |
*/
|
48 |
public interface Images extends ClientBundle, FileMenu.Images, EditMenu.Images, |
49 |
SettingsMenu.Images, GroupMenu.Images, FilePropertiesDialog.Images, |
50 |
HelpMenu.Images, LoadingIndicator.Images { |
51 |
|
52 |
@Source("gr/ebs/gss/resources/exit.png") |
53 |
ImageResource exit(); |
54 |
|
55 |
@Source("gr/ebs/gss/resources/folder_blue.png") |
56 |
ImageResource folder(); |
57 |
|
58 |
@Source("gr/ebs/gss/resources/edit.png") |
59 |
ImageResource edit(); |
60 |
|
61 |
@Source("gr/ebs/gss/resources/edit_group.png") |
62 |
ImageResource group(); |
63 |
|
64 |
@Source("gr/ebs/gss/resources/configure.png") |
65 |
ImageResource configure(); |
66 |
|
67 |
@Source("gr/ebs/gss/resources/help.png") |
68 |
ImageResource help(); |
69 |
|
70 |
@Source("gr/ebs/gss/resources/pithos-logo.png") |
71 |
ImageResource gssLogo(); |
72 |
|
73 |
@Source("gr/ebs/gss/resources/grnet-logo.png") |
74 |
ImageResource grnetLogo(); |
75 |
} |
76 |
|
77 |
/**
|
78 |
* The menu bar widget.
|
79 |
*/
|
80 |
private MenuBar menu; |
81 |
|
82 |
/**
|
83 |
* The file menu widget.
|
84 |
*/
|
85 |
private FileMenu fileMenu;
|
86 |
|
87 |
/**
|
88 |
* The edit menu widget.
|
89 |
*/
|
90 |
private EditMenu editMenu;
|
91 |
|
92 |
/**
|
93 |
* The group menu widget.
|
94 |
*/
|
95 |
private GroupMenu groupMenu;
|
96 |
|
97 |
/**
|
98 |
* The settings menu widget.
|
99 |
*/
|
100 |
private SettingsMenu settingsMenu;
|
101 |
|
102 |
/**
|
103 |
* The help menu widget.
|
104 |
*/
|
105 |
private HelpMenu helpMenu;
|
106 |
|
107 |
/**
|
108 |
* A widget that displays a message indicating that communication with the
|
109 |
* server is underway.
|
110 |
*/
|
111 |
private LoadingIndicator loading;
|
112 |
|
113 |
/**
|
114 |
* The constructor for the top panel.
|
115 |
*
|
116 |
* @param images the supplied images
|
117 |
*/
|
118 |
public TopPanel(Images images) {
|
119 |
fileMenu = new FileMenu(images);
|
120 |
editMenu = new EditMenu(images);
|
121 |
groupMenu = new GroupMenu(images);
|
122 |
settingsMenu = new SettingsMenu(images);
|
123 |
helpMenu = new HelpMenu(images);
|
124 |
loading = new LoadingIndicator(images);
|
125 |
HorizontalPanel outer = new HorizontalPanel();
|
126 |
|
127 |
outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); |
128 |
|
129 |
menu = new MenuBar(); |
130 |
menu.setWidth("100%");
|
131 |
menu.setAutoOpen(false);
|
132 |
menu.setAnimationEnabled(true);
|
133 |
menu.setStyleName("toolbarmenu");
|
134 |
|
135 |
Command quitCommand = new Command(){
|
136 |
@Override
|
137 |
public void execute() { |
138 |
QuitDialog dlg = new QuitDialog();
|
139 |
dlg.center(); |
140 |
} |
141 |
}; |
142 |
MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + |
143 |
AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand); |
144 |
quitItem.getElement().setId("topMenu.quit");
|
145 |
|
146 |
MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + |
147 |
AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){ |
148 |
@Override
|
149 |
public MenuBar getSubMenu() { |
150 |
return fileMenu.createMenu();
|
151 |
} |
152 |
}; |
153 |
fileItem.getElement().setId("topMenu.file");
|
154 |
|
155 |
MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + |
156 |
AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){ |
157 |
@Override
|
158 |
public MenuBar getSubMenu() { |
159 |
return editMenu.createMenu();
|
160 |
} |
161 |
}; |
162 |
editItem.getElement().setId("topMenu.edit");
|
163 |
|
164 |
MenuItem groupItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + |
165 |
AbstractImagePrototype.create(images.group()).getHTML() + "</td><td>Group</td></tr></table>", true, |
166 |
groupMenu.getContextMenu()); |
167 |
groupItem.getElement().setId("topMenu.group");
|
168 |
|
169 |
MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + |
170 |
AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>",
|
171 |
true,settingsMenu.getContextMenu());
|
172 |
configureItem.getElement().setId("topMenu.settings");
|
173 |
|
174 |
MenuItem helpItem = new MenuItem("<table style='font-size: 100%'><tr><td>" + |
175 |
AbstractImagePrototype.create(images.help()).getHTML() + "</td><td>Help</td></tr></table>", true, new MenuBar(true)){ |
176 |
@Override
|
177 |
public MenuBar getSubMenu() { |
178 |
return helpMenu.createMenu();
|
179 |
} |
180 |
}; |
181 |
helpItem.getElement().setId("topMenu.help");
|
182 |
|
183 |
menu.addItem(quitItem); |
184 |
menu.addItem(fileItem); |
185 |
menu.addItem(editItem); |
186 |
menu.addItem(groupItem); |
187 |
menu.addItem(configureItem); |
188 |
menu.addItem(helpItem); |
189 |
|
190 |
outer.setSpacing(2);
|
191 |
outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); |
192 |
outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE); |
193 |
outer.add(menu); |
194 |
outer.setStyleName("toolbar");
|
195 |
|
196 |
outer.add(loading); |
197 |
|
198 |
Configuration conf = (Configuration) GWT.create(Configuration.class); |
199 |
String path = Window.Location.getPath(); |
200 |
String baseUrl = GWT.getModuleBaseURL();
|
201 |
String homeUrl = baseUrl.substring(0, baseUrl.indexOf(path)); |
202 |
HTML logos = new HTML("<table><tr><td><a href='" + homeUrl + |
203 |
"' target='gss'>" + AbstractImagePrototype.create(images.gssLogo()).getHTML() +
|
204 |
"</a><a href='http://www.grnet.gr/' " + "target='grnet'>" + |
205 |
AbstractImagePrototype.create(images.grnetLogo()).getHTML()+"</a></td></tr></table>");
|
206 |
outer.add(logos); |
207 |
|
208 |
outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT); |
209 |
|
210 |
initWidget(outer); |
211 |
} |
212 |
|
213 |
|
214 |
/**
|
215 |
* Retrieve the loading.
|
216 |
*
|
217 |
* @return the loading
|
218 |
*/
|
219 |
public LoadingIndicator getLoading() {
|
220 |
return loading;
|
221 |
} |
222 |
|
223 |
/**
|
224 |
* Retrieve the fileMenu.
|
225 |
*
|
226 |
* @return the fileMenu
|
227 |
*/
|
228 |
FileMenu getFileMenu() { |
229 |
return fileMenu;
|
230 |
} |
231 |
|
232 |
/**
|
233 |
* Retrieve the editMenu.
|
234 |
*
|
235 |
* @return the editMenu
|
236 |
*/
|
237 |
EditMenu getEditMenu() { |
238 |
return editMenu;
|
239 |
} |
240 |
} |