Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (5.6 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.resources.client.ClientBundle;
38 ab1eb3f8 Christos Stathis
import com.google.gwt.resources.client.ImageResource;
39 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.Command;
40 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.AbstractImagePrototype;
41 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.Composite;
42 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HTML;
43 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
44 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HasVerticalAlignment;
45 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HorizontalPanel;
46 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.MenuBar;
47 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.MenuItem;
48 ab1eb3f8 Christos Stathis
49 ab1eb3f8 Christos Stathis
/**
50 ab1eb3f8 Christos Stathis
 * The top panel, which contains the menu bar icons and the user name.
51 ab1eb3f8 Christos Stathis
 */
52 ab1eb3f8 Christos Stathis
public class TopPanel extends Composite {
53 ab1eb3f8 Christos Stathis
54 ab1eb3f8 Christos Stathis
        /**
55 ab1eb3f8 Christos Stathis
         * A constant that denotes the completion of an IncrementalCommand.
56 ab1eb3f8 Christos Stathis
         */
57 ab1eb3f8 Christos Stathis
        public static final boolean DONE = false;
58 ab1eb3f8 Christos Stathis
59 ab1eb3f8 Christos Stathis
        /**
60 ab1eb3f8 Christos Stathis
         * An image bundle for this widgets images.
61 ab1eb3f8 Christos Stathis
         */
62 ab1eb3f8 Christos Stathis
        public interface Images extends ClientBundle, FileMenu.Images, EditMenu.Images,
63 9e8e14e4 Christos Stathis
                        SettingsMenu.Images, FilePropertiesDialog.Images,
64 ab1eb3f8 Christos Stathis
                        HelpMenu.Images, LoadingIndicator.Images {
65 ab1eb3f8 Christos Stathis
66 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/exit.png")
67 ab1eb3f8 Christos Stathis
                ImageResource exit();
68 ab1eb3f8 Christos Stathis
69 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/folder_blue.png")
70 ab1eb3f8 Christos Stathis
                ImageResource folder();
71 ab1eb3f8 Christos Stathis
72 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/edit.png")
73 ab1eb3f8 Christos Stathis
                ImageResource edit();
74 ab1eb3f8 Christos Stathis
75 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/edit_group.png")
76 ab1eb3f8 Christos Stathis
                ImageResource group();
77 ab1eb3f8 Christos Stathis
78 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/configure.png")
79 ab1eb3f8 Christos Stathis
                ImageResource configure();
80 ab1eb3f8 Christos Stathis
81 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/help.png")
82 ab1eb3f8 Christos Stathis
                ImageResource help();
83 ab1eb3f8 Christos Stathis
84 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/pithos-logo.png")
85 ab1eb3f8 Christos Stathis
                ImageResource gssLogo();
86 ab1eb3f8 Christos Stathis
87 ab1eb3f8 Christos Stathis
                @Source("gr/grnet/pithos/resources/grnet-logo.png")
88 ab1eb3f8 Christos Stathis
                ImageResource grnetLogo();
89 ab1eb3f8 Christos Stathis
        }
90 ab1eb3f8 Christos Stathis
91 ab1eb3f8 Christos Stathis
        /**
92 ab1eb3f8 Christos Stathis
         * A widget that displays a message indicating that communication with the
93 ab1eb3f8 Christos Stathis
         * server is underway.
94 ab1eb3f8 Christos Stathis
         */
95 ab1eb3f8 Christos Stathis
        private LoadingIndicator loading;
96 ab1eb3f8 Christos Stathis
97 ab1eb3f8 Christos Stathis
        /**
98 ab1eb3f8 Christos Stathis
         * The constructor for the top panel.
99 ab1eb3f8 Christos Stathis
         *
100 ab1eb3f8 Christos Stathis
         * @param images the supplied images
101 ab1eb3f8 Christos Stathis
         */
102 3d01deba Christos Stathis
        public TopPanel(final Images images) {
103 ab1eb3f8 Christos Stathis
                loading = new LoadingIndicator(images);
104 9e8e14e4 Christos Stathis
        loading.hide();
105 ab1eb3f8 Christos Stathis
                HorizontalPanel outer = new HorizontalPanel();
106 ab1eb3f8 Christos Stathis
107 ab1eb3f8 Christos Stathis
                outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
108 ab1eb3f8 Christos Stathis
109 e3f47376 Christos Stathis
                MenuBar menu = new MenuBar();
110 ab1eb3f8 Christos Stathis
                menu.setWidth("100%");
111 ab1eb3f8 Christos Stathis
                menu.setAutoOpen(false);
112 ab1eb3f8 Christos Stathis
                menu.setAnimationEnabled(true);
113 ab1eb3f8 Christos Stathis
                menu.setStyleName("toolbarmenu");
114 ab1eb3f8 Christos Stathis
115 ab1eb3f8 Christos Stathis
                Command quitCommand = new Command(){
116 ab1eb3f8 Christos Stathis
                        @Override
117 ab1eb3f8 Christos Stathis
                        public void execute() {
118 ab1eb3f8 Christos Stathis
                                QuitDialog dlg = new QuitDialog();
119 ab1eb3f8 Christos Stathis
                                dlg.center();
120 ab1eb3f8 Christos Stathis
                        }
121 ab1eb3f8 Christos Stathis
                };
122 ab1eb3f8 Christos Stathis
                MenuItem quitItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
123 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.exit()).getHTML() + "</td><td>Quit</td></tr></table>", true, quitCommand);
124 3d01deba Christos Stathis
125 ab1eb3f8 Christos Stathis
                MenuItem fileItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
126 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.folder()).getHTML() + "</td><td>File</td></tr></table>", true, new MenuBar(true)){
127 ab1eb3f8 Christos Stathis
                        @Override
128 ab1eb3f8 Christos Stathis
                        public MenuBar getSubMenu() {
129 f55cf326 Christos Stathis
                                return new FileMenu(Pithos.get(), images);
130 ab1eb3f8 Christos Stathis
                        }
131 ab1eb3f8 Christos Stathis
                };
132 3d01deba Christos Stathis
133 ab1eb3f8 Christos Stathis
                MenuItem editItem = new MenuItem("<table style='font-size: 100%'><tr><td>" +
134 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.edit()).getHTML() + "</td><td>Edit</td></tr></table>", true, new MenuBar(true)){
135 ab1eb3f8 Christos Stathis
                        @Override
136 ab1eb3f8 Christos Stathis
                        public MenuBar getSubMenu() {
137 f55cf326 Christos Stathis
                                return new EditMenu(Pithos.get(), images);
138 ab1eb3f8 Christos Stathis
                        }
139 ab1eb3f8 Christos Stathis
                };
140 3d01deba Christos Stathis
141 ab1eb3f8 Christos Stathis
                menu.addItem(quitItem);
142 ab1eb3f8 Christos Stathis
                menu.addItem(fileItem);
143 ab1eb3f8 Christos Stathis
                menu.addItem(editItem);
144 ab1eb3f8 Christos Stathis
145 ab1eb3f8 Christos Stathis
                outer.setSpacing(2);
146 ab1eb3f8 Christos Stathis
                outer.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
147 ab1eb3f8 Christos Stathis
                outer.setCellVerticalAlignment(menu, HasVerticalAlignment.ALIGN_MIDDLE);
148 ab1eb3f8 Christos Stathis
                outer.add(menu);
149 ab1eb3f8 Christos Stathis
                outer.setStyleName("toolbar");
150 ab1eb3f8 Christos Stathis
151 ab1eb3f8 Christos Stathis
                outer.add(loading);
152 ab1eb3f8 Christos Stathis
153 4a96a6c5 Christos Stathis
                HTML logos = new HTML("<table><tr><td><a href='http://pithos.grnet.gr/pithos' target='pithos'>" +        AbstractImagePrototype.create(images.gssLogo()).getHTML() +
154 ab1eb3f8 Christos Stathis
                                        "</a><a href='http://www.grnet.gr/' " +        "target='grnet'>" +
155 ab1eb3f8 Christos Stathis
                                        AbstractImagePrototype.create(images.grnetLogo()).getHTML()+"</a></td></tr></table>");
156 ab1eb3f8 Christos Stathis
                outer.add(logos);
157 ab1eb3f8 Christos Stathis
158 ab1eb3f8 Christos Stathis
                outer.setCellHorizontalAlignment(logos, HasHorizontalAlignment.ALIGN_RIGHT);
159 ab1eb3f8 Christos Stathis
160 ab1eb3f8 Christos Stathis
                initWidget(outer);
161 ab1eb3f8 Christos Stathis
        }
162 ab1eb3f8 Christos Stathis
163 ab1eb3f8 Christos Stathis
164 ab1eb3f8 Christos Stathis
        /**
165 ab1eb3f8 Christos Stathis
         * Retrieve the loading.
166 ab1eb3f8 Christos Stathis
         *
167 ab1eb3f8 Christos Stathis
         * @return the loading
168 ab1eb3f8 Christos Stathis
         */
169 ab1eb3f8 Christos Stathis
        public LoadingIndicator getLoading() {
170 ab1eb3f8 Christos Stathis
                return loading;
171 ab1eb3f8 Christos Stathis
        }
172 ab1eb3f8 Christos Stathis
}