changeset 1326:974c6b3700de

Use the theme index to identify the correct style. flys-client/trunk@2968 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 14 Oct 2011 08:36:29 +0000
parents 2f5fbfeda1d4
children 8a93fb299e64
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionItemAttribute.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Style.java
diffstat 5 files changed, 44 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Oct 13 16:30:55 2011 +0000
+++ b/flys-client/ChangeLog	Fri Oct 14 08:36:29 2011 +0000
@@ -1,3 +1,13 @@
+2011-10-14  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/shared/model/Style.java,
+	  src/main/java/de/intevation/flys/client/shared/model/CollectionItemAttribute.java,
+	  src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java:
+	  Use the theme index to identify the correct style.
+
+	* src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java:
+	  Set the style index.
+
 2011-10-13	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java	Thu Oct 13 16:30:55 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java	Fri Oct 14 08:36:29 2011 +0000
@@ -26,6 +26,7 @@
 import de.intevation.flys.client.shared.model.Style;
 import de.intevation.flys.client.shared.model.StyleSetting;
 import de.intevation.flys.client.shared.model.FacetRecord;
+import de.intevation.flys.client.shared.model.Theme;
 
 import de.intevation.flys.client.client.services.CollectionItemAttributeServiceAsync;
 import de.intevation.flys.client.client.services.CollectionItemAttributeService;
@@ -127,7 +128,8 @@
     protected VLayout createPropertyGrid() {
         VLayout properties = new VLayout();
 
-        Style s = attributes.getStyle(facet.getTheme().getFacet());
+        Theme t = facet.getTheme();
+        Style s = attributes.getStyle(t.getFacet(), t.getIndex());
 
         TextItem name = new TextItem("name", "Name");
         name.setValue(facet.getName());
@@ -265,7 +267,8 @@
     }
 
     protected final void setNewValue(String name, String value) {
-        Style s = attributes.getStyle(facet.getTheme().getFacet());
+        Theme t = facet.getTheme();
+        Style s = attributes.getStyle(t.getFacet(), t.getIndex());
         StyleSetting set = s.getSetting(name);
         if(name.equals("linecolor")) {
             value = htmlToRgb(value);
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java	Thu Oct 13 16:30:55 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java	Fri Oct 14 08:36:29 2011 +0000
@@ -129,7 +129,13 @@
         NodeList items = e.getElementsByTagName("theme");
 
         for (int i = 0; i < items.getLength(); i++) {
-            cia.appendStyle(getStyle ((Element) items.item(i)));
+            Style s = getStyle ((Element) items.item(i));
+            if(s == null) {
+                throw new ServerException(ERROR_NO_STYLES_FOUND);
+            }
+            else {
+                cia.appendStyle(s);
+            }
         }
 
         return cia;
@@ -197,6 +203,13 @@
 
         style.setName (element.getAttribute("name"));
         style.setFacet (element.getAttribute("facet"));
+        try {
+            int ndx = Integer.parseInt(element.getAttribute("index"));
+            style.setIndex (ndx);
+        }
+        catch(NumberFormatException nfe) {
+            return null;
+        }
         for(int i = 0; i < list.getLength(); i++) {
             Element e = (Element) list.item(i);
             StyleSetting set = new StyleSetting (
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionItemAttribute.java	Thu Oct 13 16:30:55 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/CollectionItemAttribute.java	Fri Oct 14 08:36:29 2011 +0000
@@ -31,10 +31,12 @@
         }
     }
 
-    public Style getStyle(String facet) {
+    public Style getStyle(String facet, int index) {
         for (int i = 0; i < styles.size(); i++) {
-            if (styles.get(i).getFacet().equals(facet)) {
-                return styles.get(i);
+            Style tmp = styles.get(i);
+            if (tmp.getFacet().equals(facet) &&
+                tmp.getIndex() == index) {
+                return tmp;
             }
         }
         return null;
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Style.java	Thu Oct 13 16:30:55 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Style.java	Fri Oct 14 08:36:29 2011 +0000
@@ -14,6 +14,8 @@
 
     protected String facet;
 
+    protected int index;
+
     protected List<StyleSetting> settings;
 
     public Style() {
@@ -32,6 +34,10 @@
         this.facet = facet;
     }
 
+    public void setIndex(int index) {
+        this.index = index;
+    }
+
     public String getName() {
         return this.name;
     }
@@ -40,6 +46,10 @@
         return this.facet;
     }
 
+    public int getIndex() {
+        return this.index;
+    }
+
     public StyleSetting getSetting(String name) {
         for (int i = 0; i < settings.size (); i++) {
             if (settings.get(i).getName().equals(name)) {

http://dive4elements.wald.intevation.org