teichmann@5835: package org.dive4elements.river.client.client.ui; ingo@6: christian@4128: import com.google.gwt.core.client.GWT; christian@4128: bjoern@4607: import com.smartgwt.client.types.Alignment; bjoern@4607: import com.smartgwt.client.types.VerticalAlignment; bjoern@4607: import com.smartgwt.client.widgets.Button; ingo@6: import com.smartgwt.client.widgets.Canvas; bjoern@4607: import com.smartgwt.client.widgets.Img; bjoern@4607: import com.smartgwt.client.widgets.Label; bjoern@4607: import com.smartgwt.client.widgets.events.ClickEvent; bjoern@4607: import com.smartgwt.client.widgets.events.ClickHandler; bjoern@4607: import com.smartgwt.client.widgets.layout.HLayout; bjoern@4607: import com.smartgwt.client.widgets.layout.VLayout; bjoern@4607: teichmann@5835: import org.dive4elements.river.client.client.FLYS; teichmann@5835: import org.dive4elements.river.client.client.FLYSConstants; ingo@6: ingo@557: import java.util.HashMap; ingo@557: import java.util.Map; ingo@6: ingo@6: ingo@6: /** ingo@3549: * "Workspace" canvas showing the CollectionViews (subwindows). ingo@6: * @author Ingo Weinzierl ingo@6: */ ingo@6: public class FLYSWorkspace extends Canvas { ingo@6: ingo@279: /** The maximal number of windows that fit into the browser view when an ingo@279: * offset is used to move windows initially.*/ ingo@279: public static int MAX_WINDOWS = 10; ingo@279: ingo@279: /** The number of pixels used to move windows.*/ ingo@279: public static int WINDOW_OFFSET = 20; ingo@279: ingo@6: /** A map that contains the open CollectionViews. */ ingo@557: protected Map views; ingo@6: bjoern@4607: /** The interface that provides the message resources. */ bjoern@4607: private FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); bjoern@4607: felix@4980: /** Application instance. */ bjoern@4607: private FLYS flys; ingo@6: felix@4980: ingo@6: /** ingo@6: * The default constructor creates an empty FLYSWorkspace with no ingo@6: * CollectionViews opened. ingo@6: */ bjoern@4607: public FLYSWorkspace(FLYS flys) { bjoern@4607: this.flys = flys; ingo@557: views = new HashMap(); christian@3522: christian@3522: setWidth("100%"); christian@3522: setHeight("100%"); bjoern@4607: bjoern@4607: addBackgroundWorkspace(); ingo@6: } ingo@6: ingo@6: ingo@6: /** ingo@6: * This method adds a new CollectionView to this workspace and stores a ingo@6: * reference in {@link views}. ingo@6: * ingo@6: * @param collectionView A new CollectionView. ingo@6: */ ingo@557: public void addView(String uuid, CollectionView collectionView) { christian@3522: collectionView.moveTo(0, 0); christian@3522: collectionView.setMaximized(true); ingo@279: ingo@557: views.put(uuid, collectionView); ingo@6: addChild(collectionView); ingo@6: } ingo@557: ingo@557: ingo@557: public void removeProject(String uuid) { ingo@557: views.remove(uuid); ingo@557: } ingo@557: ingo@557: ingo@557: public void bringUp(String uuid) { ingo@557: CollectionView view = views.get(uuid); ingo@557: christian@4128: if (view != null) { christian@4128: view.show(); christian@4128: view.restore(); christian@4128: } christian@4128: else { christian@4128: GWT.log("FLYSWorkspace.bringUp() failed!"); christian@4128: } ingo@557: } ingo@600: ingo@600: ingo@600: /** ingo@600: * Removes a project from workspace (view) and clears its reference from ingo@600: * hash map. ingo@600: * ingo@600: * @param uuid The project's uuid. ingo@600: */ ingo@600: public void destroyProject(String uuid) { ingo@600: CollectionView project = views.get(uuid); ingo@600: ingo@600: if (project != null) { ingo@600: removeProject(uuid); ingo@600: project.destroy(); ingo@600: } ingo@600: } raimund@895: raimund@895: raimund@895: public void updateTitle(String uuid, String title) { raimund@895: CollectionView view = views.get(uuid); raimund@895: view.setTitle(title); raimund@895: } raimund@896: raimund@896: raimund@896: public boolean hasView(String uuid) { raimund@896: if(views.get(uuid) != null) { raimund@896: return true; raimund@896: } raimund@896: return false; raimund@896: } bjoern@4607: bjoern@4607: private void addBackgroundWorkspace() { bjoern@4607: String baseUrl = GWT.getHostPageBaseURL(); bjoern@4607: Img bfg = new Img( bjoern@4607: baseUrl + MESSAGES.bfgLogo()); bjoern@4607: bfg.setWidth(150); bjoern@4607: bfg.setHeight(100); bjoern@4607: bfg.setLayoutAlign(Alignment.RIGHT); bjoern@4607: bjoern@4607: HLayout backgroundlayout = new HLayout(); bjoern@4607: backgroundlayout.setHeight100(); bjoern@4607: backgroundlayout.setWidth100(); bjoern@4607: backgroundlayout.setDefaultLayoutAlign(Alignment.CENTER); bjoern@4607: backgroundlayout.setDefaultLayoutAlign(VerticalAlignment.CENTER); bjoern@4607: bjoern@4607: Canvas spacer = new Canvas(); bjoern@4607: spacer.setWidth("33%"); bjoern@4607: bjoern@4607: VLayout infobox = new VLayout(); bjoern@4607: infobox.setHeight("*"); bjoern@4607: infobox.setWidth("*"); bjoern@4607: infobox.setDefaultLayoutAlign(Alignment.CENTER); bjoern@4607: bjoern@4607: Label welcome = new Label(MESSAGES.welcome()); bjoern@4607: welcome.setAlign(Alignment.CENTER); bjoern@4607: welcome.setStyleName("fontNormalBig"); bjoern@4607: bjoern@4607: Label lcreate = new Label(MESSAGES.welcome_open_or_create()); bjoern@4607: lcreate.setStyleName("welcomeCreateText"); bjoern@4607: lcreate.setWidth100(); bjoern@4607: lcreate.setAlign(Alignment.CENTER); bjoern@4607: bjoern@4607: Button addbutton = new Button(MESSAGES.new_project()); bjoern@4607: addbutton.setStyleName("projectsAddButton"); bjoern@4607: addbutton.setAlign(Alignment.CENTER); bjoern@4607: addbutton.setTitle(MESSAGES.new_project()); bjoern@4607: addbutton.setAutoFit(true); bjoern@4607: addbutton.addClickHandler(new ClickHandler() { bjoern@4607: bjoern@4607: @Override bjoern@4607: public void onClick(ClickEvent event) { bjoern@4607: flys.newProject(); bjoern@4607: } bjoern@4607: }); bjoern@4607: bjoern@4607: bjoern@4607: infobox.addMember(welcome); bjoern@4607: infobox.addMember(lcreate); bjoern@4607: infobox.addMember(addbutton); bjoern@4607: bjoern@4607: backgroundlayout.addMember(spacer); bjoern@4607: backgroundlayout.addMember(infobox); bjoern@4607: backgroundlayout.addMember(spacer); bjoern@4607: bjoern@4607: addChild(backgroundlayout); bjoern@4607: } ingo@6: } ingo@6: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :