]>
git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/jcr/class/org/argeo/jcr/ria/views/TreeView.js
1dff09f3749ac81a85828d2f142f113bf7d17af7
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 var initLength
= parts
.length
;
64 for(var i
=0;i
<initLength
;i
++){
65 var newPath
= parts
.join("/");
66 pathes
.push({label
:newPath
,icon
:'', commandId
:newPath
});
75 icon
: "org.argeo.slc.ria/media-playback-start.png",
79 toolbar
: "selection",
80 callback : function(e
) {
81 var selection
= this.tree
.getSelection();
82 if(!selection
.length
) return;
83 var jcrNode
= selection
[0].getJcrNode();
84 var viewsManager
= org
.argeo
.ria
.components
.ViewsManager
.getInstance();
85 var testView
= viewsManager
.initIViewClass(org
.argeo
.jcr
.ria
.views
.PlainXmlViewer
, "editor", jcrNode
);
86 testView
.load(jcrNode
);
89 selectionChange : function(viewId
, selection
){
97 check
:"org.argeo.ria.components.ViewSelection"
101 event
: "changeInstanceId"
105 event
: "changeInstanceLabel"
112 construct : function(){
113 this.base(arguments
);
118 * The implementation should contain the GUI initialisation.
119 * This is the role of the manager to actually add the graphical component to the pane,
120 * so it's not necessary to do it here.
121 * @param viewPane {org.argeo.ria.components.ViewPane} The pane manager
122 * @param data {Mixed} Any object or data passed by the initiator of the view
125 init : function(viewPane
, dataModel
){
126 this.setViewSelection(new org
.argeo
.ria
.components
.ViewSelection(viewPane
.getViewId()));
127 this.setLayout(new qx
.ui
.layout
.VBox());
128 this.setDataModel(dataModel
);
130 this.tree
= new qx
.ui
.tree
.Tree();
131 this.add(this.tree
, {flex
:1});
134 * The implementation should contain the real data loading (i.o. query...)
138 var dataModel
= this.getDataModel();
139 dataModel
.addListener("changeContextNode", function(event
){
140 var contextNode
= event
.getData();
141 var newRoot
= new org
.argeo
.jcr
.ria
.views
.JcrTreeFolder(contextNode
);
142 this.tree
.setRoot(newRoot
);
143 this.tree
.setSelection([newRoot
]);
145 this.tree
.addListener("changeSelection", function(e
){
146 var sel
= this.tree
.getSelection();
148 var viewSelection
= this.getViewSelection();
149 viewSelection
.clear();
150 for(var i
=0;i
<sel
.length
;i
++){
151 selection
.push(sel
[i
].getJcrNode());
152 viewSelection
.addNode(sel
[i
]);
154 this.getDataModel().setSelectionWithSource(selection
, this);
156 dataModel
.addListener("changeSelection", function(e
){
157 if(this.getDataModel().getSelectionSource() == this) return;
158 var selection
= this.getDataModel().getSelection();
159 // Arbitrary : for the moment, external select can only apply
160 // to children of the current selection
161 var crtSel
= this.tree
.getSelection();
162 if(!crtSel
.length
|| !selection
.length
) return;
163 var crtTreeSel
= crtSel
[0];
164 if(selection
[0].getParent() && crtTreeSel
.getJcrNode().getPath() == selection
[0].getParent().getPath()){
165 crtTreeSel
.setOpen(true);
166 var crtChildren
=crtTreeSel
.getChildren();
167 for(var i
=0;i
<crtChildren
.length
;i
++){
168 if(crtChildren
[i
].getJcrNode().getPath() == selection
[0].getPath()){
169 this.tree
.setSelection([crtChildren
[i
]]);
173 }else if(crtTreeSel
.getParent() && crtTreeSel
.getJcrNode().getParent().getPath() == selection
[0].getPath()){
174 this.tree
.setSelection([crtTreeSel
.getParent()]);
178 this.tree
.setContextMenu(org
.argeo
.ria
.event
.CommandsManager
179 .getInstance().createMenuFromIds(["open", "zoom_in", "zoom_out"]));
183 * Whether this component is already contained in a scroller (return false) or not (return true).
186 addScroll : function(){
190 * Called at destruction time
191 * Perform all the clean operations (stopping polling queries, etc.)