|
1 |
|
|
2 |
Ext.namespace('sitools.user.view.modules.datasetExplorerOchart');
|
|
3 |
Ext.define('sitools.user.view.modules.datasetExplorerOchart.OChart',{
|
|
4 |
extend: 'Ext.Component',
|
|
5 |
alias: 'widget.ochart',
|
|
6 |
itemId: 'ochart',
|
|
7 |
requires:[
|
|
8 |
'Ext.LoadMask',
|
|
9 |
'Ext.data.StoreManager',
|
|
10 |
'Ext.dom.Query',
|
|
11 |
'sitools.user.view.modules.datasetExplorerOchart.OChartModel',
|
|
12 |
'Ext.dd.ScrollManager'
|
|
13 |
],
|
|
14 |
|
|
15 |
mixins:{
|
|
16 |
bindable: 'Ext.util.Bindable'
|
|
17 |
},
|
|
18 |
|
|
19 |
baseCls: Ext.baseCSSPrefix + 'ochart',
|
|
20 |
|
|
21 |
/**
|
|
22 |
* In some places it's need to render full tables because <IE9 have some bugs and makes tr and table readonly
|
|
23 |
* @private
|
|
24 |
*/
|
|
25 |
renderBuffer: document.createElement('div'),
|
|
26 |
|
|
27 |
/**
|
|
28 |
* @cfg {Boolean} rootVisible=true true to include the root node in the chart.
|
|
29 |
*/
|
|
30 |
rootVisible: true,
|
|
31 |
|
|
32 |
/**
|
|
33 |
* @cfg {Boolean} toolsVisible=true true to show the item floating tools.
|
|
34 |
*/
|
|
35 |
toolsVisible: true,
|
|
36 |
|
|
37 |
/**
|
|
38 |
* @cfg {Ext.data.NodeInterface} root=null The chart´s root node or null for the store root node.
|
|
39 |
*/
|
|
40 |
root: null,
|
|
41 |
|
|
42 |
/**
|
|
43 |
* @cfg {Boolean} autoLoadStore=tru
|
|
44 |
* If this config is true and the store isn't loaded or already loading, the component will trigger a load command to the store
|
|
45 |
* during component initialization.
|
|
46 |
*/
|
|
47 |
autoLoadStore: true,
|
|
48 |
|
|
49 |
/**
|
|
50 |
* @cfg {String} displayField="text" The field used to render the node contents.
|
|
51 |
*/
|
|
52 |
displayField: 'text',
|
|
53 |
|
|
54 |
/**
|
|
55 |
* @cfg {Boolean/Object} loadMask
|
|
56 |
* False to disable a load mask from displaying while the view is loading. This can also be a
|
|
57 |
* {@link Ext.LoadMask} configuration object.
|
|
58 |
*/
|
|
59 |
loadMask: true,
|
|
60 |
|
|
61 |
/**
|
|
62 |
* @cfg {String} loadingText
|
|
63 |
* A string to display during data load operations. If specified, this text will be
|
|
64 |
* displayed in a loading div and the view's contents will be cleared while loading, otherwise the view's
|
|
65 |
* contents will continue to display normally until the new data is loaded and the contents are replaced.
|
|
66 |
*/
|
|
67 |
loadingText: 'Loading...',
|
|
68 |
|
|
69 |
/**
|
|
70 |
* @cfg {Boolean} loadingUseMsg
|
|
71 |
* Whether or not to use the loading message.
|
|
72 |
* @private
|
|
73 |
*/
|
|
74 |
loadingUseMsg: true,
|
|
75 |
|
|
76 |
/**
|
|
77 |
* @cfg {Boolean} allowContainerDrop=true
|
|
78 |
* False to disable dropping itens on the container, true to allow dropping itens on the container.
|
|
79 |
* When itens are dropped on the container they will be appended to the root node.
|
|
80 |
*/
|
|
81 |
allowContainerDrop: true,
|
|
82 |
|
|
83 |
/**
|
|
84 |
* @cfg {String} loadingCls
|
|
85 |
* The CSS class to apply to the loading message element. Defaults to Ext.LoadMask.prototype.msgCls "x-mask-loading".
|
|
86 |
*/
|
|
87 |
|
|
88 |
/**
|
|
89 |
* @cfg {Number} lineWeight=1 Weight of node connector lines.
|
|
90 |
*/
|
|
91 |
lineWeight: 1,
|
|
92 |
|
|
93 |
/**
|
|
94 |
* @property {String} lineColor="#000" HTML color to use for the node connector lines.
|
|
95 |
*/
|
|
96 |
lineColor: '#000',
|
|
97 |
|
|
98 |
/**
|
|
99 |
* @cfg {Number} levelSpacing=15 Space in pixels between the parent and children nodes.
|
|
100 |
*/
|
|
101 |
levelSpacing: 15,
|
|
102 |
|
|
103 |
/**
|
|
104 |
* @cfg {Number} nodeSpacing=10 Margin in pixels between adjacent nodes.
|
|
105 |
*/
|
|
106 |
nodeSpacing: 10,
|
|
107 |
|
|
108 |
/**
|
|
109 |
* @cfg {String} itemCls=null Additional class for the node content element.
|
|
110 |
*/
|
|
111 |
itemCls: null,
|
|
112 |
|
|
113 |
/** inheritdoc */
|
|
114 |
renderTpl: ['<table class="{baseCls}-wrap" cellpadding="0" cellspacing="0" border="0"><tbody><tr class="{baseCls}-container"></tr></tbody></table>'],
|
|
115 |
|
|
116 |
/**
|
|
117 |
* @cfg {Ext.XTemplate/String/String[]}} downLineTpl Node down line connector template
|
|
118 |
* @private
|
|
119 |
*/
|
|
120 |
downLineTpl: [
|
|
121 |
'<tr class="{view.baseCls}-lines {view.downLineCls}">',
|
|
122 |
'<td colspan="{node.childNodes.length}">',
|
|
123 |
'<div class="{view.baseCls}-left" style="border-top-width: {view.lineWeight}px; height: {view.levelSpacing}px; border-color:{view.lineColor} !important;"></div>',
|
|
124 |
'<div class="{view.baseCls}-right" style="border-top-width: {view.lineWeight}px; border-left-width: {view.lineWeight}px; height: {view.levelSpacing}px; border-color:{view.lineColor} !important;"></div>',
|
|
125 |
'</td>',
|
|
126 |
'</tr>',
|
|
127 |
'<tr class="{view.expanderRowCls}">',
|
|
128 |
'<td colspan="{node.childNodes.length}">',
|
|
129 |
'<span class="{view.expanderCmpCls}{[values.view.expanderCls ? " "+values.view.expanderCls : ""]}" data-qtip="{view.expandTip:htmlEncode}"></span>',
|
|
130 |
'</td>',
|
|
131 |
'</tr>'
|
|
132 |
],
|
|
133 |
|
|
134 |
/**
|
|
135 |
* @cfg {Ext.XTemplate/String/String[]}} childrenLineTpl Simple child inner line connector template
|
|
136 |
* @private
|
|
137 |
*/
|
|
138 |
childrenLineTpl: [
|
|
139 |
'<div class="{view.baseCls}-left" style="border-top-width:{view.lineWeight}px; height: {view.levelSpacing}px; border-color:{view.lineColor} !important;"></div>',
|
|
140 |
'<div class="{view.baseCls}-right" style="border-top-width:{view.lineWeight}px; border-left-width:{view.lineWeight}px; height: {view.levelSpacing}px; border-color:{view.lineColor} !important;"></div>'
|
|
141 |
],
|
|
142 |
|
|
143 |
/**
|
|
144 |
* @cfg {Ext.XTemplate/String/String[]}} childrenLinesTpl Multiple child line connector template
|
|
145 |
* @private
|
|
146 |
*/
|
|
147 |
childrenLinesTpl: [
|
|
148 |
'<tpl if="node.childNodes.length > 1">',
|
|
149 |
//multiple lines
|
|
150 |
'<tr class="{view.baseCls}-lines {view.childrenLinesCls}">',
|
|
151 |
'{[this.childLines(values.view, values.node.childNodes)]}',
|
|
152 |
'</tr>',
|
|
153 |
'</tpl>',
|
|
154 |
{
|
|
155 |
childLines: function(view, nodes){
|
|
156 |
var out = [],
|
|
157 |
len = nodes.length,
|
|
158 |
last = len- 1,
|
|
159 |
cls = view.baseCls,
|
|
160 |
clsLeft = cls + '-left',
|
|
161 |
clsRight = cls + '-right',
|
|
162 |
lineWeight = view.lineWeight,
|
|
163 |
lineColor = view.lineColor,
|
|
164 |
height = view.levelSpacing,
|
|
165 |
div= '<div class="{0}" style="border-color: {1}; border-top-width: {2}px; border-left-width: {3}px; border-right-width: {4}px; height: {5}px;"></div>',
|
|
166 |
format = Ext.String.format,
|
|
167 |
i, td;
|
|
168 |
|
|
169 |
for(i = 0; i<len; ++i){
|
|
170 |
td = '<td';
|
|
171 |
//it's a first or last line?
|
|
172 |
if(i == 0) td += ' class="' + cls + '-first"';
|
|
173 |
else if(i == last) td += ' class="' + cls + '-last"';
|
|
174 |
td += '>';
|
|
175 |
|
|
176 |
td += format(div, clsLeft, lineColor, lineWeight, 0, i == last ? lineWeight : 0, height);
|
|
177 |
td += format(div, clsRight, lineColor, lineWeight, lineWeight, 0, height);
|
|
178 |
|
|
179 |
td += '</td>';
|
|
180 |
|
|
181 |
out.push(td);
|
|
182 |
}
|
|
183 |
|
|
184 |
return out.join('');
|
|
185 |
}
|
|
186 |
}
|
|
187 |
],
|
|
188 |
|
|
189 |
/**
|
|
190 |
* @cfg {Ext.XTemplate/String/String[]}} childrenTpl Container with children template
|
|
191 |
* @private
|
|
192 |
*/
|
|
193 |
childrenTpl: [
|
|
194 |
'<tr class="{view.containerCls}">',
|
|
195 |
'{%values.view.renderNodes(values.node.childNodes, out)%}',
|
|
196 |
'</tr>'
|
|
197 |
],
|
|
198 |
|
|
199 |
/**
|
|
200 |
* @cfg {Ext.XTemplate/String/String[]}} containerTpl Simple container template
|
|
201 |
* @private
|
|
202 |
*/
|
|
203 |
containerTpl: '<tr class="{view.containerCls}"></tr>',
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Record node image format
|
|
207 |
* @private
|
|
208 |
*/
|
|
209 |
imgText: '<img src="{0}" class="{1}" />',
|
|
210 |
|
|
211 |
/**
|
|
212 |
* Inner node structure template
|
|
213 |
* @private
|
|
214 |
*/
|
|
215 |
innerNodeTpl: [
|
|
216 |
'<table cellpadding="0" cellspacing="0" border="0"><tbody>',
|
|
217 |
//node content
|
|
218 |
'<tr class="{view.nodeContentRowCls}">',
|
|
219 |
'<td colspan="{node.childNodes.length}">',
|
|
220 |
'<tpl if="node.data.icon || node.data.iconCls">',
|
|
221 |
'{[Ext.String.format(values.view.imgText, values.node.data.icon ? values.node.data.icon : Ext.BLANK_IMAGE_URL, values.node.data.iconCls ? values.node.data.iconCls : "")]}',
|
|
222 |
'</tpl>',
|
|
223 |
'<span id="{nodeId}" class="{view.nodeContentCls}' +
|
|
224 |
'{[values.view.itemCls ? " "+values.view.itemCls : ""]}',
|
|
225 |
'{[values.node.get("cls") ? " "+values.node.get("cls") : ""]}',
|
|
226 |
'" data-recordId="{[values.view.getRecordId(values.node)]}"',
|
|
227 |
'<tpl if="node.data.qtitle && node.data.qtip">',
|
|
228 |
' data-qtitle="{node.data.qtitle:htmlEncode}"',
|
|
229 |
'</tpl>',
|
|
230 |
'<tpl if="node.data.qtip">',
|
|
231 |
' data-qtip="{node.data.qtip:htmlEncode}"',
|
|
232 |
'</tpl>',
|
|
233 |
'>{[values.view.renderItem(values.view, values.node)]}',
|
|
234 |
'</span>',
|
|
235 |
'</td>',
|
|
236 |
'</tr>',
|
|
237 |
|
|
238 |
//children
|
|
239 |
'<tpl if="this.handleChildren(node)">',
|
|
240 |
//down line
|
|
241 |
'{[values.view.downLineTpl.apply(values)]}',
|
|
242 |
|
|
243 |
//children lines
|
|
244 |
'{[values.view.childrenLinesTpl.apply(values)]}',
|
|
245 |
|
|
246 |
//children container
|
|
247 |
'{[this.renderChildren(values)]}',
|
|
248 |
'</tpl>',
|
|
249 |
'</tbody></table>',
|
|
250 |
{
|
|
251 |
renderChildren: function(values){
|
|
252 |
var out=[];
|
|
253 |
values.view.childrenTpl.applyOut(values, out);
|
|
254 |
return out.join('');
|
|
255 |
},
|
|
256 |
handleChildren: function(node){
|
|
257 |
return (node.childNodes.length || (!node.isLeaf() && !node.get('loaded')));
|
|
258 |
}
|
|
259 |
}
|
|
260 |
],
|
|
261 |
|
|
262 |
/**
|
|
263 |
* @cfg {Ext.XTemplate/String/String[]}} nodeTpl Full node component template
|
|
264 |
* @private
|
|
265 |
*/
|
|
266 |
nodeTpl: [
|
|
267 |
'<td class="{view.nodeCls}{[!values.node.isLeaf() && !values.node.isExpanded() ? " " + values.view.collapseCls: ""]}" style="padding: 0 {view.nodeSpacing}px;">',
|
|
268 |
'{[values.view.innerNodeTpl.apply(values)]}',
|
|
269 |
'</td>'
|
|
270 |
],
|
|
271 |
|
|
272 |
/**
|
|
273 |
* @cfg {Ext.XTemplate/String/String[]} itemTpl Template used to render the node's content.
|
|
274 |
*/
|
|
275 |
itemTpl: '{text}',
|
|
276 |
|
|
277 |
/**
|
|
278 |
* @cfg {String} wrapperSelector Component wrapper CSS selector.
|
|
279 |
* @private
|
|
280 |
*/
|
|
281 |
wrapperSelector: '.'+Ext.baseCSSPrefix + 'ochart-wrap',
|
|
282 |
|
|
283 |
/**
|
|
284 |
* @cfg {String} itemSelector Node content CSS selector
|
|
285 |
* private
|
|
286 |
*/
|
|
287 |
itemSelector: '.'+Ext.baseCSSPrefix + 'ochart-node-content',
|
|
288 |
|
|
289 |
/**
|
|
290 |
* @cfg {String} itemRowSelector Item content row CSS selector
|
|
291 |
* private
|
|
292 |
*/
|
|
293 |
itemRowSelector: '.'+Ext.baseCSSPrefix + 'ochart-node-row',
|
|
294 |
|
|
295 |
/**
|
|
296 |
* @cfg {String} nodeItemContainerSelector Node content row CSS selector
|
|
297 |
* private
|
|
298 |
*/
|
|
299 |
nodeItemContainerSelector: 'table > tbody > .'+Ext.baseCSSPrefix + 'ochart-node-row',
|
|
300 |
|
|
301 |
/**
|
|
302 |
* @property {String} nodeSelector Node container CSS selector
|
|
303 |
* private
|
|
304 |
*/
|
|
305 |
nodeSelector: '.'+Ext.baseCSSPrefix + 'ochart-node',
|
|
306 |
|
|
307 |
nodeBodySelector: 'table > tbody',
|
|
308 |
|
|
309 |
nodeContainerSelector: 'table > tbody > .'+Ext.baseCSSPrefix + 'ochart-container',
|
|
310 |
|
|
311 |
expanderSelector: '.'+Ext.baseCSSPrefix + 'ochart-expander',
|
|
312 |
|
|
313 |
inlineExpanderContainerSelector: 'table > tbody > .'+Ext.baseCSSPrefix + 'ochart-expander-row',
|
|
314 |
|
|
315 |
inlineExpanderContentSelector: 'table > tbody > .'+Ext.baseCSSPrefix + 'ochart-expander-row > td',
|
|
316 |
|
|
317 |
downLineContainerSelector: 'table > tbody > .'+Ext.baseCSSPrefix + 'ochart-down',
|
|
318 |
|
|
319 |
downLineSelector: 'table > tbody > .'+Ext.baseCSSPrefix + 'ochart-down > td',
|
|
320 |
|
|
321 |
childrenLinesSelector: 'table > tbody > .' + Ext.baseCSSPrefix + 'ochart-children-lines',
|
|
322 |
|
|
323 |
expandTip: 'Click here to expand this node.',
|
|
324 |
|
|
325 |
collapseTip: 'Click here to collapse this node.',
|
|
326 |
|
|
327 |
addBeforeTip: 'Add a new item before this.',
|
|
328 |
|
|
329 |
addAfterTip: 'Add a new item after this.',
|
|
330 |
|
|
331 |
addChildTip: 'Add a new child node to this item.',
|
|
332 |
|
|
333 |
removeItemTip: 'Remove this item.',
|
|
334 |
|
|
335 |
/**
|
|
336 |
* @cfg {Boolean} trackOver
|
|
337 |
* When `true` the {@link #overItemCls} will be applied to nodes when hovered over.
|
|
338 |
* This in return will also cause {#highlightitem} and
|
|
339 |
* {#unhighlightitem} events to be fired.
|
|
340 |
*
|
|
341 |
* Enabled automatically when the {@link #overItemCls} config is set.
|
|
342 |
*/
|
|
343 |
trackOver: false,
|
|
344 |
|
|
345 |
/**
|
|
346 |
* @cfg {Number} [mouseOverOutBuffer=20]
|
|
347 |
* The number of milliseconds to buffer mouseover and mouseout event handling on view items.
|
|
348 |
*
|
|
349 |
* Configure this as `false` to process mouseover and mouseout events immediately.
|
|
350 |
*/
|
|
351 |
mouseOverOutBuffer: 20,
|
|
352 |
|
|
353 |
inputTagRe: /^textarea$|^input$/i,
|
|
354 |
|
|
355 |
/**
|
|
356 |
* @cfg {String} overItemCls='x-ochart-over-node' Mouse over item class.
|
|
357 |
*/
|
|
358 |
overItemCls: Ext.baseCSSPrefix + 'ochart-over-node',
|
|
359 |
|
|
360 |
/**
|
|
361 |
* @cfg {String} expanderCls Expand tool class.
|
|
362 |
*/
|
|
363 |
expanderCls: null,
|
|
364 |
|
|
365 |
/**
|
|
366 |
* @cfg {String} addBeforeCls Add before tool class.
|
|
367 |
*/
|
|
368 |
addBeforeCls: null,
|
|
369 |
|
|
370 |
/**
|
|
371 |
* @cfg {String} addAfterCls Add after tool class.
|
|
372 |
*/
|
|
373 |
addAfterCls: null,
|
|
374 |
|
|
375 |
/**
|
|
376 |
* @cfg {String} addChildCls Add child tool class.
|
|
377 |
*/
|
|
378 |
addChildCls: null,
|
|
379 |
|
|
380 |
/**
|
|
381 |
* @cfg {String} removeItemCls Remove item tool class.
|
|
382 |
*/
|
|
383 |
removeItemCls: null,
|
|
384 |
|
|
385 |
/**
|
|
386 |
* @cfg {String} selectedItemCls
|
|
387 |
* A CSS class to apply to each selected item in the view.
|
|
388 |
*/
|
|
389 |
selectedItemCls: Ext.baseCSSPrefix + 'item-selected',
|
|
390 |
|
|
391 |
/**
|
|
392 |
* @cfg {String} collapseCls
|
|
393 |
* A CSS class to apply to each item that is collapsed in the view.
|
|
394 |
*/
|
|
395 |
collapseCls: Ext.baseCSSPrefix + 'item-collapsed',
|
|
396 |
|
|
397 |
inheritableStatics: {
|
|
398 |
/**
|
|
399 |
* Event maps
|
|
400 |
*
|
|
401 |
* @static
|
|
402 |
* @protected
|
|
403 |
*/
|
|
404 |
EventMap: {
|
|
405 |
mousedown : 'MouseDown',
|
|
406 |
mouseup : 'MouseUp',
|
|
407 |
click : 'Click',
|
|
408 |
dblclick : 'DblClick',
|
|
409 |
contextmenu: 'ContextMenu',
|
|
410 |
mouseover : 'MouseOver',
|
|
411 |
mouseout : 'MouseOut',
|
|
412 |
mouseenter : 'MouseEnter',
|
|
413 |
mouseleave : 'MouseLeave',
|
|
414 |
keydown : 'KeyDown',
|
|
415 |
focus : 'Focus'
|
|
416 |
}
|
|
417 |
},
|
|
418 |
|
|
419 |
/**
|
|
420 |
* @cfg {String} triggerEvent="itemclick"
|
|
421 |
* Trigger event used by the selection model to handle item click
|
|
422 |
*
|
|
423 |
* @private
|
|
424 |
*/
|
|
425 |
triggerEvent: 'itemclick',
|
|
426 |
|
|
427 |
/**
|
|
428 |
* @cfg {String} triggerCtEvent="containerclick"
|
|
429 |
* Trigger event used by the selection model to handle container click
|
|
430 |
*
|
|
431 |
* @private
|
|
432 |
*/
|
|
433 |
triggerCtEvent: 'containerclick',
|
|
434 |
|
|
435 |
/** @inheritdoc */
|
|
436 |
initComponent: function(){
|
|
437 |
var me = this,
|
|
438 |
store = me.store,
|
|
439 |
root = me.root;
|
|
440 |
|
|
441 |
/**
|
|
442 |
* @cfg {String} wrapperCls Component wrapper class
|
|
443 |
* @private
|
|
444 |
*/
|
|
445 |
me.wrapperCls = me.baseCls + '-wrap';
|
|
446 |
|
|
447 |
/**
|
|
448 |
* @cfg {String} containerCls Node container class
|
|
449 |
* @private
|
|
450 |
*/
|
|
451 |
me.containerCls = me.baseCls + '-container';
|
|
452 |
|
|
453 |
/**
|
|
454 |
* @cfg {String} nodeCls Node component class
|
|
455 |
* @private
|
|
456 |
*/
|
|
457 |
me.nodeCls = me.baseCls + '-node';
|
|
458 |
|
|
459 |
/**
|
|
460 |
* @cfg {String} nodeContentRowCls Node's content line class
|
|
461 |
* @private
|
|
462 |
*/
|
|
463 |
me.nodeContentRowCls = me.baseCls + '-node-row';
|
|
464 |
|
|
465 |
/**
|
|
466 |
* @cfg {String} nodeContentCls Node's content class
|
|
467 |
* @private
|
|
468 |
*/
|
|
469 |
me.nodeContentCls = me.baseCls + '-node-content';
|
|
470 |
|
|
471 |
/**
|
|
472 |
* @cfg {String} downLineCls Node's down line connector class
|
|
473 |
* @private
|
|
474 |
*/
|
|
475 |
me.downLineCls = me.baseCls + '-down';
|
|
476 |
|
|
477 |
/**
|
|
478 |
* @cfg {String} expanderRowCls Inline expander row class
|
|
479 |
* @private
|
|
480 |
*/
|
|
481 |
me.expanderRowCls = me.baseCls + '-expander-row';
|
|
482 |
|
|
483 |
/**
|
|
484 |
* @cfg {String} expanderCmpCls Expander component class
|
|
485 |
* @private
|
|
486 |
*/
|
|
487 |
me.expanderCmpCls = me.baseCls + '-expander';
|
|
488 |
|
|
489 |
/**
|
|
490 |
* @cfg {String} addNodeCmpCls Add node component class
|
|
491 |
* @private
|
|
492 |
*/
|
|
493 |
me.addNodeCmpCls = me.baseCls + '-add';
|
|
494 |
|
|
495 |
/**
|
|
496 |
* @cfg {String} removeNodeCmpCls Remove node component class
|
|
497 |
* @private
|
|
498 |
*/
|
|
499 |
me.removeNodeCmpCls = me.baseCls + '-remove';
|
|
500 |
|
|
501 |
/**
|
|
502 |
* @cfg {String} childrenLinesCls Children connector lines row
|
|
503 |
* @private
|
|
504 |
*/
|
|
505 |
me.childrenLinesCls = me.baseCls + '-children-lines';
|
|
506 |
|
|
507 |
//prepare templates
|
|
508 |
me.rootTpl = Ext.XTemplate.getTpl(this, 'rootTpl');
|
|
509 |
me.nodesTpl = Ext.XTemplate.getTpl(this, 'nodesTpl');
|
|
510 |
me.nodeTpl = Ext.XTemplate.getTpl(this, 'nodeTpl');
|
|
511 |
me.innerNodeTpl = Ext.XTemplate.getTpl(this, 'innerNodeTpl');
|
|
512 |
me.downLineTpl = Ext.XTemplate.getTpl(this, 'downLineTpl');
|
|
513 |
me.childrenLinesTpl = Ext.XTemplate.getTpl(this, 'childrenLinesTpl');
|
|
514 |
me.childrenLineTpl = Ext.XTemplate.getTpl(this, 'childrenLineTpl');
|
|
515 |
me.childrenTpl = Ext.XTemplate.getTpl(this, 'childrenTpl');
|
|
516 |
me.containerTpl = Ext.XTemplate.getTpl(this, 'containerTpl');
|
|
517 |
me.itemTpl = Ext.XTemplate.getTpl(this, 'itemTpl');
|
|
518 |
|
|
519 |
//adjust spacings
|
|
520 |
if(me.levelSpacing < 5) me.levelSpacing = 5;
|
|
521 |
|
|
522 |
//create mouse over buffer if need
|
|
523 |
if (me.mouseOverOutBuffer) {
|
|
524 |
me.handleMouseOverOrOut = Ext.Function.createBuffered(me.handleMouseOverOrOut, me.mouseOverOutBuffer, me);
|
|
525 |
me.lastMouseOverOutEvent = new Ext.EventObjectImpl();
|
|
526 |
}
|
|
527 |
|
|
528 |
if (me.overItemCls) {
|
|
529 |
me.trackOver = true;
|
|
530 |
}
|
|
531 |
|
|
532 |
this.addEvents(
|
|
533 |
/**
|
|
534 |
* @event beforeitemmousedown
|
|
535 |
* Fires before the mousedown event on an item is processed. Returns false to cancel the default action.
|
|
536 |
* @param {Ext.view.View} this
|
|
537 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
538 |
* @param {HTMLElement} item The item's element
|
|
539 |
* @param {Number} index The item's index
|
|
540 |
* @param {Ext.EventObject} e The raw event object
|
|
541 |
*/
|
|
542 |
'beforeitemmousedown',
|
|
543 |
/**
|
|
544 |
* @event beforeitemmouseup
|
|
545 |
* Fires before the mouseup event on an item is processed. Returns false to cancel the default action.
|
|
546 |
* @param {Ext.view.View} this
|
|
547 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
548 |
* @param {HTMLElement} item The item's element
|
|
549 |
* @param {Number} index The item's index
|
|
550 |
* @param {Ext.EventObject} e The raw event object
|
|
551 |
*/
|
|
552 |
'beforeitemmouseup',
|
|
553 |
/**
|
|
554 |
* @event beforeitemmouseenter
|
|
555 |
* Fires before the mouseenter event on an item is processed. Returns false to cancel the default action.
|
|
556 |
* @param {Ext.view.View} this
|
|
557 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
558 |
* @param {HTMLElement} item The item's element
|
|
559 |
* @param {Number} index The item's index
|
|
560 |
* @param {Ext.EventObject} e The raw event object
|
|
561 |
*/
|
|
562 |
'beforeitemmouseenter',
|
|
563 |
/**
|
|
564 |
* @event beforeitemmouseleave
|
|
565 |
* Fires before the mouseleave event on an item is processed. Returns false to cancel the default action.
|
|
566 |
* @param {Ext.view.View} this
|
|
567 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
568 |
* @param {HTMLElement} item The item's element
|
|
569 |
* @param {Number} index The item's index
|
|
570 |
* @param {Ext.EventObject} e The raw event object
|
|
571 |
*/
|
|
572 |
'beforeitemmouseleave',
|
|
573 |
/**
|
|
574 |
* @event beforeitemclick
|
|
575 |
* Fires before the click event on an item is processed. Returns false to cancel the default action.
|
|
576 |
* @param {Ext.view.View} this
|
|
577 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
578 |
* @param {HTMLElement} item The item's element
|
|
579 |
* @param {Number} index The item's index
|
|
580 |
* @param {Ext.EventObject} e The raw event object
|
|
581 |
*/
|
|
582 |
'beforeitemclick',
|
|
583 |
/**
|
|
584 |
* @event beforeitemdblclick
|
|
585 |
* Fires before the dblclick event on an item is processed. Returns false to cancel the default action.
|
|
586 |
* @param {Ext.view.View} this
|
|
587 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
588 |
* @param {HTMLElement} item The item's element
|
|
589 |
* @param {Number} index The item's index
|
|
590 |
* @param {Ext.EventObject} e The raw event object
|
|
591 |
*/
|
|
592 |
'beforeitemdblclick',
|
|
593 |
/**
|
|
594 |
* @event beforeitemcontextmenu
|
|
595 |
* Fires before the contextmenu event on an item is processed. Returns false to cancel the default action.
|
|
596 |
* @param {Ext.view.View} this
|
|
597 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
598 |
* @param {HTMLElement} item The item's element
|
|
599 |
* @param {Number} index The item's index
|
|
600 |
* @param {Ext.EventObject} e The raw event object
|
|
601 |
*/
|
|
602 |
'beforeitemcontextmenu',
|
|
603 |
/**
|
|
604 |
* @event beforeitemkeydown
|
|
605 |
* Fires before the keydown event on an item is processed. Returns false to cancel the default action.
|
|
606 |
* @param {Ext.view.View} this
|
|
607 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
608 |
* @param {HTMLElement} item The item's element
|
|
609 |
* @param {Number} index The item's index
|
|
610 |
* @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.
|
|
611 |
*/
|
|
612 |
'beforeitemkeydown',
|
|
613 |
/**
|
|
614 |
* @event itemmousedown
|
|
615 |
* Fires when there is a mouse down on an item
|
|
616 |
* @param {Ext.view.View} this
|
|
617 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
618 |
* @param {HTMLElement} item The item's element
|
|
619 |
* @param {Number} index The item's index
|
|
620 |
* @param {Ext.EventObject} e The raw event object
|
|
621 |
*/
|
|
622 |
'itemmousedown',
|
|
623 |
/**
|
|
624 |
* @event itemmouseup
|
|
625 |
* Fires when there is a mouse up on an item
|
|
626 |
* @param {Ext.view.View} this
|
|
627 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
628 |
* @param {HTMLElement} item The item's element
|
|
629 |
* @param {Number} index The item's index
|
|
630 |
* @param {Ext.EventObject} e The raw event object
|
|
631 |
*/
|
|
632 |
'itemmouseup',
|
|
633 |
/**
|
|
634 |
* @event itemmouseenter
|
|
635 |
* Fires when the mouse enters an item.
|
|
636 |
* @param {Ext.view.View} this
|
|
637 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
638 |
* @param {HTMLElement} item The item's element
|
|
639 |
* @param {Number} index The item's index
|
|
640 |
* @param {Ext.EventObject} e The raw event object
|
|
641 |
*/
|
|
642 |
'itemmouseenter',
|
|
643 |
/**
|
|
644 |
* @event itemmouseleave
|
|
645 |
* Fires when the mouse leaves an item.
|
|
646 |
* @param {Ext.view.View} this
|
|
647 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
648 |
* @param {HTMLElement} item The item's element
|
|
649 |
* @param {Number} index The item's index
|
|
650 |
* @param {Ext.EventObject} e The raw event object
|
|
651 |
*/
|
|
652 |
'itemmouseleave',
|
|
653 |
/**
|
|
654 |
* @event itemclick
|
|
655 |
* Fires when an item is clicked.
|
|
656 |
* @param {Ext.view.View} this
|
|
657 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
658 |
* @param {HTMLElement} item The item's element
|
|
659 |
* @param {Number} index The item's index
|
|
660 |
* @param {Ext.EventObject} e The raw event object
|
|
661 |
*/
|
|
662 |
'itemclick',
|
|
663 |
/**
|
|
664 |
* @event itemdblclick
|
|
665 |
* Fires when an item is double clicked.
|
|
666 |
* @param {Ext.view.View} this
|
|
667 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
668 |
* @param {HTMLElement} item The item's element
|
|
669 |
* @param {Number} index The item's index
|
|
670 |
* @param {Ext.EventObject} e The raw event object
|
|
671 |
*/
|
|
672 |
'itemdblclick',
|
|
673 |
/**
|
|
674 |
* @event itemcontextmenu
|
|
675 |
* Fires when an item is right clicked.
|
|
676 |
* @param {Ext.view.View} this
|
|
677 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
678 |
* @param {HTMLElement} item The item's element
|
|
679 |
* @param {Number} index The item's index
|
|
680 |
* @param {Ext.EventObject} e The raw event object
|
|
681 |
*/
|
|
682 |
'itemcontextmenu',
|
|
683 |
/**
|
|
684 |
* @event itemkeydown
|
|
685 |
* Fires when a key is pressed while an item is currently selected.
|
|
686 |
* @param {Ext.view.View} this
|
|
687 |
* @param {Ext.data.Model} record The record that belongs to the item
|
|
688 |
* @param {HTMLElement} item The item's element
|
|
689 |
* @param {Number} index The item's index
|
|
690 |
* @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.
|
|
691 |
*/
|
|
692 |
'itemkeydown',
|
|
693 |
/**
|
|
694 |
* @event beforecontainermousedown
|
|
695 |
* Fires before the mousedown event on the container is processed. Returns false to cancel the default action.
|
|
696 |
* @param {Ext.view.View} this
|
|
697 |
* @param {Ext.EventObject} e The raw event object
|
|
698 |
*/
|
|
699 |
'beforecontainermousedown',
|
|
700 |
/**
|
|
701 |
* @event beforecontainermouseup
|
|
702 |
* Fires before the mouseup event on the container is processed. Returns false to cancel the default action.
|
|
703 |
* @param {Ext.view.View} this
|
|
704 |
* @param {Ext.EventObject} e The raw event object
|
|
705 |
*/
|
|
706 |
'beforecontainermouseup',
|
|
707 |
/**
|
|
708 |
* @event beforecontainermouseover
|
|
709 |
* Fires before the mouseover event on the container is processed. Returns false to cancel the default action.
|
|
710 |
* @param {Ext.view.View} this
|
|
711 |
* @param {Ext.EventObject} e The raw event object
|
|
712 |
*/
|
|
713 |
'beforecontainermouseover',
|
|
714 |
/**
|
|
715 |
* @event beforecontainermouseout
|
|
716 |
* Fires before the mouseout event on the container is processed. Returns false to cancel the default action.
|
|
717 |
* @param {Ext.view.View} this
|
|
718 |
* @param {Ext.EventObject} e The raw event object
|
|
719 |
*/
|
|
720 |
'beforecontainermouseout',
|
|
721 |
/**
|
|
722 |
* @event beforecontainerclick
|
|
723 |
* Fires before the click event on the container is processed. Returns false to cancel the default action.
|
|
724 |
* @param {Ext.view.View} this
|
|
725 |
* @param {Ext.EventObject} e The raw event object
|
|
726 |
*/
|
|
727 |
'beforecontainerclick',
|
|
728 |
/**
|
|
729 |
* @event beforecontainerdblclick
|
|
730 |
* Fires before the dblclick event on the container is processed. Returns false to cancel the default action.
|
|
731 |
* @param {Ext.view.View} this
|
|
732 |
* @param {Ext.EventObject} e The raw event object
|
|
733 |
*/
|
|
734 |
'beforecontainerdblclick',
|
|
735 |
/**
|
|
736 |
* @event beforecontainercontextmenu
|
|
737 |
* Fires before the contextmenu event on the container is processed. Returns false to cancel the default action.
|
|
738 |
* @param {Ext.view.View} this
|
|
739 |
* @param {Ext.EventObject} e The raw event object
|
|
740 |
*/
|
|
741 |
'beforecontainercontextmenu',
|
|
742 |
/**
|
|
743 |
* @event beforecontainerkeydown
|
|
744 |
* Fires before the keydown event on the container is processed. Returns false to cancel the default action.
|
|
745 |
* @param {Ext.view.View} this
|
|
746 |
* @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.
|
|
747 |
*/
|
|
748 |
'beforecontainerkeydown',
|
|
749 |
/**
|
|
750 |
* @event containermouseup
|
|
751 |
* Fires when there is a mouse up on the container
|
|
752 |
* @param {Ext.view.View} this
|
|
753 |
* @param {Ext.EventObject} e The raw event object
|
|
754 |
*/
|
|
755 |
'containermouseup',
|
|
756 |
/**
|
|
757 |
* @event containermouseover
|
|
758 |
* Fires when you move the mouse over the container.
|
|
759 |
* @param {Ext.view.View} this
|
|
760 |
* @param {Ext.EventObject} e The raw event object
|
|
761 |
*/
|
|
762 |
'containermouseover',
|
|
763 |
/**
|
|
764 |
* @event containermouseout
|
|
765 |
* Fires when you move the mouse out of the container.
|
|
766 |
* @param {Ext.view.View} this
|
|
767 |
* @param {Ext.EventObject} e The raw event object
|
|
768 |
*/
|
|
769 |
'containermouseout',
|
|
770 |
/**
|
|
771 |
* @event containerclick
|
|
772 |
* Fires when the container is clicked.
|
|
773 |
* @param {Ext.view.View} this
|
|
774 |
* @param {Ext.EventObject} e The raw event object
|
|
775 |
*/
|
|
776 |
'containerclick',
|
|
777 |
/**
|
|
778 |
* @event containerdblclick
|
|
779 |
* Fires when the container is double clicked.
|
|
780 |
* @param {Ext.view.View} this
|
|
781 |
* @param {Ext.EventObject} e The raw event object
|
|
782 |
*/
|
|
783 |
'containerdblclick',
|
|
784 |
/**
|
|
785 |
* @event containercontextmenu
|
|
786 |
* Fires when the container is right clicked.
|
|
787 |
* @param {Ext.view.View} this
|
|
788 |
* @param {Ext.EventObject} e The raw event object
|
|
789 |
*/
|
|
790 |
'containercontextmenu',
|
|
791 |
/**
|
|
792 |
* @event containerkeydown
|
|
793 |
* Fires when a key is pressed while the container is focused, and no item is currently selected.
|
|
794 |
* @param {Ext.view.View} this
|
|
795 |
* @param {Ext.EventObject} e The raw event object. Use {@link Ext.EventObject#getKey getKey()} to retrieve the key that was pressed.
|
|
796 |
*/
|
|
797 |
'containerkeydown',
|
|
798 |
|
|
799 |
/**
|
|
800 |
* @event
|
|
801 |
* @inheritdoc Ext.selection.DataViewModel#selectionchange
|
|
802 |
*/
|
|
803 |
'selectionchange',
|
|
804 |
/**
|
|
805 |
* @event
|
|
806 |
* @inheritdoc Ext.selection.DataViewModel#beforeselect
|
|
807 |
*/
|
|
808 |
'beforeselect',
|
|
809 |
/**
|
|
810 |
* @event
|
|
811 |
* @inheritdoc Ext.selection.DataViewModel#beforedeselect
|
|
812 |
*/
|
|
813 |
'beforedeselect',
|
|
814 |
/**
|
|
815 |
* @event
|
|
816 |
* @inheritdoc Ext.selection.DataViewModel#select
|
|
817 |
*/
|
|
818 |
'select',
|
|
819 |
/**
|
|
820 |
* @event
|
|
821 |
* @inheritdoc Ext.selection.DataViewModel#deselect
|
|
822 |
*/
|
|
823 |
'deselect',
|
|
824 |
/**
|
|
825 |
* @event
|
|
826 |
* @inheritdoc Ext.selection.DataViewModel#focuschange
|
|
827 |
*/
|
|
828 |
'focuschange',
|
|
829 |
|
|
830 |
/**
|
|
831 |
* @event highlightitem
|
|
832 |
* Fires when a node is highlighted using keyboard navigation, or mouseover.
|
|
833 |
* @param {Ext.view.View} view This View Component.
|
|
834 |
* @param {Ext.Element} node The highlighted node.
|
|
835 |
*/
|
|
836 |
'highlightitem',
|
|
837 |
|
|
838 |
/**
|
|
839 |
* @event unhighlightitem
|
|
840 |
* Fires when a node is unhighlighted using keyboard navigation, or mouseout.
|
|
841 |
* @param {Ext.view.View} view This View Component.
|
|
842 |
* @param {Ext.Element} node The previously highlighted node.
|
|
843 |
*/
|
|
844 |
'unhighlightitem',
|
|
845 |
|
|
846 |
/**
|
|
847 |
* @event additem
|
|
848 |
* Fires when one of add tools is clicked.
|
|
849 |
* @param {Ext.view.View} view This View Component.
|
|
850 |
* @param {Ext.data.NodeInterface} record The reference record for add action.
|
|
851 |
* @param {"before/after/child"} where Where to add the new record in relation to the reference record.
|
|
852 |
* @param {Ext.dom.Element} node The node element.
|
|
853 |
*/
|
|
854 |
'additem',
|
|
855 |
|
|
856 |
/**
|
|
857 |
* @event removeitem
|
|
858 |
* Fires when remove item tool is clicked.
|
|
859 |
* @param {Ext.view.View} view This View Component.
|
|
860 |
* @param {Ext.data.NodeInterface} record The reference record for remove action.
|
|
861 |
* @param {Ext.dom.Element/null} node The node element.
|
|
862 |
*/
|
|
863 |
'removeitem',
|
|
864 |
|
|
865 |
/**
|
|
866 |
* @event itemupdate
|
|
867 |
* Fires when one of nodes has been changed.
|
|
868 |
* @param {Ext.view.View} view This View Component.
|
|
869 |
* @param {Ext.data.NodeInterface} record The reference record for add action.
|
|
870 |
* @param {Ext.dom.Element} node The node element.
|
|
871 |
*/
|
|
872 |
'itemupdate'
|
|
873 |
);
|
|
874 |
|
|
875 |
//create store if needed
|
|
876 |
if(Ext.isString(store)){
|
|
877 |
//it's an store id
|
|
878 |
store = Ext.StoreManager.lookup(store);
|
|
879 |
}
|
|
880 |
else if( !store || Ext.isObject(store) && !store.isStore){
|
|
881 |
//it's an store object declaration
|
|
882 |
store = me.store = new Ext.data.TreeStore(Ext.apply({
|
|
883 |
root: root,
|
|
884 |
fields: me.fields,
|
|
885 |
model: me.model
|
|
886 |
}), store);
|
|
887 |
|
|
888 |
|
|
889 |
}
|
|
890 |
else if (root) {
|
|
891 |
store = me.store = Ext.data.StoreManager.lookup(store);
|
|
892 |
}
|
|
893 |
|
|
894 |
//sets the root node
|
|
895 |
me.root = root || store.getRootNode();
|
|
896 |
|
|
897 |
//binds the store
|
|
898 |
me.bindStore(store, true, 'dataStore');
|
|
899 |
me.callParent(arguments);
|
|
900 |
},
|
|
901 |
|
|
902 |
/** @inheritdoc */
|
|
903 |
onRender: function(){
|
|
904 |
var me = this;
|
|
905 |
me.callParent(arguments);
|
|
906 |
me.el.ddScrollConfig= {
|
|
907 |
vthresh: 25,
|
|
908 |
hthresh: 25,
|
|
909 |
frequency: 300,
|
|
910 |
increment: 100
|
|
911 |
};
|
|
912 |
},
|
|
913 |
|
|
914 |
beforeRender: function() {
|
|
915 |
var me = this;
|
|
916 |
me.callParent(arguments);
|
|
917 |
//me.protoEl.set('unselectable', true);
|
|
918 |
me.getSelectionModel().beforeViewRender(me);
|
|
919 |
},
|
|
920 |
|
|
921 |
afterRender: function(){
|
|
922 |
var me = this,
|
|
923 |
store = this.store,
|
|
924 |
onMouseOverOut = me.mouseOverOutBuffer ? me.onMouseOverOut : me.handleMouseOverOrOut;
|
|
925 |
me.callParent();
|
|
926 |
|
|
927 |
//todo handle keyboard an context menu
|
|
928 |
//init component input event handler
|
|
929 |
me.mon( me.el, {
|
|
930 |
scope : me,
|
|
931 |
/*
|
|
932 |
* We need to make copies of this since some of the events fired here will end up triggering
|
|
933 |
* a new event to be called and the shared event object will be mutated. In future we should
|
|
934 |
* investigate if there are any issues with creating a new event object for each event that
|
|
935 |
* is fired.
|
|
936 |
*/
|
|
937 |
freezeEvent: true,
|
|
938 |
click : me.handleEvent,
|
Module of the hierarchical view of datasets - datasetExplorerOchart