Search in sources :

Example 1 with ChartItem

use of net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem in project processdash by dtuma.

the class EVReport method writeCharts.

protected List<ChartItem> writeCharts(EVTaskList evModel, EVSchedule schedule, EVTaskFilter filter, boolean hideNames, int width, int height, ChartListPurpose p, String singleChartId, Map<String, String> chartHelpMap) {
    DashboardContext ctx = getDashboardContext();
    Object exportMarker = parameters.get("EXPORT");
    boolean filterInEffect = (filter != null);
    boolean isRollup = (evModel instanceof EVTaskListRollup);
    List<ChartItem> chartList = TaskScheduleChartUtil.getChartsForTaskList(evModel.getID(), getDataRepository(), filterInEffect, isRollup, hideNames, p);
    for (Iterator i = chartList.iterator(); i.hasNext(); ) {
        ChartItem chart = (ChartItem) i.next();
        if (chart == null) {
            i.remove();
            continue;
        }
        try {
            SnippetWidget w = chart.snip.getWidget("view", null);
            if (w instanceof HtmlEvChart) {
                String chartId = getChartId(chart);
                if (chartHelpMap != null && w instanceof HelpAwareEvChart) {
                    String helpUri = ((HelpAwareEvChart) w).getHelpUri();
                    if (StringUtils.hasValue(helpUri))
                        chartHelpMap.put(chartId, helpUri);
                }
                if (singleChartId != null && !singleChartId.equals(chartId))
                    continue;
                Map environment = TaskScheduleChartUtil.getEnvironment(evModel, schedule, filter, chart.snip, ctx);
                Map params = TaskScheduleChartUtil.getParameters(chart.settings);
                params.put("title", chart.name);
                params.put("width", Integer.toString(width));
                params.put("height", Integer.toString(height));
                params.put("noBorder", "t");
                if (hideNames)
                    params.put(CUSTOMIZE_HIDE_NAMES, "t");
                if (exportMarker != null)
                    params.put("EXPORT", exportMarker);
                else if (singleChartId == null)
                    params.put("href", getChartDrillDownUrl(chartId));
                // write the chart to an in-memory buffer. If any errors
                // occur, we will fall out to the exception handler.
                StringWriter buf = new StringWriter();
                ((HtmlEvChart) w).writeChartAsHtml(buf, environment, params);
                // The generation of the chart was successful.  Write out
                // the chart, surrounded by a DIV to control layout.
                out.write("<div class='evChartItem' style='width:" + width + "px; height:" + height + "px'>");
                out.write(buf.toString());
                out.write("</div>");
            } else {
                i.remove();
            }
            out.write(" ");
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Unexpected error when displaying " + "EV snippet widget with id '" + chart.snip.getId() + "'", e);
        }
    }
    return chartList;
}
Also used : DashboardContext(net.sourceforge.processdash.DashboardContext) SnippetWidget(net.sourceforge.processdash.ui.snippet.SnippetWidget) HtmlEvChart(net.sourceforge.processdash.ev.ui.chart.HtmlEvChart) HelpAwareEvChart(net.sourceforge.processdash.ev.ui.chart.HelpAwareEvChart) EVTaskListRollup(net.sourceforge.processdash.ev.EVTaskListRollup) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) IOException(java.io.IOException) StringWriter(java.io.StringWriter) Iterator(java.util.Iterator) CachedURLObject(net.sourceforge.processdash.net.cache.CachedURLObject) ChartItem(net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 2 with ChartItem

use of net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem in project processdash by dtuma.

the class EVReport method writeSingleChartPage.

protected void writeSingleChartPage(EVTaskFilter taskFilter, boolean hideNames, EVSchedule s, String singleChartId) {
    out.write("<div class='singleChartWrapper'>\n");
    // display the single chart that was requested via query parameters
    out.write("<div class='singleChartHolder'>\n");
    Map<String, String> chartHelp = new HashMap<String, String>();
    List<ChartItem> allCharts = writeCharts(evModel, s, taskFilter, hideNames, 800, 500, ChartListPurpose.ReportAll, singleChartId, chartHelp);
    // singleChartHolder
    out.write("</div>\n");
    // display a drop-down selector that can be used to select a
    // different chart to display
    out.write("<div class='singleChartSelector'><form>\n<b>");
    out.write(resources.getHTML("Report.Select_Chart"));
    out.write("</b>&nbsp;<select id='chartSelector' name='chartSelector' " + "onchange='PdashEV.selectSingleChart(this)'>\n");
    out.write("<option value='ALL'>" + resources.getHTML("Report.Show_Gallery") + "</option>\n");
    out.write("<option value=''> </option>\n");
    for (ChartItem chart : allCharts) {
        out.write("<option value='");
        String chartId = getChartId(chart);
        out.write(HTMLUtils.escapeEntities(chartId));
        if (chartId.equals(singleChartId))
            out.write("' selected='selected");
        out.write("'>");
        out.write(HTMLUtils.escapeEntities(chart.name));
        out.write("</option>\n");
    }
    // singleChartSelector
    out.write("</select></form></div>\n");
    // singleChartWrapper
    out.write("</div>");
    // write out the help topic for the current chart, if one is found.
    String chartHelpUri = chartHelp.get(singleChartId);
    if (chartHelpUri != null) {
        try {
            String helpContent = getRequestAsString(chartHelpUri);
            helpContent = fixChartHelpContent(helpContent, chartHelpUri, chartHelp);
            out.write("<div style='clear:both'></div>\n");
            out.write("<div class='singleChartHelp'>\n");
            out.write(helpContent);
            // singleChartHelp
            out.write("</div>");
        } catch (Exception e) {
        }
    }
}
Also used : HashMap(java.util.HashMap) ChartItem(net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem) TinyCGIException(net.sourceforge.processdash.net.http.TinyCGIException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ChartItem (net.sourceforge.processdash.ev.ui.TaskScheduleChartUtil.ChartItem)2 TinyCGIException (net.sourceforge.processdash.net.http.TinyCGIException)2 StringWriter (java.io.StringWriter)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 DashboardContext (net.sourceforge.processdash.DashboardContext)1 EVTaskListRollup (net.sourceforge.processdash.ev.EVTaskListRollup)1 HelpAwareEvChart (net.sourceforge.processdash.ev.ui.chart.HelpAwareEvChart)1 HtmlEvChart (net.sourceforge.processdash.ev.ui.chart.HtmlEvChart)1 CachedURLObject (net.sourceforge.processdash.net.cache.CachedURLObject)1 SnippetWidget (net.sourceforge.processdash.ui.snippet.SnippetWidget)1