comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java @ 1534:98123d34529b

Added UI parts and event for filtering distances and locations. flys-client/trunk@3749 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 23 Jan 2012 11:07:38 +0000
parents 2a00f4849738
children 4f4d29404dba
comparison
equal deleted inserted replaced
1533:7fcec57c2f2c 1534:98123d34529b
13 import com.smartgwt.client.widgets.form.DynamicForm; 13 import com.smartgwt.client.widgets.form.DynamicForm;
14 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; 14 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
15 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; 15 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
16 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; 16 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
17 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; 17 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
18 import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
19 import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
20
18 import com.smartgwt.client.widgets.form.fields.FormItem; 21 import com.smartgwt.client.widgets.form.fields.FormItem;
22 import com.smartgwt.client.widgets.form.fields.SelectItem;
23 import com.smartgwt.client.widgets.form.fields.TextItem;
19 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; 24 import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
20 import com.smartgwt.client.widgets.layout.HLayout; 25 import com.smartgwt.client.widgets.layout.HLayout;
21 import com.smartgwt.client.widgets.layout.VLayout; 26 import com.smartgwt.client.widgets.layout.VLayout;
22 import com.smartgwt.client.widgets.grid.ListGrid; 27 import com.smartgwt.client.widgets.grid.ListGrid;
23 import com.smartgwt.client.widgets.grid.ListGridField; 28 import com.smartgwt.client.widgets.grid.ListGridField;
49 import de.intevation.flys.client.client.services.DistanceInfoServiceAsync; 54 import de.intevation.flys.client.client.services.DistanceInfoServiceAsync;
50 import de.intevation.flys.client.client.FLYSConstants; 55 import de.intevation.flys.client.client.FLYSConstants;
51 import de.intevation.flys.client.client.Config; 56 import de.intevation.flys.client.client.Config;
52 import de.intevation.flys.client.client.event.FilterHandler; 57 import de.intevation.flys.client.client.event.FilterHandler;
53 import de.intevation.flys.client.client.event.StringFilterEvent; 58 import de.intevation.flys.client.client.event.StringFilterEvent;
59 import de.intevation.flys.client.client.event.RangeFilterEvent;
54 import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource; 60 import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource;
55 61
56 62
57 /** 63 /**
58 * This UIProvider creates a widget to enter locations or a distance. 64 * This UIProvider creates a widget to enter locations or a distance.
135 141
136 /** The table data. */ 142 /** The table data. */
137 protected DistanceInfoObject[] tableData; 143 protected DistanceInfoObject[] tableData;
138 144
139 /** The table filter.*/ 145 /** The table filter.*/
140 protected TableFilter filter; 146 protected TableFilter filterDescription;
147 protected RangeTableFilter filterRange;
148
149 /** The Combobox for table filter criteria. */
150 protected SelectItem filterCriteria;
151
141 152
142 /** 153 /**
143 * Creates a new LocationDistancePanel instance. 154 * Creates a new LocationDistancePanel instance.
144 */ 155 */
145 public LocationDistancePanel() { 156 public LocationDistancePanel() {
676 container.setMembersMargin(30); 687 container.setMembersMargin(30);
677 688
678 inputTables = new TabSet(); 689 inputTables = new TabSet();
679 inputTables.addTabSelectedHandler(new TabSelectedHandler() { 690 inputTables.addTabSelectedHandler(new TabSelectedHandler() {
680 public void onTabSelected(TabSelectedEvent evt) { 691 public void onTabSelected(TabSelectedEvent evt) {
681 filter.clear(); 692 filterDescription.clear();
682 } 693 }
683 }); 694 });
684 695
685 Tab locations = new Tab(MESSAGES.locations()); 696 Tab locations = new Tab(MESSAGES.locations());
686 Tab distances = new Tab(MESSAGES.distance()); 697 Tab distances = new Tab(MESSAGES.distance());
692 distances.setPane(distanceTable); 703 distances.setPane(distanceTable);
693 704
694 inputTables.addTab(locations); 705 inputTables.addTab(locations);
695 inputTables.addTab(distances); 706 inputTables.addTab(distances);
696 707
697 filter = new TableFilter(); 708 filterDescription = new TableFilter();
698 filter.setHeight("30px"); 709 filterDescription.setHeight("30px");
699 filter.addFilterHandler(this); 710 filterDescription.addFilterHandler(this);
711
712 filterRange = new RangeTableFilter();
713 filterRange.setHeight("30px");
714 filterRange.addFilterHandler(this);
715 filterRange.setVisible(false);
716
717 filterCriteria = new SelectItem();
718 filterCriteria.setShowTitle(false);
719 filterCriteria.setWidth(100);
720 filterCriteria.addChangedHandler(new ChangedHandler() {
721 public void onChanged(ChangedEvent e) {
722 if(e.getValue().toString().equals("range")) {
723 filterRange.setVisible(true);
724 filterDescription.setVisible(false);
725 filterDescription.clear();
726 }
727 else {
728 filterRange.setVisible(false);
729 filterRange.clear();
730 filterDescription.setVisible(true);
731 }
732 }
733 });
734
735 LinkedHashMap<String, String> filterMap =
736 new LinkedHashMap<String, String>();
737 filterMap.put("description", MESSAGES.description());
738 filterMap.put("range", MESSAGES.range());
739 filterCriteria.setValueMap(filterMap);
740 filterCriteria.setValue("description");
741
742 DynamicForm form = new DynamicForm();
743 form.setFields(filterCriteria);
700 744
701 inputTables.setHeight("*"); 745 inputTables.setHeight("*");
702 746
703 VLayout helper = new VLayout(); 747 VLayout helper = new VLayout();
748 HLayout filterLayout = new HLayout();
749
750 filterLayout.addMember(form);
751 filterLayout.addMember(filterDescription);
752 filterLayout.addMember(filterRange);
753 filterLayout.setHeight("33px");
704 helper.addMember(inputTables); 754 helper.addMember(inputTables);
705 helper.addMember(filter); 755 helper.addMember(filterLayout);
706 helper.setHeight100(); 756 helper.setHeight100();
707 helper.setWidth100(); 757 helper.setWidth100();
708 758
709 helperContainer.addMember(helper); 759 helperContainer.addMember(helper);
760 filterLayout.setWidth("200");
710 761
711 return layout; 762 return layout;
712 } 763 }
713 764
714 765
728 locationDistanceTable.clearCriteria(); 779 locationDistanceTable.clearCriteria();
729 } 780 }
730 } 781 }
731 782
732 783
784 public void onFilterCriteriaChanged(RangeFilterEvent event) {
785 GWT.log("filtering range");
786 }
733 787
734 788
735 @Override 789 @Override
736 public List<String> validate() { 790 public List<String> validate() {
737 if (isLocationMode()) { 791 if (isLocationMode()) {
1018 if (value == null) { 1072 if (value == null) {
1019 return; 1073 return;
1020 } 1074 }
1021 if (value.equals(FIELD_VALUE_LOCATION)) { 1075 if (value.equals(FIELD_VALUE_LOCATION)) {
1022 enableLocationPanel(); 1076 enableLocationPanel();
1023 filter.clear(); 1077 filterDescription.clear();
1024 // Remove the tab containing the locationDistanceTable. 1078 // Remove the tab containing the locationDistanceTable.
1025 // The 'updateTab()' avoids the tab content to be destroyed. 1079 // The 'updateTab()' avoids the tab content to be destroyed.
1026 inputTables.updateTab(0, null); 1080 inputTables.updateTab(0, null);
1027 inputTables.removeTab(0); 1081 inputTables.removeTab(0);
1028 1082
1034 // Bring this tab to front. 1088 // Bring this tab to front.
1035 inputTables.selectTab(0); 1089 inputTables.selectTab(0);
1036 } 1090 }
1037 else { 1091 else {
1038 enableDistancePanel(); 1092 enableDistancePanel();
1039 filter.clear(); 1093 filterDescription.clear();
1040 // Remove the tab containing the locationTable. 1094 // Remove the tab containing the locationTable.
1041 // The 'updateTab()' avoids the tab content to be destroyed. 1095 // The 'updateTab()' avoids the tab content to be destroyed.
1042 inputTables.updateTab(0, null); 1096 inputTables.updateTab(0, null);
1043 inputTables.removeTab(0); 1097 inputTables.removeTab(0);
1044 1098

http://dive4elements.wald.intevation.org