
| Current Path : /var/www/web-klick.de/dsh/50_dev2017/1300__perllib/AutoQX/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/50_dev2017/1300__perllib/AutoQX/RequViewControl.js |
/* ************************************************************************
Copyright:
License:
Authors:
************************************************************************ */
/* ************************************************************************
#asset(autotest/*)
************************************************************************ */
/**
* This class defines the logic needed for the requirement view.
*/
qx.Class.define("autotest.RequViewControl", {
extend : qx.application.Standalone,
/**
* The constructor handles the initializations for every requirement screen
*
* @param requirement_screen - a qooxdoo container for the requirement tree etc
* @param rpc_url - a string containing the rpc url
* @param rpc_service - a string containing the rpc service (method to call)
*/
construct : function(requirement_screen, rpc_url, rpc_service, testTreeCtr, tabView,dataManager,rpcManager) {
this.base(arguments); // Call super class
qx.Class.include(qx.ui.treevirtual.TreeVirtual,qx.ui.treevirtual.MNode); // include treevirtual mixin for the requirement tree
// define given parameters as global for future reference
this.dataManager = dataManager;
this.rpcManager = rpcManager;
this.requirement_screen = requirement_screen;
this.testTreeCtr = testTreeCtr;
this.tabView = tabView;
},
members : {
/**
* initialization function which will be called each time the whole requirement
* screen needs to be reloaded (i.e. when another project is selected)
*
* @param requTree_path - a string containing the requTree path in the backend
* @param testproject_name - a string containing the name of the project
*/
init : function(requTree_path,testproject_name) {
this.info("init(): called init with params: ",requTree_path,testproject_name);
//setup of the requirement screen container
this.requirement_screen.removeAll();
this.requirement_screen.setLayout (new qx.ui.layout.Canvas());
this.akt_requTree_path = requTree_path;
this.requTree=null;
this.dataManager.bindRequTreeToData(this.akt_requTree_path,this.onDataChanged,this);
},
getCellStyle : function(cellInfo){
var rgb = "rba(0,0,0,0)";
if (!cellInfo.rowData || !cellInfo.rowData[0].color){
this.error("TableRenderer (Requireview): getBackgroundColor: invalid data for computing color");
}
else if (cellInfo.rowData[0].color.length >= cellInfo.col && cellInfo.col>0){
var color = cellInfo.rowData[0].color[cellInfo.col-1];
if (color)
rgb = "rgb("+Math.round(color[0]*0.9)+","+Math.round(color[1]*0.9)+","+Math.round(color[2]*0.9)+")";
}
return "background-color: "+rgb+";";
},
/**
* called every time the datamanager has gotten new data
* tree is rebuilt because architectures might have changed
* (treevirtual doesnt allow adding new columns for architectures dynamically)
* @param data the new data for the tree
*/
onDataChanged : function(data) {
//clone old node states
if (this.requTree){
var oldNodes = this.requTree.getDataModel()._nodeArr;
for (var nodeId in data) {
if (oldNodes[nodeId]) {
data[nodeId].bSelected = oldNodes[nodeId].bSelected;
data[nodeId].bOpened = oldNodes[nodeId].bOpened;
}
}
}
//create new tree if number of columns changed
if (!this.requTree || this.requTree.getDataModel().getColumnCount() !== data.columns.length){
this.requTree = new qx.ui.treevirtual.TreeVirtual(data.columns).set({rowHeight:20});
for (var i=1;i<data.columns.length;i++)
this.requTree.getTableColumnModel().getDataCellRenderer(i)._getCellStyle = this.getCellStyle;
this.requirement_screen.add(this.requTree, {top:0,left:0,right:0,bottom:0});
this.requTree.addListener("dblclick",this.switchToTestTree, this);
this.requTree.addListener("mousemove", function(e){
this.requTree.mouseX = e.getDocumentLeft();
this.requTree.mouseY = e.getDocumentTop();
}, this);
this.bindRemarkPopupToTree(this.requTree);
}
//set node data to tree data model
this.datamodel = this.requTree.getDataModel();
this.datamodel.setColumns(data.columns);
this.datamodel.clearData();
this.datamodel._nodeArr = data;
this.datamodel.setData();
},
/**
* this part of the code overrides an internal function from the qooxdoo framework
* in order to enable popups with onmouseover without creating a new inheritance class
*/
bindRemarkPopupToTree : function(tree){
tree.setFocusedCell = function setFocusedCell(col, row, scrollVisible){
if (!this.isEditing() && (col != this.__focusedCol || row != this.__focusedRow)){
if (col === null) {col = 0;}
this.__focusedCol = col;
this.__focusedRow = row;
var scrollerArr = this._getPaneScrollerArr();
for (var i=0; i<scrollerArr.length; i++) {
scrollerArr[i].setFocusedCell(col, row);
//custom code begin
/**/ if (!this.popup) this.popup = new qx.ui.popup.Popup(new qx.ui.layout.Canvas()).set({backgroundColor: "#FFFAD3"});
/**/ if (col>0){
/**/ this.popup.removeAll();
/**/ var arch = this.getDataModel().getColumnName(col);
/**/ if (arch=="keine Architektur") arch="";
/**/ var remark = this.getDataModel().getNode(row).remark ? this.getDataModel().getNode(row).remark : "none";
/**/ this.popup.add(new qx.ui.basic.Label("Remark: "+remark));
/**/ this.popup.show();
/**/ this.popup.moveTo(this.mouseX+20,this.mouseY);
/**/ }
/**/ else this.popup.setVisibility("hidden");
//custom code end
}
if (col !== null && scrollVisible) this.scrollCellVisible(col, row);
}
};
},
/**
* is called when a testItem in the tree is expanded
* e.getData() contains the node (testItem) that was expanded
*/
createChildren : function(e) {
this.node = e.getData();
this.parent = this.node.nodeId;
this.testItem = this.node.label;
this.info("createChildren: rpc call async for ", this.testItem);
try {
this.info("createChildren: sending rpc call with params: " ,"report",this.akt_requTree_path,this.node.columnData[this.columnLocations["itemPath"]],"1",":");
this.rpc_call(qx.lang.Function.bind(this.appendChildren,this),"report",this.akt_requTree_path,this.node.columnData[this.columnLocations["itemPath"]],"1",":");
} catch(exc) {
this.error("createChildren: Exception during RPC call, please check your RPC call: " ,"report",this.akt_requTree_path,this.node.columnData[10],"1",":", "\n" + exc);
}
},
/**
* function for switching back to TestTree after double-clicking on an item
* @param e event data
*/
switchToTestTree : function(e){
var selectedNode = this.requTree.getSelectedNodes().shift();
var itemPath = selectedNode.nodeId.split("/");
itemPath.shift();
itemPath=itemPath.join("/");
var path = this.akt_requTree_path.split("/").pop() + (itemPath=="" ? "" : ("/"+ itemPath));
this.tabView.setSelection(this.tabView.getChildren()[0]);
this.testTreeCtr.selectItem(path);
},
disableUserInterface : function(){
if (this.requTree != null) this.requTree.setEnabled(false);
},
enableUserInterface : function(){
if (this.requTree != null) this.requTree.setEnabled(true);
},
//***********************************************************************************************
endofclass : null
} });