Statistics
| Branch: | Tag: | Revision:

root / web_client / src / gr / grnet / pithos / web / client / TopPanel.java @ 58777026

History | View | Annotate | Download (7.2 kB)

1 ab1eb3f8 Christos Stathis
/*
2 58777026 Christos Stathis
 * Copyright 2011 GRNET S.A. All rights reserved.
3 58777026 Christos Stathis
 *
4 58777026 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 58777026 Christos Stathis
 * without modification, are permitted provided that the following
6 58777026 Christos Stathis
 * conditions are met:
7 58777026 Christos Stathis
 *
8 58777026 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 58777026 Christos Stathis
 *      disclaimer.
11 58777026 Christos Stathis
 *
12 58777026 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 58777026 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 58777026 Christos Stathis
 *      provided with the distribution.
16 58777026 Christos Stathis
 *
17 58777026 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 58777026 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 58777026 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 58777026 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 58777026 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 58777026 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 58777026 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 58777026 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 58777026 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 58777026 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 58777026 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 58777026 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 58777026 Christos Stathis
 *
30 58777026 Christos Stathis
 * The views and conclusions contained in the software and
31 58777026 Christos Stathis
 * documentation are those of the authors and should not be
32 58777026 Christos Stathis
 * interpreted as representing official policies, either expressed
33 58777026 Christos Stathis
 * or implied, of GRNET S.A.
34 ab1eb3f8 Christos Stathis
 */
35 ab1eb3f8 Christos Stathis
package gr.grnet.pithos.web.client;
36 ab1eb3f8 Christos Stathis
37 ab1eb3f8 Christos Stathis
import com.google.gwt.core.client.GWT;
38 ab1eb3f8 Christos Stathis
import com.google.gwt.resources.client.ClientBundle;
39 ab1eb3f8 Christos Stathis
import com.google.gwt.resources.client.ImageResource;
40 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.Command;
41 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.Window;
42 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.AbstractImagePrototype;
43 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.Composite;
44 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HTML;
45 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
46 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HasVerticalAlignment;
47 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HorizontalPanel;
48 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.MenuBar;
49 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.MenuItem;
50 ab1eb3f8 Christos Stathis
51 ab1eb3f8 Christos Stathis
/**
52 ab1eb3f8 Christos Stathis
 * The top panel, which contains the menu bar icons and the user name.
53 ab1eb3f8 Christos Stathis
 */
54 ab1eb3f8 Christos Stathis
public class TopPanel extends Composite {
55 ab1eb3f8 Christos Stathis
56 ab1eb3f8 Christos Stathis
        /**
57 ab1eb3f8 Christos Stathis
         * A constant that denotes the completion of an IncrementalCommand.
58 ab1eb3f8 Christos Stathis
         */
59 ab1eb3f8 Christos Stathis
        public static final boolean DONE = false;
60 ab1eb3f8 Christos Stathis
61 ab1eb3f8 Christos Stathis
        /**
62 ab1eb3f8 Christos Stathis
         * An image bundle for this widgets images.
63 ab1eb3f8 Christos Stathis
         */
64 ab1eb3f8 Christos Stathis
        public interface Images extends ClientBundle, FileMenu.Images, EditMenu.Images,
65 9e8e14e4 Christos Stathis
                        SettingsMenu.Images, FilePropertiesDialog.Images,
66 ab1eb3f8 Christos Stathis
                        HelpMenu.Images, LoadingIndicator.Images {
67 ab1eb3f8 Christos Stathis
68 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/exit.png")
69 ab1eb3f8 Christos Stathis
                ImageResource exit();
70 ab1eb3f8 Christos Stathis
71 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/folder_blue.png")
72 ab1eb3f8 Christos Stathis
                ImageResource folder();
73 ab1eb3f8 Christos Stathis
74 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/edit.png")
75 ab1eb3f8 Christos Stathis
                ImageResource edit();
76 ab1eb3f8 Christos Stathis
77 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/edit_group.png")
78 ab1eb3f8 Christos Stathis
                ImageResource group();
79 ab1eb3f8 Christos Stathis
80 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/configure.png")
81 ab1eb3f8 Christos Stathis
                ImageResource configure();
82 ab1eb3f8 Christos Stathis
83 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/help.png")
84 ab1eb3f8 Christos Stathis
                ImageResource help();
85 ab1eb3f8 Christos Stathis
86 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/pithos-logo.png")
87 ab1eb3f8 Christos Stathis
                ImageResource gssLogo();
88 ab1eb3f8 Christos Stathis
89 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/grnet-logo.png")
90 ab1eb3f8 Christos Stathis
                ImageResource grnetLogo();
91 ab1eb3f8 Christos Stathis
        }
92 ab1eb3f8 Christos Stathis
93 ab1eb3f8 Christos Stathis
        /**
94 ab1eb3f8 Christos Stathis
         * The menu bar widget.
95 ab1eb3f8 Christos Stathis
         */
96 ab1eb3f8 Christos Stathis
        private MenuBar menu;
97 ab1eb3f8 Christos Stathis
98 ab1eb3f8 Christos Stathis
        /**
99 ab1eb3f8 Christos Stathis
         * The file menu widget.
100 ab1eb3f8 Christos Stathis
         */
101 ab1eb3f8 Christos Stathis
        private FileMenu fileMenu;
102 ab1eb3f8 Christos Stathis
103 ab1eb3f8 Christos Stathis
        /**
104 ab1eb3f8 Christos Stathis
         * The edit menu widget.
105 ab1eb3f8 Christos Stathis
         */
106 ab1eb3f8 Christos Stathis
        private EditMenu editMenu;
107 ab1eb3f8 Christos Stathis
108 ab1eb3f8 Christos Stathis
        /**
109 ab1eb3f8 Christos Stathis
         * The settings menu widget.
110 ab1eb3f8 Christos Stathis
         */
111 ab1eb3f8 Christos Stathis
        private SettingsMenu settingsMenu;
112 ab1eb3f8 Christos Stathis
113 ab1eb3f8 Christos Stathis
        /**
114 ab1eb3f8 Christos Stathis
         * The help menu widget.
115 ab1eb3f8 Christos Stathis
         */
116 ab1eb3f8 Christos Stathis
        private HelpMenu helpMenu;
117 ab1eb3f8 Christos Stathis
118 ab1eb3f8 Christos Stathis
        /**
119 ab1eb3f8 Christos Stathis
         * A widget that displays a message indicating that communication with the
120 ab1eb3f8 Christos Stathis
         * server is underway.
121 ab1eb3f8 Christos Stathis
         */
122 ab1eb3f8 Christos Stathis
        private LoadingIndicator loading;
123 ab1eb3f8 Christos Stathis
124 ab1eb3f8 Christos Stathis
        /**
125 ab1eb3f8 Christos Stathis
         * The constructor for the top panel.
126 ab1eb3f8 Christos Stathis
         *
127 ab1eb3f8 Christos Stathis
         * @param images the supplied images
128 ab1eb3f8 Christos Stathis
         */
129 ab1eb3f8 Christos Stathis
        public TopPanel(Images images) {
130 ab1eb3f8 Christos Stathis
                fileMenu = new FileMenu(images);
131 ab1eb3f8 Christos Stathis
                editMenu = new EditMenu(images);
132 ab1eb3f8 Christos Stathis
                settingsMenu = new SettingsMenu(images);
133 ab1eb3f8 Christos Stathis
                helpMenu = new HelpMenu(images);
134 ab1eb3f8 Christos Stathis
                loading = new LoadingIndicator(images);
135 9e8e14e4 Christos Stathis
        loading.hide();
136 ab1eb3f8 Christos Stathis
                HorizontalPanel outer = new HorizontalPanel();
137 ab1eb3f8 Christos Stathis
138 ab1eb3f8 Christos Stathis
                outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
139 ab1eb3f8 Christos Stathis
140 ab1eb3f8 Christos Stathis
                menu = new MenuBar();
141 ab1eb3f8 Christos Stathis
                menu.setWidth("100%");
142 ab1eb3f8 Christos Stathis
                menu.setAutoOpen(false);
143 ab1eb3f8 Christos Stathis
                menu.setAnimationEnabled(true);
144 ab1eb3f8 Christos Stathis
                menu.setStyleName("toolbarmenu");
145 ab1eb3f8 Christos Stathis
146 ab1eb3f8 Christos Stathis
                Command quitCommand = new Command(){
147 ab1eb3f8 Christos Stathis
                        @Override
148 ab1eb3f8 Christos Stathis
                        public void execute() {
149 ab1eb3f8 Christos Stathis
                                QuitDialog dlg = new QuitDialog();
150 ab1eb3f8 Christos Stathis
                                dlg.center();
151 ab1eb3f8 Christos Stathis
                        }
152 ab1eb3f8 Christos Stathis
                };
153 ab1eb3f8 Christos Stathis
                MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
154 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand);
155 ab1eb3f8 Christos Stathis
                quitItem.getElement().setId("topMenu.quit");
156 ab1eb3f8 Christos Stathis
                
157 ab1eb3f8 Christos Stathis
                MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
158 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
159 ab1eb3f8 Christos Stathis
                        @Override
160 ab1eb3f8 Christos Stathis
                        public MenuBar getSubMenu() {
161 ab1eb3f8 Christos Stathis
                                return fileMenu.createMenu();
162 ab1eb3f8 Christos Stathis
                        }
163 ab1eb3f8 Christos Stathis
                };
164 ab1eb3f8 Christos Stathis
                fileItem.getElement().setId("topMenu.file");
165 ab1eb3f8 Christos Stathis
                
166 ab1eb3f8 Christos Stathis
                MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
167 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
168 ab1eb3f8 Christos Stathis
                        @Override
169 ab1eb3f8 Christos Stathis
                        public MenuBar getSubMenu() {
170 ab1eb3f8 Christos Stathis
                                return editMenu.createMenu();
171 ab1eb3f8 Christos Stathis
                        }
172 ab1eb3f8 Christos Stathis
                };
173 ab1eb3f8 Christos Stathis
                editItem.getElement().setId("topMenu.edit");
174 ab1eb3f8 Christos Stathis
                
175 ab1eb3f8 Christos Stathis
                MenuItem configureItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
176 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.configure()).getHTML() + "</td><td>Settings</td></tr></table>",
177 ab1eb3f8 Christos Stathis
                                        true,settingsMenu.getContextMenu());
178 ab1eb3f8 Christos Stathis
                configureItem.getElement().setId("topMenu.settings");
179 ab1eb3f8 Christos Stathis
                
180 ab1eb3f8 Christos Stathis
                MenuItem helpItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
181 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.help()).getHTML() + "</td><td>Help</td></tr></table>", true, new MenuBar(true)){
182 ab1eb3f8 Christos Stathis
                        @Override
183 ab1eb3f8 Christos Stathis
                        public MenuBar getSubMenu() {
184 ab1eb3f8 Christos Stathis
                                return helpMenu.createMenu();
185 ab1eb3f8 Christos Stathis
                        }
186 ab1eb3f8 Christos Stathis
                };
187 ab1eb3f8 Christos Stathis
                helpItem.getElement().setId("topMenu.help");
188 ab1eb3f8 Christos Stathis
                
189 ab1eb3f8 Christos Stathis
                menu.addItem(quitItem);
190 ab1eb3f8 Christos Stathis
                menu.addItem(fileItem);
191 ab1eb3f8 Christos Stathis
                menu.addItem(editItem);
192 ab1eb3f8 Christos Stathis
                menu.addItem(configureItem);
193 ab1eb3f8 Christos Stathis
                menu.addItem(helpItem);
194 ab1eb3f8 Christos Stathis
195 ab1eb3f8 Christos Stathis
                outer.setSpacing(2);
196 ab1eb3f8 Christos Stathis
                outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
197 ab1eb3f8 Christos Stathis
                outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
198 ab1eb3f8 Christos Stathis
                outer.add(menu);
199 ab1eb3f8 Christos Stathis
                outer.setStyleName("toolbar");
200 ab1eb3f8 Christos Stathis
201 ab1eb3f8 Christos Stathis
                outer.add(loading);
202 ab1eb3f8 Christos Stathis
203 4a96a6c5 Christos Stathis
                HTML logos = new HTML("<table><tr><td><a href='http://pithos.grnet.gr/pithos' target='pithos'>" +        AbstractImagePrototype.create(images.gssLogo()).getHTML() +
204 ab1eb3f8 Christos Stathis
                                        "</a><a href='http://www.grnet.gr/' " +        "target='grnet'>" +
205 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.grnetLogo()).getHTML()+"</a></td></tr></table>");
206 ab1eb3f8 Christos Stathis
                outer.add(logos);
207 ab1eb3f8 Christos Stathis
208 ab1eb3f8 Christos Stathis
                outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT);
209 ab1eb3f8 Christos Stathis
210 ab1eb3f8 Christos Stathis
                initWidget(outer);
211 ab1eb3f8 Christos Stathis
        }
212 ab1eb3f8 Christos Stathis
213 ab1eb3f8 Christos Stathis
214 ab1eb3f8 Christos Stathis
        /**
215 ab1eb3f8 Christos Stathis
         * Retrieve the loading.
216 ab1eb3f8 Christos Stathis
         *
217 ab1eb3f8 Christos Stathis
         * @return the loading
218 ab1eb3f8 Christos Stathis
         */
219 ab1eb3f8 Christos Stathis
        public LoadingIndicator getLoading() {
220 ab1eb3f8 Christos Stathis
                return loading;
221 ab1eb3f8 Christos Stathis
        }
222 ab1eb3f8 Christos Stathis
223 ab1eb3f8 Christos Stathis
        /**
224 ab1eb3f8 Christos Stathis
         * Retrieve the fileMenu.
225 ab1eb3f8 Christos Stathis
         *
226 ab1eb3f8 Christos Stathis
         * @return the fileMenu
227 ab1eb3f8 Christos Stathis
         */
228 ab1eb3f8 Christos Stathis
        FileMenu getFileMenu() {
229 ab1eb3f8 Christos Stathis
                return fileMenu;
230 ab1eb3f8 Christos Stathis
        }
231 ab1eb3f8 Christos Stathis
232 ab1eb3f8 Christos Stathis
        /**
233 ab1eb3f8 Christos Stathis
         * Retrieve the editMenu.
234 ab1eb3f8 Christos Stathis
         *
235 ab1eb3f8 Christos Stathis
         * @return the editMenu
236 ab1eb3f8 Christos Stathis
         */
237 ab1eb3f8 Christos Stathis
        EditMenu getEditMenu() {
238 ab1eb3f8 Christos Stathis
                return editMenu;
239 ab1eb3f8 Christos Stathis
        }
240 ab1eb3f8 Christos Stathis
}