
| Current Path : /var/www/web-klick.de/dsh/90_akt/DEV1303/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/90_akt/DEV1303/AutoQX/ArchControl.js |
/*
Copyright:
License:
Authors:
*/
/*
#asset(autotest/*)
*/
/**
* This class defines the logic needed for the TestTree
*/
qx.Class.define("autotest.ArchControl", {
extend : qx.application.Standalone,
/**
* The constructor handles the initializations for every testtree screen
*
* @param settings_screen - a qooxdoo container for the testtree etc
* @param rpc_url - a string containing the rpc url
* @param rpc_service - a string containing the rpc service (method to call)
*/
construct : function(parent) { // Call super class
this.base(arguments);
this.parent = parent;
this.arch_screen = parent.arch_screen;
this.rpc = new qx.io.remote.Rpc().set({url:parent.rpc_url,serviceName:parent.rpc_service});
this.tabView = parent.tabView;
this.rpcMutex = false;
this.parents = {};
},
members : {
// Label formats:
f_big : {font: qx.bom.Font.fromString("18px sans-serif")},
f_normal : {font: qx.bom.Font.fromString("13px sans-serif")},
/**
* initialization method for the architectures screen
* clears the screen and sets layouts
* @param architectures - a qx.data.Array containing the architectures
*/
init : function (arch_data, testTree, arch_descr) {
this.arch_data=arch_data;
this.testTree = testTree;
this.arch_screen.setLayout (new qx.ui.layout.VBox(20));
this.arch_screen.removeAll();
this.splitpane = new qx.ui.splitpane.Pane("horizontal");
this.archName = new qx.ui.form.TextField("");
this.archDescr = new qx.ui.form.TextArea("").set({height:200,width:450});
// Creates the list and configures it
var leftContainer = new qx.ui.container.Composite(new qx.ui.layout.Canvas()).set({width:400});
var rightContainer = new qx.ui.container.Composite(new qx.ui.layout.Canvas());
this.archList = new qx.ui.form.List().set({
selectionMode : "single",
height: 400,
width: 300
});
var archLabel = new qx.ui.basic.Label("Architectures:")
this.archList.addListener("changeSelection",this.archSelChanged,this);
var infoLabel = new qx.ui.basic.Label("Right click to add or remove architectures")
leftContainer.add(archLabel,{left:'5%',top:40});
leftContainer.add(this.archList,{left:'5%',top:70});
leftContainer.add(infoLabel,{left:'5%',top:480});
var menu = new qx.ui.menu.Menu();
var addBtn = new qx.ui.menu.Button("add new architecture");
addBtn.addListener("execute",this.showAddArchForm,this);
menu.add(addBtn);
this.archList.setContextMenu(menu);
var descrLabel = new qx.ui.basic.Label("Description:").set({allowGrowY: true, rich: true});
this.descrArea = new qx.ui.form.TextArea("").set({readOnly:false,height:400, width:400});
this.descrArea.addListener("input",function(e){this.saveBtn.setVisibility("visible")},this);
this.saveBtn = new qx.ui.form.Button("save Changes");
this.saveBtn.addListener("execute",this.updateArch,this);
this.saveBtn.setVisibility("hidden");
rightContainer.add(descrLabel,{left:'5%',top:40});
rightContainer.add(this.descrArea,{left:'5%',top:70});
rightContainer.add(this.saveBtn,{left:'5%',top:480});
this.splitpane.add(leftContainer,0);
this.splitpane.add(rightContainer,1);
this.arch_screen.add(this.splitpane);
this.updateArchList(arch_data);
this.addArchWindow = new qx.ui.window.Window("Please fill out name and description for the new architecture").set({
showMinimize:false, showMaximize:false, showClose:false, width:500, height:400});
},
showAddArchForm : function (){
this.tabView.setEnabled(false);
this.addArchWindow.setLayout(new qx.ui.layout.Canvas());
var nameLabel = new qx.ui.basic.Label("Name:");
this.archName = new qx.ui.form.TextField("");
var descrLabel = new qx.ui.basic.Label("Description:");
this.archDescr = new qx.ui.form.TextArea("").set({height:200,width:450});
var submBtn = new qx.ui.form.Button("Submit");
submBtn.addListener("execute", this.addArch,this);
var cancelBtn = new qx.ui.form.Button("Cancel");
cancelBtn.addListener("execute", function(){this.addArchWindow.close();this.tabView.setEnabled(true);},this);
this.addArchWindow.add(nameLabel,{top:10,left:10});
this.addArchWindow.add(this.archName, {top:30,left:10});
this.addArchWindow.add(descrLabel, {top:60,left:10});
this.addArchWindow.add(this.archDescr,{top:90,left:10});
this.addArchWindow.add(cancelBtn, {top:310,left:10});
this.addArchWindow.add(submBtn, {top:310,right:10});
this.addArchWindow.center();
this.addArchWindow.open();
},
updateArchList : function(arch_data,exc){
this.arch_data=arch_data;
if (exc){
this.error("updateArchList: recieved backend error: "+exc);
}
this.info("updateArchList: got result: ",arch_data);
this.tabView.setEnabled(true);
this.rpcMutex = false;
this.parent.loginInfo.archSelection.removeAll();
this.archList.removeAll();
for(i in arch_data){
var item = new qx.ui.form.ListItem(i);
this.setContextMenu(item);
this.archList.add(item);
this.parent.loginInfo.archSelection.add(new qx.ui.form.ListItem(i));
};
this.saveBtn.setVisibility("hidden");
if (this.archList.getSelection().length>0){
this.archDescr.setValue(arch_data[this.archList.getSelection()[0].getLabel()]);
}else{ this.archDescr.setValue("");}
},
addArch : function(){
var architecture = this.archName.getValue();
var description = this.archDescr.getValue();
if (architecture==""){
alert("Please enter a valid name for the new architecture");
return;
}
if (description==""){
alert("Please enter a valid description for the new architecture");
return;
}
this.addArchWindow.close();
this.tabView.setEnabled(true);
this.rpc_call([qx.lang.Function.bind(this.updateArchList,this),"architectures",
this.testTree, architecture,description]);
},
updateArch : function(){
if (this.selected && this.descrArea){
this.archName.setValue(this.selected);
this.archDescr.setValue(this.descrArea.getValue());
this.addArch();
}
},
deleteArch : function(e){
var archLabel = this.archList.getSelection()[0];
if (archLabel){
this.rpc_call([qx.lang.Function.bind(this.updateArchList,this),"architectures",
this.testTree, archLabel.getLabel(),"___DELETE___"]);
}
},
archSelChanged : function (e){
var data = e.getData()[0];
if (data){
this.descrArea.setValue(this.arch_data[data.getLabel()]);
this.selected=data.getLabel();
this.saveBtn.setVisibility("hidden");
}
},
setContextMenu : function(widget){
var menu = new qx.ui.menu.Menu();
var deleteBtn = new qx.ui.menu.Button("delete");
deleteBtn.addListener("execute", this.deleteArch,this);
var addBtn = new qx.ui.menu.Button("add new architecture");
addBtn.addListener("execute",this.showAddArchForm,this);
menu.add(addBtn);
menu.add(deleteBtn);
widget.setContextMenu(menu);
},
/**
* handles all rpc calls
* @param params - contains all necessary parameters for the rpc call:
* <li> the return function for the rpc result
* <li> the name of the function to call
* <li> a maximum of 3 parameters for the target function
*/
rpc_call : function(params){
if (this.rpcMutex==true){
this.info("rpc_call: rpc mutex is reserverd, trying again in 100ms");
setTimeout(qx.lang.Function.bind(function(){this.rpc_call(params);},this), 100);
return;
}
if (params.length>5){
this.error("rpc_call(): rpc params has a length > 5!");
}
try {
this.info("rpc_call(): sending rpc call with params:", params);
this.rpcMutex=true;
this.tabView.setEnabled(false);
switch(params.length){
case 1:
this.rpc.callAsync(params[0]);
break;
case 2:
this.rpc.callAsync(params[0],params[1]);
break;
case 3:
this.rpc.callAsync(params[0],params[1],params[2]);
break;
case 4:
this.rpc.callAsync(params[0],params[1],params[2],params[3])
break;
case 5:
this.rpc.callAsync(params[0],params[1],params[2],params[3],params[4])
break;
}
} catch(exc) {
this.error("Exception during RPC call: ", exc);
this.tabView.setEnabled(true);
this.rpcMutex=false;
}
},
/**
* handles all rpc returns where no special action is needed
* @param result
* @param exc
*/
rpc_return : function(result, exc) {
this.info("rcp_return: got result: ",result);
this.tabView.setEnabled(true);
this.rpcMutex = false;
},
endofclass : null } });