Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java @ 14:fe2f4d1dd784
Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
flys-client/trunk@1326 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 17 Feb 2011 11:52:55 +0000 |
parents | e2b3966b40ca |
children | 2da6be38d8b6 |
line wrap: on
line source
package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.layout.HLayout; import de.intevation.artifacts.common.model.User; import de.intevation.flys.client.client.FLYS; import de.intevation.flys.client.client.FLYSMessages; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class MainMenu extends HLayout { /** The interface that provides i18n messages. */ private FLYSMessages messages = GWT.create(FLYSMessages.class); /** An instance to FLYS.*/ protected FLYS flys; /** The user that is currently logged in. */ protected User currentUser; /** The label that displays the current logged in user. */ protected Label userText; /** The label that displays the title of the application. */ protected Label titleText; /** The button to add new projects.*/ protected Button newCollection; /** * The default constructor for creating a new MainMenu. */ public MainMenu(FLYS flys) { this.flys = flys; userText = new Label(messages.user(messages.guest())); titleText = new Label(messages.title()); newCollection = new Button(messages.new_project()); newCollection.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'New Project' button."); createNewProject(); } }); init(); } /** * This method is called by the constructor after creating the necessary * components. It initializes layout specific stuff like width, height, * colors and so on and appends the components. */ protected void init() { setWidth100(); setHeight("40px"); setBorder("1px solid #808080"); setBackgroundColor("#C3D9FF"); setLayoutMargin(10); titleText.setWidth("7%"); Canvas buttonWrapper = new Canvas(); buttonWrapper.setWidth("*"); buttonWrapper.addChild(newCollection); userText.setWidth("20%"); addMember(titleText); addMember(buttonWrapper); addMember(userText); } /** * Set the current {@link User} and call {@link updateCurrentUser()} * afterwards. * * @param user the new user. */ public void setCurrentUser(User currentUser) { this.currentUser = currentUser; updateCurrentUser(); } /** * Update the text field that shows the current user. If no user is * currently logged in, the text will display {@link FLYSMessages.guest()}. */ public void updateCurrentUser() { String name = currentUser != null ? currentUser.getLastName() + ", " + currentUser.getFirstName() : messages.guest(); GWT.log("Update the current user: " + name); userText.setContents(messages.user(name)); } /** * Create a new project by calling FLYS.newProject(). */ protected void createNewProject() { flys.newProject(); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :