view gnv/src/main/webapp/WEB-INF/jsp/includes/display_histogram_options_inc.jsp @ 1007:de9a0b16e99f

Fixed some more XHTML-Mistakes gnv/trunk@1217 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 15 Jun 2010 08:10:44 +0000
parents c7f8a9b4b006
children 28a0628b11b0
line wrap: on
line source
<%@ 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.CommunicationKeys"%>
<%@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="de.intevation.gnv.artifactdatabase.objects.OutputParameter"%>
<%@page import="de.intevation.gnv.artifactdatabase.objects.ExportMode"%>
<%@page import="java.util.Collection"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Locale"%>
<%@page import="java.net.URLEncoder"%>
<%
    String exceptionMsg             = (String)request.getAttribute(CommunicationKeys.REQUEST_EXCEPTION_MESSAGE);
    String exceptionValue           = (String)request.getAttribute(CommunicationKeys.REQUEST_EXCEPTION_VALUE);
    String target                   = "histogram";
    String targetPDF                = "pdf";
    String targetSVG                = "svg";
    String targetIMG                = "img";
    SessionModel sm                 = SessionModelFactory.getInstance().getSessionModel(request);
    Locale locale                   = sm.getCurrentLocale();
    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>
        <legend onmousedown="displayDiv('histogramOptionsContent');" class="expandableFieldset">
           <bean:message key="gnviewer.histogram.options.header.title"/>
        </legend>

        <% if (exceptionMsg != null) {%>
            <div id="chartException" class="chartException">
                '<%=exceptionValue%>' <bean-el:message key="<%=exceptionMsg%>"/>
            </div>
        <%}%>

        <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();
                   String diaOpts = null;
                   if (diagrammOptions != null) {
                       diaOpts = request.getParameter("bintype");
                   }%>
               <tr>
                  <td>
                        <%if (om.getName().equals("bincount")) {
                            String check = "";
                            if (diaOpts != null && diaOpts.equalsIgnoreCase("binwidth")) {
                                check = "";
                            }
                            else {
                                check = "checked=\"checked\"";
                            }%>
                            <input type="checkbox" <%= check %> name="bintype" value="bincount" id="checkCount" onClick="toggleBinType('checkWidth')"/>
                        <%}%>
                        <%if (om.getName().equals("binwidth")) {
                            String check = "";
                            if (diaOpts != null && diaOpts.equalsIgnoreCase("binwidth")) {
                                check = "checked=\"checked\"";
                            }
                            else if (diaOpts == null) {
                                check = "";
                            }%>
                            <input type="checkbox" <%= check %> name="bintype" value="binwidth" id="checkWidth" onClick="toggleBinType('checkCount')"/>
                        <%}%>
                  </td>
                  <td class="parameter">
                      <bean-el:message key="<%=om.getName()%>"/>
                  </td>
                  <td>
                      <%if (om.getType().equalsIgnoreCase("boolean")){
                          boolean checked = useDiagrammOptions ? "true".equalsIgnoreCase(diagrammOptions.getValue(om.getName(), locale)) : 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(), locale): om.getValue()%>"/>
                      <%}%>
                  </td>
              </tr>
           <%}%>
           </table>
           <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="+targetIMG+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>

http://dive4elements.wald.intevation.org