Move jqPlot CSS and Javascript files to JAR

* Create own version of jqplot4java with CSS and JavaScript files embeded
* Serve CSS and JavaScript files through JAR

FEA: ItEr76S15OrganizingPerProjectDashboard
This commit is contained in:
Diego Pino 2012-05-30 09:33:00 +02:00
parent 054fbb0261
commit e3e4173524
3 changed files with 39 additions and 10 deletions

View file

@ -21,6 +21,10 @@ package org.libreplan.web.dashboard;
import static org.libreplan.web.I18nHelper._;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
@ -73,6 +77,18 @@ public class DashboardController extends GenericForwardComposer {
super.doAfterCompose(comp);
}
public String loadResourceFile(String filename) throws IOException {
StringBuffer result = new StringBuffer();
String line;
InputStream stream = BarChart.class.getClassLoader().getResourceAsStream(filename);
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
while ((line = br.readLine()) != null) {
result.append(line);
}
return result.toString();
}
public void setCurrentOrder(Order order, OrderPlanningController orderPlanningController) {
dashboardModel.setCurrentOrder(order, orderPlanningController);
if (dashboardModel.tasksAvailable()) {

View file

@ -25,7 +25,16 @@
<zscript>
<![CDATA[
dsController = arg.get("dashboardController");
contextPath = org.zkoss.zk.ui.Executions.getCurrent().getContextPath();
// Load jqPlot CSS and Javascript files
jquery_jqplot_min_css = dsController.loadResourceFile("/jqplot/jquery.jqplot.min.css");
jquery_min_js = dsController.loadResourceFile("/jqplot/jquery.min.js");
jquery_jqplot_min_js = dsController.loadResourceFile("/jqplot/jquery.jqplot.min.js");
jqplot_canvasTextRenderer_min_js = dsController.loadResourceFile("/jqplot/plugins/jqplot.canvasTextRenderer.min.js");
jqplot_canvasAxisLabelRenderer_min_js = dsController.loadResourceFile("/jqplot/plugins/jqplot.canvasAxisLabelRenderer.min.js");
jqplot_barRenderer_min_js = dsController.loadResourceFile("/jqplot/plugins/jqplot.barRenderer.min.js");
jqplot_pieRenderer_min_js = dsController.loadResourceFile("/jqplot/plugins/jqplot.pieRenderer.min.js");
jqplot_categoryAxisRenderer_min_js = dsController.loadResourceFile("/jqplot/plugins/jqplot.categoryAxisRenderer.min.js");
]]>
</zscript>
@ -125,15 +134,19 @@
<globalProgress />
<!-- Include jqPlot styles -->
<n:link class="include" rel="stylesheet" type="text/css" href="${contextPath}/jqplot/jquery.jqplot.min.css" />
<n:style rel="stylesheet" type="text/css">
${jquery_jqplot_min_css}
</n:style>
<!-- Include jqPlot library and additional plugins -->
<n:script type="text/javascript" src="${contextPath}/jqplot/jquery.min.js"></n:script>
<n:script type="text/javascript" src="${contextPath}/jqplot/jquery.jqplot.min.js"></n:script>
<n:script type="text/javascript" src="${contextPath}/jqPlot/plugins/jqplot.canvasTextRenderer.min.js"></n:script>
<n:script type="text/javascript" src="${contextPath}/jqPlot/plugins/jqplot.canvasAxisLabelRenderer.min.js"></n:script>
<n:script type="text/javascript" src="${contextPath}/jqplot/plugins/jqplot.barRenderer.min.js"></n:script>
<n:script type="text/javascript" src="${contextPath}/jqplot/plugins/jqplot.pieRenderer.min.js"></n:script>
<n:script type="text/javascript" src="${contextPath}/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></n:script>
<n:script type="text/javascript">
${jquery_min_js}
${jquery_jqplot_min_js}
${jqplot_canvasTextRenderer_min_js}
${jqplot_canvasAxisLabelRenderer_min_js}
${jqplot_barRenderer_min_js}
${jqplot_pieRenderer_min_js}
${jqplot_categoryAxisRenderer_min_js}
</n:script>
</zk>

View file

@ -752,7 +752,7 @@
<dependency>
<groupId>br.com.digilabs.jqplot</groupId>
<artifactId>jqplot4java</artifactId>
<version>1.2.0</version>
<version>1.2.3-javascript</version>
</dependency>
</dependencies>
</dependencyManagement>