Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java @ 9263:abf14917be32
Moved stepping behaviour of NaviOutputChart into an exchangeable strategy.
Allows for distinct values stepping of sinfo flood duration.
author | gernotbelger |
---|---|
date | Tue, 17 Jul 2018 19:48:18 +0200 |
parents | 972e10522ed6 |
children | d89976700474 |
rev | line source |
---|---|
9066 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.client.client.ui; | |
11 | |
9237 | 12 import com.smartgwt.client.types.Alignment; |
13 import com.smartgwt.client.types.ListGridFieldType; | |
9107 | 14 import com.smartgwt.client.widgets.form.fields.IntegerItem; |
9066 | 15 import com.smartgwt.client.widgets.form.fields.TextItem; |
9237 | 16 import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator; |
9079 | 17 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; |
9066 | 18 import com.smartgwt.client.widgets.form.validator.Validator; |
9237 | 19 import com.smartgwt.client.widgets.grid.ListGrid; |
20 import com.smartgwt.client.widgets.grid.ListGridField; | |
21 import com.smartgwt.client.widgets.grid.SortNormalizer; | |
22 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; | |
23 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; | |
9066 | 24 import com.smartgwt.client.widgets.layout.VLayout; |
25 | |
26 /** | |
27 * @author Domenico Nardi Tironi | |
28 * | |
29 */ | |
30 public class PanelHelper { | |
31 | |
32 public PanelHelper() { | |
33 | |
34 } | |
35 | |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9107
diff
changeset
|
36 public static final TextItem createItem(final String identifier, final String title, final String width, final Validator... validator) { |
9066 | 37 final TextItem item = new TextItem(identifier, title); |
38 item.setWidth(width); | |
39 item.setWrapTitle(false); | |
40 item.setValidators(validator); | |
41 return item; | |
42 } | |
43 | |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9107
diff
changeset
|
44 public static final IntegerItem createIntegerItem(final String identifier, final String title, final String width, final Validator... validator) { |
9107 | 45 final IntegerItem item = new IntegerItem(identifier, title); |
46 item.setWidth(width); | |
47 item.setWrapTitle(false); | |
48 item.setValidators(validator); | |
49 return item; | |
50 } | |
51 | |
9066 | 52 public static VLayout getSpacer(final int height) { |
53 final VLayout spacer = new VLayout(); | |
54 spacer.setHeight(height); | |
55 return spacer; | |
56 } | |
9079 | 57 |
58 public static TextItem createItem(final String title) { | |
59 final TextItem inputItem = new TextItem(title); | |
60 | |
61 final boolean hideTitle = title == null || title.isEmpty(); | |
62 inputItem.setShowTitle(!hideTitle); | |
63 // final CustomValidator validator = new CustomValidator() { | |
64 // @Override | |
65 // protected boolean condition(final Object value) { | |
66 // return validate().size() > 0 ? false : true; | |
67 // } | |
68 // }; | |
69 inputItem.setValidators(new IsIntegerValidator()); // Validator hat keinen sichtbaren Effekt. | |
70 inputItem.setWidth(60); | |
71 return inputItem; | |
72 | |
73 } | |
9237 | 74 |
75 public static final ListGridField createRemoveField(final ListGrid table, final String icon) { | |
76 final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") { | |
77 { | |
78 setType(ListGridFieldType.ICON); | |
79 setIcon(icon); | |
80 setCanEdit(false); | |
81 setCanFilter(false); | |
82 setCanSort(false); | |
83 setCanGroupBy(false); | |
84 setCanFreeze(false); | |
85 setWidth(25); | |
86 setCanDragResize(false); | |
87 super.setCanToggle(false); | |
88 } | |
89 }; | |
90 table.addRecordClickHandler(new RecordClickHandler() { | |
91 @Override | |
92 public void onRecordClick(final RecordClickEvent event) { | |
93 // Just handle remove-clicks | |
94 if (!event.getField().getName().equals(removeField.getName())) { | |
95 return; | |
96 } | |
97 event.getViewer().removeData(event.getRecord()); | |
98 } | |
99 }); | |
100 | |
101 return removeField; | |
102 } | |
103 | |
104 public static final ListGridField createIntTableField(final String key, final String msg, final boolean canSort, final SortNormalizer normalizer, | |
105 final IntegerRangeValidator validators) { | |
106 final ListGridField intField = new ListGridField(key, msg); | |
107 intField.setType(ListGridFieldType.INTEGER); | |
108 intField.setValidators(validators); | |
109 intField.setWidth(90); | |
110 intField.setAlign(Alignment.RIGHT); | |
111 intField.setSortNormalizer(normalizer); | |
112 intField.setCanSort(canSort); | |
113 intField.setCanDragResize(false); | |
114 | |
115 return intField; | |
116 } | |
117 | |
9066 | 118 } |