]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/monitor/DistListView.js
Add log4j for server JCR
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / monitor / DistListView.js
1 qx.Class.define("org.argeo.slc.ria.monitor.DistListView", {
2 extend : qx.ui.container.Composite,
3 implement : [org.argeo.ria.components.IView],
4
5 properties : {
6 /**
7 * The commands definition Map that will be automatically added and wired to the menubar and toolbar.
8 * See {@link org.argeo.ria.event.CommandsManager#definitions} for the keys to use for defining commands.
9 */
10 commands : {
11 init : {
12 "reload" : {
13 label : "Reload",
14 icon : "org.argeo.slc.ria/view-refresh.png",
15 shortcut : "control+h",
16 enabled : true,
17 menu : "Distributions",
18 toolbar : "list",
19 callback : function(e) {
20 this.load();
21 },
22 command : null
23 },
24 "uninstall" : {
25 label : "Uninstall",
26 icon : "org.argeo.slc.ria/window-close.png",
27 shortcut: null,
28 enabled : false,
29 menu : "Distributions",
30 toolbar : "list",
31 callback: function(e){
32 var selection = this.getViewSelection();
33 var node = selection.getNodes()[0];
34 var request = org.argeo.slc.ria.SlcApi.getUninstallModuleService(node[0], node[1]);
35 request.addListener("completed", this.load, this);
36 request.send();
37 },
38 selectionChange : function(viewId, selection){
39 if(viewId != "distrib") return;
40 this.setEnabled((selection!=null && selection.length==1));
41 },
42 command : null
43 }
44 }
45 },
46 viewSelection : {
47 nullable:false,
48 check:"org.argeo.ria.components.ViewSelection"
49 },
50 view : {
51 init : null
52 },
53 instanceId : {init:""},
54 instanceLabel : {init:""}
55 },
56
57 construct : function(){
58 this.base(arguments);
59 this.setLayout(new qx.ui.layout.Canvas());
60 this.xmlStub = '<slc:object-list xmlns:slc="http://argeo.org/projects/slc/schemas">' +
61 '<slc:modular-distribution-descriptor name="name" version="0.1.0">' +
62 '<slc:modulesDescriptors><slc:modulesDescriptor type="modularDistribution" url="http://localhost/modularDistribution" >toto</slc:modulesDescriptor>' +
63 '<slc:modulesDescriptor type="eclipse" url="http://localhost/updateSite" />' +
64 '</slc:modulesDescriptors></slc:modular-distribution-descriptor>' +
65 '<slc:modular-distribution-descriptor name="name2" version="0.1.1">' +
66 '<slc:modulesDescriptors><slc:modulesDescriptor type="modularDistribution" url="http://localhost/modularDistribution2" />' +
67 '<slc:modulesDescriptor type="eclipse" url="http://localhost/updateSite2" />' +
68 '</slc:modulesDescriptors></slc:modular-distribution-descriptor>' +
69 '</slc:object-list>';
70 },
71
72 members : {
73 /**
74 * The implementation should contain the GUI initialisation.
75 * This is the role of the manager to actually add the graphical component to the pane,
76 * so it's not necessary to do it here.
77 * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager
78 * @param data {Mixed} Any object or data passed by the initiator of the view
79 * @return {Boolean}
80 */
81 init : function(viewPane, data){
82 this.setView(viewPane);
83 this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId()));
84 this.tableModel = new qx.ui.table.model.Simple();
85 this.tableModel.setColumns(["Name", "Version", "Modular Distribution", "Eclipse Update Site"], ["name","version","modularDistribution","eclipse"]);
86 this.list = new qx.ui.table.Table(this.tableModel, {
87 tableColumnModel: function(obj){
88 return new qx.ui.table.columnmodel.Resize(obj)
89 }
90 });
91 this.list.set({
92 decorator:null,
93 statusBarVisible : false
94 });
95 this.tableModel.setColumnEditable(2, true);
96 this.tableModel.setColumnEditable(3, true);
97 var columnModel = this.list.getTableColumnModel();
98 columnModel.getBehavior().setWidth(0, "15%");
99 columnModel.getBehavior().setWidth(1, "15%");
100 columnModel.getBehavior().setWidth(2, "35%");
101 columnModel.getBehavior().setWidth(3, "35%");
102 var factory = function(cellInfo){
103 var tField = new qx.ui.table.celleditor.TextField();
104 tField.setValidationFunction(function(newValue, oldValue){return oldValue;});
105 return tField;
106 };
107 columnModel.setCellEditorFactory(2, new qx.ui.table.celleditor.Dynamic(factory));
108 columnModel.setCellEditorFactory(3, new qx.ui.table.celleditor.Dynamic(factory));
109
110 var selectionModel = this.list.getSelectionModel();
111 selectionModel.addListener("changeSelection", function(e){
112 var viewSelection = this.getViewSelection();
113 viewSelection.clear();
114 selectionModel.iterateSelection(function(index){
115 viewSelection.addNode(this.tableModel.getRowData(index));
116 }, this);
117 }, this);
118
119 this.add(this.list, {top:0,left:0,width:'100%',height:'100%'});
120 },
121 /**
122 * The implementation should contain the real data loading (i.o. query...)
123 * @return {Boolean}
124 */
125 load : function(){
126 this.tableModel.setData([]);
127 var req = org.argeo.slc.ria.SlcApi.getListModularDistributionsService();
128 req.addListener("completed", function(response){
129 this.parseData(response.getContent());
130 }, this);
131 req.addListener("failed", function(){
132 var xmlDoc = qx.xml.Document.fromString(this.xmlStub);
133 this.parseData(xmlDoc);
134 }, this);
135 req.send();
136 },
137
138 parseData : function(xmlDoc){
139 var data = [];
140 var descriptorPath = 'slc:object-list/slc:modular-distribution-descriptor';
141 var namePath = '@name';
142 var versionPath = '@version';
143 var distribPath = 'slc:modulesDescriptors/slc:modulesDescriptor[@type="modularDistribution"]/@url';
144 var eclipsePath = 'slc:modulesDescriptors/slc:modulesDescriptor[@type="eclipse"]/@url';
145 var nodes = org.argeo.ria.util.Element.selectNodes(xmlDoc, descriptorPath);
146 for(var i=0;i<nodes.length;i++){
147 var name = org.argeo.ria.util.Element.getSingleNodeText(nodes[i], namePath);
148 var version = org.argeo.ria.util.Element.getSingleNodeText(nodes[i], versionPath);
149 var distrib = org.argeo.ria.util.Element.getSingleNodeText(nodes[i], distribPath);
150 var eclipse = org.argeo.ria.util.Element.getSingleNodeText(nodes[i], eclipsePath);
151 data.push([name,version,distrib,eclipse]);
152 }
153 this.tableModel.setData(data);
154 },
155
156 /**
157 * Whether this component is already contained in a scroller (return false) or not (return true).
158 * @return {Boolean}
159 */
160 addScroll : function(){return true;},
161 /**
162 * Called at destruction time
163 * Perform all the clean operations (stopping polling queries, etc.)
164 */
165 close : function(){return true;}
166 }
167 });