]>
git.argeo.org Git - gpl/argeo-slc.git/blob - TreeView.js
233c316d941b04937b9cfb228ca57e1ee3860191
1 qx
.Class
.define("org.argeo.jcr.ria.views.TreeView", {
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.
13 label
: "Zoom To Node",
14 icon
: "org.argeo.slc.ria/media-playback-start.png",
19 callback : function(e
) {
20 var selection
= this.tree
.getSelection();
21 if(!selection
.length
) return;
22 var path
= selection
[0].getJcrNode().getPath();
23 this.getDataModel().requireContextChange(path
);
25 selectionChange : function(viewId
, selection
){
26 if(viewId
!= "treeview") return;
27 if(!selection
|| !selection
.length
) return;
28 var treeNode
= selection
[0];
29 if(treeNode
.getParent()!=null){
30 this.setEnabled(true);
32 this.setEnabled(false);
38 icon
: "org.argeo.slc.ria/media-playback-start.png",
44 callback : function(e
) {
46 submenuCallback : function(commandId
){
47 this.getDataModel().requireContextChange(commandId
);
49 selectionChange : function(viewId
, selection
){
50 if(viewId
!= "treeview") return;
51 if(!selection
|| !selection
.length
) return;
52 var treeNode
= selection
[0];
53 if(treeNode
.getParent()!=null || treeNode
.getJcrNode().itemIsRoot()){
54 this.setEnabled(false);
57 this.setEnabled(true);
58 var nodePath
= treeNode
.getJcrNode().getPath();
59 var parts
= nodePath
.split("\/");
63 for(var i
=0;i
<parts
.length
;i
++){
64 var newPath
= parts
.join("/");
65 pathes
.push({label
:newPath
,icon
:'', commandId
:newPath
});
76 check
:"org.argeo.ria.components.ViewSelection"
80 event
: "changeInstanceId"
84 event
: "changeInstanceLabel"
91 construct : function(){
97 * The implementation should contain the GUI initialisation.
98 * This is the role of the manager to actually add the graphical component to the pane,
99 * so it's not necessary to do it here.
100 * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager
101 * @param data {Mixed} Any object or data passed by the initiator of the view
104 init : function(viewPane
, dataModel
){
105 this.setViewSelection(new org
.argeo
.ria
.components
.ViewSelection(viewPane
.getViewId()));
106 this.setLayout(new qx
.ui
.layout
.VBox());
107 this.setDataModel(dataModel
);
109 this.tree
= new qx
.ui
.tree
.Tree();
110 this.add(this.tree
, {flex
:1});
113 * The implementation should contain the real data loading (i.o. query...)
117 var dataModel
= this.getDataModel();
118 dataModel
.addListener("changeContextNode", function(event
){
119 var contextNode
= event
.getData();
120 var loader = function(){};
121 var newRoot
= new org
.argeo
.jcr
.ria
.views
.JcrTreeFolder(contextNode
);
122 this.tree
.setRoot(newRoot
);
123 this.tree
.setSelection([newRoot
]);
125 this.tree
.addListener("changeSelection", function(e
){
126 var sel
= this.tree
.getSelection();
128 var viewSelection
= this.getViewSelection();
129 viewSelection
.clear();
130 for(var i
=0;i
<sel
.length
;i
++){
131 selection
.push(sel
[i
].getJcrNode());
132 viewSelection
.addNode(sel
[i
]);
134 this.getDataModel().setSelection(selection
);
136 this.tree
.setContextMenu(org
.argeo
.ria
.event
.CommandsManager
137 .getInstance().createMenuFromIds(["zoom_in", "zoom_out"]));
141 * Whether this component is already contained in a scroller (return false) or not (return true).
144 addScroll : function(){
148 * Called at destruction time
149 * Perform all the clean operations (stopping polling queries, etc.)