]>
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
1 qx
.Class
.define("org.argeo.slc.ria.monitor.DistListView", {
2 extend
: qx
.ui
.container
.Composite
,
3 implement
: [org
.argeo
.ria
.components
.IView
],
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.
14 icon
: "org.argeo.slc.ria/view-refresh.png",
15 shortcut
: "control+h",
17 menu
: "Distributions",
19 callback : function(e
) {
26 icon
: "org.argeo.slc.ria/window-close.png",
29 menu
: "Distributions",
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);
38 selectionChange : function(viewId
, selection
){
39 if(viewId
!= "distrib") return;
40 this.setEnabled((selection
!=null && selection
.length
==1));
48 check
:"org.argeo.ria.components.ViewSelection"
53 instanceId
: {init
:""},
54 instanceLabel
: {init
:""}
57 construct : function(){
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>' +
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
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
)
93 statusBarVisible
: false
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
;});
107 columnModel
.setCellEditorFactory(2, new qx
.ui
.table
.celleditor
.Dynamic(factory
));
108 columnModel
.setCellEditorFactory(3, new qx
.ui
.table
.celleditor
.Dynamic(factory
));
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
));
119 this.add(this.list
, {top
:0,left
:0,width
:'100%',height
:'100%'});
122 * The implementation should contain the real data loading (i.o. query...)
126 this.tableModel
.setData([]);
127 var req
= org
.argeo
.slc
.ria
.SlcApi
.getListModularDistributionsService();
128 req
.addListener("completed", function(response
){
129 this.parseData(response
.getContent());
131 req
.addListener("failed", function(){
132 var xmlDoc
= qx
.xml
.Document
.fromString(this.xmlStub
);
133 this.parseData(xmlDoc
);
138 parseData : function(xmlDoc
){
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
]);
153 this.tableModel
.setData(data
);
157 * Whether this component is already contained in a scroller (return false) or not (return true).
160 addScroll : function(){return true;},
162 * Called at destruction time
163 * Perform all the clean operations (stopping polling queries, etc.)
165 close : function(){return true;}