Mercurial > dive4elements > river
changeset 1314:4c716bec7822
Validate selection of pairs in wdiff, show error(s) if invalid.
flys-client/trunk@2952 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 12 Oct 2011 12:42:53 +0000 |
parents | 5efd9be6b2cd |
children | cf0f906921de |
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/DatacageTwinPanel.java |
diffstat | 6 files changed, 55 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Oct 12 11:03:49 2011 +0000 +++ b/flys-client/ChangeLog Wed Oct 12 12:42:53 2011 +0000 @@ -55,6 +55,20 @@ 2011-10-12 Felix Wolfsteller <felix.wolfsteller@intevation.de> + Validate selected pairs for differences, show errors if invalid. + + * src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java + (onClick, validate): Validate and show errors if data invalid. + Cosmetics, removed junk and resolved respective todo, documentation. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties: + Added error messages. + +2011-10-12 Felix Wolfsteller <felix.wolfsteller@intevation.de> + Show only "W"s in input helper for W-Diffs. * src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed Oct 12 11:03:49 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed Oct 12 12:42:53 2011 +0000 @@ -322,6 +322,10 @@ String error_no_such_user(); + String error_no_waterlevel_pair_selected(); + + String error_same_waterlevels_in_pair(); + String error_not_logged_in(); String error_load_parameterization();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed Oct 12 11:03:49 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed Oct 12 12:42:53 2011 +0000 @@ -165,6 +165,8 @@ error_describe_collection = Error while fetching the projects state. error_no_rivers_found = Error while reading supported rivers. error_no_such_user = Error - no such user found. +error_no_waterlevel_pair_selected = Error - no waterlevel pair for building differences selected. +error_same_waterlevels_in_pair = Error - minuend and subtrahend have to differ. error_not_logged_in = You need to log in before you are allowed to start your work. error_load_parameterization = Could not load the parameterization.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed Oct 12 11:03:49 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed Oct 12 12:42:53 2011 +0000 @@ -166,6 +166,8 @@ error_describe_collection = Fehler beim Laden des Projektzustandes. error_no_rivers_found = Fehler beim Lesen der unterst\u00fctzten Fl\u00fcsse. error_no_such_user = Fehler - Kein Benutzer vorhanden. +error_no_waterlevel_pair_selected = Fehler - kein Paar zur Differenzbuilding gew\u00e4hlt. +error_same_waterlevels_in_pair = Error - minuend and subtrahend m\u00fcssen sich unterscheiden. error_not_logged_in = Sie m\u00fcssen sich erst einloggen um mit der Arbeit beginnen zu k\u00f6nnen. error_load_parameterization = Fehler beim Laden der Parametrisierung.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed Oct 12 11:03:49 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed Oct 12 12:42:53 2011 +0000 @@ -159,7 +159,9 @@ error_create_collection = Error while creating a new collection. error_describe_collection = Error while fetching the projects state. error_no_rivers_found = Error while reading supported rivers. +error_same_waterlevels_in_pair = Error - minuend and subtrahend have to differ. error_no_such_user = Error - no such user found. +error_no_waterlevel_pair_selected = Error - no waterlevel pair for building differences selected. error_not_logged_in = You need to log in before you are allowed to start your work. error_load_parameterization = Could not load the parameterization.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java Wed Oct 12 11:03:49 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageTwinPanel.java Wed Oct 12 12:42:53 2011 +0000 @@ -51,10 +51,6 @@ protected User user; - protected ToLoad toLoad1; - - protected ToLoad toLoad2; - protected ListGrid differencesList; LoadArtifactServiceAsync loadArtifactService = GWT.create( @@ -125,8 +121,10 @@ // TODO real name if (recs.length % 2 != 0) return; for (int i = 0; i < recs.length; i+=2) { - Recommendation minuend = createRecommendationFromString(recs[i+0]); - Recommendation subtrahend = createRecommendationFromString(recs[i+1]); + Recommendation minuend = + createRecommendationFromString(recs[i+0]); + Recommendation subtrahend = + createRecommendationFromString(recs[i+1]); RecommendationPairRecord pr = new RecommendationPairRecord( "A", minuend, "B", subtrahend); // This Recommendation Pair comes from the data string and was thus @@ -141,38 +139,28 @@ public Canvas create(DataList dataList) { GWT.log("createData()"); - // TODO use i18n of data. - Canvas label = new Label("Subtrahend/Minuend");//data.getDescription()); Canvas widget = createWidget(); Canvas submit = getNextButton(); VLayout layout = new VLayout(); HLayout helperLayout = new HLayout(); - label.setHeight(50); helperLayout.addMember(new DatacagePairWidget(this.artifact, user, "waterlevels", differencesList)); - /*layout.addMember(label);*/ layout.addMember(widget); layout.addMember(submit); layout.setMembersMargin(10); this.helperContainer.addMember(helperLayout); - // Find old data, if any. + // Find old data, if any, handle "diffids". Data data = dataList.get(0); - // "diffids" data handling. this.dataName = data.getLabel(); for (int i = 0; i < dataList.size(); i++) { - if (dataList.get(i) != null) { + if (dataList.get(i) != null && dataList.get(i).getItems() != null) { if (dataList.get(i).getItems() != null) { - populateGridFromString(dataList.get(i).getItems()[0].getStringValue()); + populateGridFromString( + dataList.get(i).getItems()[0].getStringValue()); } - else{ - System.out.println("DatacageTwinPanel: Datalist for item is null"); - } - } - else{ - System.out.println("DatacageTwinPanel: Data " + i + " is null (not displayable)."); } } @@ -180,14 +168,22 @@ } + /** + * Validates the selection. + */ @Override public List<String> validate() { List<String> errors = new ArrayList<String>(); if (differencesList.getRecords().length == 0) { - // TODO i18n of error message. (MSG.no_waterlevel_pair_selected()) - errors.add("No pair of waterlevel items selected"); + errors.add(MSG.error_no_waterlevel_pair_selected()); } // Check whether minuend and subtrahend are equal. + for (ListGridRecord record: differencesList.getRecords()) { + RecommendationPairRecord r = (RecommendationPairRecord) record; + if (r.getFirst().equals(r.getSecond())) { + errors.add(MSG.error_same_waterlevels_in_pair()); + } + } return errors; } @@ -200,10 +196,11 @@ VLayout layout = new VLayout(); differencesList = new ListGrid(); + differencesList.setCanEdit(false); + differencesList.setCanRemoveRecords(true); + differencesList.setCanSort(false); differencesList.setHeight(150); differencesList.setShowAllRecords(true); - differencesList.setCanEdit(false); - differencesList.setCanRemoveRecords(true); ListGridField nameField = new ListGridField("first", "Minuend"); ListGridField capitalField = new ListGridField("second", "Subtrahend"); @@ -216,17 +213,20 @@ } + /** + * Validates data, does nothing if invalid, otherwise clones new selected + * waterlevels and add them to collection, forward the artifact. + */ @Override public void onClick(ClickEvent e) { - /* - TODO: Validation/Error + GWT.log("DatacageTwinPanel.onClick"); + List<String> errors = validate(); - if (errors == null || errors.isEmpty()) { - ... - else {showErrors(errors);} + if (errors != null && !errors.isEmpty()) { + showErrors(errors); + return; + } - * */ - GWT.log("DatacageTwinPanel.onClick"); Config config = Config.getInstance(); ListGridRecord[] records = differencesList.getRecords();