]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcExecLoggerApplet.js
New icons for the tree
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / SlcExecLoggerApplet.js
1 /**
2 * A simple Hello World applet for documentation purpose.
3 * The only associated command is the "Close" command.
4 */
5 qx.Class.define("org.argeo.slc.ria.SlcExecLoggerApplet",
6 {
7 extend : qx.ui.container.Composite,
8 implement : [org.argeo.ria.components.IView],
9
10 construct : function(){
11 this.base(arguments);
12 this.setLayout(new qx.ui.layout.Dock());
13 },
14
15 properties :
16 {
17 /**
18 * The viewPane inside which this applet is added.
19 */
20 view : {
21 init : null
22 },
23 viewSelection : {
24 nullable:false,
25 check:"org.argeo.ria.components.ViewSelection"
26 },
27 instanceId : {init:""},
28 instanceLabel : {init:""},
29 /**
30 * Commands definition, see {@link org.argeo.ria.event.CommandsManager#definitions}
31 */
32 commands : {
33 init : {
34 "reloadlogs" : {
35 label : "Reload Logs",
36 icon : "org.argeo.slc.ria/view-refresh.png",
37 shortcut : "Control+r",
38 enabled : true,
39 menu : null,
40 toolbar : null,
41 callback : function(e){
42 this._reloadLogger();
43 },
44 command : null
45 }
46 }
47 }
48 },
49
50 members :
51 {
52 /**
53 * Called at applet creation. Just registers viewPane.
54 * @param viewPane {org.argeo.ria.components.ViewPane} The viewPane.
55 */
56 init : function(viewPane){
57 this.setView(viewPane);
58 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
59 this._createLayout();
60 this.UIBus = org.argeo.ria.event.UIBus.getInstance();
61 },
62
63 /**
64 *
65 */
66 load : function(){
67 this._reloadLogger();
68 this.UIBus.addListener("newSlcExecution", this._reloadLogger, this);
69 this.UIBus.addListener("updateSlcExecutionStatus", this._reloadLogger, this);
70 },
71
72 addScroll : function(){
73 return false;
74 },
75
76 close : function(){
77 this.UIBus.removeListener("newSlcExecution", this._reloadLogger, this);
78 this.UIBus.removeListener("updateSlcExecutionStatus", this._reloadLogger, this);
79 },
80
81 /**
82 * Creates the applet layout
83 */
84 _createLayout : function(){
85 this.logModel = new qx.ui.table.model.Simple();
86 this.logModel.setColumns(["Date", "Host", "Id", "Status"]);
87 this.logPane = new qx.ui.table.Table(this.logModel, {
88 tableColumnModel: function(obj){
89 return new qx.ui.table.columnmodel.Resize(obj)
90 }
91 });
92 this.logPane.setDecorator(null);
93 this._initLogger();
94 this.add(this.logPane, {edge:'center'});
95 },
96
97 /**
98 * Initialize the log table.
99 */
100 _initLogger : function(){
101 this.logPane.set({
102 statusBarVisible: false,
103 showCellFocusIndicator:false
104 });
105 var columnModel = this.logPane.getTableColumnModel();
106 columnModel.getBehavior().setWidth(0, "30%");
107 columnModel.getBehavior().setWidth(1, "15%");
108 columnModel.getBehavior().setWidth(3, "12%");
109 },
110
111 /**
112 * Refresh the data model.
113 */
114 _reloadLogger : function(){
115 var request = org.argeo.slc.ria.SlcApi.getListSlcExecutionsService();
116 request.addListener("completed", function(response){
117 var messages = org.argeo.ria.util.Element.selectNodes(response.getContent(), "//slc:slc-execution");
118 this.logModel.setData([]);
119 for(var i=0;i<messages.length;i++){
120 var message = messages[i];
121 var slcExec = new org.argeo.slc.ria.SlcExecutionMessage(message.getAttribute("uuid"));
122 slcExec.fromXml(message);
123 this.logModel.addRows([
124 [slcExec.getDate(), slcExec.getHost(), slcExec.getUuid(), slcExec.getStatus()]
125 ]);
126 }
127 }, this);
128 request.send();
129 }
130
131 }
132 });