changeset 220:35094660f91a

Implemented a context menu for the project list. flys-client/trunk@1663 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 11 Apr 2011 15:38:43 +0000
parents 7523faf567e5
children f03c34bec364
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java
diffstat 6 files changed, 73 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Apr 11 14:32:36 2011 +0000
+++ b/flys-client/ChangeLog	Mon Apr 11 15:38:43 2011 +0000
@@ -1,3 +1,15 @@
+2011-04-11  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java:
+	  Added strings that are used in the context menu of the project list.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ProjectList.java:
+	  A right mouse click on a project opens a context menu with the options
+	  to open / delete a project.
+
 2011-04-11  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/DistanceInfoServiceImpl.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Apr 11 14:32:36 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Apr 11 15:38:43 2011 +0000
@@ -18,6 +18,10 @@
 
     String projects();
 
+    String open_project();
+
+    String delete_project();
+
     String manage_projects();
 
     String logout();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Apr 11 14:32:36 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Apr 11 15:38:43 2011 +0000
@@ -4,6 +4,8 @@
 guest = guest
 logout = Logout
 projects = Calculations
+open_project = Open Project
+delete_project = Delete Project
 manage_projects = Manage Projects
 switch_language = German
 info = Info
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Apr 11 14:32:36 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Apr 11 15:38:43 2011 +0000
@@ -4,6 +4,8 @@
 guest = Gast
 logout = Abmelden
 projects = Projekte
+open_project = Projekt \u00d6ffnen
+delete_project = Projekt l\u00f6schen
 manage_projects = Projekte verwalten
 switch_language = Englisch
 info = Info
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Apr 11 14:32:36 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Apr 11 15:38:43 2011 +0000
@@ -4,6 +4,8 @@
 guest = guest
 logout = Logout
 projects = Calculations
+open_project = Open Project
+delete_project = Delete Project
 manage_projects = Manage Projects
 switch_language = German
 info = Info
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Mon Apr 11 14:32:36 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Mon Apr 11 15:38:43 2011 +0000
@@ -3,12 +3,19 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
+import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RowContextClickEvent;
+import com.smartgwt.client.widgets.grid.events.RowContextClickHandler;
 import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
 import com.smartgwt.client.types.VerticalAlignment;
 
 import de.intevation.flys.client.shared.model.Collection;
@@ -79,6 +86,50 @@
         name.setWidth(195);
 
         grid.setFields(date, name);
+
+        grid.addRowContextClickHandler(new RowContextClickHandler() {
+            public void onRowContextClick(RowContextClickEvent event) {
+                CollectionRecord record = (CollectionRecord) event.getRecord();
+
+                Menu menu = createContextMenu(record);
+                grid.setContextMenu(menu);
+                menu.showContextMenu();
+
+                event.cancel();
+            }
+        });
+    }
+
+
+    /**
+     * Creates a new context menu that interacts with a CollectionRecord.
+     *
+     * @param record The selected record.
+     *
+     * @return the context menu with operations that interact with
+     * <i>record</i>.
+     */
+    protected Menu createContextMenu(final CollectionRecord record) {
+        Menu menu = new Menu();
+
+        MenuItem open = new MenuItem(messages.open_project());
+        open.addClickHandler(new ClickHandler() {
+            public void onClick(MenuItemClickEvent evt) {
+                SC.say("Open project: " + record.getName());
+            }
+        });
+
+        MenuItem del = new MenuItem(messages.delete_project());
+        del.addClickHandler(new ClickHandler() {
+            public void onClick(MenuItemClickEvent evt) {
+                SC.warn("Removing projects is not implemented.");
+            }
+        });
+
+        menu.addItem(open);
+        menu.addItem(del);
+
+        return menu;
     }
 
 

http://dive4elements.wald.intevation.org