# HG changeset patch # User Felix Wolfsteller # Date 1318952613 0 # Node ID 46a4b74d87bf20a11e64d395393b5d779ebd0e33 # Parent fb224f54c6430c7032798c461902d46fee425b97 Allow (yet limited) usage of zus and flood-protection data in wdiffs. flys-client/trunk@3020 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fb224f54c643 -r 46a4b74d87bf flys-client/ChangeLog --- a/flys-client/ChangeLog Tue Oct 18 15:20:24 2011 +0000 +++ b/flys-client/ChangeLog Tue Oct 18 15:43:33 2011 +0000 @@ -1,3 +1,25 @@ +2011-10-18 Felix Wolfsteller + + Make "zus" and flood protections usable for W-Differences (with yet + many constraints, e.g. server will fail if flood protection is + subtrahend). + + * src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java: + Discern static and calculated data by pretty ugly hack, set factory + to "clone" with accordingly. + + * src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java: + Request the system ("static") part of datacage in wdiff-input + selection as well. + + * src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java: + Enable hack in DatacageTwinPanel, set ids to id content, such that + recommendations and toloads can be created from selected elements in + Datacage. + + * src/main/java/de/intevation/flys/client/shared/model/Recommendation.java: + (setFactory): Allow to change factory during live time. + 2011-10-18 Raimund Renkert * src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java: diff -r fb224f54c643 -r 46a4b74d87bf flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java Tue Oct 18 15:20:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java Tue Oct 18 15:43:33 2011 +0000 @@ -53,8 +53,18 @@ this.grid = grid; HLayout hLayout = new HLayout(); - firstDatacageWidget = new DatacageWidget(artifact, user, outs, false); - secondDatacageWidget = new DatacageWidget(artifact, user, outs, false); + firstDatacageWidget = new DatacageWidget( + artifact, + user, + outs, + "load-system:true", + false); + secondDatacageWidget = new DatacageWidget( + artifact, + user, + outs, + "load-system:true", + false); firstDatacageWidget.setIsMutliSelectable(false); secondDatacageWidget.setIsMutliSelectable(false); diff -r fb224f54c643 -r 46a4b74d87bf flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java --- 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 ar = new ArrayList(); List all = new ArrayList(); - List statics = new ArrayList(); + 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() { 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() { + this.collection, + toClone, + //"staticwkms", + null, + url, + locale, + new AsyncCallback() { 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> outs = filter.getOuts(); - Set>> entries = outs.entrySet(); + if(filter != null) { + Map> outs = filter.getOuts(); + Set>> entries = outs.entrySet(); - for (Map.Entry> entry: entries) { - List fs = entry.getValue(); + for (Map.Entry> entry: entries) { + List 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 : diff -r fb224f54c643 -r 46a4b74d87bf flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java Tue Oct 18 15:20:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java Tue Oct 18 15:43:33 2011 +0000 @@ -312,6 +312,11 @@ } + /** + * Adds to toLoad, from info in node. + * Afterwards, add all children of node to stack to parse (next time + * collectToLoads is called). + */ protected void collectToLoads(TreeNode node) { Stack stack = new Stack(); @@ -325,6 +330,14 @@ String out = node.getAttribute("out"); String name = node.getAttribute("facet"); String ids = node.getAttribute("ids"); + String debugAttributeValues = ""; + for (String attr: node.getAttributes()) { + debugAttributeValues += ("[" + attr +": " + + node.getAttributeAsString(attr) + "] "); + } + GWT.log("DatacageWidget.collectToLoad, attributes are " + + debugAttributeValues); + if(ids == null) ids = node.getAttribute("id"); toLoad.add(artifact, factory, out, name, ids); } diff -r fb224f54c643 -r 46a4b74d87bf flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java --- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java Tue Oct 18 15:20:24 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java Tue Oct 18 15:43:33 2011 +0000 @@ -125,6 +125,10 @@ return factory; } + public void setFactory(String factory) { + this.factory = factory; + } + public String getIDs() { return ids; }