comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LocationDistancePanel.java @ 8448:e98dbf72c9ec

(issue1733) Fix switch between location and distance This changes the enable methods to state switchers. Combining them avoids the problem that they could be out of sync.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 27 Oct 2014 12:52:00 +0100
parents 4b315e5d2d4f
children f61e2791ccdf
comparison
equal deleted inserted replaced
8447:4b315e5d2d4f 8448:e98dbf72c9ec
690 setLocationValues(lDef.getStringValue()); 690 setLocationValues(lDef.getStringValue());
691 } 691 }
692 } 692 }
693 693
694 if (theMode.equals(FIELD_VALUE_DISTANCE)) { 694 if (theMode.equals(FIELD_VALUE_DISTANCE)) {
695 enableDistancePanel(); 695 enableDistanceMode();
696 inputTables.selectTab(1); 696 inputTables.selectTab(1);
697 } 697 }
698 currentFiltered = (ListGrid)inputTables.getSelectedTab().getPane(); 698 currentFiltered = (ListGrid)inputTables.getSelectedTab().getPane();
699 699
700 distancePanel.setValues(getFrom(), getTo(), getStep()); 700 distancePanel.setValues(getFrom(), getTo(), getStep());
731 @Override 731 @Override
732 public void onTabSelected(TabSelectedEvent evt) { 732 public void onTabSelected(TabSelectedEvent evt) {
733 filterDescription.clear(); 733 filterDescription.clear();
734 filterRange.clear(); 734 filterRange.clear();
735 filterResultCount.setValue(""); 735 filterResultCount.setValue("");
736
737 // The assumption is that location is tab 0 and distance tab 1
738 if (inputTables.getSelectedTabNumber() == 0) {
739 enableLocationMode();
740 } else {
741 enableDistanceMode();
742 }
736 743
737 Canvas c = evt.getTabPane(); 744 Canvas c = evt.getTabPane();
738 if(c instanceof ListGrid) { 745 if(c instanceof ListGrid) {
739 currentFiltered = (ListGrid)c; 746 currentFiltered = (ListGrid)c;
740 } 747 }
1155 1162
1156 1163
1157 /** 1164 /**
1158 * Activates the location panel. 1165 * Activates the location panel.
1159 */ 1166 */
1160 protected void enableLocationPanel() { 1167 protected void enableLocationMode() {
1168 mode.setValue(FIELD_MODE, FIELD_VALUE_LOCATION);
1161 container.hideMember(distancePanel); 1169 container.hideMember(distancePanel);
1162 container.showMember(locationPanel); 1170 container.showMember(locationPanel);
1163 } 1171 }
1164 1172
1165 1173
1166 /** 1174 /**
1167 * Activates the distance panel. 1175 * Activates the distance panel.
1168 */ 1176 */
1169 protected void enableDistancePanel() { 1177 protected void enableDistanceMode() {
1178 mode.setValue(FIELD_MODE, FIELD_VALUE_DISTANCE);
1170 container.hideMember(locationPanel); 1179 container.hideMember(locationPanel);
1171 container.showMember(distancePanel); 1180 container.showMember(distancePanel);
1172 } 1181 }
1173 1182
1174 1183
1183 1192
1184 if (value == null) { 1193 if (value == null) {
1185 return; 1194 return;
1186 } 1195 }
1187 if (value.equals(FIELD_VALUE_LOCATION)) { 1196 if (value.equals(FIELD_VALUE_LOCATION)) {
1188 event.getItem().setValue(FIELD_VALUE_LOCATION); 1197 enableLocationMode();
1189 enableLocationPanel();
1190 filterDescription.clear(); 1198 filterDescription.clear();
1191 filterRange.clear(); 1199 filterRange.clear();
1192 filterResultCount.setValue(""); 1200 filterResultCount.setValue("");
1193 1201
1194 // Bring this tab to front. 1202 // Bring this tab to front.
1195 inputTables.selectTab(0); 1203 inputTables.selectTab(0);
1196 } 1204 }
1197 else { 1205 else {
1198 event.getItem().setValue(FIELD_VALUE_DISTANCE); 1206 enableDistanceMode();
1199 enableDistancePanel();
1200 filterDescription.clear(); 1207 filterDescription.clear();
1201 filterRange.clear(); 1208 filterRange.clear();
1202 filterResultCount.setValue(""); 1209 filterResultCount.setValue("");
1203 1210
1204 // Bring the distanceTable tab to front. 1211 // Bring the distanceTable tab to front.

http://dive4elements.wald.intevation.org