Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java @ 6:e2b3966b40ca
Added a workspace that handles the collection windows. New button to open a new collection.
flys-client/trunk@1314 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 11 Feb 2011 09:51:32 +0000 |
parents | bc5d4d2297b9 |
children | 2da6be38d8b6 |
comparison
equal
deleted
inserted
replaced
5:14bf7895a2ec | 6:e2b3966b40ca |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 | 4 |
5 import com.smartgwt.client.widgets.Button; | |
6 import com.smartgwt.client.widgets.Canvas; | |
5 import com.smartgwt.client.widgets.Label; | 7 import com.smartgwt.client.widgets.Label; |
8 import com.smartgwt.client.widgets.events.ClickEvent; | |
9 import com.smartgwt.client.widgets.events.ClickHandler; | |
6 import com.smartgwt.client.widgets.layout.HLayout; | 10 import com.smartgwt.client.widgets.layout.HLayout; |
7 | 11 |
8 import de.intevation.artifacts.common.model.User; | 12 import de.intevation.artifacts.common.model.User; |
9 | 13 |
14 import de.intevation.flys.client.client.FLYS; | |
10 import de.intevation.flys.client.client.FLYSMessages; | 15 import de.intevation.flys.client.client.FLYSMessages; |
11 | 16 |
12 | 17 |
13 /** | 18 /** |
14 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
16 public class MainMenu extends HLayout { | 21 public class MainMenu extends HLayout { |
17 | 22 |
18 /** The interface that provides i18n messages. */ | 23 /** The interface that provides i18n messages. */ |
19 private FLYSMessages messages = GWT.create(FLYSMessages.class); | 24 private FLYSMessages messages = GWT.create(FLYSMessages.class); |
20 | 25 |
26 /** An instance to FLYS.*/ | |
27 protected FLYS flys; | |
28 | |
21 /** The user that is currently logged in. */ | 29 /** The user that is currently logged in. */ |
22 protected User currentUser; | 30 protected User currentUser; |
23 | 31 |
24 /** The label that displays the current logged in user. */ | 32 /** The label that displays the current logged in user. */ |
25 protected Label userText; | 33 protected Label userText; |
26 | 34 |
27 /** The label that displays the title of the application. */ | 35 /** The label that displays the title of the application. */ |
28 protected Label titleText; | 36 protected Label titleText; |
29 | 37 |
38 /** The button to add new projects.*/ | |
39 protected Button newCollection; | |
40 | |
30 /** | 41 /** |
31 * The default constructor for creating a new MainMenu. | 42 * The default constructor for creating a new MainMenu. |
32 */ | 43 */ |
33 public MainMenu() { | 44 public MainMenu(FLYS flys) { |
34 userText = new Label(messages.user(messages.guest())); | 45 this.flys = flys; |
35 titleText = new Label(messages.title()); | 46 |
47 userText = new Label(messages.user(messages.guest())); | |
48 titleText = new Label(messages.title()); | |
49 newCollection = new Button(messages.new_project()); | |
50 | |
51 newCollection.addClickHandler(new ClickHandler() { | |
52 public void onClick(ClickEvent event) { | |
53 GWT.log("Clicked 'New Project' button."); | |
54 createNewProject(); | |
55 } | |
56 }); | |
36 | 57 |
37 init(); | 58 init(); |
38 } | 59 } |
39 | 60 |
40 | 61 |
42 * This method is called by the constructor after creating the necessary | 63 * This method is called by the constructor after creating the necessary |
43 * components. It initializes layout specific stuff like width, height, | 64 * components. It initializes layout specific stuff like width, height, |
44 * colors and so on and appends the components. | 65 * colors and so on and appends the components. |
45 */ | 66 */ |
46 protected void init() { | 67 protected void init() { |
47 setWidth("100%"); | 68 setWidth100(); |
48 setHeight("50"); | 69 setHeight("40px"); |
49 setBorder("1px solid #808080"); | 70 setBorder("1px solid #808080"); |
50 setBackgroundColor("#C3D9FF"); | 71 setBackgroundColor("#C3D9FF"); |
72 setLayoutMargin(10); | |
51 | 73 |
52 titleText.setWidth("60%"); | 74 titleText.setWidth("7%"); |
75 | |
76 Canvas buttonWrapper = new Canvas(); | |
77 buttonWrapper.setWidth("*"); | |
78 buttonWrapper.addChild(newCollection); | |
79 | |
80 userText.setWidth("20%"); | |
53 | 81 |
54 addMember(titleText); | 82 addMember(titleText); |
83 addMember(buttonWrapper); | |
55 addMember(userText); | 84 addMember(userText); |
56 } | 85 } |
57 | 86 |
58 | 87 |
59 /** | 88 /** |
79 : messages.guest(); | 108 : messages.guest(); |
80 | 109 |
81 GWT.log("Update the current user: " + name); | 110 GWT.log("Update the current user: " + name); |
82 userText.setContents(messages.user(name)); | 111 userText.setContents(messages.user(name)); |
83 } | 112 } |
113 | |
114 | |
115 /** | |
116 * Create a new project by calling FLYS.newProject(). | |
117 */ | |
118 protected void createNewProject() { | |
119 flys.newProject(); | |
120 } | |
84 } | 121 } |
85 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 122 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |