annotate gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java @ 1022:28a0628b11b0

Added license file and license header. gnv/trunk@1258 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:15:08 +0000
parents 33198e55371c
children
rev   line source
1022
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
1 /*
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
3 *
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
5 * Read the file LGPL.txt coming with the software for details
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
7 */
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
8
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.action;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
683
d49e8695786c Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 681
diff changeset
11 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
12 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
13 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
14
d49e8695786c Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 681
diff changeset
15 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
16 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
17 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
18
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
19 import java.text.NumberFormat;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
20 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
21
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
22 import java.util.Collection;
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
23 import java.util.Iterator;
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
24 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
25 import java.util.Map;
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
26
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 import javax.servlet.http.HttpServletRequest;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 import javax.servlet.http.HttpServletResponse;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 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
31
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 import org.apache.struts.action.ActionForm;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 import org.apache.struts.action.ActionForward;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 import org.apache.struts.action.ActionMapping;
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 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
37 * 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
38 * (e.g. width, height, etc).
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
39 *
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
40 * @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
41 */
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
42 public class ChangeOptionsAction extends DescribeUIAction {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 * 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
45 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 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
47
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 * Constructor
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 public ChangeOptionsAction() {
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 super();
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 @Override
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 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
57 HttpServletRequest request,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
58 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
59 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
60 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
61 }
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
62
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 log.debug("NextArtifactStepAction.execute");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
64 try {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
65 SessionModel sm = SessionModelFactory.getInstance()
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
66 .getSessionModel(request);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
67
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
68 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
69
967
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
70 String target = request.getParameter("target");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
71 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
72 Locale locale = sm.getCurrentLocale();
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
73
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
74 if (outputMode != null) {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
75 Collection<OutputParameter> op = outputMode
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
76 .getOutputParameters();
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
77 if (op != null) {
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
78 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
79 DiagrammOptions oldOptions = sm.getDiagrammOptions();
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
80 DiagrammOptions diagrammOptions = new DiagrammOptions();
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
81 while (it.hasNext()) {
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
82 OutputParameter parameter = it.next();
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
83 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
84 Object old = oldOptions != null
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
85 ? oldOptions.getValue(name)
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
86 : parameter.getValue();
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
87 String value = request.getParameter(name);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
88 String type = parameter.getType();
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
89
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
90 if (log.isDebugEnabled()) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
91 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
92 log.debug("Parameter name: " + name);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
93 log.debug("Parameter type: " + type);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
94 log.debug("Parameter value: " + value);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
95 }
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 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
98 if (value == null){
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
99 value = "false";
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
100 }
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
101 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
102 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
103 }
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
104
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
105 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
106 }
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
107 else if (type.equalsIgnoreCase("integer")) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
108 if (validInteger(request.getLocale(), value)) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
109 diagrammOptions.setValue(name, value);
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 else {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
112 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
113 diagrammOptions.setValue(name, old);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
114
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
115 request.setAttribute(
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
116 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
117 "input.not.a.integer"
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
118 );
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
119
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
120 request.setAttribute(
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
121 CommunicationKeys.REQUEST_EXCEPTION_VALUE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
122 value
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
123 );
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
124 }
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 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
127 try {
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
128 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
129 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
130 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
131 + name +"] to " + val);
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
132 diagrammOptions.setValue(name, val);
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
133 }
967
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
134 catch (ParseException pe) {
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
135 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
136 diagrammOptions.setValue(name, old);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
137
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
138 request.setAttribute(
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
139 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
140 "input.not.a.double"
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
141 );
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
142
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
143 request.setAttribute(
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
144 CommunicationKeys.REQUEST_EXCEPTION_VALUE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
145 value
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
146 );
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
147 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
148 }
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
149 }
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
150 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
151
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
152 // 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
153 // 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
154 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
155 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
156 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
157 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
158 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
159 }
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
160 }
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
161 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
162
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
163 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
164 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
165 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
166 }
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
167 else {
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 571
diff changeset
168 request.setAttribute(target, true);
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
169 }
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
170
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
171 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
172 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
173 log.error(e, e);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
174 request.setAttribute(
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
175 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
176 .getMessage());
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
177 return super.getExceptionForward(mapping);
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
178 }
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
179 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
180
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
181 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
182 try {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
183 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
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
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
187 NumberFormat format = NumberFormat.getIntegerInstance(locale);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
188 format.setParseIntegerOnly(true);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
189 Number number = format.parse(value);
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 if (number.longValue() < 0)
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
192 return false;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
193
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
194 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
195 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
196 catch (ParseException pe) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
197 return false;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
198 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
199 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
200
967
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
201 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
202 throws ParseException
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
203 {
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
204 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
205 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
206 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
207
967
c7f8a9b4b006 Improved parsing i18n values of chart/histogram options (issue289).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 703
diff changeset
208 return number.doubleValue();
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
209 }
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210 }
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
211 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org