Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java @ 9580:839b2aa84dd0
minuend/subtrahend-UI-switch
author | gernotbelger |
---|---|
date | Tue, 08 Jan 2019 17:01:09 +0100 |
parents | d89976700474 |
children |
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 | |
9346 | 12 import com.google.gwt.user.client.ui.Label; |
9237 | 13 import com.smartgwt.client.types.Alignment; |
14 import com.smartgwt.client.types.ListGridFieldType; | |
9107 | 15 import com.smartgwt.client.widgets.form.fields.IntegerItem; |
9066 | 16 import com.smartgwt.client.widgets.form.fields.TextItem; |
9237 | 17 import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator; |
9079 | 18 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; |
9066 | 19 import com.smartgwt.client.widgets.form.validator.Validator; |
9237 | 20 import com.smartgwt.client.widgets.grid.ListGrid; |
21 import com.smartgwt.client.widgets.grid.ListGridField; | |
22 import com.smartgwt.client.widgets.grid.SortNormalizer; | |
23 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; | |
24 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; | |
9066 | 25 import com.smartgwt.client.widgets.layout.VLayout; |
26 | |
27 /** | |
28 * @author Domenico Nardi Tironi | |
29 * | |
30 */ | |
31 public class PanelHelper { | |
32 | |
33 public PanelHelper() { | |
34 | |
35 } | |
36 | |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9107
diff
changeset
|
37 public static final TextItem createItem(final String identifier, final String title, final String width, final Validator... validator) { |
9066 | 38 final TextItem item = new TextItem(identifier, title); |
39 item.setWidth(width); | |
40 item.setWrapTitle(false); | |
41 item.setValidators(validator); | |
42 return item; | |
43 } | |
44 | |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9107
diff
changeset
|
45 public static final IntegerItem createIntegerItem(final String identifier, final String title, final String width, final Validator... validator) { |
9107 | 46 final IntegerItem item = new IntegerItem(identifier, title); |
47 item.setWidth(width); | |
48 item.setWrapTitle(false); | |
49 item.setValidators(validator); | |
50 return item; | |
51 } | |
52 | |
9066 | 53 public static VLayout getSpacer(final int height) { |
54 final VLayout spacer = new VLayout(); | |
55 spacer.setHeight(height); | |
56 return spacer; | |
57 } | |
9079 | 58 |
59 public static TextItem createItem(final String title) { | |
60 final TextItem inputItem = new TextItem(title); | |
61 | |
62 final boolean hideTitle = title == null || title.isEmpty(); | |
63 inputItem.setShowTitle(!hideTitle); | |
64 // final CustomValidator validator = new CustomValidator() { | |
65 // @Override | |
66 // protected boolean condition(final Object value) { | |
67 // return validate().size() > 0 ? false : true; | |
68 // } | |
69 // }; | |
70 inputItem.setValidators(new IsIntegerValidator()); // Validator hat keinen sichtbaren Effekt. | |
71 inputItem.setWidth(60); | |
72 return inputItem; | |
73 | |
74 } | |
9237 | 75 |
76 public static final ListGridField createRemoveField(final ListGrid table, final String icon) { | |
77 final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") { | |
78 { | |
79 setType(ListGridFieldType.ICON); | |
80 setIcon(icon); | |
81 setCanEdit(false); | |
82 setCanFilter(false); | |
83 setCanSort(false); | |
84 setCanGroupBy(false); | |
85 setCanFreeze(false); | |
86 setWidth(25); | |
87 setCanDragResize(false); | |
88 super.setCanToggle(false); | |
89 } | |
90 }; | |
91 table.addRecordClickHandler(new RecordClickHandler() { | |
92 @Override | |
93 public void onRecordClick(final RecordClickEvent event) { | |
94 // Just handle remove-clicks | |
95 if (!event.getField().getName().equals(removeField.getName())) { | |
96 return; | |
97 } | |
98 event.getViewer().removeData(event.getRecord()); | |
99 } | |
100 }); | |
101 | |
102 return removeField; | |
103 } | |
104 | |
105 public static final ListGridField createIntTableField(final String key, final String msg, final boolean canSort, final SortNormalizer normalizer, | |
106 final IntegerRangeValidator validators) { | |
107 final ListGridField intField = new ListGridField(key, msg); | |
108 intField.setType(ListGridFieldType.INTEGER); | |
109 intField.setValidators(validators); | |
110 intField.setWidth(90); | |
111 intField.setAlign(Alignment.RIGHT); | |
112 intField.setSortNormalizer(normalizer); | |
113 intField.setCanSort(canSort); | |
114 intField.setCanDragResize(false); | |
115 | |
116 return intField; | |
117 } | |
118 | |
9346 | 119 public static final Label getValidationLabel() { |
120 final Label label = new Label(); | |
121 label.setHeight("15px"); | |
122 label.getElement().getStyle().setColor("red"); | |
123 return label; | |
124 } | |
125 | |
9066 | 126 } |