Mercurial > dive4elements > gnv-client
annotate gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java @ 967:c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
gnv/trunk@1129 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 26 May 2010 17:03:29 +0000 |
parents | 21ad44ccdb84 |
children | 33198e55371c |
rev | line source |
---|---|
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.gnv.action; |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
3 import de.intevation.gnv.action.sessionmodel.DiagrammOptions; |
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
4 import de.intevation.gnv.action.sessionmodel.SessionModel; |
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
5 import de.intevation.gnv.action.sessionmodel.SessionModelFactory; |
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
6 |
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
7 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; |
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
8 import de.intevation.gnv.artifactdatabase.objects.OutputMode; |
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
9 import de.intevation.gnv.artifactdatabase.objects.OutputParameter; |
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
10 |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
11 import java.text.NumberFormat; |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
12 import java.text.ParseException; |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
13 |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
14 import java.util.Collection; |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
15 import java.util.Iterator; |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
16 import java.util.Locale; |
407
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
17 import java.util.Map; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
18 |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 import javax.servlet.http.HttpServletRequest; |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 import javax.servlet.http.HttpServletResponse; |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 import org.apache.log4j.Logger; |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
23 |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 import org.apache.struts.action.ActionForm; |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 import org.apache.struts.action.ActionForward; |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
26 import org.apache.struts.action.ActionMapping; |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 /** |
690
254f062e334b
Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
684
diff
changeset
|
29 * This controller is called to change options used in charts and histograms |
254f062e334b
Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
684
diff
changeset
|
30 * (e.g. width, height, etc). |
254f062e334b
Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
684
diff
changeset
|
31 * |
684
57fa8019fbdc
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
683
diff
changeset
|
32 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 */ |
409
df78178e1180
Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
408
diff
changeset
|
34 public class ChangeOptionsAction extends DescribeUIAction { |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 /** |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 * the logger, used to log exceptions and additonaly information |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
37 */ |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
38 private static Logger log = Logger.getLogger(ChangeOptionsAction.class); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
39 |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 /** |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 * Constructor |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 */ |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 public ChangeOptionsAction() { |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 super(); |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
45 } |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
47 @Override |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 public ActionForward execute(ActionMapping mapping, ActionForm form, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
49 HttpServletRequest request, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
50 HttpServletResponse response) throws Exception { |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 log.debug("NextArtifactStepAction.execute"); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
52 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
53 SessionModel sm = SessionModelFactory.getInstance() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
54 .getSessionModel(request); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
55 |
409
df78178e1180
Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
408
diff
changeset
|
56 ArtifactDescription ad = sm.getArtifactDescription(); |
df78178e1180
Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
408
diff
changeset
|
57 |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
58 String target = request.getParameter("target"); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
59 OutputMode outputMode = sm.getOutputMode(target); |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
60 Locale locale = sm.getCurrentLocale(); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
61 |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
62 if (outputMode != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
63 Collection<OutputParameter> op = outputMode |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
64 .getOutputParameters(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
65 if (op != null) { |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
66 Iterator<OutputParameter> it = op.iterator(); |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
67 DiagrammOptions oldOptions = sm.getDiagrammOptions(); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
68 DiagrammOptions diagrammOptions = new DiagrammOptions(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
69 while (it.hasNext()) { |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
70 OutputParameter parameter = it.next(); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
71 String name = parameter.getName(); |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
72 Object old = oldOptions != null |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
73 ? oldOptions.getValue(name) |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
74 : parameter.getValue(); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
75 String value = request.getParameter(name); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
76 String type = parameter.getType(); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
77 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
78 if (log.isDebugEnabled()) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
79 log.debug("Change chart options now..."); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
80 log.debug("Parameter name: " + name); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
81 log.debug("Parameter type: " + type); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
82 log.debug("Parameter value: " + value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
83 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
84 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
85 if (type.equalsIgnoreCase("boolean")){ |
289
890d7a41ab93
Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
86 if (value == null){ |
890d7a41ab93
Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
87 value = "false"; |
890d7a41ab93
Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
88 } |
407
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
89 else { |
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
90 value = "true"; |
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
91 } |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
92 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
93 diagrammOptions.setValue(name,value); |
289
890d7a41ab93
Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
94 } |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
95 else if (type.equalsIgnoreCase("integer")) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
96 if (validInteger(request.getLocale(), value)) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
97 diagrammOptions.setValue(name, value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
98 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
99 else { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
100 log.warn("Text is not a valid integer: "+value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
101 diagrammOptions.setValue(name, old); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
102 |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
103 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
104 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
105 "input.not.a.integer" |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
106 ); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
107 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
108 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
109 CommunicationKeys.REQUEST_EXCEPTION_VALUE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
110 value |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
111 ); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
112 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
113 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
114 else if (type.equalsIgnoreCase("double")) { |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
115 try { |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
116 double val = parseDoubleValue(locale, value); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
117 String valStr = Double.toString(val); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
118 log.debug("Change diagram options [" |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
119 + name +"] to " + val); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
120 diagrammOptions.setValue(name, val); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
121 } |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
122 catch (ParseException pe) { |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
123 log.warn("Text is not a valid double: "+value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
124 diagrammOptions.setValue(name, old); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
125 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
126 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
127 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
128 "input.not.a.double" |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
129 ); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
130 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
131 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
132 CommunicationKeys.REQUEST_EXCEPTION_VALUE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
133 value |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
134 ); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
135 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
136 } |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
137 } |
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
138 sm.setDiagrammOptions(diagrammOptions); |
575
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
139 |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
140 // XXX Little workarround. We should implement a 'choice' type, |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
141 // if we need further choice elements! (iw) |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
142 String bintype = request.getParameter("bintype"); |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
143 if (bintype != null) { |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
144 diagrammOptions.setValue("bintype", bintype); |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
145 sm.setDiagrammOptions(diagrammOptions); |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
146 request.setAttribute("bintype", bintype); |
a634d5ee961d
Added checkboxes for selecting the field which is used to adjust the number of bins in histogram charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
573
diff
changeset
|
147 } |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
148 } |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
149 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
150 |
407
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
151 Map tmpOuts = ad.getOutputModes(); |
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
152 if (tmpOuts == null || tmpOuts.isEmpty()) { |
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
153 request.setAttribute("furthertargets", true); |
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
154 } |
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
155 else { |
573
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
571
diff
changeset
|
156 request.setAttribute(target, true); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
157 } |
407
55dae5bb76db
Fixed issue149. Render the chart if there are output modes existing for this state - not if there are further states. TODO: We should check if there is an output mode named 'chart' before rendering a chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
158 |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
159 return super.execute(mapping, form, request, response); |
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
160 } catch (Exception e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
161 log.error(e, e); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
162 request.setAttribute( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
163 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
164 .getMessage()); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
165 return super.getExceptionForward(mapping); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
166 } |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
167 } |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
168 |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
169 protected boolean validInteger(Locale locale, String value) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
170 try { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
171 if (value.split("\\.").length > 1 || value.split("\\,").length > 1){ |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
172 return false; |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
173 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
174 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
175 NumberFormat format = NumberFormat.getIntegerInstance(locale); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
176 format.setParseIntegerOnly(true); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
177 Number number = format.parse(value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
178 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
179 if (number.longValue() < 0) |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
180 return false; |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
181 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
182 return (number instanceof Integer) || (number instanceof Long); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
183 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
184 catch (ParseException pe) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
185 return false; |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
186 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
187 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
188 |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
189 protected double parseDoubleValue(Locale locale, String value) |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
190 throws ParseException |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
191 { |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
192 log.error("LOCALE FOR DOUBLE PARSING: " + locale.toString()); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
193 NumberFormat format = NumberFormat.getNumberInstance(locale); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
194 Number number = format.parse(value); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
195 |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
196 return number.doubleValue(); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
197 } |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
198 } |
409
df78178e1180
Moved user interface creation to an own action. This makes avoids code duplication and makes it easier to write new action to handle special interactions, because there is no need for parsing the describe document and creating the user interface after this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
408
diff
changeset
|
199 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |