changeset 573:bd67164cf28b

Devided actions and exports. Adjusted output and export actions. gnv/trunk@704 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 17:43:16 +0000
parents 3f7bbc6dc751
children 800874dc0b29
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultExportMode.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ExportMode.java gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java gnv/src/main/resources/applicationMessages.properties gnv/src/main/resources/applicationMessages_en.properties gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp gnv/src/main/webapp/images/arrow_refresh.png
diffstat 14 files changed, 369 insertions(+), 70 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/ChangeLog	Tue Feb 23 17:43:16 2010 +0000
@@ -1,3 +1,38 @@
+2010-02-23  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java,
+	  src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java:
+	  New method returning export modes.
+
+	* src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultExportMode.java,
+	  src/main/java/de/intevation/gnv/artifactdatabase/objects/ExportMode.java:
+	  Object storing information about mime-type, description and name of an
+	  export mode.
+
+	* src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java:
+	  Parse export modes from describe document and put them into OutputMode
+	  objects.
+
+	* src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java: Now, this
+	  action is able to adjust histogram parameter as well.
+
+	* src/main/java/de/intevation/gnv/action/DoExportAction.java: An export is
+	  triggered regarding a new parameter 'mode' which value can be 'pdf', 
+	  'svg' or 'img'. Before, we just took care on 'target' parameter.
+
+	* src/main/resources/applicationMessages.properties,
+	  src/main/resources/applicationMessages_en.properties: Transformed draw
+	  button into an update button.
+
+	* src/main/webapp/images/arrow_refresh.png: Icon for update button. (source:
+	  famfamfam)
+
+	* src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp,
+	  src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp,
+	  src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp: Moved
+	  exports from action panel into options panel. Actions (chart, histogram,
+	  etc) are devided from exports (png, pdf, svg).
+
 2010-02-23  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/webapp/WEB-INF/config/struts-config.xml: Foward to wmslayout.jsp
@@ -7,6 +42,9 @@
 	  client (OpenLayers). JavaScript loading take place in this page. If the
 	  user select the wms target, a forward to this page will be done.
 
+	  TODO: Include OpenLayers library from local filesystem instead of loading
+	  it from openlayers.org!
+
 	* src/main/webapp/WEB-INF/jsp/mainlayout.jsp: Removed OpenLayers JavaScript
 	  library and function to initialize OpenLayers. This reduces traffic while
 	  parameterization.
--- a/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/ChangeOptionsAction.java	Tue Feb 23 17:43:16 2010 +0000
@@ -79,7 +79,7 @@
                 request.setAttribute("furthertargets", true);
             }
             else {
-                request.setAttribute("chart", true);
+                request.setAttribute(target, true);
             }
 
             return super.execute(mapping, form, request, response);
--- a/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/DoExportAction.java	Tue Feb 23 17:43:16 2010 +0000
@@ -8,11 +8,38 @@
 
 import org.apache.log4j.Logger;
 
+import de.intevation.gnv.action.sessionmodel.SessionModel;
+import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
+
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
+import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
+
+import de.intevation.gnv.artifactdatabase.objects.DefaultInputParameter;
+import de.intevation.gnv.artifactdatabase.objects.ExportMode;
+import de.intevation.gnv.artifactdatabase.objects.InputParameter;
+import de.intevation.gnv.artifactdatabase.objects.OutputMode;
+import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
+
+import java.io.OutputStream;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+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 Tim Englich <tim.englich@intevation.de>
  * 
  */
-public class DoExportAction extends DoOutputAction {
+public class DoExportAction extends ArtifactDatabaseActionBase {
 
     /**
      * the logger, used to log exceptions and additonaly information
@@ -26,13 +53,93 @@
         super();
     }
 
+    /**
+     * @see de.intevation.gnv.action.ArtifactDatabaseActionBase#execute(org.apache.struts.action.ActionMapping,
+     *      org.apache.struts.action.ActionForm,
+     *      javax.servlet.http.HttpServletRequest,
+     *      javax.servlet.http.HttpServletResponse)
+     */
     @Override
+    public ActionForward execute(
+        ActionMapping       mapping,
+        ActionForm          form,
+        HttpServletRequest  request,
+        HttpServletResponse response)
+    throws Exception
+    {
+        try {
+            String target   = request.getParameter("target");
+            String mimeType = request.getParameter("mimetype");
+            String mode     = request.getParameter("mode");
+
+            log.debug("Target: " + target);
+            log.debug("MimeType: " + mimeType);
+            log.debug("ExportMode: " + mode);
+
+            SessionModel sm = SessionModelFactory.getInstance()
+                    .getSessionModel(request);
+            OutputMode outputMode = sm.getOutputMode(target);
+            if (outputMode != null) {
+                ExportMode exportMode = outputMode.getExportMode(mode);
+
+                if (target.equals(mode) || (exportMode != null
+                &&  exportMode.getMimeType().equals(mimeType)))
+                {
+                    Collection<OutputParameter> inputParameter = outputMode
+                            .getOutputParameters();
+                    Collection<InputParameter> ips = null;
+                    if (inputParameter != null) {
+                        ips = new ArrayList<InputParameter>(inputParameter.size());
+                        Iterator<OutputParameter> it = inputParameter.iterator();
+                        while (it.hasNext()) {
+                            String name = it.next().getName();
+                            String[] values = request.getParameterValues(name);
+                            InputParameter ip = new DefaultInputParameter(name,
+                                    values);
+                            ips.add(ip);
+                        }
+                    }
+
+                    ArtifactDatabaseClient adc = ArtifactDatabaseClientFactory
+                            .getInstance()
+                            .getArtifactDatabaseClient(getLocale(request));
+
+                    this.setHeaders(mode, mimeType, response, request);
+
+                    OutputStream outputStream = response.getOutputStream();
+                    adc.doOutput(sm.getSelectedArtifactFactory(), sm
+                            .getCurrentArtifact(), outputStream, mode, mimeType,
+                            ips);
+
+                    outputStream.flush();
+                    outputStream.close();
+                }
+                else {
+                    if (outputMode == null) {
+                        log.error("Outputmode is not supported.");
+                    }
+                    else if (!exportMode.getMimeType().equals(mimeType)) {
+                        log.error("MimeType "+mimeType+" wis not supported.");
+                    }
+                    // TODO FIXME: Fehlerbehandlung
+                }
+            }
+            return super.execute(mapping, form, request, response);
+        } catch (Exception e) {
+            log.error(e, e);
+            request.setAttribute(
+                    CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID, e
+                            .getMessage());
+            return super.getExceptionForward(mapping);
+        }
+    }
+
     protected void setHeaders(String target, String mimeType,
                               HttpServletResponse response,
                               HttpServletRequest request) {
         log.debug("DoExportAction.setHeaders");
         try {
-            super.setHeaders(target, mimeType, response, request);
+            response.setHeader("Content-Type", mimeType);
             String fileName = "GNVEXPORT_" + System.currentTimeMillis() + ".";
 
             target = target.toLowerCase();
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java	Tue Feb 23 17:43:16 2010 +0000
@@ -38,8 +38,10 @@
 import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet;
 import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticValue;
 import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticsSet;
+import de.intevation.gnv.artifactdatabase.objects.DefaultExportMode;
 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputMode;
 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputParameter;
+import de.intevation.gnv.artifactdatabase.objects.ExportMode;
 import de.intevation.gnv.artifactdatabase.objects.InputParameter;
 import de.intevation.gnv.artifactdatabase.objects.OutputMode;
 import de.intevation.gnv.artifactdatabase.objects.OutputParameter;
@@ -478,8 +480,28 @@
                                                 outputParameterNode, "@type")));
                             }
                         }
+
+                        NodeList exportNodes = xmlUtils.getNodeSetXPath(
+                            outputModeNode, "art:exports/art:export");
+                        Map exports = null;
+                        
+                        if (exportNodes != null) {
+                            int size = exportNodes.getLength();
+                            exports = new HashMap<String, ExportMode>(size);
+
+                            for (int k = 0; k < size; k++) {
+                                Node export = exportNodes.item(k);
+                                String expName = xmlUtils.getStringXPath(
+                                    export, "@name");
+                                exports.put(expName, new DefaultExportMode(
+                                    expName,
+                                    xmlUtils.getStringXPath(export, "@description"),
+                                    xmlUtils.getStringXPath(export, "@mime-type")));
+                            }
+                        }
+
                         outputModes.put(name, new DefaultOutputMode(name,
-                                mimeType, parameter));
+                                mimeType, parameter, exports));
                     }
 
                 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultExportMode.java	Tue Feb 23 17:43:16 2010 +0000
@@ -0,0 +1,31 @@
+package de.intevation.gnv.artifactdatabase.objects;
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public class DefaultExportMode
+implements   ExportMode
+{
+    protected String name;
+    protected String description;
+    protected String mimeType;
+
+    public DefaultExportMode(String name, String description, String mimeType){
+        this.name        = name;
+        this.description = description;
+        this.mimeType    = mimeType;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public String getMimeType() {
+        return mimeType;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/DefaultOutputMode.java	Tue Feb 23 17:43:16 2010 +0000
@@ -4,6 +4,7 @@
 package de.intevation.gnv.artifactdatabase.objects;
 
 import java.util.Collection;
+import java.util.Map;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -22,12 +23,19 @@
 
     private Collection<OutputParameter> outputParameter = null;
 
-    public DefaultOutputMode(String name, String mimeType,
-                             Collection<OutputParameter> outputParameter) {
+    private Map<String, ExportMode> exports;
+
+    public DefaultOutputMode(
+        String name,
+        String mimeType,
+        Collection<OutputParameter> outputParameter,
+        Map<String, ExportMode> exports)
+    {
         super();
-        this.name = name;
-        this.mimeType = mimeType;
+        this.name            = name;
+        this.mimeType        = mimeType;
         this.outputParameter = outputParameter;
+        this.exports         = exports;
     }
 
     /**
@@ -51,4 +59,7 @@
         return this.outputParameter;
     }
 
+    public ExportMode getExportMode(String mode) {
+        return exports.get(mode);
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/ExportMode.java	Tue Feb 23 17:43:16 2010 +0000
@@ -0,0 +1,15 @@
+package de.intevation.gnv.artifactdatabase.objects;
+
+import java.io.Serializable;
+
+/**
+ * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ */
+public interface ExportMode
+extends          Serializable
+{
+    public String getName();
+    public String getDescription();
+    public String getMimeType();
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/artifactdatabase/objects/OutputMode.java	Tue Feb 23 17:43:16 2010 +0000
@@ -18,4 +18,5 @@
 
     public Collection<OutputParameter> getOutputParameters();
 
+    public ExportMode getExportMode(String mode);
 }
--- a/gnv/src/main/resources/applicationMessages.properties	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages.properties	Tue Feb 23 17:43:16 2010 +0000
@@ -29,7 +29,7 @@
 gnviewer.fis.fis_icestations = Eismeldungen
 
 gnviewer.select.button = Ausw\u00e4hlen
-gnviewer.draw.button = Zeichnen
+gnviewer.draw.button = Aktualisieren
 
 gnviewer.productselection.overlay.title = Die Anfrage wird bearbeitet, bitte gedulden Sie sich einen Moment.
 gnviewer.productselection.fisselection.title = Fachinformationssystem
--- a/gnv/src/main/resources/applicationMessages_en.properties	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/resources/applicationMessages_en.properties	Tue Feb 23 17:43:16 2010 +0000
@@ -29,7 +29,7 @@
 gnviewer.fis.fis_icestations = Ice Station Report
 
 gnviewer.select.button = Choose
-gnviewer.draw.button = Draw
+gnviewer.draw.button = Update
 
 gnviewer.productselection.overlay.title = Your request will be processed. Please wait...
 gnviewer.productselection.fisselection.title = Data set
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_diagramm_options_inc.jsp	Tue Feb 23 17:43:16 2010 +0000
@@ -4,15 +4,51 @@
 <%@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="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.ExportMode"%>
 <%@page import="java.util.Collection"%>
-<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
 <%@page import="java.util.Iterator"%>
+<%@page import="java.net.URLEncoder"%>
 <%
-  SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
-  DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
-  boolean useDiagrammOptions = diagrammOptions != null;
-  String target = "chart";
-  OutputMode outputMode = sm.getOutputMode(target);
+    String target                   = "chart";
+    String targetPDF                = "pdf";
+    String targetSVG                = "svg";
+    String targetIMG                = "img";
+    SessionModel sm                 = SessionModelFactory.getInstance().getSessionModel(request);
+    OutputMode outputMode           = sm.getOutputMode(target);
+    DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
+
+    boolean useDiagrammOptions = diagrammOptions != null;
+    ExportMode supportIMG      = outputMode.getExportMode(targetIMG);
+    ExportMode supportPDF      = outputMode.getExportMode(targetPDF);
+    ExportMode supportSVG      = outputMode.getExportMode(targetSVG);
+
+    String mimeType                 = outputMode.getMimeType();
+    String parameterString          = "";
+    Collection<OutputParameter> op  = outputMode.getOutputParameters();
+
+    if (op != null){
+        Iterator<OutputParameter> it = op.iterator();
+        while (it.hasNext()){
+            OutputParameter parameter = it.next(); 
+            parameterString = parameterString +"&amp;"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue());
+        }
+    }
+
+
+    String mimeTypeIMG = null;
+    if (supportIMG != null) {
+        mimeTypeIMG = supportIMG.getMimeType();
+    } 
+    String mimeTypePDF = null;
+    if (supportPDF != null) {
+        mimeTypePDF = supportPDF.getMimeType();
+    }
+    String mimeTypeSVG = null;
+    if (supportSVG != null) {
+        mimeTypeSVG = supportSVG.getMimeType();
+        mimeTypeSVG = URLEncoder.encode(mimeTypeSVG, "UTF-8");
+    }
 %>
 <div id="diagramOptionsContent">
     <fieldset>
@@ -43,9 +79,25 @@
               </tr>
            <%}%>
            </table>
-           <input type="hidden" name="target" value="<%=target%>"/>
-           <input type="submit" value="<bean:message key="gnviewer.draw.button"/>"/>
-           <%}%>
+           <div class="exportBar">
+               <input type="image" name="target" value="chart" src="images/arrow_refresh.png" alt="<bean:message key="gnviewer.draw.button"/>"/>
+               <%}%>
+                <%if (supportIMG != null) { %>
+                   <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeIMG+"&amp;target="+target+"&amp;mode="+target+parameterString+"uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
+                        <img src="images/diagram_export.png" border="0"/>
+                    </a>
+                <%}%>
+                <%if (supportPDF != null) { %>
+                    <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypePDF+"&amp;target="+target+"&amp;mode="+targetPDF+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.pdf.title"/>">
+                        <img src="images/pdf.png" border="0"/>
+                    </a>
+                <%}%>
+                <%if (supportSVG != null) { %>
+                    <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeSVG+"&amp;target="+target+"&amp;mode="+targetSVG+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.svg.title"/>">
+                        <img src="images/svg.png" border="0"/>
+                    </a>
+                <%}%>
+            </div>
         </form>
     </fieldset>
 </div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_export_inc.jsp	Tue Feb 23 17:43:16 2010 +0000
@@ -8,18 +8,15 @@
 <%@page import="java.util.Iterator"%>
 <%@page import="java.net.URLEncoder"%>
 <%
-    SessionModel sm        = SessionModelFactory.getInstance().getSessionModel(request);
-    ArtifactObject artifact         = sm.getCurrentArtifact();
-    String mimeType        = null;
-    String parameterString = "";
-    String wmslayer        = null;
-    
+    SessionModel sm         = SessionModelFactory.getInstance().getSessionModel(request);
+    ArtifactObject artifact = sm.getCurrentArtifact();
+    String mimeType         = null;
+    String wmslayer         = null;
+    String parameterString  = "";
 
     String target    = "chart";
     String targetCSV = "csv";
     String targetODV = "odv";
-    String targetPDF = "pdf";
-    String targetSVG = "svg";
     String targetZIP = "zip";
     String targetWMS = "wms";
     String targetSta = "statistics";
@@ -28,8 +25,6 @@
     boolean supportChart = sm.getOutputMode(target)    != null;
     boolean supportCSV   = sm.getOutputMode(targetCSV) != null;
     boolean supportODV   = sm.getOutputMode(targetODV) != null;
-    boolean supportPDF   = sm.getOutputMode(targetPDF) != null;
-    boolean supportSVG   = sm.getOutputMode(targetSVG) != null;
     boolean supportZIP   = sm.getOutputMode(targetZIP) != null;
     boolean supportWMS   = sm.getOutputMode(targetWMS) != null;
     boolean supportSta   = sm.getOutputMode(targetSta) != null;
@@ -49,15 +44,6 @@
        }
     }
 
-    String mimeTypePDF = null;
-    if (supportPDF) {
-       mimeTypePDF = sm.getOutputMode(targetPDF).getMimeType();
-    }
-    String mimeTypeSVG = null;
-    if (supportSVG) {
-        mimeTypeSVG = sm.getOutputMode(targetSVG).getMimeType();
-        mimeTypeSVG = URLEncoder.encode(mimeTypeSVG, "UTF-8");
-    }
     String mimeTypeCSV = null;
     if (supportCSV){
         mimeTypeCSV = sm.getOutputMode(targetCSV).getMimeType();
@@ -81,7 +67,7 @@
 %>
 
 <%-- display export options if one is supported in this state --%>
-<% if (supportPDF || supportSVG || supportCSV || supportODV || supportWMS || supportZIP) { %>
+<% if (supportChart || supportCSV || supportODV || supportWMS || supportZIP) { %>
     <div id="export">
         <fieldset>
             <legend><bean:message key="gnviewer.export.fieldset.title"/></legend>
@@ -89,29 +75,6 @@
             <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>
-            <%}%>
-            <%if (supportPDF) { %>
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypePDF+"&amp;target="+targetPDF+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.pdf.title"/>">
-                <img src="images/pdf.png" border="0"/>
-            </a>
-            <%}%>
-            <%if (supportSVG) { %>
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeSVG+"&amp;target="+targetSVG+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.svg.title"/>">
-                <img src="images/svg.png" border="0"/>
-            </a>
-            <%}%>
-            <%if (supportCSV) { %>
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeCSV+"&amp;target="+targetCSV+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.csv.title"/>">
-                <img src="images/data_export.png" border="0"/>
-            </a>
-            <%}%>
-            <%if (supportODV) { %>
-            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeODV+"&amp;target="+targetODV+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.odv.title"/>">
-                <img src="images/data_export.png" border="0"/>
-            </a>
             <%}%>
             <%if (supportWMS) { %>
             <a href="<%=response.encodeURL("wms.do?mimetype="+mimeTypeWMS+"&amp;target="+targetWMS+"&amp;uid="+System.currentTimeMillis()+"&amp;layer="+wmslayer)%>" title="<bean:message key="gnviewer.output.options.export.wms.title"/>">
@@ -134,6 +97,16 @@
                 <a href="<%=response.encodeURL("histogram.do")%>" title="<bean:message key="gnviewer.histogram.button"/>">
                     <img src="images/chart_bar.png" border="0"/>
                 </a>
+            <%}%> 
+            <%if (supportCSV) { %>
+            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeCSV+"&amp;target="+targetCSV+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.csv.title"/>">
+                <img src="images/data_export.png" border="0"/>
+            </a>
+            <%}%>
+            <%if (supportODV) { %>
+            <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeODV+"&amp;target="+targetODV+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.odv.title"/>">
+                <img src="images/data_export.png" border="0"/>
+            </a> 
             <%}%>
         </fieldset>
     </div>
--- a/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp	Tue Feb 23 15:26:50 2010 +0000
+++ b/gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp	Tue Feb 23 17:43:16 2010 +0000
@@ -4,15 +4,50 @@
 <%@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="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
+<%@page import="de.intevation.gnv.artifactdatabase.objects.ExportMode"%>
 <%@page import="java.util.Collection"%>
-<%@page import="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
 <%@page import="java.util.Iterator"%>
+<%@page import="java.net.URLEncoder"%>
 <%
-  SessionModel sm = SessionModelFactory.getInstance().getSessionModel(request);
-  DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
-  boolean useDiagrammOptions = diagrammOptions != null;
-  String target = "histogram";
-  OutputMode outputMode = sm.getOutputMode(target);
+    String target                   = "histogram";
+    String targetPDF                = "pdf";
+    String targetSVG                = "svg";
+    String targetIMG                = "img";
+    SessionModel sm                 = SessionModelFactory.getInstance().getSessionModel(request);
+    OutputMode outputMode           = sm.getOutputMode(target);
+    DiagrammOptions diagrammOptions = sm.getDiagrammOptions();
+
+    boolean useDiagrammOptions = diagrammOptions != null;
+    ExportMode supportIMG      = outputMode.getExportMode(targetIMG);
+    ExportMode supportPDF      = outputMode.getExportMode(targetPDF);
+    ExportMode supportSVG      = outputMode.getExportMode(targetSVG);
+
+    String mimeType                 = outputMode.getMimeType();
+    String parameterString          = "";
+    Collection<OutputParameter> op  = outputMode.getOutputParameters();
+
+    if (op != null){
+        Iterator<OutputParameter> it = op.iterator();
+        while (it.hasNext()){
+            OutputParameter parameter = it.next(); 
+            parameterString = parameterString +"&amp;"+parameter.getName()+"="+(diagrammOptions != null ? diagrammOptions.getValue(parameter.getName()): parameter.getValue());
+        }
+    } 
+
+    String mimeTypeIMG = null;
+    if (supportIMG != null) {
+        mimeTypeIMG = supportIMG.getMimeType();
+    } 
+    String mimeTypePDF = null;
+    if (supportPDF != null) {
+        mimeTypePDF = supportPDF.getMimeType();
+    }
+    String mimeTypeSVG = null;
+    if (supportSVG != null) {
+        mimeTypeSVG = supportSVG.getMimeType();
+        mimeTypeSVG = URLEncoder.encode(mimeTypeSVG, "UTF-8");
+    }
 %>
 <div id="diagramOptionsContent">
     <fieldset>
@@ -43,9 +78,23 @@
               </tr>
            <%}%>
            </table>
-           <input type="hidden" name="target" value="<%=target%>"/>
-           <input type="submit" value="<bean:message key="gnviewer.draw.button"/>"/>
+           <input type="image" name="target" value="histogram" src="images/arrow_refresh.png" alt="<bean:message key="gnviewer.draw.button"/>"/>
            <%}%>
+           <%if (supportIMG != null) { %>
+               <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeIMG+"&amp;target="+target+"&amp;mode="+target+parameterString+"uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.save.title"/>">
+                    <img src="images/diagram_export.png" border="0"/>
+                </a>
+            <%}%>
+            <%if (supportPDF != null) { %>
+                <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypePDF+"&amp;target="+target+"&amp;mode="+targetPDF+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.pdf.title"/>">
+                    <img src="images/pdf.png" border="0"/>
+                </a>
+            <%}%>
+            <%if (supportSVG != null) { %>
+                <a href="<%=response.encodeURL("export.do?mimetype="+mimeTypeSVG+"&amp;target="+target+"&amp;mode="+targetSVG+parameterString+"&amp;uid="+System.currentTimeMillis())%>" title="<bean:message key="gnviewer.output.options.export.svg.title"/>">
+                    <img src="images/svg.png" border="0"/>
+                </a>
+            <%}%>
         </form>
     </fieldset>
 </div>
Binary file gnv/src/main/webapp/images/arrow_refresh.png has changed

http://dive4elements.wald.intevation.org