Mercurial > dive4elements > river
changeset 1352:01b18db3b288
In WDiff datacage input make names survive backjumps.
flys-client/trunk@3027 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 19 Oct 2011 11:08:03 +0000 (2011-10-19) |
parents | 19f621663b7a |
children | fd408dfbd3b8 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java flys-client/src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ToLoad.java |
diffstat | 7 files changed, 88 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Oct 19 09:35:41 2011 +0000 +++ b/flys-client/ChangeLog Wed Oct 19 11:08:03 2011 +0000 @@ -1,3 +1,22 @@ +2011-10-19 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Added a displayName propertie to Recommendations and add names to data + String such that they survive a "backjump" (reparameterization). + + * src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java, + src/main/java/de/intevation/flys/client/shared/model/ToLoad.java: + Keep displayNames for recommendations. + + * src/main/java/de/intevation/flys/client/shared/model/Recommendation.java: + Added displayName, getter and setter. + + * src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java: + Set displayName for create recommendations, add it to Data String. + + * src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java, + src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java: + Do not store name separately from Recommendation + 2011-10-19 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/server/ChartServiceHelper.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java Wed Oct 19 09:35:41 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java Wed Oct 19 11:08:03 2011 +0000 @@ -92,8 +92,6 @@ public void plusClicked() { ToLoad toLoad1 = firstDatacageWidget.getSelection(); ToLoad toLoad2 = secondDatacageWidget.getSelection(); - String [] sel1 = firstDatacageWidget.getSelectionTitles(); - String [] sel2 = secondDatacageWidget.getSelectionTitles(); // TODO further sanitize (toRecommendations.length) if (toLoad1 == null || toLoad2 == null) { @@ -101,9 +99,7 @@ } grid.addData(new RecommendationPairRecord( - sel1[0], toLoad1.toRecommendations().get(0), - sel2[0], toLoad2.toRecommendations().get(0))); } }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java Wed Oct 19 09:35:41 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java Wed Oct 19 11:08:03 2011 +0000 @@ -125,6 +125,7 @@ filter.add("longitudinal_section", facets); Recommendation r = new Recommendation("waterlevel", parts[0], this.artifact.getUuid(), filter); + r.setDisplayName(parts[3]); return r; } @@ -143,8 +144,9 @@ createRecommendationFromString(recs[i+0]); Recommendation subtrahend = createRecommendationFromString(recs[i+1]); + //minuend.setDisplayName("hum"); subtrahend.setDisplayName("wim"); RecommendationPairRecord pr = new RecommendationPairRecord( - "A", minuend, "B", subtrahend); + minuend, subtrahend); // This Recommendation Pair comes from the data string and was thus // already cloned. pr.setIsAlreadyLoaded(true); @@ -389,7 +391,7 @@ loadArtifactService.loadMany( this.collection, toClone, - //"staticwkms", + //"staticwkms" and "waterlevel" null, url, locale, @@ -434,7 +436,7 @@ r.setMasterArtifact(uuid); if (i>0) dataItemString += "#"; - dataItemString += createDataString(uuid, r.getFilter()); + dataItemString += createDataString(uuid, r); } for (int i = 0; i < oldRecommendations.length; i++) { @@ -442,9 +444,11 @@ String uuid = r.getIDs(); if (dataItemString.length() > 0) dataItemString += "#"; - dataItemString += createDataString(uuid, r.getFilter()); + dataItemString += createDataString(uuid, r); } + // TODO some hassle could be resolved by using multiple DataItems + // (e.g. one per pair). DataItem item = new DefaultDataItem(dataName, dataName, dataItemString); return new Data[] { new DefaultData( dataName, null, null, new DataItem[] {item}) }; @@ -454,8 +458,12 @@ /** * Creates part of the String that encodes minuend or subtrahend. */ - protected String createDataString(String artifact, Filter filter) { - Facet f = null; + protected String createDataString( + String artifact, + Recommendation recommendation) + { + Filter filter = recommendation.getFilter(); + Facet f = null; if(filter != null) { Map<String, List<Facet>> outs = filter.getOuts(); @@ -470,13 +478,12 @@ } } - return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]"; + // Hell get the creepy name inside. + return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + ";" + recommendation.getDisplayName() + "]"; } else { - return "[" + artifact + ";staticwkms;0]"; + return "[" + artifact + ";staticwkms;0;" + recommendation.getDisplayName() + "]"; } - - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java Wed Oct 19 09:35:41 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java Wed Oct 19 11:08:03 2011 +0000 @@ -337,9 +337,13 @@ } GWT.log("DatacageWidget.collectToLoad, attributes are " + debugAttributeValues); - if(ids == null) ids = node.getAttribute("id"); - toLoad.add(artifact, factory, out, name, ids); + toLoad.add(artifact, + factory, + out, + name, + ids, + node.getAttribute("name")); } TreeNode [] children = tree.getChildren(node); if (children != null) {
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java Wed Oct 19 09:35:41 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RecommendationPairRecord.java Wed Oct 19 11:08:03 2011 +0000 @@ -22,12 +22,6 @@ /** The "second" recommendation (typically the subtrahend). */ Recommendation second; - /** Human-readable short information about the "first" recommendation. */ - String firstName; - - /** Human-readable short information about the "second" recommendation. */ - String secondName; - /** * Whether the RecommendationPairRecord was restored from data and thus * already loaded (usually cloned) in an ArtifactCollection or not. @@ -43,19 +37,15 @@ /** * Create a new RecommendationPairRecord. * - * @param firstName Name for the first recommendation (typical minuend). - * @param first The first recommendation (typically the minuend). - * @param secondName Name for the second recommendation (subtrahend). - * @param first The second recommendation (typically the subtrahend). + * @param first The first recommendation (typically the minuend). + * @param second The second recommendation (typically the subtrahend). */ public RecommendationPairRecord( - String firstName, Recommendation first, - String secondName, Recommendation second) { - setFirst(first, firstName); - setSecond(second, secondName); + setFirst(first); + setSecond(second); alreadyLoaded = false; } @@ -63,24 +53,20 @@ /** * Sets the first recommendation with info (minuend). * @param first Recommendation to store. - * @param name human-readable name to identify recommendation */ - public void setFirst(Recommendation first, String name) { + public void setFirst(Recommendation first) { this.first = first; - this.firstName = name; - setAttribute(ATTRIBUTE_FIRST, name); + setAttribute(ATTRIBUTE_FIRST, first.getDisplayName()); } /** * Sets the second recommendation with info (subtrahend). * @param second Recommendation to store. - * @param name human-readable name to identify recommendation. */ - public void setSecond(Recommendation second, String name) { + public void setSecond(Recommendation second) { this.second = second; - this.secondName = name; - setAttribute(ATTRIBUTE_SECOND, name); + setAttribute(ATTRIBUTE_SECOND, second.getDisplayName()); } @@ -107,7 +93,7 @@ * @return name of first recommendation (typically the minuend). */ public String getFirstName() { - return firstName; + return first.getDisplayName(); } @@ -116,7 +102,7 @@ * @return name of second recommendation (typically the subtrahend). */ public String getSecondName() { - return secondName; + return second.getDisplayName(); }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java Wed Oct 19 09:35:41 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java Wed Oct 19 11:08:03 2011 +0000 @@ -101,6 +101,7 @@ protected String ids; protected String masterArtifact; protected Filter filter; + protected String displayName = null; public Recommendation() { } @@ -129,6 +130,14 @@ this.factory = factory; } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return this.displayName; + } + public String getIDs() { return ids; }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/ToLoad.java Wed Oct 19 09:35:41 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ToLoad.java Wed Oct 19 11:08:03 2011 +0000 @@ -9,12 +9,27 @@ public class ToLoad implements Serializable { + + public class StringPair { + public String first; + public String second; + public StringPair(String first, String second) { + this.first = first; + this.second = second; + } + public int hashCode() { + return first.hashCode() + second.hashCode(); + } + public boolean equals(StringPair other) { + return (this.second.equals(other.second)) && (this.first.equals(other.first)); + } + } public static final String SYNTHETIC_KEY = "key-"; - protected Map<String, Map<String, ArtifactFilter>> artifacts; + protected Map<String, Map<StringPair, ArtifactFilter>> artifacts; public ToLoad() { - artifacts = new HashMap<String, Map<String, ArtifactFilter>>(); + artifacts = new HashMap<String, Map<StringPair, ArtifactFilter>>(); } public static final String uniqueKey(Map<?, ?> map) { @@ -32,23 +47,24 @@ String factory, String out, String name, - String ids + String ids, + String displayName ) { if (artifactName == null) { artifactName = uniqueKey(artifacts); } - Map<String, ArtifactFilter> artifact = artifacts.get(artifactName); + Map<StringPair, ArtifactFilter> artifact = artifacts.get(artifactName); if (artifact == null) { - artifact = new HashMap<String, ArtifactFilter>(); + artifact = new HashMap<StringPair, ArtifactFilter>(); artifacts.put(artifactName, artifact); } ArtifactFilter filter = artifact.get(factory); if (filter == null) { filter = new ArtifactFilter(factory); - artifact.put(factory, filter); + artifact.put(new StringPair(factory, displayName), filter); } filter.add(out, name, ids); @@ -61,7 +77,7 @@ public List<Recommendation> toRecommendations() { List<Recommendation> recommendations = new ArrayList<Recommendation>(); - for (Map.Entry<String, Map<String, ArtifactFilter>> all: + for (Map.Entry<String, Map<StringPair, ArtifactFilter>> all: artifacts.entrySet() ) { String masterArtifact = all.getKey(); @@ -70,10 +86,11 @@ masterArtifact = null; } - for (Map.Entry<String, ArtifactFilter> entry: + for (Map.Entry<StringPair, ArtifactFilter> entry: all.getValue().entrySet() ) { - String factory = entry.getKey(); + StringPair pair = entry.getKey(); + String factory = pair.first; ArtifactFilter artifactFilter = entry.getValue(); String ids; @@ -90,6 +107,7 @@ Recommendation recommendation = new Recommendation( factory, ids, masterArtifact, filter); + recommendation.setDisplayName(pair.second); recommendations.add(recommendation); }