git_sitools_idoc / Module_DatasetExplorerOchart_sitools2v3 / DatasetExplorerOchartViewSimple.js @ 20ff13ec
1 |
/***************************************
|
---|---|
2 |
* Copyright 2010-2014 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
|
3 |
*
|
4 |
* This file is part of SITools2.
|
5 |
*
|
6 |
* SITools2 is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* SITools2 is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with SITools2. If not, see <http://www.gnu.org/licenses/>.
|
18 |
***************************************/
|
19 |
/*global Ext, sitools, projectGlobal, commonTreeUtils, showResponse, document, i18n, loadUrl, SITOOLS_DEFAULT_PROJECT_IMAGE_URL, SitoolsDesk*/
|
20 |
/*
|
21 |
* @include "../../env.js"
|
22 |
*/
|
23 |
|
24 |
|
25 |
Ext.namespace('sitools.user.view.modules.datasetExplorerOchart');
|
26 |
Ext.define( 'sitools.user.view.modules.datasetExplorerOchart.DatasetExplorerOchartViewSimple', {
|
27 |
extend: 'Ext.panel.Panel', |
28 |
alias: 'widget.datasetExplorerOchartViewSimple', |
29 |
|
30 |
layout:{ type: 'fit' }, |
31 |
border : false, |
32 |
requires: [
|
33 |
'sitools.user.modules.OChartDragDrop',
|
34 |
'sitools.user.view.modules.datasetExplorerOchart.OChart'
|
35 |
], |
36 |
autoDestroyStore: true, |
37 |
|
38 |
initComponent: function(){ |
39 |
var me = this; |
40 |
if(!me.store){
|
41 |
Ext.apply(me, { |
42 |
store : me.buildStore()
|
43 |
}); |
44 |
} |
45 |
|
46 |
me.chartConfig = me.chartConfig || {}; |
47 |
|
48 |
Ext.applyIf(me.chartConfig,{ |
49 |
xtype: 'ochart', |
50 |
autoScroll : true, |
51 |
simpleSelect: true, |
52 |
rootVisible: false, |
53 |
store: me.store,
|
54 |
plugins : [
|
55 |
{ |
56 |
ptype : 'ochartdragdrop', |
57 |
allowParentInserts: true, |
58 |
containerScroll: true, |
59 |
ddGroup: 'ochart-dd' |
60 |
} |
61 |
], |
62 |
|
63 |
listeners: {
|
64 |
scope: me,
|
65 |
additem: me.onAddItem,
|
66 |
removeitem: me.onRemoveItem,
|
67 |
itemdblclick: me.onItemDblClick
|
68 |
} |
69 |
}); |
70 |
|
71 |
Ext.apply(me, { |
72 |
items: me.chartConfig
|
73 |
}); |
74 |
me.callParent(arguments);
|
75 |
}, |
76 |
|
77 |
buildStore: function() { |
78 |
var store = Ext.create('sitools.user.view.modules.datasetExplorerOchart.NodesStore'); |
79 |
return store;
|
80 |
}, |
81 |
|
82 |
onRender: function(){ |
83 |
//console.log(this);
|
84 |
var chart = this.down('ochart' ); |
85 |
// var view = this.up('viewport');
|
86 |
console.log(chart); |
87 |
chart.lineWeight =2; //view.lineWeight; |
88 |
chart.lineColor = '#888888';//'#' + view.lineColor; |
89 |
chart.levelSpacing =20;//view.levelSpacing; |
90 |
chart.nodeSpacing = 10;//view.nodeSpacing; |
91 |
chart.readOnly = true;//view.readOnly; |
92 |
chart.rootVisible = true;//view.rootVisible; |
93 |
chart.allowContainerDrop = false;//view.allowContainerDrop; |
94 |
chart.toolsVisible = true;//view.toolsVisible; |
95 |
|
96 |
this.callParent(arguments); |
97 |
}, |
98 |
|
99 |
afterRender: function(){ |
100 |
var me = this; |
101 |
var view = me.up('#mainView'); |
102 |
//me.mon(view,'changelineweight', me.onChangeLineWeight, me);
|
103 |
//me.mon(view,'changelinecolor', me.onChangeLineColor, me);
|
104 |
//me.mon(view,'changelevelspace', me.onChangeLevelSpace, me);
|
105 |
//me.mon(view,'changeitemspace', me.onChangeItemSpace, me);
|
106 |
//me.mon(view,'changereadonly', me.onChangeReadOnly, me);
|
107 |
//me.mon(view,'changerootvisible', me.onChangeRootVisible, me);
|
108 |
//me.mon(view,'changecontainerdrop', me.onChangeContainerDrop, me);
|
109 |
//me.mon(view,'changetools', me.onChangeTools, me);
|
110 |
me.view = view; |
111 |
me.callParent(arguments);
|
112 |
}, |
113 |
|
114 |
onDestroy: function(){ |
115 |
var me = this, |
116 |
view = me.view; |
117 |
me.mun(view,'changelineweight', me.onChangeLineWeight, me);
|
118 |
me.mun(view,'changelinecolor', me.onChangeLineColor, me);
|
119 |
me.mun(view,'changelevelspace', me.onChangeLevelSpace, me);
|
120 |
me.mun(view,'changeitemspace', me.onChangeItemSpace, me);
|
121 |
me.mun(view,'changereadonly', me.onChangeReadOnly, me);
|
122 |
me.mun(view,'changerootvisible', me.onChangeRootVisible, me);
|
123 |
me.mun(view,'changecontainerdrop', me.onChangeContainerDrop, me);
|
124 |
me.mun(view,'changetools', me.onChangeTools, me);
|
125 |
me.view = null;
|
126 |
if(me.autoDestroyStore){
|
127 |
me.store.destroyStore(); |
128 |
} |
129 |
me.store = null;
|
130 |
me.callParent(arguments);
|
131 |
}, |
132 |
|
133 |
onItemDblClick: function(view, record, item, index, e){ |
134 |
if(view.readOnly) return; |
135 |
|
136 |
Ext.Msg.prompt('Edit Node', 'Type the node name',function(btn, text){ |
137 |
if(btn == 'ok'){ |
138 |
record.set('text',text);
|
139 |
} |
140 |
}, window, false, record.get('text')); |
141 |
}, |
142 |
|
143 |
onAddItem: function (view, record, where, nodeEl){ |
144 |
Ext.Msg.prompt('New Node', 'Type the node name',function(btn, text){ |
145 |
if(btn == 'ok'){ |
146 |
var newrec = {text: text, leaf: true}; |
147 |
switch(where){
|
148 |
case 'before': |
149 |
var parent = record.parentNode;
|
150 |
newrec = parent.insertBefore(newrec, record); |
151 |
break;
|
152 |
case 'after': |
153 |
var node = record.nextSibling;
|
154 |
var parent = record.parentNode;
|
155 |
newrec = parent.insertBefore(newrec, node); |
156 |
break;
|
157 |
case 'child': |
158 |
newrec = record.appendChild(newrec); |
159 |
record.expand(function(){view.focusNode(newrec);});
|
160 |
break;
|
161 |
} |
162 |
} |
163 |
}); |
164 |
}, |
165 |
|
166 |
onRemoveItem: function(view, record, nodeEl){ |
167 |
Ext.Msg.confirm('Remove Item', 'Do you really want\'s remove this items?',function(btn, text){ |
168 |
if(btn == 'yes'){ |
169 |
record.remove(); |
170 |
} |
171 |
}); |
172 |
}, |
173 |
|
174 |
onChangeLineWeight: function(panel, weight){ |
175 |
var chart = this.down('ochart'); |
176 |
chart.lineWeight = weight; |
177 |
chart.refresh(); |
178 |
}, |
179 |
|
180 |
onChangeLineColor: function(panel, color){ |
181 |
var chart = this.down('ochart' ); |
182 |
chart.lineColor = '#' + color;
|
183 |
chart.refresh(); |
184 |
}, |
185 |
|
186 |
onChangeLevelSpace: function(panel, space){ |
187 |
var chart = this.down('ochart'); |
188 |
chart.levelSpacing = space; |
189 |
chart.refresh(); |
190 |
}, |
191 |
|
192 |
onChangeItemSpace: function(panel, space){ |
193 |
var chart = this.down('ochart'); |
194 |
chart.nodeSpacing = space; |
195 |
chart.refresh(); |
196 |
}, |
197 |
|
198 |
onChangeReadOnly: function(panel, value){ |
199 |
var chart = this.down('ochart'); |
200 |
chart.readOnly = value; |
201 |
}, |
202 |
|
203 |
onChangeRootVisible: function(panel, value){ |
204 |
var chart = this.down('ochart'); |
205 |
chart.rootVisible = value; |
206 |
chart.refresh(); |
207 |
}, |
208 |
|
209 |
onChangeContainerDrop: function(panel, value){ |
210 |
var chart = this.down('ochart'); |
211 |
chart.allowContainerDrop = value; |
212 |
}, |
213 |
|
214 |
onChangeTools: function(panel, value){ |
215 |
var chart = this.down('ochart'); |
216 |
chart.toolsVisible = value; |
217 |
}, |
218 |
|
219 |
/**
|
220 |
* method called when trying to save preference
|
221 |
* @returns
|
222 |
*/
|
223 |
_getSettings: function () { |
224 |
return {
|
225 |
preferencesPath: "/modules", |
226 |
preferencesFileName: this.id |
227 |
}; |
228 |
} |
229 |
|
230 |
} ); |