changeset 1286:b643622d77fe

Added context menu to themes list. flys-client/trunk@2872 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 30 Sep 2011 11:03:33 +0000
parents 0f3b19df1880
children 95ecb98c6015
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/chart/ChartThemePanel.java
diffstat 6 files changed, 91 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Sep 30 10:57:56 2011 +0000
+++ b/flys-client/ChangeLog	Fri Sep 30 11:03:33 2011 +0000
@@ -1,3 +1,14 @@
+2011-09-30  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java:
+	  Added context menu to themes list.
+
+	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants.properties,
+	  src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties:
+	  Added string for context menu entry.
+
 2011-09-30  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Sep 30 10:57:56 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Fri Sep 30 11:03:33 2011 +0000
@@ -222,6 +222,8 @@
 
     String search();
 
+    String properties();
+
     // OUTPUT TYPES
 
     String discharge_curve();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Sep 30 10:57:56 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Fri Sep 30 11:03:33 2011 +0000
@@ -48,6 +48,7 @@
 unitWidth = m
 search = Search
 discharge = FIXME(Name)
+properties = Properties
 
 dpLabelFrom = From
 dpUnitFrom = km
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Sep 30 10:57:56 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Fri Sep 30 11:03:33 2011 +0000
@@ -48,6 +48,7 @@
 unitWidth = m
 search = Suchbegriff
 discharge = Kennzeichnender Abfluss
+properties = Eigenschaften
 
 dpLabelFrom = Von
 dpUnitFrom = km
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Sep 30 10:57:56 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Fri Sep 30 11:03:33 2011 +0000
@@ -48,6 +48,7 @@
 unitWidth = m
 search = Search
 discharge = FIXME(Name)
+properties = Properties
 
 dpLabelFrom = From
 dpUnitFrom = km
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java	Fri Sep 30 10:57:56 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java	Fri Sep 30 11:03:33 2011 +0000
@@ -1,21 +1,38 @@
 package de.intevation.flys.client.client.ui.chart;
 
+import org.w3c.dom.Document;
+import de.intevation.artifacts.common.utils.XMLUtils;
+
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
 
 import com.smartgwt.client.types.ListGridFieldType;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.grid.events.RowContextClickEvent;
+import com.smartgwt.client.widgets.grid.events.RowContextClickHandler;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.MenuItemSeparator;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
 
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.Theme;
 import de.intevation.flys.client.shared.model.OutputMode;
+import de.intevation.flys.client.shared.model.FacetRecord;
+import de.intevation.flys.client.shared.model.Facet;
+import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.CollectionItemAttribute;
 
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.ui.ThemePanel;
+import de.intevation.flys.client.client.Config;
 
 import de.intevation.flys.client.client.services.FeedService;
 import de.intevation.flys.client.client.services.FeedServiceAsync;
-
+import de.intevation.flys.client.client.services.CollectionItemAttributeService;
+import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync;
 
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
@@ -25,6 +42,13 @@
     /** The interface that provides i18n messages. */
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
+    /** The collection */
+    protected Collection collection;
+
+    /** The service used to get collection item attributes. */
+    protected CollectionItemAttributeServiceAsync itemAttributeService =
+        GWT.create(CollectionItemAttributeService.class);
+
     public static final String GRID_FIELD_ACTIVE  = "active";
     public static final String GRID_FIELD_NAME    = "name";
     public static final String GRID_FIELD_ACTIONS = "actions";
@@ -34,6 +58,7 @@
 
     public ChartThemePanel(Collection collection, OutputMode mode) {
         super(collection, mode);
+        this.collection = collection;
 
         initGrid();
         initLayout();
@@ -74,6 +99,17 @@
         list.setHeight100();
 
         list.addEditCompleteHandler(this);
+        list.addRowContextClickHandler(new RowContextClickHandler() {
+            public void onRowContextClick(RowContextClickEvent event) {
+                FacetRecord record = (FacetRecord) event.getRecord();
+
+                Menu menu = createContextMenu(record);
+                list.setContextMenu(menu);
+                menu.showContextMenu();
+
+                event.cancel();
+            }
+        });
 
         ListGridField active = new ListGridField(GRID_FIELD_ACTIVE,
             MSG.chart_themepanel_header_actions(), 20);
@@ -87,9 +123,47 @@
     }
 
 
+    protected Menu createContextMenu(final FacetRecord record) {
+        Menu menu = new Menu();
+
+        MenuItem properties = new MenuItem(MSG.properties());
+        properties.addClickHandler(new ClickHandler() {
+            public void onClick(MenuItemClickEvent evt) {
+                GWT.log("clicked properties");
+                getItemAttributes(record);
+            }
+        });
+        menu.addItem(properties);
+        return menu;
+    }
+
+
     @Override
     public void activateTheme(Theme theme, boolean active) {
         theme.setActive(active ? 1 : 0);
     }
+
+
+    protected void getItemAttributes(FacetRecord record) {
+        Config config = Config.getInstance();
+        String url = config.getServerUrl();
+        String locale = config.getLocale();
+
+        String artifact = record.getTheme().getArtifact();
+
+        itemAttributeService.getCollectionItemAttribute(
+            this.collection,
+            artifact,
+            url,
+            locale,
+            new AsyncCallback<CollectionItemAttribute>() {
+                public void onFailure (Throwable caught) {
+                    GWT.log("Could not get Collection item attributes.");
+                }
+                public void onSuccess(CollectionItemAttribute cia) {
+                    GWT.log("Successfully loaded collectionitem attributes.");
+                }
+            });
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org