Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java Fri Feb 11 09:45:59 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java Fri Feb 11 09:51:32 2011 +0000 @@ -2,11 +2,16 @@ 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; @@ -18,6 +23,9 @@ /** 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; @@ -27,12 +35,25 @@ /** 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() { - userText = new Label(messages.user(messages.guest())); - titleText = new Label(messages.title()); + 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(); } @@ -44,14 +65,22 @@ * colors and so on and appends the components. */ protected void init() { - setWidth("100%"); - setHeight("50"); + setWidth100(); + setHeight("40px"); setBorder("1px solid #808080"); setBackgroundColor("#C3D9FF"); + setLayoutMargin(10); - titleText.setWidth("60%"); + titleText.setWidth("7%"); + + Canvas buttonWrapper = new Canvas(); + buttonWrapper.setWidth("*"); + buttonWrapper.addChild(newCollection); + + userText.setWidth("20%"); addMember(titleText); + addMember(buttonWrapper); addMember(userText); } @@ -81,5 +110,13 @@ 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 :