Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/AutoIntegerPanel.java @ 3847:f3b821735e39
Calculate the info url via i18n
Don't fetch the info url from the artifact service and use i18n to calculate the
url by using the official gauge and river number.
flys-client/trunk@5582 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 24 Sep 2012 08:39:22 +0000 |
parents | d900ab031dfe |
children | 360e22afb98b |
rev | line source |
---|---|
787
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import com.google.gwt.core.client.GWT; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import com.smartgwt.client.widgets.Canvas; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import com.smartgwt.client.widgets.Label; |
791
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
7 import com.smartgwt.client.widgets.form.validator.Validator; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
8 import com.smartgwt.client.widgets.form.validator.CustomValidator; |
787
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import com.smartgwt.client.widgets.layout.VLayout; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.client.shared.model.Data; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.client.shared.model.DataList; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.flys.client.client.FLYSConstants; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 /** |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 */ |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 public class AutoIntegerPanel extends TextProvider { |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
791
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
22 public static final String FIELD_NAME = "integer_field"; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
23 |
874
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
24 public static final String FIELD_DEFAULT_VALUE = "auto"; |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
25 |
791
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
26 |
787
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 protected String dataName; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 @Override |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public Canvas create(DataList dataList) { |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 Data data = dataList.get(0); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 this.dataName = data.getLabel(); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 Canvas label = new Label(data.getDescription()); |
791
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
38 Canvas form = createForm(getTitle()); |
787
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 Canvas submit = getNextButton(); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 VLayout layout = new VLayout(); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 layout.setHeight(35); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 label.setHeight(35); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 layout.addMember(label); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 layout.addMember(form); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 layout.addMember(submit); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 layout.setMembersMargin(10); |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
794
40269a176cd2
Set default values in the BooleanPanel, TextProvider and AutoIntegerPanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
791
diff
changeset
|
50 initDefaultValues(dataList); |
40269a176cd2
Set default values in the BooleanPanel, TextProvider and AutoIntegerPanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
791
diff
changeset
|
51 |
787
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 return layout; |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 } |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
874
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
56 @Override |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
57 protected void initDefaultValues(DataList dataList) { |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
58 super.initDefaultValues(dataList); |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
59 |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
60 String def = getValueAsString(); |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
61 |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
62 if (def == null || def.length() == 0) { |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
63 form.setValue(getFieldName(), FIELD_DEFAULT_VALUE); |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
64 } |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
65 } |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
66 |
d900ab031dfe
Set the default value of the AutoInteger panel to 'auto' if no other value is set.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
794
diff
changeset
|
67 |
791
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
68 protected String getTitle() { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
69 return MSG.uesk_profile_distance(); |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
70 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
71 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
72 |
787
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 @Override |
791
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
74 protected String getDataName() { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
75 return dataName; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
76 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
77 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
78 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
79 @Override |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
80 protected String getValueAsString() { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
81 String v = (String) form.getValue(getFieldName()); |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
82 return v.toLowerCase(); |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
83 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
84 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
85 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
86 @Override |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
87 protected Validator getValidator() { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
88 Validator v = new AutoIntegerValidator(); |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
89 v.setValidateOnChange(false); |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
90 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
91 return v; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
92 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
93 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
94 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
95 public class AutoIntegerValidator extends CustomValidator { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
96 @Override |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
97 protected boolean condition(Object value) { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
98 String v = (String) value; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
99 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
100 if (v == null || v.length() == 0) { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
101 return false; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
102 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
103 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
104 if (v.trim().equalsIgnoreCase("auto")) { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
105 return true; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
106 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
107 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
108 try { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
109 Integer anInt = Integer.parseInt(v); |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
110 |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
111 return true; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
112 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
113 catch (NumberFormatException nfe) { |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
114 return false; |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
115 } |
9b1499a65aaa
Finished the panel that allows integers and the string 'auto'.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
790
diff
changeset
|
116 } |
787
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 } |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 } |
4e0b73b7113b
Added new UI providers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |