changeset 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 14bf7895a2ec
children a65793e08245
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java
diffstat 9 files changed, 209 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Feb 11 09:45:59 2011 +0000
+++ b/flys-client/ChangeLog	Fri Feb 11 09:51:32 2011 +0000
@@ -1,3 +1,32 @@
+2011-02-11  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSMessages.java: New
+	  strings for the CollectionViews.
+
+	* src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java: New.
+	  This is the workspace for FLYS. It contains the windows for each
+	  collection of the user.
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  New. This window will display a collection. Currently, it has just a
+	  title, but no content.
+
+	* src/main/java/de/intevation/flys/client/client/ui/FLYSView.java: Displays
+	  the FLYSWorkspace.
+
+	* src/main/java/de/intevation/flys/client/client/ui/MainMenu.java: Added a
+	  button to open new collections.
+
+	* src/main/java/de/intevation/flys/client/client/FLYS.java: The
+	  FLYSWorkspace is created here. FLYS stores a reference to it and puts the
+	  workspace into the FLYSView. Furthermore, there is a new method that
+	  creates new Collections.
+
+	  NOTE: Currently, there is no communication with the artifact server,
+	  because Collections aren't implemented yet!
+
 2011-02-11  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Fri Feb 11 09:45:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Fri Feb 11 09:51:32 2011 +0000
@@ -9,9 +9,14 @@
 
 import de.intevation.artifacts.common.model.User;
 
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.DefaultCollection;
+
 import de.intevation.flys.client.client.services.UserService;
 import de.intevation.flys.client.client.services.UserServiceAsync;
+import de.intevation.flys.client.client.ui.CollectionView;
 import de.intevation.flys.client.client.ui.FLYSView;
+import de.intevation.flys.client.client.ui.FLYSWorkspace;
 import de.intevation.flys.client.client.ui.MainMenu;
 import de.intevation.flys.client.client.ui.ProjectList;
 
@@ -35,6 +40,9 @@
     /** The project list that displays the projects of the user.*/
     protected ProjectList projectList;
 
+    /** The FLYSWorkspace.*/
+    protected FLYSWorkspace workspace;
+
 
     /**
      * This is the entry point method.
@@ -47,7 +55,7 @@
         vertical.setWidth100();
         vertical.setHeight100();
 
-        menu = new MainMenu();
+        menu = new MainMenu(this);
         view = new FLYSView();
 
         vertical.addMember(menu);
@@ -66,9 +74,22 @@
                 menu.setCurrentUser(user);
 
                 projectList = new ProjectList(user);
+                workspace   = new FLYSWorkspace();
                 view.setProjectList(projectList);
+                view.setFLYSWorkspace(workspace);
             }
         });
     }
+
+
+    /**
+     * This method creates a new CollectionView and adds it to the workspace.
+     */
+    public void newProject() {
+        // TODO Call the REST service to create a new Collection
+        // TODO Use the UUID of the Collection to add a new CollectionView!
+        Collection c = new DefaultCollection(new java.util.Date().toString());
+        workspace.addView(c.identifier(), new CollectionView(c));
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java	Fri Feb 11 09:45:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java	Fri Feb 11 09:51:32 2011 +0000
@@ -28,5 +28,8 @@
 
     @DefaultMessage("yyyy-MM-dd")
     String date_format();
+
+    @DefaultMessage("New Project")
+    String new_project();
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties	Fri Feb 11 09:45:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties	Fri Feb 11 09:51:32 2011 +0000
@@ -5,3 +5,4 @@
 no_projects = Keine alten Berechnungen gefunden.
 load_projects = Lade Berechnungen...
 date_format = dd.MM.yyyy
+new_project = Neues Projekt
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties	Fri Feb 11 09:45:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties	Fri Feb 11 09:51:32 2011 +0000
@@ -5,3 +5,4 @@
 no_projects = No existing calculations found.
 load_projects = Load calculations...
 date_format = yyyy-MM-dd
+new_project = New Project
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Fri Feb 11 09:51:32 2011 +0000
@@ -0,0 +1,52 @@
+package de.intevation.flys.client.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.i18n.client.DateTimeFormat;
+
+import com.smartgwt.client.widgets.Window;
+
+import de.intevation.flys.client.shared.model.Collection;
+
+import de.intevation.flys.client.client.FLYSMessages;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class CollectionView extends Window {
+
+    /** The message class that provides i18n strings.*/
+    FLYSMessages messages = GWT.create(FLYSMessages.class);
+
+    /** The collection to be displayed.*/
+    protected Collection collection;
+
+
+    /**
+     * This constructor creates a new CollectionView that is used to display the
+     * <i>collection</i>.
+     *
+     * @param collection The collection to be displayed.
+     */
+    public CollectionView(Collection collection) {
+        this.collection = collection;
+
+        init();
+    }
+
+
+    /**
+     * This method handles the initial layout stuff.
+     */
+    protected void init() {
+        setWidth(600);
+        setHeight(400);
+
+        setCanDragResize(true);
+
+        DateTimeFormat dtf = DateTimeFormat.getFormat(messages.date_format());
+        String lastAccess  = dtf.format(collection.getLastAccess());
+        setTitle(lastAccess + " - " + collection.getName());
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSView.java	Fri Feb 11 09:45:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSView.java	Fri Feb 11 09:51:32 2011 +0000
@@ -12,6 +12,9 @@
     /** The project list displaying the projects of a user.*/
     protected ProjectList projectList;
 
+    /** The workspace that handles the artifact collection views.*/
+    protected FLYSWorkspace workspace;
+
     /** The layout provided by this widget.*/
     protected HLayout layout;
 
@@ -53,5 +56,21 @@
         this.projectList = projectList;
         layout.addMember(this.projectList);
     }
+
+
+    /**
+     * Set the current FLYSWorkspace. Previous workspaces are replaced by the
+     * new one.
+     *
+     * @param workspaces The new FLYSWorkspace.
+     */
+    public void setFLYSWorkspace(FLYSWorkspace workspace) {
+        if (this.workspace != null) {
+            removeChild(this.workspace);
+        }
+
+        this.workspace = workspace;
+        layout.addMember(this.workspace);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java	Fri Feb 11 09:51:32 2011 +0000
@@ -0,0 +1,39 @@
+package de.intevation.flys.client.client.ui;
+
+import com.smartgwt.client.widgets.Canvas;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class FLYSWorkspace extends Canvas {
+
+    /** A map that contains the open CollectionViews. */
+    protected Map<String, CollectionView> views;
+
+
+    /**
+     * The default constructor creates an empty FLYSWorkspace with no
+     * CollectionViews opened.
+     */
+    public FLYSWorkspace() {
+        views = new HashMap<String, CollectionView>();
+    }
+
+
+    /**
+     * 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) {
+        views.put(uuid, collectionView);
+
+        addChild(collectionView);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- 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 :

http://dive4elements.wald.intevation.org