Mercurial > dive4elements > gnv-client
annotate gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java @ 991:33198e55371c
Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
gnv/trunk@1192 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Jun 2010 15:13:08 +0000 |
parents | c7f8a9b4b006 |
children | 28a0628b11b0 |
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 { |
991
33198e55371c
Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
967
diff
changeset
|
51 if (isSessionExhausted(request)) { |
33198e55371c
Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
967
diff
changeset
|
52 return sessionExhaustedForward(mapping, form, request, response); |
33198e55371c
Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
967
diff
changeset
|
53 } |
33198e55371c
Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
967
diff
changeset
|
54 |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 log.debug("NextArtifactStepAction.execute"); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
56 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
57 SessionModel sm = SessionModelFactory.getInstance() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
58 .getSessionModel(request); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
59 |
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
|
60 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
|
61 |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
62 String target = request.getParameter("target"); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
63 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
|
64 Locale locale = sm.getCurrentLocale(); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
65 |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
66 if (outputMode != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
67 Collection<OutputParameter> op = outputMode |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
68 .getOutputParameters(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
69 if (op != null) { |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
70 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
|
71 DiagrammOptions oldOptions = sm.getDiagrammOptions(); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
72 DiagrammOptions diagrammOptions = new DiagrammOptions(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
73 while (it.hasNext()) { |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
74 OutputParameter parameter = it.next(); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
75 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
|
76 Object old = oldOptions != null |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
77 ? oldOptions.getValue(name) |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
78 : parameter.getValue(); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
79 String value = request.getParameter(name); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
80 String type = parameter.getType(); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
81 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
82 if (log.isDebugEnabled()) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
83 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
|
84 log.debug("Parameter name: " + name); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
85 log.debug("Parameter type: " + type); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
86 log.debug("Parameter value: " + value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
87 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
88 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
89 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
|
90 if (value == null){ |
890d7a41ab93
Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
91 value = "false"; |
890d7a41ab93
Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
92 } |
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
|
93 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
|
94 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
|
95 } |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
96 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
97 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
|
98 } |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
99 else if (type.equalsIgnoreCase("integer")) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
100 if (validInteger(request.getLocale(), value)) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
101 diagrammOptions.setValue(name, value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
102 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
103 else { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
104 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
|
105 diagrammOptions.setValue(name, old); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
106 |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
107 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
108 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
109 "input.not.a.integer" |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
110 ); |
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 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
113 CommunicationKeys.REQUEST_EXCEPTION_VALUE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
114 value |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
115 ); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
116 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
117 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
118 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
|
119 try { |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 + name +"] to " + val); |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
124 diagrammOptions.setValue(name, val); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
125 } |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
126 catch (ParseException pe) { |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
127 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
|
128 diagrammOptions.setValue(name, old); |
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 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
131 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
132 "input.not.a.double" |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
133 ); |
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 request.setAttribute( |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
136 CommunicationKeys.REQUEST_EXCEPTION_VALUE, |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
137 value |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
138 ); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
139 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
140 } |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
141 } |
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
142 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
|
143 |
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 // 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
|
145 // 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 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
|
151 } |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
152 } |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
153 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
154 |
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
|
155 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
|
156 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
|
157 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
|
158 } |
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
|
159 else { |
573
bd67164cf28b
Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
571
diff
changeset
|
160 request.setAttribute(target, true); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
161 } |
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
|
162 |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
163 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
|
164 } catch (Exception e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
165 log.error(e, e); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
166 request.setAttribute( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
34
diff
changeset
|
167 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
|
168 .getMessage()); |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
169 return super.getExceptionForward(mapping); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
29
diff
changeset
|
170 } |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
171 } |
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
172 |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
173 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
|
174 try { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
175 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
|
176 return false; |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
177 } |
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 NumberFormat format = NumberFormat.getIntegerInstance(locale); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
180 format.setParseIntegerOnly(true); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
181 Number number = format.parse(value); |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
182 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
183 if (number.longValue() < 0) |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
184 return false; |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
185 |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
186 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
|
187 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
188 catch (ParseException pe) { |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
189 return false; |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
190 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
191 } |
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
192 |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
193 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
|
194 throws ParseException |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
195 { |
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 |
967
c7f8a9b4b006
Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
703
diff
changeset
|
200 return number.doubleValue(); |
663
9a019c125b60
Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
575
diff
changeset
|
201 } |
29
bba8fd97e549
Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
202 } |
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
|
203 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |