Mercurial > dive4elements > river
diff flys-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSWorkspace.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java@e70ff0a600a3 |
children | 821a02bbfb4e |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/org/dive4elements/river/client/client/ui/FLYSWorkspace.java Thu Apr 25 12:31:32 2013 +0200 @@ -0,0 +1,179 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.core.client.GWT; + +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.VerticalAlignment; +import com.smartgwt.client.widgets.Button; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.Img; +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 com.smartgwt.client.widgets.layout.VLayout; + +import de.intevation.flys.client.client.FLYS; +import de.intevation.flys.client.client.FLYSConstants; + +import java.util.HashMap; +import java.util.Map; + + +/** + * "Workspace" canvas showing the CollectionViews (subwindows). + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class FLYSWorkspace extends Canvas { + + /** The maximal number of windows that fit into the browser view when an + * offset is used to move windows initially.*/ + public static int MAX_WINDOWS = 10; + + /** The number of pixels used to move windows.*/ + public static int WINDOW_OFFSET = 20; + + /** A map that contains the open CollectionViews. */ + protected Map<String, CollectionView> views; + + /** The interface that provides the message resources. */ + private FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); + + /** Application instance. */ + private FLYS flys; + + + /** + * The default constructor creates an empty FLYSWorkspace with no + * CollectionViews opened. + */ + public FLYSWorkspace(FLYS flys) { + this.flys = flys; + views = new HashMap<String, CollectionView>(); + + setWidth("100%"); + setHeight("100%"); + + addBackgroundWorkspace(); + } + + + /** + * This method adds a new CollectionView to this workspace and stores a + * reference in {@link views}. + * + * @param collectionView A new CollectionView. + */ + public void addView(String uuid, CollectionView collectionView) { + collectionView.moveTo(0, 0); + collectionView.setMaximized(true); + + views.put(uuid, collectionView); + addChild(collectionView); + } + + + public void removeProject(String uuid) { + views.remove(uuid); + } + + + public void bringUp(String uuid) { + CollectionView view = views.get(uuid); + + if (view != null) { + view.show(); + view.restore(); + } + else { + GWT.log("FLYSWorkspace.bringUp() failed!"); + } + } + + + /** + * Removes a project from workspace (view) and clears its reference from + * hash map. + * + * @param uuid The project's uuid. + */ + public void destroyProject(String uuid) { + CollectionView project = views.get(uuid); + + if (project != null) { + removeProject(uuid); + project.destroy(); + } + } + + + public void updateTitle(String uuid, String title) { + CollectionView view = views.get(uuid); + view.setTitle(title); + } + + + public boolean hasView(String uuid) { + if(views.get(uuid) != null) { + return true; + } + return false; + } + + private void addBackgroundWorkspace() { + String baseUrl = GWT.getHostPageBaseURL(); + Img bfg = new Img( + baseUrl + MESSAGES.bfgLogo()); + bfg.setWidth(150); + bfg.setHeight(100); + bfg.setLayoutAlign(Alignment.RIGHT); + + HLayout backgroundlayout = new HLayout(); + backgroundlayout.setHeight100(); + backgroundlayout.setWidth100(); + backgroundlayout.setDefaultLayoutAlign(Alignment.CENTER); + backgroundlayout.setDefaultLayoutAlign(VerticalAlignment.CENTER); + + Canvas spacer = new Canvas(); + spacer.setWidth("33%"); + + VLayout infobox = new VLayout(); + infobox.setHeight("*"); + infobox.setWidth("*"); + infobox.setDefaultLayoutAlign(Alignment.CENTER); + + Label welcome = new Label(MESSAGES.welcome()); + welcome.setAlign(Alignment.CENTER); + welcome.setStyleName("fontNormalBig"); + + Label lcreate = new Label(MESSAGES.welcome_open_or_create()); + lcreate.setStyleName("welcomeCreateText"); + lcreate.setWidth100(); + lcreate.setAlign(Alignment.CENTER); + + Button addbutton = new Button(MESSAGES.new_project()); + addbutton.setStyleName("projectsAddButton"); + addbutton.setAlign(Alignment.CENTER); + addbutton.setTitle(MESSAGES.new_project()); + addbutton.setAutoFit(true); + addbutton.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + flys.newProject(); + } + }); + + + infobox.addMember(welcome); + infobox.addMember(lcreate); + infobox.addMember(addbutton); + + backgroundlayout.addMember(spacer); + backgroundlayout.addMember(infobox); + backgroundlayout.addMember(spacer); + + addChild(backgroundlayout); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :