diff flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java @ 1349:46a4b74d87bf

Allow (yet limited) usage of zus and flood-protection data in wdiffs. flys-client/trunk@3020 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 18 Oct 2011 15:43:33 +0000
parents 1627a28c4504
children 01b18db3b288
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java	Tue Oct 18 15:20:24 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java	Tue Oct 18 15:43:33 2011 +0000
@@ -74,6 +74,7 @@
     RemoveArtifactServiceAsync removeArtifactService = GWT.create(
             de.intevation.flys.client.client.services.RemoveArtifactService.class);
 
+
     public DatacageTwinPanel(User user) {
         super();
         this.user = user;
@@ -221,6 +222,7 @@
 
         differencesList.setCanEdit(false);
         differencesList.setCanSort(false);
+        differencesList.setShowHeaderContextMenu(false);
         differencesList.setHeight(150);
         differencesList.setShowAllRecords(true);
 
@@ -231,6 +233,8 @@
         final ListGridField removeField  =
             new ListGridField("_removeRecord", "Remove Record"){{
                 setType(ListGridFieldType.ICON);
+                // TODO evaluate which icon to use (and how).
+                //setIcon("images/removeFeature.png");
                 setIcon("[SKIN]/actions/remove.png");
                 setCanEdit(false);
                 setCanFilter(false);
@@ -283,11 +287,14 @@
         }
 
         Config config = Config.getInstance();
+        String url    = config.getServerUrl();
+        String locale = config.getLocale();
+
         ListGridRecord[] records = differencesList.getRecords();
 
         List<Recommendation> ar  = new ArrayList<Recommendation>();
         List<Recommendation> all = new ArrayList<Recommendation>();
-        List<Recommendation> statics = new ArrayList<Recommendation>();
+
         for (ListGridRecord record : records) {
             RecommendationPairRecord r =
                 (RecommendationPairRecord) record;
@@ -295,13 +302,36 @@
             if (!r.isAlreadyLoaded()) {
                 // Check whether one of those is a dike or similar.
                 // TODO differentiate and merge: new clones, new, old.
-                if(r.getFirst().getIDs() != null
-                    && r.getFirst().getIDs().startsWith("flood_protection"))
+                Recommendation firstR = r.getFirst();
+                if(firstR.getIDs() != null) {
+                    GWT.log("First IDs: " + firstR.getIDs());
+                }
+                // TODO resolve this hack, fix datacage/recommendation for this case.
+                if(firstR.getIDs() != null &&
+                    firstR.getIDs().startsWith("flood_protection"))
                 {
                     // These do not get cloned but loaded ("spawned").
+                    firstR.setFactory("staticwkms");
                 }
-                ar.add(r.getFirst());
-                ar.add(r.getSecond());
+                else {
+                    firstR.setFactory("waterlevel");
+                }
+                Recommendation secondR = r.getSecond();
+                if(secondR.getIDs() != null) {
+                    GWT.log("Second IDs: " + secondR.getIDs());
+                }
+                if(secondR.getIDs() != null
+                    && secondR.getIDs().startsWith("flood_protection"))
+                {
+                    // These do not get cloned but loaded ("spawned").
+                    secondR.setFactory("staticwkms");
+                }
+                else {
+                    secondR.setFactory("waterlevel");
+                }
+
+                ar.add(firstR);
+                ar.add(secondR);
             }
             else {
                 all.add(r.getFirst());
@@ -343,8 +373,8 @@
         for(final String uuid: artifactIdsToRemove) {
             removeArtifactService.remove(this.collection,
                 uuid,
-                config.getServerUrl(),
-                config.getLocale(),
+                url,
+                locale,
                 new AsyncCallback<Collection>() {
                     public void onFailure(Throwable caught) {
                         GWT.log("RemoveArtifact (" + uuid + ") failed.");
@@ -355,25 +385,26 @@
                 });
         }
 
-        // Clone new ones, go forward.
+        // Clone new ones (and spawn statics), go forward.
         loadArtifactService.loadMany(
-              this.collection,
-              toClone,
-              "waterlevel",
-              config.getServerUrl(),
-              config.getLocale(),
-              new AsyncCallback<Artifact[]>() {
+            this.collection,
+            toClone,
+            //"staticwkms",
+            null,
+            url,
+            locale,
+            new AsyncCallback<Artifact[]>() {
                 public void onFailure(Throwable caught) {
-                    GWT.log("Failure of cloning with waterlevelfactory!");
+                    GWT.log("Failure of cloning with factories!");
                 }
                 public void onSuccess(Artifact[] artifacts) {
                     GWT.log("Successfully cloned " + toClone.length +
-                        " with watelevelfactory.");
+                        " with factories.");
 
                     fireStepForwardEvent(new StepForwardEvent(
                         getData(toClone, artifacts, toUse)));
                 }
-              } );
+            });
     }
 
 
@@ -426,19 +457,26 @@
     protected String createDataString(String artifact, Filter filter) {
         Facet f = null;
 
-        Map<String, List<Facet>>               outs = filter.getOuts();
-        Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet();
+        if(filter != null) {
+            Map<String, List<Facet>>               outs = filter.getOuts();
+            Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet();
 
-        for (Map.Entry<String, List<Facet>> entry: entries) {
-            List<Facet> fs = entry.getValue();
+            for (Map.Entry<String, List<Facet>> entry: entries) {
+                List<Facet> fs = entry.getValue();
 
-            f = fs.get(0);
-            if (f != null) {
-                break;
+                f = fs.get(0);
+                if (f != null) {
+                    break;
+                }
             }
+
+            return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]";
+        }
+        else {
+            return "[" + artifact + ";staticwkms;0]";
         }
 
-        return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]";
+        
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org