comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java @ 9114:31b3cae5de0d

sortable table veg'zones
author gernotbelger
date Mon, 04 Jun 2018 11:25:29 +0200
parents f5b55b383ef9
children 431f1c269be5
comparison
equal deleted inserted replaced
9113:bfc0da2aa3aa 9114:31b3cae5de0d
28 import com.smartgwt.client.widgets.Label; 28 import com.smartgwt.client.widgets.Label;
29 import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator; 29 import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
30 import com.smartgwt.client.widgets.grid.ListGrid; 30 import com.smartgwt.client.widgets.grid.ListGrid;
31 import com.smartgwt.client.widgets.grid.ListGridField; 31 import com.smartgwt.client.widgets.grid.ListGridField;
32 import com.smartgwt.client.widgets.grid.ListGridRecord; 32 import com.smartgwt.client.widgets.grid.ListGridRecord;
33 import com.smartgwt.client.widgets.grid.SortNormalizer;
33 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; 34 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
34 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; 35 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
35 import com.smartgwt.client.widgets.layout.HLayout; 36 import com.smartgwt.client.widgets.layout.HLayout;
36 import com.smartgwt.client.widgets.layout.Layout; 37 import com.smartgwt.client.widgets.layout.Layout;
37 import com.smartgwt.client.widgets.layout.VLayout; 38 import com.smartgwt.client.widgets.layout.VLayout;
61 62
62 this.elements.setWidth(width); // 185 63 this.elements.setWidth(width); // 185
63 this.elements.setHeight(300); // 64 this.elements.setHeight(300); //
64 this.elements.setShowHeaderContextMenu(false); 65 this.elements.setShowHeaderContextMenu(false);
65 this.elements.setCanReorderFields(false); 66 this.elements.setCanReorderFields(false);
66 this.elements.setCanSort(false); 67 // this.elements.setCanSort(true);
68
67 this.elements.setCanEdit(editable); 69 this.elements.setCanEdit(editable);
68 70
69 final ListGridField vegzoneField = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label()); 71 final ListGridField vegzoneField = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label());
70 vegzoneField.setType(ListGridFieldType.TEXT); 72 vegzoneField.setType(ListGridFieldType.TEXT);
71 vegzoneField.setWidth(245); 73 vegzoneField.setWidth(245);
72 74 final SortNormalizer normalizer = new SortNormalizer() {
73 final ListGridField fromField = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from()); 75
74 fromField.setType(ListGridFieldType.INTEGER); 76 @Override
77 public Object normalize(final ListGridRecord record, final String fieldName) {
78 final String number = record.getAttribute(fieldName);
79 // String.format("%03d", number);// format.format(Integer.valueOf(number)); funktioniert hier leider nicht
80 final String numberFormat = "000" + number;
81 return numberFormat.substring(numberFormat.length() - 3);
82 }
83 };
75 final IntegerRangeValidator validator = new IntegerRangeValidator(); 84 final IntegerRangeValidator validator = new IntegerRangeValidator();
76 validator.setMin(0); 85 validator.setMin(0);
77 validator.setMax(365); 86 validator.setMax(365);
78 validator.setErrorMessage(this.MSG.uinfo_vegetation_zones_validation_range()); 87 validator.setErrorMessage(this.MSG.uinfo_vegetation_zones_validation_range());
79 88
89 final ListGridField fromField = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from());
90 fromField.setType(ListGridFieldType.INTEGER);
91 fromField.setCanSort(true);
92 fromField.setSortNormalizer(normalizer);
80 fromField.setValidators(validator); 93 fromField.setValidators(validator);
81 fromField.setWidth(80); 94 fromField.setWidth(80);
82 fromField.setAlign(Alignment.RIGHT); 95 fromField.setAlign(Alignment.RIGHT);
83 96
84 final ListGridField toField = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to()); 97 final ListGridField toField = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to());
85 toField.setType(ListGridFieldType.INTEGER); 98 toField.setType(ListGridFieldType.INTEGER);
86 toField.setValidators(validator); 99 toField.setValidators(validator);
87 toField.setWidth(80); 100 toField.setWidth(80);
88 toField.setAlign(Alignment.RIGHT); 101 toField.setAlign(Alignment.RIGHT);
89 102 toField.setSortNormalizer(normalizer);
90 if (editable) { 103
104 if (editable)
105
106 {
91 final ListGridField removeField = createRemoveField(); 107 final ListGridField removeField = createRemoveField();
92 this.elements.setFields(vegzoneField, fromField, toField, removeField); 108 this.elements.setFields(vegzoneField, fromField, toField, removeField);
93 109
94 } else { 110 } else {
95 this.elements.setFields(vegzoneField, fromField, toField); 111 this.elements.setFields(vegzoneField, fromField, toField);

http://dive4elements.wald.intevation.org