Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (5.7 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
         * A widget that displays a message indicating that communication with the
95 ab1eb3f8 Christos Stathis
         * server is underway.
96 ab1eb3f8 Christos Stathis
         */
97 ab1eb3f8 Christos Stathis
        private LoadingIndicator loading;
98 ab1eb3f8 Christos Stathis
99 ab1eb3f8 Christos Stathis
        /**
100 ab1eb3f8 Christos Stathis
         * The constructor for the top panel.
101 ab1eb3f8 Christos Stathis
         *
102 ab1eb3f8 Christos Stathis
         * @param images the supplied images
103 ab1eb3f8 Christos Stathis
         */
104 3d01deba Christos Stathis
        public TopPanel(final Images images) {
105 ab1eb3f8 Christos Stathis
                loading = new LoadingIndicator(images);
106 9e8e14e4 Christos Stathis
        loading.hide();
107 ab1eb3f8 Christos Stathis
                HorizontalPanel outer = new HorizontalPanel();
108 ab1eb3f8 Christos Stathis
109 ab1eb3f8 Christos Stathis
                outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
110 ab1eb3f8 Christos Stathis
111 e3f47376 Christos Stathis
                MenuBar menu = new MenuBar();
112 ab1eb3f8 Christos Stathis
                menu.setWidth("100%");
113 ab1eb3f8 Christos Stathis
                menu.setAutoOpen(false);
114 ab1eb3f8 Christos Stathis
                menu.setAnimationEnabled(true);
115 ab1eb3f8 Christos Stathis
                menu.setStyleName("toolbarmenu");
116 ab1eb3f8 Christos Stathis
117 ab1eb3f8 Christos Stathis
                Command quitCommand = new Command(){
118 ab1eb3f8 Christos Stathis
                        @Override
119 ab1eb3f8 Christos Stathis
                        public void execute() {
120 ab1eb3f8 Christos Stathis
                                QuitDialog dlg = new QuitDialog();
121 ab1eb3f8 Christos Stathis
                                dlg.center();
122 ab1eb3f8 Christos Stathis
                        }
123 ab1eb3f8 Christos Stathis
                };
124 ab1eb3f8 Christos Stathis
                MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
125 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand);
126 3d01deba Christos Stathis
127 ab1eb3f8 Christos Stathis
                MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
128 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
129 ab1eb3f8 Christos Stathis
                        @Override
130 ab1eb3f8 Christos Stathis
                        public MenuBar getSubMenu() {
131 3d01deba Christos Stathis
                                return new FileMenu(GSS.get(), images);
132 ab1eb3f8 Christos Stathis
                        }
133 ab1eb3f8 Christos Stathis
                };
134 3d01deba Christos Stathis
135 ab1eb3f8 Christos Stathis
                MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
136 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
137 ab1eb3f8 Christos Stathis
                        @Override
138 ab1eb3f8 Christos Stathis
                        public MenuBar getSubMenu() {
139 e3f47376 Christos Stathis
                                return new EditMenu(GSS.get(), images);
140 ab1eb3f8 Christos Stathis
                        }
141 ab1eb3f8 Christos Stathis
                };
142 3d01deba Christos Stathis
143 ab1eb3f8 Christos Stathis
                menu.addItem(quitItem);
144 ab1eb3f8 Christos Stathis
                menu.addItem(fileItem);
145 ab1eb3f8 Christos Stathis
                menu.addItem(editItem);
146 ab1eb3f8 Christos Stathis
147 ab1eb3f8 Christos Stathis
                outer.setSpacing(2);
148 ab1eb3f8 Christos Stathis
                outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
149 ab1eb3f8 Christos Stathis
                outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
150 ab1eb3f8 Christos Stathis
                outer.add(menu);
151 ab1eb3f8 Christos Stathis
                outer.setStyleName("toolbar");
152 ab1eb3f8 Christos Stathis
153 ab1eb3f8 Christos Stathis
                outer.add(loading);
154 ab1eb3f8 Christos Stathis
155 4a96a6c5 Christos Stathis
                HTML logos = new HTML("<table><tr><td><a href='http://pithos.grnet.gr/pithos' target='pithos'>" +        AbstractImagePrototype.create(images.gssLogo()).getHTML() +
156 ab1eb3f8 Christos Stathis
                                        "</a><a href='http://www.grnet.gr/' " +        "target='grnet'>" +
157 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.grnetLogo()).getHTML()+"</a></td></tr></table>");
158 ab1eb3f8 Christos Stathis
                outer.add(logos);
159 ab1eb3f8 Christos Stathis
160 ab1eb3f8 Christos Stathis
                outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT);
161 ab1eb3f8 Christos Stathis
162 ab1eb3f8 Christos Stathis
                initWidget(outer);
163 ab1eb3f8 Christos Stathis
        }
164 ab1eb3f8 Christos Stathis
165 ab1eb3f8 Christos Stathis
166 ab1eb3f8 Christos Stathis
        /**
167 ab1eb3f8 Christos Stathis
         * Retrieve the loading.
168 ab1eb3f8 Christos Stathis
         *
169 ab1eb3f8 Christos Stathis
         * @return the loading
170 ab1eb3f8 Christos Stathis
         */
171 ab1eb3f8 Christos Stathis
        public LoadingIndicator getLoading() {
172 ab1eb3f8 Christos Stathis
                return loading;
173 ab1eb3f8 Christos Stathis
        }
174 ab1eb3f8 Christos Stathis
}