Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / TopPanel.java @ 031f1fe0

History | View | Annotate | Download (5.7 kB)

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