comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java @ 9239:4e3757202d5c

salix.supraregional better error- + advance-handling
author gernotbelger
date Tue, 10 Jul 2018 14:45:40 +0200
parents 1c756bfee472
children 54173301bc34
comparison
equal deleted inserted replaced
9238:1c756bfee472 9239:4e3757202d5c
108 this.maxKm = temp; 108 this.maxKm = temp;
109 } 109 }
110 110
111 final VLayout layout = new VLayout(); 111 final VLayout layout = new VLayout();
112 final Canvas submit = getNextButton(); 112 final Canvas submit = getNextButton();
113 //
114 // new Button(this.MSG.buttonNext());
115 // final HandlerRegistration reg = submit.addClickHandler(new ClickHandler() {
116 //
117 // @Override
118 // public void onClick(final ClickEvent event) {
119 // final String msg = getErrorMsg();
120 // if (!msg.equals("")) {
121 // SC.warn(msg);
122 // } else {
123 // // continue, forward, advance
124 //
125 // }
126 // }
127 // });
113 128
114 final VLayout root = new VLayout(); 129 final VLayout root = new VLayout();
115 root.setWidth(420); 130 root.setWidth(420);
116 createWidget(root, data, tableData); 131 createWidget(root, data, tableData);
117 132
147 } 162 }
148 163
149 public Canvas createWidget(final Layout root, final DataList data, final String tableData) { 164 public Canvas createWidget(final Layout root, final DataList data, final String tableData) {
150 165
151 this.table = createTable(root, data, tableData); 166 this.table = createTable(root, data, tableData);
152
153 final TextItem dwspl = PanelHelper.createItem("_label_dwspl", this.MSG.uinfo_salix_dmwspl_short(), "50"); 167 final TextItem dwspl = PanelHelper.createItem("_label_dwspl", this.MSG.uinfo_salix_dmwspl_short(), "50");
154 // this.dwspl.setColSpan(3);
155 final TextItem start = PanelHelper.createIntegerItem("_from_dwspl", getLabelFromTo(this.MSG.from()), "50"); 168 final TextItem start = PanelHelper.createIntegerItem("_from_dwspl", getLabelFromTo(this.MSG.from()), "50");
156 // this.start.setColSpan(3);
157 final TextItem end = PanelHelper.createIntegerItem("_to_dwspl", getLabelFromTo(this.MSG.to()), "50"); 169 final TextItem end = PanelHelper.createIntegerItem("_to_dwspl", getLabelFromTo(this.MSG.to()), "50");
158 // this.end.setColSpan(3);
159 170
160 final HLayout fields = new HLayout(); 171 final HLayout fields = new HLayout();
161 172
162 final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific 173 final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific
163 174
381 return field; 392 return field;
382 } 393 }
383 394
384 private String validate(final String fromInput, final String toInput, final String dmwspl) { 395 private String validate(final String fromInput, final String toInput, final String dmwspl) {
385 396
397 final List<SalixZone> zones = getSalixZones(this.table.getRecords());
398
386 if (fromInput == null || toInput == null || dmwspl == null || fromInput.trim().isEmpty() || toInput.trim().isEmpty() || dmwspl.trim().isEmpty()) 399 if (fromInput == null || toInput == null || dmwspl == null || fromInput.trim().isEmpty() || toInput.trim().isEmpty() || dmwspl.trim().isEmpty())
387 return this.MSG.uinfo_vegetation_zones_validation_empty(); 400 return this.MSG.uinfo_vegetation_zones_validation_empty();
388 401
389 try { 402 try {
390 final Double from = this.format.parse(fromInput); 403 final Double from = this.format.parse(fromInput);
391 final Double to = this.format.parse(toInput); 404 final Double to = this.format.parse(toInput);
392 Integer.valueOf(dmwspl); 405 Integer.valueOf(dmwspl);
393 406
407 if (!SalixZone.hasGaps(zones, this.minKm, this.maxKm))
408 return this.MSG.uinfo_salix_input_complete();
409
394 if (from < this.minKm || from > this.maxKm || to > this.maxKm || to < this.minKm) 410 if (from < this.minKm || from > this.maxKm || to > this.maxKm || to < this.minKm)
395 return this.MSG.uinfo_salix_km_limit_exceed(); 411 return this.MSG.uinfo_salix_km_limit_exceed();
396 412
397 // range anschluss 413 // range anschluss
398 if (!SalixZone.isValidAnschlussRange(from, to, getSalixZones(this.table.getRecords()), this.minKm)) { 414 if (!SalixZone.isValidAnschlussRange(from, to, zones, this.minKm)) {
399 return this.MSG.uinfo_salix_km_anschluss(); 415 return this.MSG.uinfo_salix_km_anschluss();
400 } 416 }
401 return null; 417 return null;
402 } 418 }
403 catch (final NumberFormatException e) { 419 catch (final NumberFormatException e) {
404 return this.MSG.wrongFormat(); 420 return this.MSG.wrongFormat();
405 } 421 }
406 } 422 }
407 423
424 @Override
425 public List<String> validate() {
426 final List<String> errors = new ArrayList<String>();
427
428 if (SalixZone.zonesAreOverlapping(this.getSalixZones(this.table.getRecords())))
429 errors.add(this.MSG.uinfo_salix_km_overlap());
430 if (SalixZone.hasGaps(this.getSalixZones(this.table.getRecords()), this.minKm, this.maxKm))
431 errors.add(this.MSG.uinfo_salix_km_has_gaps());// "Der Km-Bereich wird nicht vollst. abgedeckt.";
432 return errors;
433 }
434
408 private void validateRangeOverlap() { 435 private void validateRangeOverlap() {
409 final StringBuilder builder = new StringBuilder(); 436 this.validationLabel.setText(validate().toString().replace("[", "").replace("]", "").replace(",", ""));
410 if (SalixZone.zonesAreOverlapping(this.getSalixZones(this.table.getRecords())))
411 builder.append(this.MSG.uinfo_salix_km_overlap()).append(" ");
412 if (SalixZone.hasGaps(this.getSalixZones(this.table.getRecords()), this.minKm, this.maxKm))
413 builder.append(this.MSG.uinfo_salix_km_has_gaps());// "Der Km-Bereich wird nicht vollst. abgedeckt.";
414
415 this.validationLabel.setText(builder.toString());
416 } 437 }
417 } 438 }

http://dive4elements.wald.intevation.org