comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java @ 28:dfdb927b137d

Improved the main menu - added further buttons (clickable labels). flys-client/trunk@1428 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 08 Mar 2011 16:20:34 +0000
parents 2da6be38d8b6
children a361ce81abcf
comparison
equal deleted inserted replaced
27:e4155a6833a9 28:dfdb927b137d
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; 5 import com.smartgwt.client.types.Alignment;
6 import com.smartgwt.client.widgets.Canvas;
7 import com.smartgwt.client.widgets.Label; 6 import com.smartgwt.client.widgets.Label;
8 import com.smartgwt.client.widgets.events.ClickEvent; 7 import com.smartgwt.client.widgets.events.ClickEvent;
9 import com.smartgwt.client.widgets.events.ClickHandler; 8 import com.smartgwt.client.widgets.events.ClickHandler;
10 import com.smartgwt.client.widgets.layout.HLayout; 9 import com.smartgwt.client.widgets.layout.HLayout;
11 10
29 protected User currentUser; 28 protected User currentUser;
30 29
31 /** The label that displays the current logged in user. */ 30 /** The label that displays the current logged in user. */
32 protected Label userText; 31 protected Label userText;
33 32
34 /** The label that displays the title of the application. */ 33 /** The button to log the current user out.*/
35 protected Label titleText; 34 protected Label logout;
36 35
37 /** The button to add new projects.*/ 36 /** The button to add new projects.*/
38 protected Button newCollection; 37 protected Label newProject;
38
39 /** The button to open the project list.*/
40 protected Label projectList;
41
42 /** The button to switch between the english and german version.*/
43 protected Label language;
44
45 /** The button to open an info panel.*/
46 protected Label info;
39 47
40 /** 48 /**
41 * The default constructor for creating a new MainMenu. 49 * The default constructor for creating a new MainMenu.
42 */ 50 */
43 public MainMenu(FLYS flys) { 51 public MainMenu(FLYS flys) {
44 this.flys = flys; 52 this.flys = flys;
45 53
46 userText = new Label(messages.user(messages.guest())); 54 userText = new Label(messages.user(messages.guest()));
47 titleText = new Label(messages.title()); 55 newProject = new Label(messages.new_project());
48 newCollection = new Button(messages.new_project()); 56 projectList = new Label(messages.manage_projects());
57 logout = new Label(messages.logout());
58 language = new Label(messages.switch_language());
59 info = new Label(messages.info());
49 60
50 newCollection.addClickHandler(new ClickHandler() { 61 newProject.addClickHandler(new ClickHandler() {
51 public void onClick(ClickEvent event) { 62 public void onClick(ClickEvent event) {
52 GWT.log("Clicked 'New Project' button."); 63 GWT.log("Clicked 'New Project' button.");
53 createNewProject(); 64 createNewProject();
65 }
66 });
67
68 projectList.addClickHandler(new ClickHandler() {
69 public void onClick(ClickEvent event) {
70 GWT.log("Clicked 'Open ProjectList' button.");
71 getFlys().getProjectList().show();
72 }
73 });
74
75 logout.addClickHandler(new ClickHandler() {
76 public void onClick(ClickEvent event) {
77 GWT.log("Clicked 'logout' button.");
78 GWT.log("IMPLEMENT the 'logout' function.");
79 }
80 });
81
82 language.addClickHandler(new ClickHandler() {
83 public void onClick(ClickEvent event) {
84 GWT.log("Clicked 'language' button.");
85 GWT.log("IMPLEMENT the 'switch language' function.");
86 }
87 });
88
89 info.addClickHandler(new ClickHandler() {
90 public void onClick(ClickEvent event) {
91 GWT.log("Clicked 'info' button.");
92 GWT.log("IMPLEMENT the 'open info panel' function.");
54 } 93 }
55 }); 94 });
56 95
57 init(); 96 init();
58 } 97 }
63 * components. It initializes layout specific stuff like width, height, 102 * components. It initializes layout specific stuff like width, height,
64 * colors and so on and appends the components. 103 * colors and so on and appends the components.
65 */ 104 */
66 protected void init() { 105 protected void init() {
67 setWidth100(); 106 setWidth100();
68 setHeight("40px"); 107 setHeight("35px");
69 setBorder("1px solid #808080"); 108 setBorder("1px solid #808080");
70 setBackgroundColor("#C3D9FF"); 109 setBackgroundColor("#C3D9FF");
71 setLayoutMargin(10); 110 setLayoutMargin(5);
72 111
73 titleText.setWidth("7%"); 112 HLayout leftPanel = new HLayout();
113 leftPanel.setWidth("80%");
114 leftPanel.setMembersMargin(5);
115 leftPanel.addMember(newProject);
116 leftPanel.addMember(projectList);
74 117
75 Canvas buttonWrapper = new Canvas(); 118 userText.setAlign(Alignment.RIGHT);
76 buttonWrapper.setWidth("*"); 119 logout.setAlign(Alignment.RIGHT);
77 buttonWrapper.addChild(newCollection); 120 info.setAlign(Alignment.RIGHT);
121 language.setAlign(Alignment.RIGHT);
78 122
79 userText.setWidth("20%"); 123 userText.setWidth(200);
124 logout.setWidth(70);
125 info.setWidth(40);
126 language.setWidth(70);
80 127
81 addMember(titleText); 128 HLayout rightPanel = new HLayout();
82 addMember(buttonWrapper); 129 rightPanel.setAlign(Alignment.RIGHT);
83 addMember(userText); 130 rightPanel.setMembersMargin(3);
131 rightPanel.setLayoutRightMargin(5);
132 rightPanel.addMember(userText);
133 rightPanel.addMember(logout);
134 rightPanel.addMember(language);
135 rightPanel.addMember(info);
136
137 addMember(leftPanel);
138 addMember(rightPanel);
139 }
140
141
142 /**
143 * Returns the FLYS instance stored in this class.
144 *
145 * @return the flys instance.
146 */
147 protected FLYS getFlys() {
148 return flys;
84 } 149 }
85 150
86 151
87 /** 152 /**
88 * Set the current {@link User} and call {@link updateCurrentUser()} 153 * Set the current {@link User} and call {@link updateCurrentUser()}

http://dive4elements.wald.intevation.org