make portlet title and chart title changable. delete report_float.js

This commit is contained in:
zhaowei8188127 2014-01-15 13:58:09 +08:00
parent c65a8b2764
commit d7e971d082
6 changed files with 84 additions and 157 deletions

View File

@ -27,6 +27,7 @@ import javax.persistence.Table;
private int height;
private int left_pos;
private int top_pos;
private String chart_title;
private Report report;
private Set<PortletConfiguration> configurations;
@ -47,16 +48,23 @@ import javax.persistence.Table;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Column(name="type")
@Column(name="chart_title")
public String getChart_title() {
return chart_title;
}
public void setChart_title(String chart_title) {
this.chart_title = chart_title;
}
@Column(name="type")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@ -65,7 +73,6 @@ import javax.persistence.Table;
public int getPosition() {
return position;
}
public void setPosition(int position) {
this.position = position;
}
@ -75,7 +82,6 @@ import javax.persistence.Table;
public Report getReport() {
return report;
}
public void setReport(Report report) {
this.report = report;
}

View File

@ -66,6 +66,7 @@ public class ReportHelper {
portletModel.setHeight(portlet.getHeight());
portletModel.setLeft(portlet.getLeft_pos());
portletModel.setTop(portlet.getTop_pos());
portletModel.setChartTitle(portlet.getChart_title());
Set<PortletConfigurationItemModel> configurations = new HashSet<PortletConfigurationItemModel>();
for( PortletConfiguration pc : portlet.getConfigurations() ){
@ -129,6 +130,7 @@ public class ReportHelper {
portlet.setHeight(portletModel.getHeight());
portlet.setLeft_pos(portletModel.getLeft());
portlet.setTop_pos(portletModel.getTop());
portlet.setChart_title(portletModel.getChartTitle());
Set<PortletConfiguration> portletConfigurations = new HashSet<PortletConfiguration>();
for( PortletConfigurationItemModel cim : portletModel.getConfigurations()){

View File

@ -19,6 +19,7 @@ public class PortletModel {
private int height;
private int left;
private int top;
private String chartTitle;
private UUID reportId;
private Set<PortletConfigurationItemModel> configurations;
@ -122,6 +123,13 @@ public class PortletModel {
this.top = top;
}
public String getChartTitle() {
return chartTitle;
}
public void setChartTitle(String chartTitle) {
this.chartTitle = chartTitle;
}
@XmlElementWrapper(name="chartSeries")
@XmlElement(name="chartSerie")
public Set<ChartSerieModel> getChartSeries() {

View File

@ -330,6 +330,7 @@ HAFlow.Main.prototype.onReportPortletClicked = function(portletId, chart, portle
var text = "";
text += "<table border=\"0\">";
text += "<tr style=\"tr\"><th align=\"left\">Portlet Info</th>" + "<td>" + portletId + "</td></tr>";
//find current protlet
var portlets = reportInfo.portlets;
var portlet;
@ -340,6 +341,19 @@ HAFlow.Main.prototype.onReportPortletClicked = function(portletId, chart, portle
}
}
//portlet configuration -- title
var titleTextBoxId = "portlet_title_text_box_" + portletId;
var titleTextBoxSpanId = "portlet_title_text_box_pane_" + portletId;
text += "<tr style=\"tr\"><th align=\"left\">" + "title" + "</th>"
+ "<td><span id=" + titleTextBoxSpanId + ">" + "</span></td></tr>";
//portlet configuration -- chart title
var chartTitleTextBoxId = "portlet_chart_title_text_box_" + portletId;
var chartTitleTextBoxSpanId = "portlet_chart_title_text_box_pane_" + portletId;
text += "<tr style=\"tr\"><th align=\"left\">" + "chart title" + "</th>"
+ "<td><span id=" + chartTitleTextBoxSpanId + ">" + "</span></td></tr>";
//chart configurations
var configurations = portlet.configurations;
for( var i = 0; i < configurations.length; i++ ){
var configuration = configurations[i];
@ -348,6 +362,7 @@ HAFlow.Main.prototype.onReportPortletClicked = function(portletId, chart, portle
+ "<td><span id=" + configurationTextBoxSpanId + ">" + "</span></td></tr>";
}
//series configurations
var series = portlet.chartSeries;
for ( var i = 0; i < series.length; i++) {
var serie = series[i];
@ -368,12 +383,37 @@ HAFlow.Main.prototype.onReportPortletClicked = function(portletId, chart, portle
text += "<tr style=\"tr\"><td align=\"left\">" +
"<div id=\"save_portlet_configurations_button_pane\" class=\"configuration-content\"></div>" +
"</td></tr>";
//delete button
text += "<tr style=\"tr\"><td align=\"left\">" +
"<div id=\"delete_portlet_configurations_button_pane\" class=\"configuration-content\"></div>" +
"</td></tr>";
text += "</table>";
$("#" + instance.informationContainerId).html(text);
//title
if( dijit.byId(titleTextBoxId) != null ){
dijit.registry.remove(titleTextBoxId);
}
var titleTextBox = new dijit.form.TextBox({
id : titleTextBoxId,
value : portlet.title,
style : "width:300px;"
});
titleTextBox.placeAt(dojo.byId(titleTextBoxSpanId));
titleTextBox.startup();
//chart title
if( dijit.byId(chartTitleTextBoxId) != null ){
dijit.registry.remove(chartTitleTextBoxId);
}
var chartTitleTextBox = new dijit.form.TextBox({
id : chartTitleTextBoxId,
value : portlet.chartTitle,
style : "width:300px;"
});
chartTitleTextBox.placeAt(dojo.byId(chartTitleTextBoxSpanId));
chartTitleTextBox.startup();
for( var i = 0; i < configurations.length; i++ ){
var configuration = configurations[i];
var configurationTextBoxId = "portlet_configuration_" + configuration.id + "_text_box";
@ -473,6 +513,17 @@ HAFlow.Main.prototype.savePortletConfiguration = function(portletId, chart){
}
}
//save portlet title
var titleTextBoxId = "portlet_title_text_box_" + portletId;
var newTitle = dijit.byId(titleTextBoxId).value;
portlet.title = newTitle;
//save chart title
var chartTitleTextBoxId = "portlet_chart_title_text_box_" + portletId;
var newChartTitle = dijit.byId(chartTitleTextBoxId).value;
portlet.chartTitle = newChartTitle;
//save chart configurations
var configurations = portlet.configurations;
for( var i = 0; i < configurations.length; i++ ){
var configuration = configurations[i];
@ -481,6 +532,7 @@ HAFlow.Main.prototype.savePortletConfiguration = function(portletId, chart){
configuration.value = newValue;
}
//save series configurations
var series = portlet.chartSeries;
for( var i = 0; i < series.length; i++ ){
var serie = series[i];
@ -688,7 +740,7 @@ HAFlow.Main.prototype.onReportModuleAdded = function(currentInstance, reportId,
var currentPortlet = {
id: newPortletId,
title: reportModuleId,
title: "untitled " + reportModuleId,
type: reportModuleId,
reportId: reportId,
configurations : portletConfigurations,
@ -703,6 +755,8 @@ HAFlow.Main.prototype.onReportModuleAdded = function(currentInstance, reportId,
//for grid pane
column: column,
zone: -1,
chartTitle : reportModuleId + " graph",
};
this.reports[reportId].portlets.push(currentPortlet);
this.addReport(reportId, currentPortlet);
@ -722,7 +776,7 @@ HAFlow.Main.prototype.addReport = function(reportId, currentPortlet){
dijit.registry.remove("portlet_" + currentPortlet.id);
}
var portlet = new dojox.widget.Portlet({
title : currentPortlet.type,
title : currentPortlet.title,//TODO
id : "portlet_" + currentPortlet.id,
closable: false,
dndType: 'Portlet',
@ -852,7 +906,7 @@ HAFlow.Main.prototype.calculateChartDivSize = function(reportId, currentPortlet,
HAFlow.Main.prototype.initChart = function(chart, currentPortlet, legendDivId){
this.chartMap[currentPortlet.id] = chart;
//var configurations
chart["title"] = currentPortlet.title;
chart["title"] = currentPortlet.chartTitle;
chart.titlePos = "bottom";
chart.titleGap = 25;
chart.titleFont = "normal normal normal 15pt Arial";
@ -886,6 +940,10 @@ HAFlow.Main.prototype.initChart = function(chart, currentPortlet, legendDivId){
}
obj[configuration.key] = realValue;
}
//this does not work because title is the property of chart not the plot
//obj["title"] = "ttttttttttttttt";
chart.addPlot("default", obj);//TODO
var legend;

View File

@ -1,148 +0,0 @@
dojo.require("dojox.widget.Portlet");
dojo.require("dojox.charting.Chart");
dojo.require("dojox.charting.plot2d.StackedAreas");
dojo.require("dojox.charting.themes.Wetland");
dojo.require("dojox.charting.themes.Julie");
dojo.require("dojox.charting.themes.Claro");
dojo.require("dojox.charting.axis2d.Default");
dojo.require("dojox.charting.plot2d.Columns");
dojo.require("dojo.fx.easing");
dojo.require("dojox.fx.scroll");
dojo.require("dijit.registry");
dojo.require("dojo.window");
dojo.require("dojox.charting.plot2d.Lines");
dojo.require("dojox.charting.plot2d.Markers");
dojo.require("dojox.charting.plot2d.Stacked");
dojo.require("dojox.charting.plot2d.Bars");
dojo.require("dojox.charting.plot2d.Columns");
dojo.require("dojox.charting.plot2d.Pie");
dojo.require("dojox.charting.plot2d.ClusteredBars");
dojo.require("dojox.charting.axis2d.Default");
dojo.require("dojox/charting/action2d/Tooltip");
dojo.require("dojox.layout.GridContainer");
dojo.require("dojox.charting.widget.Legend");
dojo.require("dojo.topic");
dojo.require("dojo.dnd.Source");
dojo.require("dojo.dnd.Mover");
dojo.require("dojox.layout.FloatingPane");
dojo.require("dojo.dnd.Source");
dojo.require("dojo.dnd.Moveable");
dojo.require("dojo.dom");
dojo.require("dojo.on");
dojo.require("dojox.layout.ResizeHandle");
//dojo.require("dojo.resize.stop");
HAFlow.Main.prototype.newFloatReport5 = function(parentId) {
var _currentInstance = this;
var reportId = HAFlow.generateUUID();
var contentPane = dijit.byId("reportFloatContainerPane_" + reportId);//mush be dijit.byId
if( contentPane == null){
var reportFloatContainerInnerPaneId = "reportFloatContainerInnerPane_"+ reportId;
contentPane = new dijit.layout.ContentPane({//stable
id : "reportFloatContainerPane_" + reportId,
title : "test",
content : "<div class='reportcontainerdiv'>" + "<div id='tttt' style='width:400px; height:700px;background-color: red;'></div>" + "</div>",
// content : "<div class='reportfloatcontainerdiv' style='width: 900px;height: 978px;'>" + //width: 900px;height: 978px;
// "<div id='"+ reportFloatContainerDivId + "'></div>" +
// "</div>",
closable : true,
});
contentPane.startup();
this.ui.centerContainer.addChild(contentPane);
var innerContentPane = new dijit.layout.ContentPane({
id: reportFloatContainerInnerPaneId,
style: 'width:100%; height:100%; background-color: blue;',
}, "tttt");
//start test portlet
var dummyPortletId = "dummy_portlet_id_" + reportId;
var portlet1 = dojox.widget.Portlet({
id: dummyPortletId,
closable: false,
dndType: 'Portlet',
title: 'Sample portlet',
content: "<div id='chartchart'></div>",//dummyPortlet,
style: 'width:200px;',//height is auto fit
});
var handle = new dojox.layout.ResizeHandle({
id: "ddddd",
targetId : dummyPortletId
}).placeAt(dummyPortletId);
// dojo.place("ddddd", dummyPortletId);
handle.startup();
portlet1.startup();
innerContentPane.addChild(portlet1);
var dnd = new dojo.dnd.Moveable(dojo.byId(dummyPortletId));//dnd
var dummyPortletId2 = "dummy_portlet_id2_" + reportId;
var portlet2 = dojox.widget.Portlet({
id: dummyPortletId2,
closable: false,
dndType: 'Portlet',
title: 'Sample portlet',
content: "<div id='chartchart2' style='width:180px; height:140px; background-color: red;'>abc</div>",//dummyPortlet,
style: 'width:200px;',
});
portlet2.startup();
innerContentPane.addChild(portlet2);
var handleDiv = document.createElement('div');
// dojo.byId(dummyPortletId2).appendChild(handleDiv);
var handle2 = new dojox.layout.ResizeHandle({
targetId : dummyPortletId2,
activeResize: true,
// style: "bottom:4px; right:4px;",
}).placeAt('chartchart2',"after"); //, handleDiv
handle2.startup();
// handle2.buildRendering();
//portlet2.addChild(handle2);
var dnd2 = new dojo.dnd.Moveable(dojo.byId(dummyPortletId2));//dnd
// dojo.connect(dnd2, "onMoveStop", function(e){ });
var chart = new dojox.charting.Chart("chartchart").
addAxis("y", {fixLower: "minor", fixUpper: "minor", natural: true}).
addAxis("x", {vertical: true, fixLower: "major", fixUpper: "major", includeZero: true}).
addPlot("default", {type: "ClusteredBars", gap: 5}).
addSeries("Series A", [0.53, 0.51]).
addSeries("Series B", [0.84, 0.79]).
addSeries("Series C", [0.68, 0.95]).
addSeries("Series D", [0.77, 0.66]);
chart.render();
chart.resize(180, 140);
dojo.subscribe("/dojo/resize/stop", function(inst) {
// inst.targetDomNode is the node resized.
// sometimes there will be a inst.targetWidget. inst is the
// ResizeHandle instance.
// var pp = portlet1;
_currentInstance.addToConsole("portlet2.domNode.offsetWidth:"
+ portlet1.domNode.offsetWidth
+ " portlet2.domNode.offsetHeight:"
+ portlet1.domNode.offsetHeight, false); // the new size
_currentInstance.addToConsole("inst.targetDomNode.offsetWidth:"
+ inst.targetDomNode.offsetWidth
+ " inst.targetDomNode.offsetHeight:"
+ inst.targetDomNode.offsetHeight, false);// the new size
// _currentInstance.addToConsole("portlet2.size.w:" + portlet1._size.w
// + " portlet2.size.h:" + portlet1._size.h, false);// the original size
_currentInstance.addToConsole("inst.startSize.w:"
+ inst.startSize.w + " inst.startSize.h:"
+ inst.startSize.h, false);// the original size
var newHeight = inst.targetDomNode.offsetHeight;
var newWidth = inst.targetDomNode.offsetWidth;
// portlet2.resize({w:newWidth, h:newHeight});// not work
chart.resize(newWidth * 0.9, newHeight * 0.9 - 10);
_currentInstance.addToConsole("newWidth:" + newWidth
+ " newHeight:" + newHeight, false);// the original size
});
}else{
// this.ui.centerContainer.selectChild(contentPane); //todo
}
this.ui.centerContainer.selectChild(contentPane); //todo
};

View File

@ -60,6 +60,7 @@ HAFlow.Main.prototype.fillReportsData = function(data) {
this.reports[reportItemId].panelType = reportItem.panelType;//TODO
this.reports[reportItemId].parentid = reportItem.parentid;
this.reports[reportItemId].portlets = new Array();
this.reports[reportItemId].chartTitle = reportItem.chartTitle;
var portlets = reportItem.portlets;
for( var j = 0; j < portlets.length; j++){