comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java @ 520:9e2b151770bd

Bugfix in the range/location panel - avoid NullPointerExceptions in getData(). flys-client/trunk@1999 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 25 May 2011 07:05:22 +0000
parents ec965bf8dfef
children 9f16ac843dda
comparison
equal deleted inserted replaced
519:77234b1d009c 520:9e2b151770bd
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2 2
3 import java.util.ArrayList;
3 import java.util.LinkedHashMap; 4 import java.util.LinkedHashMap;
4 import java.util.List; 5 import java.util.List;
5 6
6 import com.google.gwt.core.client.GWT; 7 import com.google.gwt.core.client.GWT;
7 import com.google.gwt.user.client.rpc.AsyncCallback; 8 import com.google.gwt.user.client.rpc.AsyncCallback;
559 DoubleRangePanel form = (DoubleRangePanel) member; 560 DoubleRangePanel form = (DoubleRangePanel) member;
560 saveDistanceValues(form); 561 saveDistanceValues(form);
561 } 562 }
562 } 563 }
563 564
564 return new Data[] { 565 Data dMode = getDataMode();
565 getDataMode(), 566 Data dLocations = getDataLocations();
566 getDataLocations(), 567 Data dFrom = getDataFrom();
567 getDataFrom(), 568 Data dTo = getDataTo();
568 getDataTo(), 569 Data dStep = getDataStep();
569 getDataStep() }; 570
571 List<Data> data = new ArrayList<Data>();
572
573 if (dMode != null) {
574 data.add(dMode);
575 }
576
577 if (dLocations != null) {
578 data.add(dLocations);
579 }
580
581 if (dFrom != null) {
582 data.add(dFrom);
583 }
584
585 if (dTo != null) {
586 data.add(dTo);
587 }
588
589 if (dStep != null) {
590 data.add(dStep);
591 }
592
593 return (Data[]) data.toArray(new Data[data.size()]);
570 } 594 }
571 595
572 596
573 /** 597 /**
574 * Returns the Data object for the 'mode' attribute. 598 * Returns the Data object for the 'mode' attribute.
583 607
584 608
585 protected Data getDataLocations() { 609 protected Data getDataLocations() {
586 double[] locations = getLocationValues(); 610 double[] locations = getLocationValues();
587 boolean first = true; 611 boolean first = true;
612
613 if (locations == null) {
614 return null;
615 }
588 616
589 StringBuilder sb = new StringBuilder(); 617 StringBuilder sb = new StringBuilder();
590 618
591 for (double l: locations) { 619 for (double l: locations) {
592 if (!first) { 620 if (!first) {

http://dive4elements.wald.intevation.org