Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java @ 50:827eb4e06ebf
Added space between old params panel and new params panel.
flys-client/trunk@1499 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 17 Mar 2011 11:49:03 +0000 |
parents | dfdb927b137d |
children | a361ce81abcf |
line wrap: on
line source
package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.Alignment; 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.flys.client.client.FLYS; import de.intevation.flys.client.client.FLYSMessages; import de.intevation.flys.client.shared.model.User; /** * @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 button to log the current user out.*/ protected Label logout; /** The button to add new projects.*/ protected Label newProject; /** The button to open the project list.*/ protected Label projectList; /** The button to switch between the english and german version.*/ protected Label language; /** The button to open an info panel.*/ protected Label info; /** * The default constructor for creating a new MainMenu. */ public MainMenu(FLYS flys) { this.flys = flys; userText = new Label(messages.user(messages.guest())); newProject = new Label(messages.new_project()); projectList = new Label(messages.manage_projects()); logout = new Label(messages.logout()); language = new Label(messages.switch_language()); info = new Label(messages.info()); newProject.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'New Project' button."); createNewProject(); } }); projectList.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'Open ProjectList' button."); getFlys().getProjectList().show(); } }); logout.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'logout' button."); GWT.log("IMPLEMENT the 'logout' function."); } }); language.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'language' button."); GWT.log("IMPLEMENT the 'switch language' function."); } }); info.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { GWT.log("Clicked 'info' button."); GWT.log("IMPLEMENT the 'open info panel' function."); } }); 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("35px"); setBorder("1px solid #808080"); setBackgroundColor("#C3D9FF"); setLayoutMargin(5); HLayout leftPanel = new HLayout(); leftPanel.setWidth("80%"); leftPanel.setMembersMargin(5); leftPanel.addMember(newProject); leftPanel.addMember(projectList); userText.setAlign(Alignment.RIGHT); logout.setAlign(Alignment.RIGHT); info.setAlign(Alignment.RIGHT); language.setAlign(Alignment.RIGHT); userText.setWidth(200); logout.setWidth(70); info.setWidth(40); language.setWidth(70); HLayout rightPanel = new HLayout(); rightPanel.setAlign(Alignment.RIGHT); rightPanel.setMembersMargin(3); rightPanel.setLayoutRightMargin(5); rightPanel.addMember(userText); rightPanel.addMember(logout); rightPanel.addMember(language); rightPanel.addMember(info); addMember(leftPanel); addMember(rightPanel); } /** * Returns the FLYS instance stored in this class. * * @return the flys instance. */ protected FLYS getFlys() { return flys; } /** * 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.getName() : 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 :