changeset 571:f2ba58011a2d

Added histogram option panel. Show chart/histogram options panel after the user selected chart or histogram. Moved options panel beneath action panel. gnv/trunk@699 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 10:36:02 +0000
parents cbd397712ecf
children 3f7bbc6dc751
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java gnv/src/main/java/de/intevation/gnv/action/CreateChartAction.java gnv/src/main/resources/applicationMessages.properties gnv/src/main/resources/applicationMessages_en.properties gnv/src/main/webapp/WEB-INF/config/struts-config.xml gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/index.jsp gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp gnv/src/main/webapp/images/chart_curve.png
diffstat 13 files changed, 158 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/ChangeLog	Tue Feb 23 10:36:02 2010 +0000
@@ -1,3 +1,34 @@
+2010-02-23  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/action/CreateChartAction.java: Class to
+	  trigger chart rendering.
+
+	* src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java: Changed
+	  request parameter from 'diagram' (deprecated) to 'chart'.
+
+	* src/main/resources/applicationMessages.properties,
+	  src/main/resources/applicationMessages_en.properties: Added title and
+	  labels for histogram options.
+
+	* src/main/webapp/images/chart_curve.png: Chart icon (source: famfamfam)
+
+	* src/main/webapp/WEB-INF/config/struts-config.xml: Added new action to
+	  trigger chart rendering analog to histogram action.
+
+	* src/main/webapp/WEB-INF/jsp/index.jsp: Render chart option panel only if
+	  the user already selected charts.
+
+	* src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp,
+	  src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp,
+	  src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp: Show
+	  diagram/chart options panel only if the user chose one of them. Placed
+	  these option panels beneath the action panel.
+	  
+	* src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp: Added new
+	  icon for chart rendering.
+
+	* src/main/webapp/WEB-INF/jsp/mainlayout.jsp: Removed js debug output.
+
 2010-02-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/webapp/WEB-INF/config/struts-config.xml: New action 'WMSAction'.
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Tue Feb 23 10:36:02 2010 +0000
@@ -79,7 +79,7 @@
                 request.setAttribute("furthertargets", true);
             }
             else {
-                request.setAttribute("diagramm", true);
+                request.setAttribute("chart", true);
             }
 
             return super.execute(mapping, form, request, response);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/CreateChartAction.java	Tue Feb 23 10:36:02 2010 +0000
@@ -0,0 +1,40 @@
+package de.intevation.gnv.action;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public class CreateChartAction extends DescribeUIAction {
+
+    private static Logger logger = Logger.getLogger(CreateChartAction.class);
+
+
+    public CreateChartAction() {
+        super();
+    }
+
+
+    @Override
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          form,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+    throws Exception {
+        logger.debug("Create chart.");
+
+        request.setAttribute("chart", true);
+
+        return super.execute(mapping, form, request, response);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/gnv/src/main/resources/applicationMessages.properties	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages.properties	Tue Feb 23 10:36:02 2010 +0000
@@ -58,6 +58,9 @@
 
 # Histogramm
 gnviewer.histogram.button=Histogramm
+gnviewer.histogram.options.header.title=Histogrammoptionen
+bincount=Anzahl der Klassen
+binwidth=Breite einer Klasse
 
 # diagram options dialog
 gnviewer.diagram.options.header.title=Diagrammoptionen
--- a/gnv/src/main/resources/applicationMessages_en.properties	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages_en.properties	Tue Feb 23 10:36:02 2010 +0000
@@ -58,6 +58,9 @@
 
 # Histogramm
 gnviewer.histogram.button=Histogram
+gnviewer.histogram.options.header.title=Histogram Options
+bincount=Number of classes
+binwidth=Class width
 
 # diagram options dialog
 gnviewer.diagram.options.header.title=Diagram options
--- a/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/config/struts-config.xml	Tue Feb 23 10:36:02 2010 +0000
@@ -140,6 +140,20 @@
                 name="selectfis"
                 path="/gnv/selectFis.do"/>
         </action>
+        <action path="/chart" 
+                type="de.intevation.gnv.action.CreateChartAction"
+                scope="request"
+                validate="false">
+            <forward
+                name="success"
+                path="/WEB-INF/jsp/mainlayout.jsp"/>
+            <forward
+                name="back"
+                path="/gnv/back.do"/>
+            <forward
+                name="selectfis"
+                path="/gnv/selectFis.do"/>
+        </action>
         <action path="/statistic"
                 type="de.intevation.gnv.action.ShowStatisticAction"
                 scope="request"
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_inc.jsp	Tue Feb 23 10:36:02 2010 +0000
@@ -8,7 +8,6 @@
 <%@page import="java.net.URLEncoder"%>
 <%
     // fetch diagramm parameter from request if the user clicked 'draw'
-    Object diagramm = request.getAttribute("diagramm");
     SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
 
     String target          = "chart"; 
@@ -32,15 +31,9 @@
     }
 %> 
 
-<%-- show chart options if output mode 'chart' is supported --%>
-<% if (supportChart) { %>
-    <jsp:include page="/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp"></jsp:include>
-<%}%>
-
 <%-- diagramm is not null if the user clicked the 'draw' button --%>
-<%if (diagramm != null) { %>
-    <div id="diagram">
-        <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&amp;target="+target+parameterString+"&amp;uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.diagramm.alt"/>'/>
-        <br/>
-    </div>
-<%}%>
+<jsp:include page="/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp"></jsp:include>
+<div id="diagram">
+    <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&amp;target="+target+parameterString+"&amp;uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.diagramm.alt"/>'/>
+    <br/>
+</div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Tue Feb 23 10:36:02 2010 +0000
@@ -86,6 +86,9 @@
         <fieldset>
             <legend><bean:message key="gnviewer.export.fieldset.title"/></legend>
             <%if (supportChart) { %>
+            <a href="<%=response.encodeURL("chart.do?mimetype="+mimeType+"&amp;target="+target+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
+                <img src="images/chart_curve.png" border="0"/>
+            </a>
             <a href="<%=response.encodeURL("export.do?mimetype="+mimeType+"&amp;target="+target+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
                 <img src="images/diagram_export.png" border="0"/>
             </a>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_inc.jsp	Tue Feb 23 10:36:02 2010 +0000
@@ -9,6 +9,7 @@
     String mimeType = sm.getOutputMode(target).getMimeType();
 %>
 
+<jsp:include page="/WEB-INF/jsp/includes/display_histogram_options_inc.jsp"></jsp:include>
 <div class="histogram">
     <img src='<%=response.encodeURL("out.do?mimetype="+mimeType+"&amp;target=histogram&amp;uid="+System.currentTimeMillis())%>' alt='<bean:message key="gnviewer.output.options.histogram.alt"/>'/>
 </div>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp	Tue Feb 23 10:36:02 2010 +0000
@@ -0,0 +1,51 @@
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean-el" prefix="bean-el" %>
+<%@page import="de.intevation.gnv.action.sessionmodel.DiagrammOptions"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModelFactory"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputMode"%>
+<%@page import="de.intevation.gnv.action.sessionmodel.SessionModel"%>
+<%@page import="java.util.Collection"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
+<%@page import="java.util.Iterator"%>
+<%
+  SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
+  DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
+  boolean useDiagrammOptions = diagrammOptions != null;
+  String target = "histogram";
+  OutputMode outputMode = sm.getOutputMode(target);
+%>
+<div id="diagramOptionsContent">
+    <fieldset>
+        <legend onmousedown="displayDiv('histogramOptionsContent');" class="expandableFieldset">
+           <bean:message key="gnviewer.histogram.options.header.title"/>
+        </legend>
+        <form id="outputOptionsForm" method="post" action="<%=response.encodeURL("changeOptions.do?target="+target)%>">
+           <table>
+           <%if (outputMode != null && outputMode.getOutputParameters() != null && !outputMode.getOutputParameters().isEmpty()){
+               Iterator<OutputParameter> it = outputMode.getOutputParameters().iterator();
+               while (it.hasNext()){
+                   OutputParameter om = it.next(); %>
+               <tr>
+                  <td>
+                      <bean-el:message key="<%=om.getName()%>"/>
+                  </td>
+                  <td>
+                      <%if (om.getType().equalsIgnoreCase("boolean")){
+                          boolean checked = useDiagrammOptions ? "true".equalsIgnoreCase(diagrammOptions.getValue(om.getName())) : om.getValue().equalsIgnoreCase("true");
+                      %>
+                            <input type="checkbox" 
+                                   name="<%=om.getName() %>" 
+                                   <%=checked ? " value=\"true\" checked=\"checked\"": "" %>/>
+                      <%}else{%>
+                            <input type="text" name="<%=om.getName() %>" value="<%=useDiagrammOptions ? diagrammOptions.getValue(om.getName()): om.getValue()%>"/>
+                      <%}%>
+                  </td>
+              </tr>
+           <%}%>
+           </table>
+           <input type="hidden" name="target" value="<%=target%>"/>
+           <input type="submit" value="<bean:message key="gnviewer.draw.button"/>"/>
+           <%}%>
+        </form>
+    </fieldset>
+</div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/index.jsp	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/index.jsp	Tue Feb 23 10:36:02 2010 +0000
@@ -6,6 +6,7 @@
 <%@page import="java.util.Iterator"%>
 <%  Object ui              = request.getAttribute("ui");
     Object staticui        = request.getAttribute("staticui");
+    Object chart           = request.getAttribute("chart");
     Object statistic       = request.getAttribute("statistic");
     Object histogram       = request.getAttribute("histogram");
     Object wms             = request.getAttribute("wms");
@@ -46,11 +47,13 @@
 
     <div id="map"></div>
 
+        <%-- render export options if existing for this state --%>
+    <jsp:include page="includes/display_export_inc.jsp"></jsp:include>
+
+    <%if (chart != null) {%>
     <%-- render chart options if existing for this state --%>
     <jsp:include page="includes/display_diagramm_inc.jsp"></jsp:include>
-
-    <%-- render export options if existing for this state --%>
-    <jsp:include page="includes/display_export_inc.jsp"></jsp:include>
+    <%}%>
 
     <%-- render statistic --%>
     <%if (statistic != null) {%>
--- a/gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp	Mon Feb 22 18:04:55 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/mainlayout.jsp	Tue Feb 23 10:36:02 2010 +0000
@@ -52,7 +52,6 @@
 
             function init() {
                 if (getURLParam("target") == "wms") {
-                    console.log("LAYER NAME: " + getURLParam("layer"));
                     map   = new OpenLayers.Map('map');
                     layer = new OpenLayers.Layer.WMS(
                         "MyWMS",
Binary file gnv/src/main/webapp/images/chart_curve.png has changed

http://dive4elements.wald.intevation.org