Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DoubleArrayPanel.java @ 9404:bc9a45d2b1fa
common time range for gauges incl. error messages
author | gernotbelger |
---|---|
date | Wed, 15 Aug 2018 13:59:09 +0200 |
parents | 3141f0e7314e |
children | c86ae5562e68 |
comparison
equal
deleted
inserted
replaced
9403:e2da9c8a7c57 | 9404:bc9a45d2b1fa |
---|---|
25 public class DoubleArrayPanel extends DynamicForm { | 25 public class DoubleArrayPanel extends DynamicForm { |
26 /** The message class that provides i18n strings. */ | 26 /** The message class that provides i18n strings. */ |
27 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); | 27 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); |
28 | 28 |
29 protected TextItem ti; | 29 protected TextItem ti; |
30 | |
31 private final StaticTextItem errorItem = new StaticTextItem("error"); | |
30 | 32 |
31 private String title; | 33 private String title; |
32 | 34 |
33 /** The constant input field name. */ | 35 /** The constant input field name. */ |
34 public static final String FIELD_NAME = "doublearray"; | 36 public static final String FIELD_NAME = "doublearray"; |
50 * @param blurHandler | 52 * @param blurHandler |
51 * The BlurHandler that is used to valide the input. | 53 * The BlurHandler that is used to valide the input. |
52 * @param focusHandler | 54 * @param focusHandler |
53 * The FocueHandler that is used to valide the input. | 55 * The FocueHandler that is used to valide the input. |
54 */ | 56 */ |
57 | |
55 public DoubleArrayPanel(final String title, final double[] values, final BlurHandler blurHandler, final FocusHandler focusHandler, | 58 public DoubleArrayPanel(final String title, final double[] values, final BlurHandler blurHandler, final FocusHandler focusHandler, |
56 final TitleOrientation titleOrientation) { | 59 final TitleOrientation titleOrientation, final String errorMsg) { |
60 | |
57 this.title = title; | 61 this.title = title; |
58 this.ti = new TextItem(FIELD_NAME); | 62 this.ti = new TextItem(FIELD_NAME); |
59 final StaticTextItem sti = new StaticTextItem("staticarray"); | 63 final StaticTextItem sti = new StaticTextItem("staticarray"); |
60 | 64 sti.setColSpan(2); |
61 this.ti.setShowTitle(false); | 65 |
66 this.errorItem.setTitle(""); | |
67 if (errorMsg != null) | |
68 this.errorItem.setValue(errorMsg); | |
69 | |
70 this.errorItem.setShowTitle(false); | |
71 this.errorItem.setVisible(true); | |
72 this.errorItem.setColSpan(2); | |
62 sti.setShowTitle(false); | 73 sti.setShowTitle(false); |
63 sti.setValue(title); | 74 sti.setValue(title); |
64 | 75 sti.setColSpan(1); |
76 | |
77 this.ti.setShowTitle(false); | |
78 this.ti.setColSpan(1); | |
65 this.ti.addBlurHandler(blurHandler); | 79 this.ti.addBlurHandler(blurHandler); |
66 if (focusHandler != null) { | 80 if (focusHandler != null) { |
67 this.ti.addFocusHandler(focusHandler); | 81 this.ti.addFocusHandler(focusHandler); |
68 } | 82 } |
69 | 83 |
70 if (titleOrientation == TitleOrientation.RIGHT) { | 84 if (titleOrientation == TitleOrientation.RIGHT) { |
71 setFields(this.ti, sti); | 85 setFields(this.ti, sti, this.errorItem); |
72 } else { | 86 } else { |
73 setFields(sti, this.ti); | 87 setFields(sti, this.ti, this.errorItem); |
74 } | 88 } |
75 | 89 |
76 setTitleOrientation(titleOrientation); | 90 setTitleOrientation(titleOrientation); |
77 setNumCols(2); | 91 setNumCols(5); |
78 | 92 |
79 if (values == null) { | 93 if (values == null) { |
80 return; | 94 return; |
81 } | 95 } |
82 | 96 |
94 | 108 |
95 firstItem = false; | 109 firstItem = false; |
96 } | 110 } |
97 | 111 |
98 this.ti.setValue(text.toString()); | 112 this.ti.setValue(text.toString()); |
113 | |
114 } | |
115 | |
116 public DoubleArrayPanel(final String title, final double[] values, final BlurHandler blurHandler, final FocusHandler focusHandler, | |
117 final TitleOrientation titleOrientation) { | |
118 this(title, values, blurHandler, focusHandler, titleOrientation, null); | |
99 } | 119 } |
100 | 120 |
101 /** | 121 /** |
102 * This method takes the double array to set the values to the textbox. | 122 * This method takes the double array to set the values to the textbox. |
103 * | 123 * |
145 } else { | 165 } else { |
146 current += " " + f.format(value); | 166 current += " " + f.format(value); |
147 } | 167 } |
148 | 168 |
149 this.ti.setValue(current); | 169 this.ti.setValue(current); |
170 } | |
171 | |
172 public void setError(final String error) { | |
173 this.errorItem.setValue(error); | |
150 } | 174 } |
151 | 175 |
152 public boolean validateForm() { | 176 public boolean validateForm() { |
153 return validateForm(this.ti); | 177 return validateForm(this.ti); |
154 } | 178 } |