annotate gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java @ 663:9a019c125b60

Improved error handling when changing chart/histogram options. gnv/trunk@755 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 09 Mar 2010 15:18:11 +0000
parents a634d5ee961d
children 15ac78a91d1b
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
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
3 import java.text.NumberFormat;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
4 import java.text.ParseException;
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
5 import java.util.Collection;
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
6 import java.util.Iterator;
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
7 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
8 import java.util.Map;
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
9
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 import javax.servlet.http.HttpServletRequest;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import javax.servlet.http.HttpServletResponse;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import org.apache.struts.action.ActionForm;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import org.apache.struts.action.ActionForward;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import org.apache.struts.action.ActionMapping;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
18 import de.intevation.gnv.action.sessionmodel.DiagrammOptions;
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.action.sessionmodel.SessionModel;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription;
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
22 import de.intevation.gnv.artifactdatabase.objects.OutputMode;
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
23 import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
24 import de.intevation.gnv.propertiesreader.PropertiesReaderFactory;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
25 import de.intevation.gnv.propertiesreader.PropertiesReader;
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
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 * @author Tim Englich <tim.englich@intevation.de>
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
29 *
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 */
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
31 public class ChangeOptionsAction extends DescribeUIAction {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 /**
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 * 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
34 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 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
36
29
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 * Constructor
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 */
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 public ChangeOptionsAction() {
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 super();
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
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 @Override
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 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
46 HttpServletRequest request,
fccf90761825 Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents: 36
diff changeset
47 HttpServletResponse response) throws Exception {
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 log.debug("NextArtifactStepAction.execute");
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
49 try {
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
50 PropertiesReaderFactory fac = PropertiesReaderFactory.getInstance();
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
51 PropertiesReader reader = fac.getPropertiesReader();
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
52 SessionModel sm = SessionModelFactory.getInstance()
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
53 .getSessionModel(request);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
54
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
55 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
56
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
57 String target = request.getParameter("target");
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
58 OutputMode outputMode = sm.getOutputMode(target);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
59 if (outputMode != null) {
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
60
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
61 Collection<OutputParameter> op = outputMode
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
62 .getOutputParameters();
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
63 if (op != null) {
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
64 Iterator<OutputParameter> it = op.iterator();
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
65 DiagrammOptions diagrammOptions = new DiagrammOptions();
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
66 while (it.hasNext()) {
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
67 OutputParameter parameter = it.next();
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
68 String name = parameter.getName();
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
69 String old = parameter.getValue();
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
70 String value = request.getParameter(name);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
71 String type = parameter.getType();
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
72
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
73 if (log.isDebugEnabled()) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
74 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
75 log.debug("Parameter name: " + name);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
76 log.debug("Parameter type: " + type);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
77 log.debug("Parameter value: " + value);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
78 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
79
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
80 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
81 if (value == null){
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
82 value = "false";
890d7a41ab93 Added Support for Boolean-Output-Parameters in Diagramm-Options
Tim Englich <tim.englich@intevation.de>
parents: 157
diff changeset
83 }
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
84 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
85 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
86 }
663
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 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
89 }
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
90 else if (type.equalsIgnoreCase("integer")) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
91 if (validInteger(request.getLocale(), value)) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
92 diagrammOptions.setValue(name, value);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
93 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
94 else {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
95 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
96 diagrammOptions.setValue(name, old);
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
97
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
98 request.setAttribute(
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
99 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
100 "input.not.a.integer"
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
101 );
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 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_VALUE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
105 value
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 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
109 else if (type.equalsIgnoreCase("double")) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
110 if (validDouble(request.getLocale(), value)) {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
111 diagrammOptions.setValue(name, value);
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 else {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
114 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
115 diagrammOptions.setValue(name, old);
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 request.setAttribute(
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
118 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
119 "input.not.a.double"
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
120 );
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
121
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
122 request.setAttribute(
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
123 CommunicationKeys.REQUEST_EXCEPTION_VALUE,
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
124 value
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 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
127 }
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
128 }
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
129 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
130
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
131 // 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
132 // 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
133 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
134 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
135 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
136 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
137 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
138 }
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
139 }
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
140 }
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
141
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
142 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
143 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
144 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
145 }
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
146 else {
573
bd67164cf28b Devided actions and exports. Adjusted output and export actions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 571
diff changeset
147 request.setAttribute(target, true);
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
148 }
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
149
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
150 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
151 } catch (Exception e) {
36
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
152 log.error(e, e);
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
153 request.setAttribute(
ad381cc47217 Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents: 34
diff changeset
154 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
155 .getMessage());
34
25fdec8b4c69 Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents: 30
diff changeset
156 return super.getExceptionForward(mapping);
30
07e9c137a2f1 Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents: 29
diff changeset
157 }
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
158 }
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
159
663
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
160 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
161 try {
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
162 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
163 return false;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
164 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
165
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
166 NumberFormat format = NumberFormat.getIntegerInstance(locale);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
167 format.setParseIntegerOnly(true);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
168 Number number = format.parse(value);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
169
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
170 if (number.longValue() < 0)
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
171 return false;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
172
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
173 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
174 }
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
175 catch (ParseException pe) {
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
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
180
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
181 protected boolean validDouble(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 NumberFormat format = NumberFormat.getInstance(locale);
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
184 Number number = format.parse(value);
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 if (number.doubleValue() < 0)
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
187 return false;
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
188
9a019c125b60 Improved error handling when changing chart/histogram options.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 575
diff changeset
189 return (number instanceof Double) || validInteger(locale, 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 catch (ParseException pe) {
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 }
29
bba8fd97e549 Export and Diagrammoptions integrated into GUI
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 }
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
196 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org