Commit 74b77f584654865b330fc362d61663d3a0a13c3e
1 parent
b2c5ec48
Exists in
master
and in
111 other branches
init remote branch
Showing
11 changed files
with
2156 additions
and
2097 deletions
Show diff stats
js/app/models/InteractiveNode.js
... | ... | @@ -89,13 +89,15 @@ Ext.define('amdaModel.InteractiveNode', { |
89 | 89 | { |
90 | 90 | this.callParent(arguments); |
91 | 91 | this.set('nodeType',this.self.nodeType); |
92 | - this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
93 | - // if id of this node have root category suffix | |
94 | - if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) | |
95 | - { | |
96 | - // set the expanded property to true | |
97 | - this.set('expanded',true); | |
98 | - } | |
92 | + this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
93 | + if (this.get('id')) { // TODO why sometimes (delete in remote interoper tree) this.get('id') = undefined ? | |
94 | + // if id of this node have root category suffix | |
95 | + if (Ext.util.Format.substr(this.get('id'), -(amdaUI.ExplorerUI.CAT_SUFFIX.length), this.get('id').length) === amdaUI.ExplorerUI.CAT_SUFFIX) | |
96 | + { | |
97 | + // set the expanded property to true | |
98 | + this.set('expanded',true); | |
99 | + } | |
100 | + } | |
99 | 101 | }, |
100 | 102 | |
101 | 103 | /** |
... | ... |
js/app/models/RemoteParamNode.js
... | ... | @@ -3,152 +3,143 @@ |
3 | 3 | * Name : RemoteParamNode.js |
4 | 4 | * @class amdaModel.RemoteParamNode |
5 | 5 | * @extends amdaModel.LocalParamNode |
6 | - * @brief | |
7 | - * @author | |
8 | - * @version $Id: RemoteParamNode.js 2544 2014-10-03 10:21:56Z elena $ | |
6 | + * @author elena | |
9 | 7 | */ |
10 | 8 | |
11 | 9 | Ext.define('amdaModel.RemoteParamNode', { |
10 | + extend: 'amdaModel.LocalParamNode', | |
12 | 11 | |
13 | - extend: 'amdaModel.LocalParamNode', | |
14 | - | |
15 | - statics:{ | |
16 | - nodeType: 'remoteParam' | |
17 | - }, | |
18 | - | |
19 | - fields: [ | |
20 | - {name: 'isRemoteDataSet', type:'boolean', persist: false, defaultValue: false}, | |
21 | - {name: 'isSimulation', type:'boolean', defaultValue: false} | |
22 | - ], | |
23 | - | |
24 | - constructor : function(config){ | |
25 | - this.callParent(arguments); | |
26 | - //TODO only for INTEROPER TREE | |
27 | - if (!this.get('leaf')) this.set('allowDrag', false); | |
28 | - if (this.get('isParameter')) this.set('allowDrag',true); | |
29 | - if (this.get('leaf') && this.get('isSpectra')) this.set('iconCls', 'icon-spectra'); | |
30 | - if (this.get('disable')) { | |
31 | - this.set('cls', 'icon-disabled'); | |
32 | - this.set('allowDrag', false); | |
33 | - } | |
34 | - }, | |
35 | - | |
36 | - | |
37 | - allMenuItems : function() { | |
38 | - var menuItems = | |
39 | - [{ | |
40 | - fnId : 'dire-addData', | |
41 | - text : 'Add Data' | |
42 | - },{ | |
43 | - fnId : 'root-addData', | |
44 | - text : 'Add Data' | |
45 | - },{ | |
46 | - fnId : 'dire-deleteNode', | |
47 | - text : 'Delete Data' | |
48 | - },{ | |
49 | - fnId : 'root-collapseAll', | |
50 | - text : 'Close All' | |
51 | - }, { | |
52 | - fnId : 'dire-collapseAll', | |
53 | - text : 'Close All' | |
54 | - }, { | |
55 | - fnId : 'para-plotParam', | |
56 | - text : 'Plot Parameter', | |
57 | - hidden : true | |
58 | - }, { | |
59 | - fnId : 'para-downParam', | |
60 | - text : 'Download Parameter', | |
61 | - hidden : true | |
62 | - },{ | |
63 | - fnId : 'leaf-createAlias', | |
64 | - text : 'Create/Edit Alias' | |
65 | - }, { | |
66 | - fnId : 'leaf-createDerivedParam', | |
67 | - text : 'Create Derived Parameter' | |
68 | - },{ | |
69 | - fnId : 'leaf-deleteNode', | |
70 | - text : 'Delete Parameter' | |
71 | - },{ | |
72 | - fnId : 'leaf-plotParam', | |
73 | - text : 'Plot Parameter', | |
74 | - hidden : true | |
75 | - }, { | |
76 | - fnId : 'leaf-downParam', | |
77 | - text : 'Download Parameter', | |
78 | - hidden : true | |
79 | - }]; | |
80 | - | |
81 | - return menuItems; | |
82 | - } , | |
83 | - | |
84 | - onMenuItemClick : function(menu,item,event) { | |
12 | + statics:{ | |
13 | + nodeType: 'remoteParam' | |
14 | + }, | |
85 | 15 | |
86 | - if (item) { | |
87 | - switch (item.fnId) { | |
16 | + fields: [{name: 'isRemoteDataSet', type:'boolean', persist: false, defaultValue: true}, | |
17 | + {name: 'isSimulation', type:'boolean', defaultValue: false}], | |
18 | + | |
19 | + constructor : function(config){ | |
20 | + this.callParent(arguments); | |
21 | + | |
22 | + //TODO only for INTEROPER TREE | |
23 | + if (!this.get('leaf')) this.set('allowDrag', false); | |
24 | + if (this.get('isParameter')) this.set('allowDrag',true); | |
25 | + if (this.get('leaf') && this.get('isSpectra')) this.set('iconCls', 'icon-spectra'); | |
26 | + | |
27 | + if (this.get('disable')) { | |
28 | + this.set('cls', 'icon-disabled'); | |
29 | + this.set('allowDrag', false); | |
30 | + } | |
31 | + }, | |
88 | 32 | |
89 | - case 'root-collapseAll': | |
90 | - case 'dire-collapseAll': | |
91 | - if(this && !this.isLeaf()) { | |
92 | - this.collapse(true); | |
93 | - } | |
94 | - break; | |
95 | - case 'leaf-createDerivedParam': | |
96 | - this.createLeaf(this); | |
97 | - break; | |
98 | - case 'leaf-createAlias': | |
99 | - this.createAlias(this); | |
100 | - break; | |
101 | - case 'leaf-deleteNode': | |
102 | - case 'dire-deleteNode' : | |
103 | - this.deleteData(); | |
104 | - break; | |
105 | - case 'dire-addData': | |
106 | - case 'root-addData': | |
107 | - this.addData(); | |
108 | - break; | |
109 | - case 'leaf-plotParam': | |
110 | - case 'para-plotParam': | |
111 | - this.createPlot(this); | |
112 | - break; | |
113 | - case 'leaf-downParam': | |
114 | - case 'para-downParam': | |
115 | - this.createDownload(this); | |
116 | - break; | |
117 | - default: | |
118 | - break; | |
119 | - } | |
120 | - } | |
121 | - }, | |
33 | + allMenuItems : function() { | |
34 | + var menuItems = | |
35 | + [{ | |
36 | + fnId : 'dire-addData', | |
37 | + text : 'Add Data' | |
38 | + },{ | |
39 | + fnId : 'root-addData', | |
40 | + text : 'Add Data' | |
41 | + },{ | |
42 | + fnId : 'dire-deleteNode', | |
43 | + text : 'Delete Data' | |
44 | + },{ | |
45 | + fnId : 'root-collapseAll', | |
46 | + text : 'Close All' | |
47 | + }, { | |
48 | + fnId : 'dire-collapseAll', | |
49 | + text : 'Close All' | |
50 | + }, { | |
51 | + fnId : 'para-plotParam', | |
52 | + text : 'Plot Parameter', | |
53 | + hidden : true | |
54 | + }, { | |
55 | + fnId : 'para-downParam', | |
56 | + text : 'Download Parameter', | |
57 | + hidden : true | |
58 | + },{ | |
59 | + fnId : 'leaf-createAlias', | |
60 | + text : 'Create/Edit Alias' | |
61 | + }, { | |
62 | + fnId : 'leaf-createDerivedParam', | |
63 | + text : 'Create Derived Parameter' | |
64 | + },{ | |
65 | + fnId : 'leaf-deleteNode', | |
66 | + text : 'Delete Parameter' | |
67 | + },{ | |
68 | + fnId : 'leaf-plotParam', | |
69 | + text : 'Plot Parameter', | |
70 | + hidden : true | |
71 | + }, { | |
72 | + fnId : 'leaf-downParam', | |
73 | + text : 'Download Parameter', | |
74 | + hidden : true | |
75 | + }]; | |
76 | + | |
77 | + return menuItems; | |
78 | + }, | |
122 | 79 | |
123 | - deleteData : function() { | |
124 | - // var parent = this.parentNode; | |
125 | - AmdaAction.deleteFromTree({nodeType: this.get('nodeType'), id : this.get('id')}, function(res,e){ | |
126 | - //TODO if () not error ?? | |
127 | - this.remove(); | |
128 | - this.destroy(); | |
129 | - },this); | |
130 | - }, | |
80 | + onMenuItemClick : function(menu,item,event) { | |
81 | + if (item) { | |
82 | + switch (item.fnId) { | |
83 | + case 'root-collapseAll': | |
84 | + case 'dire-collapseAll': | |
85 | + if(this && !this.isLeaf()) { | |
86 | + this.collapse(true); | |
87 | + } | |
88 | + break; | |
89 | + case 'leaf-createDerivedParam': | |
90 | + this.createLeaf(this); | |
91 | + break; | |
92 | + case 'leaf-createAlias': | |
93 | + this.createAlias(this); | |
94 | + break; | |
95 | + case 'leaf-deleteNode': | |
96 | + case 'dire-deleteNode' : | |
97 | + this.deleteData(); | |
98 | + break; | |
99 | + case 'dire-addData': | |
100 | + case 'root-addData': | |
101 | + this.addData(); | |
102 | + break; | |
103 | + case 'leaf-plotParam': | |
104 | + case 'para-plotParam': | |
105 | + this.createPlot(this); | |
106 | + break; | |
107 | + case 'leaf-downParam': | |
108 | + case 'para-downParam': | |
109 | + this.createDownload(this); | |
110 | + break; | |
111 | + default: | |
112 | + break; | |
113 | + } | |
114 | + } | |
115 | + }, | |
131 | 116 | |
132 | - addData : function() { | |
117 | + deleteData : function() { | |
118 | + // var parent = this.parentNode; | |
119 | + AmdaAction.deleteFromTree({nodeType: this.get('nodeType'), id : this.get('id')}, function(res,e){ | |
120 | + //TODO if () not error ?? | |
121 | + this.remove(); | |
122 | + this.destroy(); | |
123 | + },this); | |
124 | + }, | |
133 | 125 | |
134 | - if (this.get('disable')) return; | |
126 | + addData : function() { | |
127 | + if (this.get('disable')) return; | |
135 | 128 | |
136 | - var me = this; | |
137 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) { | |
138 | - module.createWindow(me.getBaseId()); | |
139 | - }); | |
129 | + var me = this; | |
130 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) { | |
131 | + module.createWindow(me.getBaseId()); | |
132 | + }); | |
140 | 133 | }, |
141 | 134 | |
142 | -// Depth of Base Root Node = 3 : root, Parameters, Remote Parameters, BaseName | |
143 | - getBaseId : function() { | |
144 | - | |
145 | - if (this.getDepth() < 3) return 'root'; | |
135 | + // Depth of Base Root Node = 3 : root, Parameters, Remote Parameters, BaseName | |
136 | + getBaseId : function() { | |
137 | + if (this.getDepth() < 3) return 'root'; | |
146 | 138 | |
147 | - var node = this; | |
148 | - while (node.getDepth() > 3) { | |
149 | - node = node.parentNode; | |
139 | + var node = this; | |
140 | + while (node.getDepth() > 3) { | |
141 | + node = node.parentNode; | |
142 | + } | |
143 | + return node.get('id'); | |
150 | 144 | } |
151 | - return node.get('id'); | |
152 | - } | |
153 | - | |
154 | 145 | }); |
... | ... |
js/app/views/ExplorerUI.js
1 | 1 | /** |
2 | 2 | * Project : AMDA-NG4 |
3 | 3 | * Name : ExplorerUI.js |
4 | - * Description : Explorer Module UI definition (View) | |
5 | - * @class amdaUI.ExplorerUI | |
4 | + * @class amdaUI.ExplorerUI | |
6 | 5 | * @extends Ext.tab.Panel |
6 | + * @class amdaUI.TreeToolColumn | |
7 | + * @extends Ext.tree.Column | |
8 | + * @class MyTreeEditor | |
9 | + * @extends Ext.grid.plugin.CellEditing | |
7 | 10 | * @brief Explorer View |
8 | 11 | * @author CDA |
9 | - * @version $Id: ExplorerUI.js 2544 2014-10-03 10:21:56Z elena $ | |
10 | 12 | */ |
11 | 13 | |
12 | 14 | Ext.define('amdaUI.TreeToolColumn', { |
13 | - extend: 'Ext.tree.Column', | |
14 | - alias: 'widget.treetoolcolumn', | |
15 | - | |
16 | - /** | |
17 | - * Add more tools here. These will be on the prototype for all TreeToolColumns | |
18 | - */ | |
19 | - tools: { | |
20 | - 'info': 'js/resources/images/16x16/info_mini.png' | |
21 | - }, | |
22 | - | |
23 | - initComponent: function() | |
24 | - { | |
25 | - var me = this; | |
26 | - me.addEvents( 'toolclick' ); | |
27 | - me.callParent(); | |
28 | - me.on('toolclick', me.toolHandler, me); | |
29 | - }, | |
30 | - | |
31 | - renderer: function(value, metaData, record, rowIdx, colIdx, store, view) | |
32 | - { | |
33 | - var toolCol = view.getHeaderAtIndex(colIdx); | |
34 | - | |
35 | - if (!toolCol.toolIsVisible(record)) | |
36 | - return value; | |
37 | - | |
38 | - var toolId = 'tool-' + rowIdx + '-' + colIdx, | |
39 | - toolImg = toolCol.tools[toolCol.tool], | |
40 | - imgHtml = Ext.DomHelper.markup({ | |
41 | - id : toolId, | |
42 | - tag : 'img', | |
43 | - tooltype: toolCol.tool, | |
44 | - src : toolImg, | |
45 | - style : 'cursor:hand;' | |
46 | - }); | |
47 | - | |
48 | - return value + ' ' + imgHtml; | |
49 | - }, | |
50 | - | |
51 | - processEvent: function(type, view, cell, recordIndex, cellIndex, e) | |
52 | - { | |
53 | - if(type === "click" && e.target.tagName === "IMG") | |
54 | - { | |
55 | - var tooltype = e.target.getAttribute("tooltype"); | |
56 | - if(tooltype) | |
57 | - return this.fireEvent("toolclick", view, cell, recordIndex, cellIndex, e); | |
58 | - } | |
59 | - return this.fireEvent.apply(this, arguments); | |
60 | - }, | |
61 | - | |
62 | - /** | |
63 | - * Override this when you add columns to the tree... see example below | |
64 | - */ | |
15 | + extend: 'Ext.tree.Column', | |
16 | + alias: 'widget.treetoolcolumn', | |
17 | + | |
18 | + /** | |
19 | + * Add more tools here. These will be on the prototype for all TreeToolColumns | |
20 | + */ | |
21 | + tools: { | |
22 | + 'info': 'js/resources/images/16x16/info_mini.png' | |
23 | + }, | |
24 | + | |
25 | + initComponent: function() | |
26 | + { | |
27 | + var me = this; | |
28 | + me.addEvents('toolclick'); | |
29 | + me.callParent(); | |
30 | + me.on('toolclick', me.toolHandler, me); | |
31 | + }, | |
32 | + | |
33 | + renderer: function(value, metaData, record, rowIdx, colIdx, store, view) | |
34 | + { | |
35 | + var toolCol = view.getHeaderAtIndex(colIdx); | |
36 | + | |
37 | + if (!toolCol.toolIsVisible(record)) return value; | |
38 | + | |
39 | + var toolId = 'tool-' + rowIdx + '-' + colIdx, | |
40 | + toolImg = toolCol.tools[toolCol.tool], | |
41 | + imgHtml = Ext.DomHelper.markup({ | |
42 | + id : toolId, | |
43 | + tag : 'img', | |
44 | + tooltype: toolCol.tool, | |
45 | + src : toolImg, | |
46 | + style : 'cursor:hand;' | |
47 | + }); | |
48 | + | |
49 | + return value + ' ' + imgHtml; | |
50 | + }, | |
51 | + | |
52 | + processEvent: function(type, view, cell, recordIndex, cellIndex, e) | |
53 | + { | |
54 | + if(type === "click" && e.target.tagName === "IMG") | |
55 | + { | |
56 | + var tooltype = e.target.getAttribute("tooltype"); | |
57 | + if(tooltype) | |
58 | + return this.fireEvent("toolclick", view, cell, recordIndex, cellIndex, e); | |
59 | + } | |
60 | + return this.fireEvent.apply(this, arguments); | |
61 | + }, | |
62 | + | |
63 | + /** | |
64 | + * Override this when you add columns to the tree... see example below | |
65 | + */ | |
65 | 66 | // toolHandler: function() { |
66 | 67 | // alert("override this"); |
67 | 68 | // }, |
68 | 69 | |
69 | - toolIsVisible : function(record) { | |
70 | - return false; | |
71 | - } | |
70 | + toolIsVisible : function(record) { | |
71 | + return false; | |
72 | + } | |
72 | 73 | }); |
73 | 74 | |
74 | 75 | |
76 | +// ExplorerUI | |
75 | 77 | Ext.define('amdaUI.ExplorerUI', { |
76 | - | |
77 | - extend: 'Ext.tab.Panel', | |
78 | - alias : 'widget.panelExplorer', | |
79 | - | |
80 | - statics: | |
81 | - { | |
82 | - RESRC_TAB : { | |
83 | - TREE_ID:'resourcesTree', | |
84 | - TREE_TYPE:'resources' | |
85 | - }, | |
86 | - OPE_TAB : { | |
87 | - TREE_ID:'operationsTree', | |
88 | - TREE_TYPE:'operations' | |
89 | - }, | |
90 | - JOB_TAB : { | |
91 | - TREE_ID:'jobsTree', | |
92 | - TREE_TYPE:'jobs' | |
93 | - }, | |
94 | - | |
95 | - CAT_SUFFIX: '-treeBase', | |
96 | - ROOT_SUFFIX: '-treeRootNode', | |
97 | - SUB_ROOT_SUFFIX : 'RootNode', | |
98 | - | |
99 | - ITEM_KIND_ROOT : 'root', | |
100 | - ITEM_KIND_LEAF : 'leaf', | |
101 | - ITEM_KIND_DIRE : 'dire', | |
102 | - ITEM_KIND_PARA : 'para', | |
103 | - ITEM_KIND_MISS : 'miss' | |
104 | - }, | |
105 | - | |
106 | - initComponent : function (config) { | |
107 | - | |
108 | - var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
109 | - | |
110 | - var myConf = { | |
111 | - split : true, | |
112 | - width : '100%', | |
113 | - height : '100%', | |
114 | - autoScroll : true, | |
115 | - border : true, | |
116 | - header : false, | |
117 | - defaults : { | |
118 | - // applied to each contained panel | |
119 | - containerScroll : true | |
120 | - }, | |
121 | - stateful: true, | |
122 | - // stateId: 'tp1', | |
123 | - stateEvents: ['tabchange'], | |
124 | - getState: function() { | |
125 | - return { | |
126 | - activeTab: this.items.findIndex('id',this.getActiveTab().id) | |
127 | - }; | |
128 | - }, | |
129 | - applyState: function(s) { | |
130 | - this.setActiveTab(s.activeTab); | |
131 | - }, | |
132 | - // activeTab: 0, | |
133 | - items: [ | |
134 | - this.initTree(amdaUI.ExplorerUI.RESRC_TAB.TREE_TYPE), | |
135 | - this.initTree(amdaUI.ExplorerUI.OPE_TAB.TREE_TYPE), | |
136 | - this.initTree(amdaUI.ExplorerUI.JOB_TAB.TREE_TYPE) | |
137 | - ], | |
138 | - tbar : [ | |
139 | - { | |
140 | - xtype : 'combo', | |
141 | - fieldLabel: 'Filter', | |
142 | - labelWidth: 25, | |
143 | - width: 140, | |
144 | - store: explorerModule.filtersStore, | |
145 | - queryMode: 'local', | |
146 | - displayField: 'name', | |
147 | - valueField: 'id', | |
148 | - listeners : { | |
149 | - scope : this, | |
150 | - select: function(combo, records) { | |
151 | - AmdaAction.setCrtFilterId({id : records[0].get('id')}, | |
152 | - function (result, e) | |
153 | - { | |
154 | - var t = e.getTransaction(); | |
155 | - if (e.status) | |
156 | - { | |
157 | - if (result) | |
158 | - { | |
159 | - var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
160 | - if (explorerModule) | |
161 | - explorerModule.setCrtFilter(); | |
162 | - } | |
163 | - else | |
164 | - Ext.Msg.show( { | |
165 | - title : 'Filter', | |
166 | - msg : 'Cannot apply filter', | |
167 | - modal : true, | |
168 | - icon : Ext.Msg.ERROR, | |
169 | - buttons : Ext.Msg.OK | |
170 | - }); | |
171 | - } | |
172 | - else | |
173 | - { | |
174 | - // FAILURE | |
175 | - Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | |
176 | - } | |
177 | - },this); | |
178 | - } | |
179 | - } | |
180 | - }, | |
181 | - { | |
182 | - text: '', | |
183 | - iconCls : 'icon-parameters', | |
184 | - tooltip: { text: 'Edit Filter', align: 'bl-tl' }, | |
185 | - handler: function(t){ | |
186 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.filters.id, true, function (module) { | |
187 | - module.createWindow(); | |
188 | - }); | |
189 | - } | |
190 | - }, | |
191 | - { | |
192 | - text: '', | |
193 | - iconCls : 'icon-remover', | |
194 | - tooltip: { text: 'Reset Filter', align: 'bl-tl' }, | |
195 | - handler: function(t){ | |
196 | - var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
197 | - explorerModule.resetFilter(); | |
198 | - } | |
199 | - }, '-', | |
200 | - { | |
201 | - xtype: 'displayfield', | |
202 | - fieldLabel: 'SortBy', | |
203 | - width: 40 | |
204 | - }, | |
205 | - { | |
206 | - text: 'Name', | |
207 | - scope : this, | |
208 | - tooltip: { text: 'Sort out AMDA DataBase Data by Mission Name', align: 'bl-tl' }, | |
209 | - pressed: true, | |
210 | - enableToggle : true, | |
211 | - toggleGroup: 'sorting', | |
212 | - handler: function(){ | |
213 | - var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
214 | - tree.getStore().sort([ | |
215 | - { sorterFn: function(o1, o2){ | |
216 | - if (o1.get('nodeType') !== 'localParam') | |
217 | - return; | |
218 | - | |
219 | - return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1; | |
220 | - } } ]); | |
221 | - this.updateFilter(); | |
222 | - } | |
223 | - }, | |
224 | - { | |
225 | - text: 'Target', | |
226 | - scope : this, | |
227 | - tooltip: { text: 'Sort out AMDA DataBase Data by Mission Main Target', align: 'bl-tl' }, | |
228 | - enableToggle : true, | |
229 | - toggleGroup: 'sorting', | |
230 | - handler: function(){ | |
231 | - var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
232 | - tree.getStore().sort([{ property : 'rank' }]); | |
233 | - this.updateFilter(); | |
234 | - } | |
235 | - } | |
236 | - ] | |
237 | - }; | |
238 | - Ext.apply (this , Ext.apply (arguments, myConf)); | |
239 | - this.callParent(arguments); | |
240 | - }, | |
241 | - | |
242 | - initTree : function(treeType){ | |
243 | - | |
244 | - switch (treeType) { | |
245 | - case amdaUI.ExplorerUI.RESRC_TAB.TREE_TYPE: | |
246 | - treeId = amdaUI.ExplorerUI.RESRC_TAB.TREE_ID; | |
247 | - break; | |
248 | - case amdaUI.ExplorerUI.OPE_TAB.TREE_TYPE: | |
249 | - treeId = amdaUI.ExplorerUI.OPE_TAB.TREE_ID; | |
250 | - break; | |
251 | - case amdaUI.ExplorerUI.JOB_TAB.TREE_TYPE: | |
252 | - treeId = amdaUI.ExplorerUI.JOB_TAB.TREE_ID; | |
253 | - break; | |
254 | - default: | |
255 | - treeId = amdaUI.ExplorerUI.RESRC_TAB.TREE_ID; | |
256 | - break; | |
257 | - } | |
258 | - | |
259 | - var store = Ext.create('Ext.data.TreeStore', { | |
260 | - root: { | |
261 | - expanded: true, | |
262 | - nodeType : treeType | |
263 | - }, | |
264 | - model: 'amdaModel.AmdaNode', | |
265 | - sorters:[{ direction: 'DES' }, | |
266 | - { sorterFn: function(o1, o2){ | |
267 | - if (o1.get('nodeType') !== 'localParam') | |
268 | - return; | |
269 | - | |
270 | - return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1; | |
271 | - } }], | |
272 | - listeners: { | |
273 | - beforeload: function(store, operation){ | |
274 | - store.proxy.extraParams = { | |
275 | - nodeType: operation.node.get('nodeType') | |
276 | - }; | |
277 | - } | |
278 | - } | |
279 | - | |
280 | - }); | |
281 | - | |
282 | - var menu = new Ext.menu.Menu(); | |
283 | - | |
284 | - var tree = Ext.create('Ext.tree.Panel', { | |
285 | - id : treeId, | |
286 | - title: treeType, | |
287 | - store: store, | |
288 | - rootVisible: false, | |
289 | - animate: false, | |
290 | - hideHeaders : true, | |
291 | - selModel: Ext.create('Ext.selection.TreeModel', { | |
292 | - // ignoreRightMouseSelection: true, | |
293 | - mode: 'MULTI' | |
294 | - }), | |
295 | - | |
296 | - viewConfig: | |
297 | - { | |
298 | - plugins: | |
299 | - { | |
300 | - ptype: 'treeviewdragdrop', | |
301 | - enableDrag:true, | |
302 | - enableDrop:true, | |
303 | - //TODO - BRE - Wait a fix for drag&drop issue | |
304 | - ddGroup:'explorerTree', | |
305 | - pluginId : 'ddplugin', | |
306 | - isValidDropPoint : function (node, position, dragZone, e, data) | |
307 | - { | |
308 | - if (!node || !data.item) { | |
309 | - return false; | |
310 | - } | |
311 | - | |
312 | - var view = this.view, | |
313 | - targetNode = view.getRecord(node), | |
314 | - draggedRecords = data.records, | |
315 | - dataLength = draggedRecords.length, | |
316 | - ln = draggedRecords.length, | |
317 | - i, record; | |
318 | - | |
319 | - // No drop position, or dragged records: invalid drop point | |
320 | - if (!(targetNode && position && dataLength)) { | |
321 | - return false; | |
322 | - } | |
323 | - | |
324 | - // If the targetNode is within the folder we are dragging | |
325 | - for (i = 0; i < ln; i++) { | |
326 | - record = draggedRecords[i]; | |
327 | - if (record.isNode && record.contains(targetNode)) { | |
328 | - return false; | |
329 | - } | |
330 | - } | |
331 | - | |
332 | - // Respect the allowDrop field on Tree nodes | |
333 | - if (position === 'append' && targetNode.get('allowDrop') === false) { | |
334 | - return false; | |
335 | - } | |
336 | - else if (position != 'append' && targetNode.parentNode.get('allowDrop') === false) { | |
337 | - return false; | |
338 | - } | |
339 | - | |
340 | - // If the target record is in the dragged dataset, then invalid drop | |
341 | - if (Ext.Array.contains(draggedRecords, targetNode)) { | |
342 | - return false; | |
343 | - } | |
344 | - | |
345 | - // | |
346 | - if (dataLength > 1) | |
347 | - return false; | |
348 | - var draggedRecord = draggedRecords[0]; | |
349 | - | |
350 | - // | |
351 | - switch (targetNode.data.nodeType) | |
352 | - { | |
353 | - case 'localParam' : | |
354 | - case 'remoteParam' : | |
355 | - case 'remoteSimuParam' : | |
356 | - case 'myData' : | |
357 | - return false; | |
358 | - default : | |
359 | - if (draggedRecord.data.id == targetNode.data.nodeType+'-treeRootNode') | |
360 | - return false; | |
361 | - if ((position == 'before') && (targetNode.data.id == targetNode.data.nodeType+'-treeRootNode')) | |
362 | - return false; | |
363 | - return (draggedRecord.data.nodeType == targetNode.data.nodeType); | |
364 | - } | |
365 | - return false; | |
366 | - }, | |
367 | - onViewRender : function(view) | |
368 | - { | |
369 | - var me = this; | |
370 | - | |
371 | - view.on('itemupdate', function(record,index,node,opts) | |
372 | - { | |
373 | - var forceHide = false; | |
374 | - var crtRec = record.parentNode; | |
375 | - while (crtRec && !forceHide) | |
376 | - { | |
377 | - if (crtRec.get('filtered')) | |
378 | - forceHide = crtRec.get('filtered'); | |
379 | - crtRec = crtRec.parentNode; | |
380 | - } | |
381 | - tree.setNodesVisibility(record,forceHide); | |
382 | - tree.applyDisableToNode(record); | |
383 | - }); | |
384 | - | |
385 | - view.on('itemadd', function(records,index,node,opts) | |
386 | - { | |
387 | - Ext.each(records,function (rec) | |
388 | - { | |
389 | - tree.applyFilterToNode(rec); | |
390 | - tree.applyDisableToNode(rec); | |
391 | - }); | |
392 | - | |
393 | - }); | |
394 | - | |
395 | - view.on('afteritemexpand', function(record,index,node,opts) | |
396 | - { | |
397 | - var forceHide = false; | |
398 | - var crtRec = record.parentNode; | |
399 | - while (crtRec && !forceHide) | |
400 | - { | |
401 | - if (crtRec.get('filtered')) | |
402 | - forceHide = crtRec.get('filtered'); | |
403 | - crtRec = crtRec.parentNode; | |
404 | - | |
405 | - } | |
406 | - tree.setNodesVisibility(record,forceHide); | |
407 | - tree.applyDisableToNode(record); | |
408 | - }); | |
409 | - | |
410 | - if (me.enableDrag) | |
411 | - { | |
412 | - me.dragZone = Ext.create('Ext.tree.ViewDragZone', { | |
413 | - view: view, | |
414 | - ddGroup: me.dragGroup || me.ddGroup, | |
415 | - dragText: me.dragText, | |
416 | - repairHighlightColor: me.nodeHighlightColor, | |
417 | - repairHighlight: me.nodeHighlightOnRepair | |
418 | - }); | |
419 | - } | |
420 | - | |
421 | - if (me.enableDrop) | |
422 | - { | |
423 | - me.dropZone = Ext.create('Ext.tree.ViewDropZone', { | |
424 | - view: view, | |
425 | - ddGroup: me.dropGroup || me.ddGroup, | |
426 | - allowContainerDrops: me.allowContainerDrops, | |
427 | - appendOnly: me.appendOnly, | |
428 | - allowParentInserts: me.allowParentInserts, | |
429 | - expandDelay: me.expandDelay, | |
430 | - dropHighlightColor: me.nodeHighlightColor, | |
431 | - dropHighlight: me.nodeHighlightOnDrop, | |
432 | - isValidDropPoint : me.isValidDropPoint | |
433 | - }); | |
434 | - } | |
435 | - } | |
436 | - }, | |
437 | - listeners : | |
438 | - { | |
439 | - beforedrop : function(node, data, overModel, dropPosition) | |
440 | - { | |
441 | - var parentId; | |
442 | - switch(dropPosition) | |
443 | - { | |
444 | - case 'append' : | |
445 | - if (overModel.isLeaf()) | |
446 | - parentId = overModel.parentNode.get('id'); | |
447 | - else | |
448 | - parentId = overModel.get('id'); | |
449 | - | |
450 | - if(!overModel.isExpanded() && overModel.isExpandable()) { | |
451 | - myDesktopApp.warningMsg('Please open the folder before node adding'); | |
452 | - return false; | |
453 | - } | |
454 | - break; | |
455 | - case 'before' : | |
456 | - case 'after' : | |
457 | - parentId = overModel.parentNode.get('id'); | |
458 | - break; | |
459 | - } | |
460 | - | |
461 | - Ext.each(data.records, function(rec) | |
462 | - { | |
463 | - rec.renameDD(parentId,function(result) | |
464 | - { | |
465 | - if (result) | |
466 | - { | |
467 | - if (!result.id) | |
468 | - { | |
469 | - Ext.Msg.show({ | |
470 | - title : 'Drop is impossible', | |
471 | - msg : result.error, | |
472 | - buttons : Ext.Msg.OK, | |
473 | - icon : Ext.MessageBox.WARNING | |
474 | - }); | |
475 | - | |
476 | - return false; | |
477 | - } | |
478 | - } | |
479 | - else | |
480 | - { | |
481 | - Ext.Msg.show({ | |
482 | - title : 'Drop is impossible', | |
483 | - msg : 'Cannot connect to the server', | |
484 | - buttons : Ext.Msg.OK, | |
485 | - icon : Ext.MessageBox.WARNING | |
486 | - }); | |
487 | - | |
488 | - return false; | |
489 | - } | |
490 | - | |
491 | - return true; | |
492 | - }); | |
493 | - }); | |
494 | - } | |
495 | - }, | |
496 | - }, | |
497 | - listeners: { | |
498 | - | |
499 | - itemmouseenter: function(view, record, item){ | |
500 | - if(record.get('isParameter')){ | |
501 | - var el = Ext.get(item), | |
502 | - td = el.down('td > div'); | |
503 | - td.setStyle('cursor', 'crosshair'); | |
504 | - } | |
505 | - else | |
506 | - { | |
507 | - var el = Ext.get(item), | |
508 | - td = el.down('td > div'); | |
509 | - td.setStyle('cursor', 'pointer'); | |
510 | - } | |
78 | + extend: 'Ext.tab.Panel', | |
79 | + alias : 'widget.panelExplorer', | |
80 | + | |
81 | + statics: | |
82 | + { | |
83 | + RESRC_TAB : { | |
84 | + TREE_ID:'resourcesTree', | |
85 | + TREE_TYPE:'resources' | |
86 | + }, | |
87 | + OPE_TAB : { | |
88 | + TREE_ID:'operationsTree', | |
89 | + TREE_TYPE:'operations' | |
90 | + }, | |
91 | + JOB_TAB : { | |
92 | + TREE_ID:'jobsTree', | |
93 | + TREE_TYPE:'jobs' | |
511 | 94 | }, |
512 | 95 | |
513 | - itemcontextmenu: function(view, rec, item, index, e){ | |
514 | - // block other events | |
515 | - e.stopEvent(); | |
96 | + CAT_SUFFIX: '-treeBase', | |
97 | + ROOT_SUFFIX: '-treeRootNode', | |
98 | + SUB_ROOT_SUFFIX : 'RootNode', | |
516 | 99 | |
517 | - // unlock selection | |
518 | -// view.ownerCt.getSelectionModel().setLocked(false); | |
519 | - // already selected by default by right click | |
520 | -// view.ownerCt.getSelectionModel().select(rec,true); | |
100 | + ITEM_KIND_ROOT : 'root', | |
101 | + ITEM_KIND_LEAF : 'leaf', | |
102 | + ITEM_KIND_DIRE : 'dire', | |
103 | + ITEM_KIND_PARA : 'para', | |
104 | + ITEM_KIND_MISS : 'miss' | |
105 | + }, | |
521 | 106 | |
522 | - // clear menu items | |
523 | - menu.removeAll(); | |
524 | - var menuItems; | |
107 | + initComponent : function (config) | |
108 | + { | |
109 | + var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
110 | + | |
111 | + var myConf = { | |
112 | + split : true, | |
113 | + width : '100%', | |
114 | + height : '100%', | |
115 | + autoScroll : true, | |
116 | + border : true, | |
117 | + header : false, | |
118 | + defaults : { | |
119 | + // applied to each contained panel | |
120 | + containerScroll : true | |
121 | + }, | |
122 | + stateful: true, | |
123 | + //stateId: 'tp1', | |
124 | + stateEvents: ['tabchange'], | |
125 | + getState: function() { | |
126 | + return { | |
127 | + activeTab: this.items.findIndex('id',this.getActiveTab().id) | |
128 | + }; | |
129 | + }, | |
130 | + applyState: function(s) { | |
131 | + this.setActiveTab(s.activeTab); | |
132 | + }, | |
133 | + items: [ | |
134 | + this.initTree(amdaUI.ExplorerUI.RESRC_TAB.TREE_TYPE), | |
135 | + this.initTree(amdaUI.ExplorerUI.OPE_TAB.TREE_TYPE), | |
136 | + this.initTree(amdaUI.ExplorerUI.JOB_TAB.TREE_TYPE) | |
137 | + ], | |
138 | + tbar : [ | |
139 | + { | |
140 | + xtype : 'combo', | |
141 | + fieldLabel: 'Filter', | |
142 | + labelWidth: 25, | |
143 | + width: 140, | |
144 | + store: explorerModule.filtersStore, | |
145 | + queryMode: 'local', | |
146 | + displayField: 'name', | |
147 | + valueField: 'id', | |
148 | + listeners : { | |
149 | + scope : this, | |
150 | + select: function(combo, records) { | |
151 | + AmdaAction.setCrtFilterId({id : records[0].get('id')}, | |
152 | + function (result, e) | |
153 | + { | |
154 | + var t = e.getTransaction(); | |
155 | + if (e.status) | |
156 | + { | |
157 | + if (result) | |
158 | + { | |
159 | + var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
160 | + if (explorerModule) | |
161 | + explorerModule.setCrtFilter(); | |
162 | + } | |
163 | + else | |
164 | + Ext.Msg.show( { | |
165 | + title : 'Filter', | |
166 | + msg : 'Cannot apply filter', | |
167 | + modal : true, | |
168 | + icon : Ext.Msg.ERROR, | |
169 | + buttons : Ext.Msg.OK | |
170 | + }); | |
171 | + } | |
172 | + else | |
173 | + { | |
174 | + // FAILURE | |
175 | + Ext.Msg.show({title:'Error System', msg: e.message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK}); | |
176 | + } | |
177 | + },this); | |
178 | + } | |
179 | + } | |
180 | + }, | |
181 | + { | |
182 | + text: '', | |
183 | + iconCls : 'icon-parameters', | |
184 | + tooltip: { text: 'Edit Filter', align: 'bl-tl' }, | |
185 | + handler: function(t){ | |
186 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.filters.id, true, function (module) { | |
187 | + module.createWindow(); | |
188 | + }); | |
189 | + } | |
190 | + }, | |
191 | + { | |
192 | + text: '', | |
193 | + iconCls : 'icon-remover', | |
194 | + tooltip: { text: 'Reset Filter', align: 'bl-tl' }, | |
195 | + handler: function(t){ | |
196 | + var explorerModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
197 | + explorerModule.resetFilter(); | |
198 | + } | |
199 | + }, '-', | |
200 | + { | |
201 | + xtype: 'displayfield', | |
202 | + fieldLabel: 'SortBy', | |
203 | + width: 40 | |
204 | + }, | |
205 | + { | |
206 | + text: 'Name', | |
207 | + scope : this, | |
208 | + tooltip: { text: 'Sort out AMDA DataBase Data by Mission Name', align: 'bl-tl' }, | |
209 | + pressed: true, | |
210 | + enableToggle : true, | |
211 | + toggleGroup: 'sorting', | |
212 | + handler: function(){ | |
213 | + var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
214 | + tree.getStore().sort([ | |
215 | + { sorterFn: function(o1, o2){ | |
216 | + if (o1.get('nodeType') !== 'localParam') | |
217 | + return; | |
525 | 218 | |
526 | - // if it's a single selection | |
527 | - if (view.ownerCt.getSelectionModel().selected.length === 1) { | |
528 | - // get items menu corresponding to right clicked record | |
529 | - menuItems = rec.getContextMenuItems(this); | |
219 | + return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1; | |
220 | + } | |
221 | + }]); | |
222 | + this.updateFilter(); | |
223 | + } | |
224 | + }, | |
225 | + { | |
226 | + text: 'Target', | |
227 | + scope : this, | |
228 | + tooltip: {text: 'Sort out AMDA DataBase Data by Mission Main Target', align: 'bl-tl'}, | |
229 | + enableToggle : true, | |
230 | + toggleGroup: 'sorting', | |
231 | + handler: function(){ | |
232 | + var tree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
233 | + tree.getStore().sort([{ property : 'rank' }]); | |
234 | + this.updateFilter(); | |
235 | + } | |
236 | + }] | |
237 | + }; | |
238 | + Ext.apply (this , Ext.apply (arguments, myConf)); | |
239 | + this.callParent(arguments); | |
240 | + }, | |
241 | + | |
242 | + initTree : function(treeType) | |
243 | + { | |
244 | + switch (treeType) | |
245 | + { | |
246 | + case amdaUI.ExplorerUI.RESRC_TAB.TREE_TYPE: | |
247 | + treeId = amdaUI.ExplorerUI.RESRC_TAB.TREE_ID; | |
248 | + break; | |
249 | + case amdaUI.ExplorerUI.OPE_TAB.TREE_TYPE: | |
250 | + treeId = amdaUI.ExplorerUI.OPE_TAB.TREE_ID; | |
251 | + break; | |
252 | + case amdaUI.ExplorerUI.JOB_TAB.TREE_TYPE: | |
253 | + treeId = amdaUI.ExplorerUI.JOB_TAB.TREE_ID; | |
254 | + break; | |
255 | + default: | |
256 | + treeId = amdaUI.ExplorerUI.RESRC_TAB.TREE_ID; | |
257 | + break; | |
258 | + } | |
530 | 259 | |
531 | - } else if (view.ownerCt.getSelectionModel().selected.length > 1) { | |
532 | - // get items menu corresponding to right clicked record | |
533 | - menuItems = rec.getContextMenuMultiItems(this); | |
260 | + var store = Ext.create('Ext.data.TreeStore', { | |
261 | + root: { | |
262 | + expanded: true, | |
263 | + nodeType : treeType | |
264 | + }, | |
265 | + model: 'amdaModel.AmdaNode', | |
266 | + sorters:[{ direction: 'DES' }, | |
267 | + { sorterFn: function(o1, o2){ | |
268 | + if (o1.get('nodeType') !== 'localParam') | |
269 | + return; | |
270 | + | |
271 | + return o1.get('text').toUpperCase() < o2.get('text').toUpperCase() ? -1 : 1; | |
272 | + } | |
273 | + }], | |
274 | + listeners: { | |
275 | + beforeload: function(store, operation){ | |
276 | + store.proxy.extraParams = { | |
277 | + nodeType: operation.node.get('nodeType') | |
278 | + }; | |
279 | + } | |
534 | 280 | } |
535 | - // if there's at least one item menu | |
536 | - if (menuItems && menuItems.length){ | |
537 | - // add the items | |
538 | - menu.add(menuItems); | |
539 | - // add listener on right clicked record | |
540 | - var onRecordClick = function (menu, item, e, eOpts) | |
281 | + }); | |
282 | + | |
283 | + var menu = new Ext.menu.Menu(); | |
284 | + | |
285 | + var tree = Ext.create('Ext.tree.Panel', { | |
286 | + id : treeId, | |
287 | + title: treeType, | |
288 | + store: store, | |
289 | + rootVisible: false, | |
290 | + animate: false, | |
291 | + hideHeaders : true, | |
292 | + selModel: Ext.create('Ext.selection.TreeModel', { | |
293 | + // ignoreRightMouseSelection: true, | |
294 | + mode: 'MULTI' | |
295 | + }), | |
296 | + viewConfig: | |
297 | + { | |
298 | + plugins: | |
299 | + { | |
300 | + ptype: 'treeviewdragdrop', | |
301 | + enableDrag:true, | |
302 | + enableDrop:true, | |
303 | + //TODO - BRE - Wait a fix for drag&drop issue | |
304 | + ddGroup:'explorerTree', | |
305 | + pluginId : 'ddplugin', | |
306 | + | |
307 | + isValidDropPoint : function (node, position, dragZone, e, data) | |
541 | 308 | { |
542 | - if (this.myGetOwnerTree().getSelectionModel().isSelected(this)) { | |
543 | - //Dispatch click event to the record | |
544 | - this.onMenuItemClick(menu,item,e); | |
309 | + if (!node || !data.item) { | |
310 | + return false; | |
545 | 311 | } |
546 | - //Remove old click listener | |
547 | - menu.removeListener('click',onRecordClick,this); | |
548 | - }; | |
312 | + var view = this.view, | |
313 | + targetNode = view.getRecord(node), | |
314 | + draggedRecords = data.records, | |
315 | + dataLength = draggedRecords.length, | |
316 | + ln = draggedRecords.length, | |
317 | + i, record; | |
318 | + | |
319 | + // No drop position, or dragged records: invalid drop point | |
320 | + if (!(targetNode && position && dataLength)) { | |
321 | + return false; | |
322 | + } | |
323 | + // If the targetNode is within the folder we are dragging | |
324 | + for (i = 0; i < ln; i++) { | |
325 | + record = draggedRecords[i]; | |
326 | + if (record.isNode && record.contains(targetNode)) { | |
327 | + return false; | |
328 | + } | |
329 | + } | |
330 | + // Respect the allowDrop field on Tree nodes | |
331 | + if (position === 'append' && targetNode.get('allowDrop') === false) { | |
332 | + return false; | |
333 | + } | |
334 | + else if (position != 'append' && targetNode.parentNode.get('allowDrop') === false) { | |
335 | + return false; | |
336 | + } | |
337 | + // If the target record is in the dragged dataset, then invalid drop | |
338 | + if (Ext.Array.contains(draggedRecords, targetNode)) { | |
339 | + return false; | |
340 | + } | |
341 | + // | |
342 | + if (dataLength > 1) | |
343 | + return false; | |
344 | + | |
345 | + var draggedRecord = draggedRecords[0]; | |
346 | + // | |
347 | + switch (targetNode.data.nodeType) | |
348 | + { | |
349 | + case 'localParam' : | |
350 | + case 'remoteParam' : | |
351 | + case 'remoteSimuParam' : | |
352 | + case 'myData' : | |
353 | + return false; | |
354 | + default : | |
355 | + if (draggedRecord.data.id == targetNode.data.nodeType+'-treeRootNode') | |
356 | + return false; | |
357 | + if ((position == 'before') && (targetNode.data.id == targetNode.data.nodeType+'-treeRootNode')) | |
358 | + return false; | |
359 | + return (draggedRecord.data.nodeType == targetNode.data.nodeType); | |
360 | + } | |
361 | + return false; | |
362 | + }, | |
363 | + onViewRender : function(view) | |
364 | + { | |
365 | + var me = this; | |
366 | + | |
367 | + view.on('itemupdate', function(record,index,node,opts) | |
368 | + { | |
369 | + var forceHide = false; | |
370 | + var crtRec = record.parentNode; | |
371 | + while (crtRec && !forceHide) | |
372 | + { | |
373 | + if (crtRec.get('filtered')) | |
374 | + forceHide = crtRec.get('filtered'); | |
375 | + crtRec = crtRec.parentNode; | |
376 | + } | |
377 | + tree.setNodesVisibility(record,forceHide); | |
378 | + tree.applyDisableToNode(record); | |
379 | + }); | |
380 | + | |
381 | + view.on('itemadd', function(records,index,node,opts) | |
382 | + { | |
383 | + Ext.each(records,function (rec) | |
384 | + { | |
385 | + tree.applyFilterToNode(rec); | |
386 | + tree.applyDisableToNode(rec); | |
387 | + }); | |
388 | + }); | |
389 | + | |
390 | + view.on('afteritemexpand', function(record,index,node,opts) | |
391 | + { | |
392 | + var forceHide = false; | |
393 | + var crtRec = record.parentNode; | |
394 | + while (crtRec && !forceHide) | |
395 | + { | |
396 | + if (crtRec.get('filtered')) | |
397 | + forceHide = crtRec.get('filtered'); | |
398 | + crtRec = crtRec.parentNode; | |
549 | 399 | |
550 | - menu.addListener('click',onRecordClick,rec); | |
551 | - // then show menu | |
552 | - menu.showAt(e.getXY()); | |
553 | - } | |
554 | - }, | |
400 | + } | |
401 | + tree.setNodesVisibility(record,forceHide); | |
402 | + tree.applyDisableToNode(record); | |
403 | + }); | |
404 | + | |
405 | + if (me.enableDrag) | |
406 | + { | |
407 | + me.dragZone = Ext.create('Ext.tree.ViewDragZone', { | |
408 | + view: view, | |
409 | + ddGroup: me.dragGroup || me.ddGroup, | |
410 | + dragText: me.dragText, | |
411 | + repairHighlightColor: me.nodeHighlightColor, | |
412 | + repairHighlight: me.nodeHighlightOnRepair | |
413 | + }); | |
414 | + } | |
555 | 415 | |
556 | - itemdblclick: function(view, record, item, index, event){ | |
557 | - event.stopEvent(); | |
558 | - | |
559 | - // first check if it is for SAVE-START-STOP plugin... | |
560 | - if (Ext.PluginManager.getCount() > 0 && | |
561 | - record.get('nodeType') == amdaModel.TimeTableNode.nodeType && record.isLeaf()) { | |
562 | - var zmgr = myDesktopApp.desktop.getDesktopZIndexManager(); | |
563 | - var winActive = zmgr.getActive(); | |
564 | - var winId = winActive.getId(); | |
565 | - if (winId == 'explorer-win') { | |
566 | - zmgr.eachTopDown(function(win) { | |
567 | - var id = win.getId(); | |
568 | - if (id !== 'explorer-win') { | |
569 | - winId = id; | |
570 | - return false; | |
416 | + if (me.enableDrop) | |
417 | + { | |
418 | + me.dropZone = Ext.create('Ext.tree.ViewDropZone', { | |
419 | + view: view, | |
420 | + ddGroup: me.dropGroup || me.ddGroup, | |
421 | + allowContainerDrops: me.allowContainerDrops, | |
422 | + appendOnly: me.appendOnly, | |
423 | + allowParentInserts: me.allowParentInserts, | |
424 | + expandDelay: me.expandDelay, | |
425 | + dropHighlightColor: me.nodeHighlightColor, | |
426 | + dropHighlight: me.nodeHighlightOnDrop, | |
427 | + isValidDropPoint : me.isValidDropPoint | |
428 | + }); | |
429 | + } | |
430 | + } | |
431 | + }, | |
432 | + listeners : | |
433 | + { | |
434 | + beforedrop : function(node, data, overModel, dropPosition) | |
435 | + { | |
436 | + var parentId; | |
437 | + switch(dropPosition) | |
438 | + { | |
439 | + case 'append' : | |
440 | + if (overModel.isLeaf()) | |
441 | + parentId = overModel.parentNode.get('id'); | |
442 | + else | |
443 | + parentId = overModel.get('id'); | |
444 | + | |
445 | + if(!overModel.isExpanded() && overModel.isExpandable()) { | |
446 | + myDesktopApp.warningMsg('Please open the folder before node adding'); | |
447 | + return false; | |
448 | + } | |
449 | + break; | |
450 | + case 'before' : | |
451 | + case 'after' : | |
452 | + parentId = overModel.parentNode.get('id'); | |
453 | + break; | |
571 | 454 | } |
572 | - }); | |
455 | + | |
456 | + Ext.each(data.records, function(rec) | |
457 | + { | |
458 | + rec.renameDD(parentId,function(result) | |
459 | + { | |
460 | + if (result) | |
461 | + { | |
462 | + if (!result.id) | |
463 | + { | |
464 | + Ext.Msg.show({ | |
465 | + title : 'Drop is impossible', | |
466 | + msg : result.error, | |
467 | + buttons : Ext.Msg.OK, | |
468 | + icon : Ext.MessageBox.WARNING | |
469 | + }); | |
470 | + | |
471 | + return false; | |
472 | + } | |
473 | + } | |
474 | + else | |
475 | + { | |
476 | + Ext.Msg.show({ | |
477 | + title : 'Drop is impossible', | |
478 | + msg : 'Cannot connect to the server', | |
479 | + buttons : Ext.Msg.OK, | |
480 | + icon : Ext.MessageBox.WARNING | |
481 | + }); | |
482 | + | |
483 | + return false; | |
484 | + } | |
485 | + | |
486 | + return true; | |
487 | + }); | |
488 | + }); | |
489 | + } | |
573 | 490 | } |
574 | - } | |
491 | + }, | |
492 | + listeners: | |
493 | + { | |
494 | + itemmouseenter: function(view, record, item){ | |
495 | + if(record.get('isParameter')){ | |
496 | + var el = Ext.get(item), | |
497 | + td = el.down('td > div'); | |
498 | + td.setStyle('cursor', 'crosshair'); | |
499 | + } | |
500 | + else | |
501 | + { | |
502 | + var el = Ext.get(item), | |
503 | + td = el.down('td > div'); | |
504 | + td.setStyle('cursor', 'pointer'); | |
505 | + } | |
506 | + }, | |
507 | + | |
508 | + itemcontextmenu: function(view, rec, item, index, e){ | |
509 | + // block other events | |
510 | + e.stopEvent(); | |
511 | + | |
512 | + // clear menu items | |
513 | + menu.removeAll(); | |
514 | + var menuItems; | |
515 | + | |
516 | + // if it's a single selection | |
517 | + if (view.ownerCt.getSelectionModel().selected.length === 1) { | |
518 | + // get items menu corresponding to right clicked record | |
519 | + menuItems = rec.getContextMenuItems(this); | |
520 | + | |
521 | + } else if (view.ownerCt.getSelectionModel().selected.length > 1) { | |
522 | + // get items menu corresponding to right clicked record | |
523 | + menuItems = rec.getContextMenuMultiItems(this); | |
524 | + } | |
525 | + // if there's at least one item menu | |
526 | + if (menuItems && menuItems.length){ | |
527 | + // add the items | |
528 | + menu.add(menuItems); | |
529 | + // add listener on right clicked record | |
530 | + var onRecordClick = function (menu, item, e, eOpts) | |
531 | + { | |
532 | + if (this.myGetOwnerTree().getSelectionModel().isSelected(this)) { | |
533 | + //Dispatch click event to the record | |
534 | + this.onMenuItemClick(menu,item,e); | |
535 | + } | |
536 | + //Remove old click listener | |
537 | + menu.removeListener('click',onRecordClick,this); | |
538 | + }; | |
539 | + | |
540 | + menu.addListener('click',onRecordClick,rec); | |
541 | + // then show menu | |
542 | + menu.showAt(e.getXY()); | |
543 | + } | |
544 | + }, | |
545 | + | |
546 | + itemdblclick: function(view, record, item, index, event){ | |
547 | + event.stopEvent(); | |
548 | + // first check if it is for SAVE-START-STOP plugin... | |
549 | + if (Ext.PluginManager.getCount() > 0 && | |
550 | + record.get('nodeType') == amdaModel.TimeTableNode.nodeType && record.isLeaf()) { | |
551 | + var zmgr = myDesktopApp.desktop.getDesktopZIndexManager(); | |
552 | + var winActive = zmgr.getActive(); | |
553 | + var winId = winActive.getId(); | |
554 | + if (winId == 'explorer-win') { | |
555 | + zmgr.eachTopDown(function(win) { | |
556 | + var id = win.getId(); | |
557 | + if (id !== 'explorer-win') { | |
558 | + winId = id; | |
559 | + return false; | |
560 | + } | |
561 | + }); | |
562 | + } | |
563 | + } | |
564 | + | |
565 | + if (record.get('nodeType') == 'remoteParam' && !record.isLeaf() | |
566 | + && !record.get('isParameter')) { | |
567 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) { | |
568 | + module.createWindow(record.getBaseId()); | |
569 | + }); | |
570 | + } | |
571 | + | |
572 | + if (record.isLeaf() || record.data.isParameter) | |
573 | + switch (record.get('nodeType')) | |
574 | + { | |
575 | + case 'myData' : | |
576 | + case 'myDataParam' : | |
577 | + case 'derivedParam' : | |
578 | + case 'timeTable' : | |
579 | + case 'sharedtimeTable' : | |
580 | + case 'sharedcatalog' : | |
581 | + case 'catalog' : | |
582 | + case 'request' : | |
583 | + case 'condition' : | |
584 | + record.editLeaf(); | |
585 | + break; | |
586 | + case 'localParam' : | |
587 | + case 'remoteParam': | |
588 | + case 'remoteSimuParam': | |
589 | + record.createAlias(record); | |
590 | + break; | |
591 | + case 'bkgWorks' : | |
592 | + if (!record.get('object')) { | |
593 | + AmdaAction.getObject(record.get('id'), record.get('nodeType'), record.getObjectCallback, record); | |
594 | + } | |
595 | + else { | |
596 | + if (record.get('status') == 'done') { | |
597 | + var isInteractive = false; | |
598 | + var isNewTab = true; | |
599 | + record.editNode(isNewTab, isInteractive); | |
600 | + } | |
601 | + else { | |
602 | + myDesktopApp.infoMsg('Job Status: ' + record.get('status')); | |
603 | + } | |
604 | + } | |
605 | + break; | |
606 | + } | |
607 | + }, | |
608 | + | |
609 | + beforeselect: function(view,node,index,options){ | |
610 | + // if there's at least one node already selected | |
611 | + if(view.selected.length | |
612 | + //AND (the node which is beeing selected has a different nodeType than the first selected node OR the first selected node isn't a leaf | |
613 | + && ( node.get('nodeType')!== view.selected.items[0].get('nodeType') || !view.selected.items[0].isLeaf()) | |
614 | + // OR the node which is beeing selected has no nodeType OR it isn't a leaf OR | |
615 | + || !node.get('nodeType') || !node.isLeaf() | |
616 | + ){ | |
617 | + // clear old selection | |
618 | + view.deselectAll(); | |
619 | + } | |
620 | + }, | |
621 | + | |
622 | + afterrender: function(comp){ | |
623 | + var view = comp.getView(); | |
624 | + view.tip = Ext.create('Ext.tip.ToolTip', { | |
625 | + // The overall target element. | |
626 | + target: view.el, | |
627 | + // Each grid row causes its own seperate show and hide. | |
628 | + delegate: view.itemSelector, | |
629 | + dismissDelay : 0, | |
630 | + // showDelay: 100, | |
631 | + // anchor: 'left', | |
632 | + // Moving within the row should not hide the tip. | |
633 | + trackMouse: true, | |
634 | + autoRender: true, | |
635 | + listeners: { | |
636 | + // Change content dynamically depending on which element triggered the show. | |
637 | + beforeshow: function updateTipBody(tip) { | |
638 | + if (view.getRecord(tip.triggerElement)) { | |
639 | + var info = view.getRecord(tip.triggerElement).get('info'); | |
640 | + if (!info || info == '') { | |
641 | + tip.addCls('hide'); | |
642 | + } | |
643 | + else { | |
644 | + tip.removeCls('hide'); | |
645 | + tip.update(info); | |
646 | + } | |
647 | + } | |
648 | + } | |
649 | + } | |
650 | + }); | |
651 | + }, | |
652 | + // if remote base is empty - open interoperability module | |
653 | + itemexpand: function(node) { | |
654 | + if ( node.get('nodeType') == amdaModel.RemoteParamNode.nodeType | |
655 | + && node.getDepth() == 3 && !node.hasChildNodes()) { | |
656 | + node.addData(); | |
657 | + } | |
658 | + }, | |
659 | + scope: this | |
660 | + }, | |
575 | 661 | |
576 | - if (record.get('nodeType') == 'remoteParam' && !record.isLeaf() | |
577 | - && !record.get('isParameter')) { | |
578 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) { | |
579 | - module.createWindow(record.getBaseId()); | |
580 | - }); | |
581 | - } | |
662 | + hideHeaders: true, | |
663 | + // must define a column with a field to enable editor | |
664 | + columns: [{ | |
665 | + xtype : 'treetoolcolumn', | |
666 | + text : 'Name', | |
667 | + flex : 1, | |
668 | + dataIndex: 'text', | |
669 | + tool: 'info', // this references the "tools" object on the prototype | |
670 | + toolHandler: function(view, cell, recordIndex, cellIndex, e) { | |
671 | + var tooltype = e.target.getAttribute("tooltype"); | |
672 | + var record = view.store.getAt(recordIndex); | |
673 | + switch (tooltype) | |
674 | + { | |
675 | + case 'info' : | |
676 | + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function (module) { | |
677 | + module.createWindow(record.get('help'), record.get('info')); | |
678 | + }); | |
679 | + break; | |
680 | + } | |
681 | + }, | |
682 | + toolIsVisible : function(record) { | |
582 | 683 | |
583 | - if (record.isLeaf() || record.data.isParameter) | |
584 | - switch (record.get('nodeType')) | |
585 | - { | |
586 | - case 'myData' : | |
587 | - case 'myDataParam' : | |
588 | - case 'derivedParam' : | |
589 | - case 'timeTable' : | |
590 | - case 'sharedtimeTable' : | |
591 | - case 'sharedcatalog' : | |
592 | - case 'catalog' : | |
593 | - case 'request' : | |
594 | - case 'condition' : | |
595 | - record.editLeaf(); | |
596 | - break; | |
597 | - case 'localParam' : | |
598 | - case 'remoteParam': | |
599 | - case 'remoteSimuParam': | |
600 | - record.createAlias(record); | |
601 | - break; | |
602 | - case 'bkgWorks' : | |
603 | - if (!record.get('object')) { | |
604 | - AmdaAction.getObject(record.get('id'), record.get('nodeType'), record.getObjectCallback, record); | |
684 | + switch (record.get('nodeType')) | |
685 | + { | |
686 | + case 'localParam' : | |
687 | + case 'remoteParam' : | |
688 | + case 'remoteSimuParam' : | |
689 | + | |
690 | + return record.get('help') != ''; | |
691 | + } | |
692 | + return false; | |
693 | + }, | |
694 | + field: { | |
695 | + validFlag: false, | |
696 | + validator : function(value) { | |
697 | + // get explorerModule | |
698 | + var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
699 | + var explUI = explModule.getUiContent(); | |
700 | + var activeTreePanel = explUI.getActiveTab(); | |
701 | + | |
702 | + var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; | |
703 | + if (editedNode) { | |
704 | + if (!editedNode.get('id') && value === amdaModel.AmdaNode.NEW_DIR_NAME){ | |
705 | + return false; | |
706 | + } else { | |
707 | + return this.validFlag; | |
708 | + } | |
709 | + } else { | |
710 | + return true; | |
711 | + } | |
712 | + }, | |
713 | + listeners: { | |
714 | + change : function( field, newValue, oldValue, eOpts ) | |
715 | + { | |
716 | + var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
717 | + var explUI = explModule.getUiContent(); | |
718 | + var activeTreePanel = explUI.getActiveTab(); | |
719 | + | |
720 | + var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; | |
721 | + if (editedNode) { | |
722 | + editedNode.isValidName(newValue, function (res) { | |
723 | + if (!res) | |
724 | + { | |
725 | + field.validFlag = 'Error during object validation'; | |
726 | + field.validate(); | |
727 | + return; | |
728 | + } | |
729 | + if (!res.valid) | |
730 | + { | |
731 | + if (res.error) | |
732 | + { | |
733 | + field.validFlag = res.error; | |
734 | + field.validate(); | |
735 | + return; | |
736 | + } | |
737 | + else | |
738 | + { | |
739 | + field.validFlag = 'Invalid object name'; | |
740 | + field.validate(); | |
741 | + return; | |
742 | + } | |
743 | + } | |
744 | + | |
745 | + field.validFlag = true; | |
746 | + field.validate(); | |
747 | + }); | |
748 | + } | |
749 | + } | |
750 | + }, | |
751 | + scope: this | |
605 | 752 | } |
606 | - else { | |
607 | - if (record.get('status') == 'done') { | |
608 | - var isInteractive = false; | |
609 | - var isNewTab = true; | |
610 | - record.editNode(isNewTab, isInteractive); | |
753 | + }], | |
754 | + //add our custom editor plugin | |
755 | + plugins: [ new MyTreeEditor({ | |
756 | + pluginId: 'treeEditor', | |
757 | + listeners: { | |
758 | + 'canceledit' : function(editor, context) { | |
759 | + if (editor && editor.startValue===amdaModel.AmdaNode.NEW_DIR_NAME) { | |
760 | + context.record.remove(true); | |
761 | + } | |
611 | 762 | } |
612 | - else { | |
613 | - myDesktopApp.infoMsg('Job Status: ' + record.get('status')); | |
763 | + } | |
764 | + })], | |
765 | + | |
766 | + setNodesVisibility : function(node,forceHide) | |
767 | + { | |
768 | + var isFiltered = node.get('filtered'); | |
769 | + | |
770 | + for (var i = 0; i < node.childNodes.length; i++) | |
771 | + this.setNodesVisibility(node.childNodes[i],forceHide || isFiltered); | |
772 | + | |
773 | + this.setNodeVisibility(node,!(forceHide || isFiltered)); | |
774 | + }, | |
775 | + | |
776 | + setNodeVisibility : function(node,isVisible) | |
777 | + { | |
778 | + var record = store.getNodeById(node.internalId); | |
779 | + var viewNode = Ext.fly(tree.getView().getNode(record)); | |
780 | + if (viewNode) | |
781 | + { | |
782 | + viewNode.setVisibilityMode(Ext.Element.DISPLAY); | |
783 | + if (isVisible) | |
784 | + { | |
785 | + viewNode.show(); | |
786 | + this.applyDisableToNode(record); | |
614 | 787 | } |
788 | + else | |
789 | + viewNode.hide(); | |
615 | 790 | } |
616 | - break; | |
617 | - } | |
618 | - }, | |
619 | - beforeselect: function(view,node,index,options){ | |
620 | - // if there's at least one node already selected | |
621 | - if(view.selected.length | |
622 | - //AND (the node which is beeing selected has a different nodeType than the first selected node OR the first selected node isn't a leaf | |
623 | - && ( node.get('nodeType')!== view.selected.items[0].get('nodeType') || !view.selected.items[0].isLeaf()) | |
624 | - // OR the node which is beeing selected has no nodeType OR it isn't a leaf OR | |
625 | - || !node.get('nodeType') || !node.isLeaf() | |
626 | - ){ | |
627 | - // clear old selection | |
628 | - view.deselectAll(); | |
629 | - } | |
630 | - }, | |
631 | -// Already done in ExtJS 4.2.4 selection model | |
632 | -// itemmousedown: function(tree,rec,item,index,event,options){ | |
633 | -// if(event.button===2){ | |
634 | -// // if the right clicked item is already selected | |
635 | -// if (tree.getSelectionModel().isSelected(rec)) { | |
636 | -// // lock selection to prevent the selection modification by the right click | |
637 | -// tree.getSelectionModel().setLocked(true); | |
638 | -// } | |
639 | -// } | |
640 | -// }, | |
641 | - afterrender: function(comp){ | |
642 | - var view = comp.getView(); | |
643 | - view.tip = Ext.create('Ext.tip.ToolTip', { | |
644 | - // The overall target element. | |
645 | - target: view.el, | |
646 | - // Each grid row causes its own seperate show and hide. | |
647 | - delegate: view.itemSelector, | |
648 | - dismissDelay : 0, | |
649 | - // showDelay: 100, | |
650 | - // anchor: 'left', | |
651 | - // Moving within the row should not hide the tip. | |
652 | - trackMouse: true, | |
653 | - autoRender: true, | |
654 | - listeners: { | |
655 | - // Change content dynamically depending on which element triggered the show. | |
656 | - beforeshow: function updateTipBody(tip) { | |
657 | - if (view.getRecord(tip.triggerElement)) { | |
658 | - var info = view.getRecord(tip.triggerElement).get('info'); | |
659 | - if (!info || info == '') { | |
660 | - tip.addCls('hide'); | |
661 | - } | |
662 | - else { | |
663 | - tip.removeCls('hide'); | |
664 | - tip.update(info); | |
665 | - } | |
666 | - } | |
667 | - } | |
668 | - } | |
791 | + }, | |
792 | + | |
793 | + applyFilterToNode : function(node) | |
794 | + { | |
795 | + if (!node) | |
796 | + return; | |
797 | + | |
798 | + var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
799 | + | |
800 | + switch (node.get('nodeType')) | |
801 | + { | |
802 | + case 'localParam' : | |
803 | + if (!filter || !filter['param']) | |
804 | + { | |
805 | + //no filter applied | |
806 | + node.set('filtered',false); | |
807 | + return; | |
808 | + } | |
809 | + var pos = node.get('depth') - 3; //depth from local param root node | |
810 | + if (pos < 0 || pos > 2) | |
811 | + { | |
812 | + node.set('filtered',false); | |
813 | + return; | |
814 | + } | |
815 | + var isFiltered = true; | |
816 | + for (var i = 0; i < filter['param'].length; i++) | |
817 | + { | |
818 | + s = filter['param'][i].split(';'); | |
819 | + if (node.get('id') == s[pos]) | |
820 | + { | |
821 | + isFiltered = false; | |
822 | + break; | |
823 | + } | |
824 | + } | |
825 | + node.set('filtered',isFiltered); | |
826 | + break; | |
827 | + | |
828 | + case 'remoteSimuParam' : | |
829 | + if (!filter || !filter['simu'] ) | |
830 | + { | |
831 | + //no filter applied | |
832 | + node.set('filtered',false); | |
833 | + return; | |
834 | + } | |
835 | + var pos = node.get('depth') - 3; //depth from remote param root node | |
836 | + | |
837 | + if (pos < 0 || pos > 5) | |
838 | + { | |
839 | + node.set('filtered',false); | |
840 | + return; | |
841 | + } | |
842 | + var isFiltered = true; | |
843 | + | |
844 | + for (var i = 0; i < filter['simu'].length; i++) | |
845 | + { | |
846 | + s = filter['simu'][i].split(';'); | |
847 | + | |
848 | + if (node.get('id') == s[pos]) | |
849 | + { | |
850 | + isFiltered = false; | |
851 | + break; | |
852 | + } | |
853 | + } | |
854 | + node.set('filtered',isFiltered); | |
855 | + break; | |
856 | + /*case 'alias' : | |
857 | + if (!this.localParamFilter.result || this.localParamFilter.id == "" || | |
858 | + !node.isLeaf()) | |
859 | + { | |
860 | + //no filter applied | |
861 | + node.set('filtered',false); | |
862 | + return; | |
863 | + } | |
864 | + var crtParam = node.get('id'); | |
865 | + crtParam = crtParam.replace('alias_',''); | |
866 | + crtParam = crtParam.replace(/_/g,':'); | |
867 | + var isFiltered = true; | |
868 | + for (var i = 0; i < this.localParamFilter.result.length; i++) | |
869 | + { | |
870 | + s = this.localParamFilter.result[i].split(';'); | |
871 | + console.log(s[2]); | |
872 | + if (crtParam == s[2]) | |
873 | + { | |
874 | + isFiltered = false; | |
875 | + break; | |
876 | + } | |
877 | + } | |
878 | + node.set('filtered',isFiltered); | |
879 | + break;*/ | |
880 | + default : | |
881 | + return; | |
882 | + } | |
883 | + }, | |
884 | + | |
885 | + applyFilterToNodes : function(node) | |
886 | + { | |
887 | + node.eachChild(function (child){ | |
888 | + tree.applyFilterToNodes(child); | |
889 | + }); | |
890 | + tree.applyFilterToNode(node); | |
891 | + }, | |
892 | + | |
893 | + applyDisableToNode : function(node) | |
894 | + { | |
895 | + var crtNode = node; | |
896 | + var disable = false; | |
897 | + | |
898 | + do | |
899 | + { | |
900 | + if (crtNode.get('disable')) | |
901 | + { | |
902 | + disable = true; | |
903 | + break; | |
904 | + } | |
905 | + crtNode = crtNode.parentNode; | |
906 | + } while (crtNode); | |
907 | + | |
908 | + | |
909 | + var viewNode = Ext.fly(tree.getView().getNode(node)); | |
910 | + if (disable) | |
911 | + { | |
912 | + node.set('disable',true); | |
913 | + viewNode.setStyle('opacity',0.5); | |
914 | + } | |
915 | + } | |
669 | 916 | }); |
670 | - }, | |
671 | - // if remote base is empty - open interoperability module | |
672 | - itemexpand: function(node) { | |
673 | - if ( node.get('nodeType') == amdaModel.RemoteParamNode.nodeType | |
674 | - && node.getDepth() == 3 && !node.hasChildNodes()) { | |
675 | - node.addData(); | |
676 | - } | |
677 | - }, | |
678 | - scope: this | |
679 | - }, | |
680 | 917 | |
681 | - hideHeaders: true, | |
682 | - // must define a column with a field to enable editor | |
683 | - columns: [{ | |
684 | - xtype : 'treetoolcolumn', | |
685 | - text : 'Name', | |
686 | - flex : 1, | |
687 | - dataIndex: 'text', | |
688 | - tool: 'info', // this references the "tools" object on the prototype | |
689 | - toolHandler: function(view, cell, recordIndex, cellIndex, e) { | |
690 | - var tooltype = e.target.getAttribute("tooltype"); | |
691 | - var record = view.store.getAt(recordIndex); | |
692 | - switch (tooltype) | |
693 | - { | |
694 | - case 'info' : | |
695 | - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function (module) { | |
696 | - module.createWindow(record.get('help'), record.get('info')); | |
697 | - }); | |
698 | - break; | |
699 | - } | |
700 | - }, | |
701 | - toolIsVisible : function(record) { | |
702 | - | |
703 | - switch (record.get('nodeType')) | |
704 | - { | |
705 | - case 'localParam' : | |
706 | - case 'remoteParam' : | |
707 | - case 'remoteSimuParam' : | |
708 | - | |
709 | - return record.get('help') != ''; | |
710 | - } | |
711 | - return false; | |
712 | - }, | |
713 | - field: { | |
714 | - validFlag: false, | |
715 | - validator : function(value) { | |
716 | - // get explorerModule | |
717 | - var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
718 | - var explUI = explModule.getUiContent(); | |
719 | - var activeTreePanel = explUI.getActiveTab(); | |
720 | - | |
721 | - var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; | |
722 | - if (editedNode) { | |
723 | - if (!editedNode.get('id') && value === amdaModel.AmdaNode.NEW_DIR_NAME){ | |
724 | - return false; | |
725 | - } else { | |
726 | - return this.validFlag; | |
727 | - } | |
728 | - } else { | |
729 | - return true; | |
730 | - } | |
731 | - }, | |
732 | - listeners: { | |
733 | - change : function( field, newValue, oldValue, eOpts ) | |
734 | - { | |
735 | - var explModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id); | |
736 | - var explUI = explModule.getUiContent(); | |
737 | - var activeTreePanel = explUI.getActiveTab(); | |
738 | - | |
739 | - var editedNode = activeTreePanel.getSelectionModel().selected.items[0]; | |
740 | - if (editedNode) { | |
741 | - editedNode.isValidName(newValue, function (res) { | |
742 | - if (!res) | |
743 | - { | |
744 | - field.validFlag = 'Error during object validation'; | |
745 | - field.validate(); | |
746 | - return; | |
747 | - } | |
748 | - | |
749 | - if (!res.valid) | |
750 | - { | |
751 | - if (res.error) | |
752 | - { | |
753 | - field.validFlag = res.error; | |
754 | - field.validate(); | |
755 | - return; | |
756 | - } | |
757 | - else | |
758 | - { | |
759 | - field.validFlag = 'Invalid object name'; | |
760 | - field.validate(); | |
761 | - return; | |
762 | - } | |
763 | - } | |
764 | - | |
765 | - field.validFlag = true; | |
766 | - field.validate(); | |
767 | - }); | |
768 | - } | |
769 | - } | |
770 | - }, | |
771 | - scope: this | |
772 | - } | |
773 | - }], | |
774 | - //add our custom editor plugin | |
775 | - plugins: [new MyTreeEditor({ | |
776 | - pluginId: 'treeEditor', | |
777 | - listeners: { | |
778 | - 'canceledit' : function(editor, context) { | |
779 | - if (editor && editor.startValue===amdaModel.AmdaNode.NEW_DIR_NAME) { | |
780 | - context.record.remove(true); | |
781 | - } | |
782 | - } | |
783 | - | |
784 | - }})], | |
785 | - | |
786 | - setNodesVisibility : function(node,forceHide) | |
787 | - { | |
788 | - var isFiltered = node.get('filtered'); | |
789 | - | |
790 | - for (var i = 0; i < node.childNodes.length; i++) | |
791 | - this.setNodesVisibility(node.childNodes[i],forceHide || isFiltered); | |
792 | - | |
793 | - this.setNodeVisibility(node,!(forceHide || isFiltered)); | |
794 | - }, | |
795 | - | |
796 | - setNodeVisibility : function(node,isVisible) | |
797 | - { | |
798 | - var record = store.getNodeById(node.internalId); | |
799 | - var viewNode = Ext.fly(tree.getView().getNode(record)); | |
800 | - if (viewNode) | |
801 | - { | |
802 | - viewNode.setVisibilityMode(Ext.Element.DISPLAY); | |
803 | - if (isVisible) | |
804 | - { | |
805 | - viewNode.show(); | |
806 | - this.applyDisableToNode(record); | |
807 | - } | |
808 | - else | |
809 | - viewNode.hide(); | |
810 | - } | |
811 | - }, | |
812 | - | |
813 | - applyFilterToNode : function(node) | |
814 | - { | |
815 | - if (!node) | |
816 | - return; | |
817 | - | |
818 | - var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
819 | - | |
820 | - switch (node.get('nodeType')) | |
821 | - { | |
822 | - case 'localParam' : | |
823 | - if (!filter || !filter['param']) | |
824 | - { | |
825 | - //no filter applied | |
826 | - node.set('filtered',false); | |
827 | - return; | |
828 | - } | |
829 | - var pos = node.get('depth') - 3; //depth from local param root node | |
830 | - if (pos < 0 || pos > 2) | |
831 | - { | |
832 | - node.set('filtered',false); | |
833 | - return; | |
834 | - } | |
835 | - var isFiltered = true; | |
836 | - for (var i = 0; i < filter['param'].length; i++) | |
837 | - { | |
838 | - s = filter['param'][i].split(';'); | |
839 | - if (node.get('id') == s[pos]) | |
840 | - { | |
841 | - isFiltered = false; | |
842 | - break; | |
843 | - } | |
844 | - } | |
845 | - node.set('filtered',isFiltered); | |
846 | - break; | |
847 | - case 'remoteSimuParam' : | |
848 | - | |
849 | - if (!filter || !filter['simu'] ) | |
850 | - { | |
851 | - //no filter applied | |
852 | - node.set('filtered',false); | |
853 | - return; | |
854 | - } | |
855 | - | |
856 | - var pos = node.get('depth') - 3; //depth from remote param root node | |
857 | - | |
858 | - if (pos < 0 || pos > 5) | |
859 | - { | |
860 | - node.set('filtered',false); | |
861 | - return; | |
862 | - } | |
863 | - | |
864 | - var isFiltered = true; | |
865 | - | |
866 | - for (var i = 0; i < filter['simu'].length; i++) | |
867 | - { | |
868 | - s = filter['simu'][i].split(';'); | |
869 | - | |
870 | - if (node.get('id') == s[pos]) | |
871 | - { | |
872 | - isFiltered = false; | |
873 | - break; | |
874 | - } | |
875 | - } | |
876 | - node.set('filtered',isFiltered); | |
877 | - break; | |
878 | - /*case 'alias' : | |
879 | - if (!this.localParamFilter.result || this.localParamFilter.id == "" || | |
880 | - !node.isLeaf()) | |
881 | - { | |
882 | - //no filter applied | |
883 | - node.set('filtered',false); | |
884 | - return; | |
885 | - } | |
886 | - var crtParam = node.get('id'); | |
887 | - crtParam = crtParam.replace('alias_',''); | |
888 | - crtParam = crtParam.replace(/_/g,':'); | |
889 | - var isFiltered = true; | |
890 | - for (var i = 0; i < this.localParamFilter.result.length; i++) | |
891 | - { | |
892 | - s = this.localParamFilter.result[i].split(';'); | |
893 | - console.log(s[2]); | |
894 | - if (crtParam == s[2]) | |
895 | - { | |
896 | - isFiltered = false; | |
897 | - break; | |
898 | - } | |
899 | - } | |
900 | - node.set('filtered',isFiltered); | |
901 | - break;*/ | |
902 | - default : | |
903 | - return; | |
904 | - } | |
905 | - }, | |
906 | - | |
907 | - applyFilterToNodes : function(node) | |
908 | - { | |
909 | - node.eachChild(function (child){ | |
910 | - tree.applyFilterToNodes(child); | |
911 | - }); | |
912 | - tree.applyFilterToNode(node); | |
913 | - }, | |
914 | - | |
915 | - applyDisableToNode : function(node) | |
916 | - { | |
917 | - var crtNode = node; | |
918 | - var disable = false; | |
919 | - | |
920 | - do | |
921 | - { | |
922 | - if (crtNode.get('disable')) | |
923 | - { | |
924 | - disable = true; | |
925 | - break; | |
926 | - } | |
927 | - crtNode = crtNode.parentNode; | |
928 | - } while (crtNode); | |
929 | - | |
930 | - | |
931 | - var viewNode = Ext.fly(tree.getView().getNode(node)); | |
932 | - if (disable) | |
933 | - { | |
934 | - node.set('disable',true); | |
935 | - viewNode.setStyle('opacity',0.5); | |
936 | - } | |
937 | - } | |
938 | - }); | |
939 | - | |
940 | - tree.addEvents('edition'); | |
941 | - | |
942 | - | |
943 | - | |
944 | - return tree; | |
945 | - }, | |
946 | - | |
947 | - updateFilter : function() | |
948 | - { | |
949 | - var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
950 | - | |
951 | - var keys = []; | |
952 | - for (var f in filter) { | |
953 | - if (hasOwnProperty.call(filter, f)) | |
954 | - keys.push(f); | |
955 | - } | |
956 | - | |
957 | - var tree = this.query('#'+amdaUI.ExplorerUI.RESRC_TAB.TREE_ID)[0]; | |
958 | - tree.getView().refresh(); | |
959 | - | |
960 | - for (var i = 0; i < keys.length; i++) | |
961 | - { | |
962 | - if (keys[i] == "_empty_") | |
963 | - continue; | |
918 | + tree.addEvents('edition'); | |
919 | + | |
920 | + return tree; | |
921 | + }, | |
964 | 922 | |
965 | - switch (keys[i]) | |
923 | + updateFilter : function() | |
966 | 924 | { |
967 | - case 'param' : | |
968 | - | |
969 | - //apply filter to local datasets | |
970 | - var localNode = tree.getRootNode().findChild('id','myLocalData-treeRootNode',true); | |
971 | - tree.applyFilterToNodes(localNode); | |
972 | - tree.setNodesVisibility(localNode,false); | |
973 | - tree.applyDisableToNode(localNode); | |
974 | - | |
975 | - //apply filter to aliases | |
976 | - var aliasNode = tree.getRootNode().findChild('id','alias-treeRootNode',true); | |
977 | - tree.applyFilterToNodes(aliasNode); | |
978 | - tree.setNodesVisibility(aliasNode,false); | |
979 | - tree.applyDisableToNode(aliasNode); | |
980 | - break; | |
981 | - | |
982 | - case 'simu' : | |
983 | - //apply filter to simulation datasets (in remote data) | |
984 | - var remoteNode = tree.getRootNode().findChild('id','myRemoteSimuData-treeRootNode',true); | |
985 | - tree.applyFilterToNodes(remoteNode); | |
986 | - tree.setNodesVisibility(remoteNode,false); | |
987 | - tree.applyDisableToNode(remoteNode); | |
988 | - break; | |
989 | - } | |
990 | - } | |
925 | + var filter = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.explorer.id).filter; | |
991 | 926 | |
992 | - this.dockedItems.getAt(1).items.items[0].select(filter['name']); | |
993 | - } | |
927 | + var keys = []; | |
928 | + for (var f in filter) { | |
929 | + if (hasOwnProperty.call(filter, f)) | |
930 | + keys.push(f); | |
931 | + } | |
932 | + | |
933 | + var tree = this.query('#'+amdaUI.ExplorerUI.RESRC_TAB.TREE_ID)[0]; | |
934 | + tree.getView().refresh(); | |
935 | + | |
936 | + for (var i = 0; i < keys.length; i++) | |
937 | + { | |
938 | + if (keys[i] == "_empty_") | |
939 | + continue; | |
994 | 940 | |
941 | + switch (keys[i]) | |
942 | + { | |
943 | + case 'param' : | |
944 | + //apply filter to local datasets | |
945 | + var localNode = tree.getRootNode().findChild('id','myLocalData-treeRootNode',true); | |
946 | + tree.applyFilterToNodes(localNode); | |
947 | + tree.setNodesVisibility(localNode,false); | |
948 | + tree.applyDisableToNode(localNode); | |
949 | + | |
950 | + //apply filter to aliases | |
951 | + var aliasNode = tree.getRootNode().findChild('id','alias-treeRootNode',true); | |
952 | + tree.applyFilterToNodes(aliasNode); | |
953 | + tree.setNodesVisibility(aliasNode,false); | |
954 | + tree.applyDisableToNode(aliasNode); | |
955 | + break; | |
956 | + | |
957 | + case 'simu' : | |
958 | + //apply filter to simulation datasets (in remote data) | |
959 | + var remoteNode = tree.getRootNode().findChild('id','myRemoteSimuData-treeRootNode',true); | |
960 | + tree.applyFilterToNodes(remoteNode); | |
961 | + tree.setNodesVisibility(remoteNode,false); | |
962 | + tree.applyDisableToNode(remoteNode); | |
963 | + break; | |
964 | + } | |
965 | + } | |
966 | + | |
967 | + this.dockedItems.getAt(1).items.items[0].select(filter['name']); | |
968 | + } | |
995 | 969 | }); |
996 | 970 | |
971 | +// MyTreeEditor | |
997 | 972 | Ext.define( 'MyTreeEditor', { |
998 | - extend: 'Ext.grid.plugin.CellEditing', | |
999 | - alias: 'editing.treeeditor', | |
1000 | - | |
1001 | - // initialization method of plugin | |
1002 | - init: function(cmp) { | |
1003 | - var me = this; | |
1004 | - me.hostCmp = cmp; | |
1005 | - // on parent event | |
1006 | - me.hostCmp.on({ | |
1007 | - // on edition event | |
1008 | - edition : { | |
1009 | - delay: 50, | |
1010 | - fn : function(view, record, item, index, e){ | |
1011 | - view.getHeaderAtIndex(0).field.validFlag = 'Not modified'; | |
1012 | - // call the start edition method | |
1013 | - me.startEdit(record, view.getHeaderAtIndex(0)); | |
1014 | - }, | |
1015 | - scope: me | |
1016 | - } | |
1017 | - }); | |
1018 | - me.callParent(arguments); | |
1019 | - }, | |
1020 | - | |
1021 | - /** | |
1022 | - * Cancel any active editing. | |
1023 | - */ | |
1024 | - cancelEdit: function() { | |
1025 | - var me = this, | |
1026 | - activeEd = me.getActiveEditor(), | |
1027 | - viewEl = me.grid.getView().getEl(me.getActiveColumn()); | |
1028 | - | |
1029 | - me.setActiveEditor(null); | |
1030 | - me.setActiveColumn(null); | |
1031 | - me.setActiveRecord(null); | |
1032 | - if (activeEd) { | |
1033 | - activeEd.cancelEdit(); | |
1034 | - viewEl.focus(); | |
1035 | - this.fireEvent('canceledit', activeEd, me.context); | |
1036 | - } | |
1037 | - }, | |
1038 | - | |
1039 | - /** | |
1040 | - * overwrite the initEditTriggers to disable edition on click/dblclick | |
1041 | - * and to add custom | |
1042 | - */ | |
1043 | - initEditTriggers: function() { | |
1044 | - | |
1045 | - var me = this, | |
1046 | - view = me.view; | |
1047 | - | |
1048 | - me.on({ | |
1049 | - edit: function(editor,event){ | |
1050 | - // if there is a modification | |
1051 | - if (event.originalValue !== event.value) { | |
1052 | - // delegate rename action on model | |
1053 | - event.record.rename(event.value,function(result){ | |
1054 | - // if a result has been returned : success | |
1055 | - if(result) { | |
1056 | - // delegate commit action to delete modification flag | |
1057 | - event.record.commit(); | |
1058 | - var rec = event.record.data; | |
1059 | - // in case of directory | |
1060 | - if (!rec.leaf){ | |
1061 | - // set folder's ID returned by server | |
1062 | - rec.id = result.id; | |
1063 | - } | |
1064 | - } else { // in case of transaction error | |
1065 | - // reset originalValue | |
1066 | - event.record.value = event.originalValue; | |
1067 | - event.record.get('text') = event.originalValue; | |
1068 | - event.record.commit(); | |
1069 | - } | |
1070 | - }); | |
1071 | - } | |
1072 | - | |
1073 | - } | |
1074 | - }); | |
1075 | - | |
1076 | - // enable Enter key and Esc Key | |
1077 | - view.on('render', function() { | |
1078 | - me.keyNav = Ext.create('Ext.util.KeyNav', view.el, { | |
1079 | - enter: me.onEnterKey, | |
1080 | - esc: me.onEscKey, | |
1081 | - scope: me | |
1082 | - }); | |
1083 | - }, me, { single: true }); | |
1084 | - }, | |
1085 | - | |
1086 | - //overwrite the getEditing context because we do not need the rowId | |
1087 | - getEditingContext: function(record, columnHeader) { | |
1088 | - var me = this, | |
1089 | - grid = me.grid, | |
1090 | - store = grid.store, | |
1091 | - colIdx, | |
1092 | - view = grid.getView(), | |
1093 | - value; | |
1094 | - | |
1095 | - // getting colIdx and real columnHeader | |
1096 | - if (Ext.isNumber(columnHeader)) { | |
1097 | - colIdx = columnHeader; | |
1098 | - columnHeader = grid.headerCt.getHeaderAtIndex(colIdx); | |
1099 | - } else { | |
1100 | - colIdx = columnHeader.getIndex(); | |
1101 | - } | |
1102 | - // getting current value | |
1103 | - value = record.get(columnHeader.dataIndex); | |
1104 | - | |
1105 | - // return editing context | |
1106 | - return { | |
1107 | - grid: grid, | |
1108 | - record: record, | |
1109 | - field: columnHeader.dataIndex, | |
1110 | - value: value, | |
1111 | - column: columnHeader, | |
1112 | - colIdx: colIdx, | |
1113 | - view: columnHeader.getOwnerHeaderCt().view | |
1114 | - }; | |
1115 | - } | |
1116 | -} ); | |
973 | + extend: 'Ext.grid.plugin.CellEditing', | |
974 | + alias: 'editing.treeeditor', | |
975 | + | |
976 | + // initialization method of plugin | |
977 | + init: function(cmp) { | |
978 | + var me = this; | |
979 | + me.hostCmp = cmp; | |
980 | + // on parent event | |
981 | + me.hostCmp.on({ | |
982 | + // on edition event | |
983 | + edition : { | |
984 | + delay: 50, | |
985 | + fn : function(view, record, item, index, e){ | |
986 | + view.getHeaderAtIndex(0).field.validFlag = 'Not modified'; | |
987 | + // call the start edition method | |
988 | + me.startEdit(record, view.getHeaderAtIndex(0)); | |
989 | + }, | |
990 | + scope: me | |
991 | + } | |
992 | + }); | |
993 | + me.callParent(arguments); | |
994 | + }, | |
995 | + | |
996 | + /** | |
997 | + * Cancel any active editing. | |
998 | + */ | |
999 | + cancelEdit: function() { | |
1000 | + var me = this, | |
1001 | + activeEd = me.getActiveEditor(), | |
1002 | + viewEl = me.grid.getView().getEl(me.getActiveColumn()); | |
1003 | + | |
1004 | + me.setActiveEditor(null); | |
1005 | + me.setActiveColumn(null); | |
1006 | + me.setActiveRecord(null); | |
1007 | + if (activeEd) { | |
1008 | + activeEd.cancelEdit(); | |
1009 | + viewEl.focus(); | |
1010 | + this.fireEvent('canceledit', activeEd, me.context); | |
1011 | + } | |
1012 | + }, | |
1013 | + | |
1014 | + /** | |
1015 | + * overwrite the initEditTriggers to disable edition on click/dblclick | |
1016 | + * and to add custom | |
1017 | + */ | |
1018 | + initEditTriggers: function() | |
1019 | + { | |
1020 | + var me = this, | |
1021 | + view = me.view; | |
1022 | + | |
1023 | + me.on({ | |
1024 | + edit: function(editor,event){ | |
1025 | + // if there is a modification | |
1026 | + if (event.originalValue !== event.value) { | |
1027 | + // delegate rename action on model | |
1028 | + event.record.rename(event.value,function(result){ | |
1029 | + // if a result has been returned : success | |
1030 | + if(result) { | |
1031 | + // delegate commit action to delete modification flag | |
1032 | + event.record.commit(); | |
1033 | + var rec = event.record.data; | |
1034 | + // in case of directory | |
1035 | + if (!rec.leaf){ | |
1036 | + // set folder's ID returned by server | |
1037 | + rec.id = result.id; | |
1038 | + } | |
1039 | + } else { // in case of transaction error | |
1040 | + // reset originalValue | |
1041 | + event.record.value = event.originalValue; | |
1042 | + event.record.get('text') = event.originalValue; | |
1043 | + event.record.commit(); | |
1044 | + } | |
1045 | + }); | |
1046 | + } | |
1047 | + } | |
1048 | + }); | |
1049 | + | |
1050 | + // enable Enter key and Esc Key | |
1051 | + view.on('render', function() { | |
1052 | + me.keyNav = Ext.create('Ext.util.KeyNav', view.el, { | |
1053 | + enter: me.onEnterKey, | |
1054 | + esc: me.onEscKey, | |
1055 | + scope: me | |
1056 | + }); | |
1057 | + }, me, { single: true }); | |
1058 | + }, | |
1059 | + //overwrite the getEditing context because we do not need the rowId | |
1060 | + getEditingContext: function(record, columnHeader) { | |
1061 | + var me = this, | |
1062 | + grid = me.grid, | |
1063 | + store = grid.store, | |
1064 | + colIdx, | |
1065 | + view = grid.getView(), | |
1066 | + value; | |
1067 | + | |
1068 | + // getting colIdx and real columnHeader | |
1069 | + if (Ext.isNumber(columnHeader)) { | |
1070 | + colIdx = columnHeader; | |
1071 | + columnHeader = grid.headerCt.getHeaderAtIndex(colIdx); | |
1072 | + } else { | |
1073 | + colIdx = columnHeader.getIndex(); | |
1074 | + } | |
1075 | + // getting current value | |
1076 | + value = record.get(columnHeader.dataIndex); | |
1077 | + | |
1078 | + // return editing context | |
1079 | + return { | |
1080 | + grid: grid, | |
1081 | + record: record, | |
1082 | + field: columnHeader.dataIndex, | |
1083 | + value: value, | |
1084 | + column: columnHeader, | |
1085 | + colIdx: colIdx, | |
1086 | + view: columnHeader.getOwnerHeaderCt().view | |
1087 | + }; | |
1088 | + } | |
1089 | +}); | |
... | ... |
js/app/views/ParamsMgrUI.js
1 | 1 | /** |
2 | 2 | * Project : AMDA-NG |
3 | - * Name : amdaUI.ParamsMgrUI | |
4 | - * @class : | |
3 | + * Name : ParamsMgrUI.js | |
4 | + * @class amdaUI.ParamsMgrUI | |
5 | 5 | * @extends Ext.Panel.Panel |
6 | 6 | * @brief |
7 | - * @author Elena | |
8 | - * @version $Id: ParamsMgrUI.js 1871 2013-11-22 13:54:17Z elena $ | |
9 | - ****************************************************************************** | |
10 | - * FT Id : Date : Name - Description | |
11 | - ****************************************************************************** | |
12 | - * | |
7 | + * @author Elena | |
13 | 8 | */ |
14 | 9 | |
15 | -Ext.define('amdaUI.ParamsMgrUI', { | |
16 | - extend: 'Ext.panel.Panel', | |
17 | - | |
18 | - alias: 'widget.paramsMgrPanel', | |
19 | - | |
20 | - baseId : null, | |
21 | - srcTree : null, | |
22 | - destTree : null, | |
10 | +Ext.define('amdaUI.ParamsMgrUI',{ | |
11 | + extend: 'Ext.panel.Panel', | |
12 | + alias: 'widget.paramsMgrPanel', | |
13 | + | |
14 | + baseId : null, | |
15 | + srcTree : null, | |
16 | + destTree : null, | |
23 | 17 | |
18 | + //TODO where keep this (==baseId) description ? Global variable? | |
19 | + basesNames : ['CDAWEB', 'THEMIS', 'MAPSKP'], | |
20 | + bases : [], | |
24 | 21 | |
25 | - hasModifs: false, | |
26 | - | |
27 | - //TODO where keep this (==baseId) description ? Global variable? | |
28 | - basesNames : ['VEXGRAZ', 'CDAWEB', 'THEMIS', 'MAPSKP'], | |
29 | - bases : [], | |
30 | - | |
31 | - configSrc : {title: 'source', enableDrag : true, enableDrop: false}, | |
32 | - configDest : {title: 'destination', enableDrag : false, enableDrop:true}, | |
22 | + configSrc : {title: 'source', enableDrag : true, enableDrop: false}, | |
23 | + configDest : {title: 'destination', enableDrag : false, enableDrop:true}, | |
24 | + | |
25 | + constructor: function(config){ | |
26 | + this.init(config); | |
27 | + this.callParent(arguments); | |
28 | + }, | |
33 | 29 | |
34 | - | |
35 | - constructor: function(config) { | |
36 | - this.init(config); | |
37 | - this.callParent(arguments); | |
38 | - }, | |
39 | - | |
40 | - /* | |
41 | - * Load new data bases trees : source & destination | |
42 | - */ | |
43 | - loadTrees : function(button, pressed) { | |
44 | - if (pressed) { | |
45 | - this.baseId = button.text; | |
46 | - this.loadTree('source'); | |
47 | - this.loadTree('destination'); | |
48 | - } | |
49 | - }, | |
50 | - | |
51 | - /* | |
52 | - * Real Load data base tree | |
53 | - */ | |
54 | - loadTree : function(type) { | |
55 | - | |
56 | - var title = this.baseId; | |
57 | - if (type == 'source') var store = this.srcTree.getStore(); | |
58 | - else { | |
59 | - var store = this.destTree.getStore(); | |
60 | - title = 'My '+ this.baseId; | |
61 | - } | |
62 | - // or RELOAD? | |
63 | - var root = store.getRootNode(); | |
64 | - store.load({ | |
65 | - node: root, | |
66 | - params: { | |
67 | - nodeType: type, | |
68 | - baseId: this.baseId | |
69 | - } | |
70 | - }); | |
71 | - root.set('text', title); | |
72 | - }, | |
73 | - | |
74 | -/* | |
75 | - * Store and tree creation | |
76 | - */ | |
77 | - initTree: function(config) { | |
78 | - | |
79 | - if (this.baseId) { | |
80 | - var title = config.title == 'source' ? this.baseId : 'My '+ this.baseId; | |
81 | - } | |
82 | - else var title = config.title; | |
83 | - | |
84 | - var selMode = config.title == 'source' ? {mode: 'SIMPLE'} : {mode: 'SINGLE'}; | |
85 | - | |
86 | - var store = Ext.create('Ext.data.TreeStore', { | |
87 | - model: 'amdaModel.AmdaNode', | |
88 | - root: { | |
89 | - text: title, | |
90 | - //TODO if use the same logic for localParam? | |
91 | - nodeType : 'remoteParam', | |
92 | - expanded: true | |
93 | - }, | |
94 | - listeners: { | |
95 | - scope : this, | |
96 | - beforeload: function(store, operation){ | |
97 | - store.proxy.extraParams = { | |
98 | - nodeType: config.title, | |
99 | - baseId: this.baseId | |
100 | - } | |
101 | - }} | |
102 | - }); | |
30 | + /* | |
31 | + * Load new data bases trees : source & destination | |
32 | + */ | |
33 | + loadTrees : function(button, pressed){ | |
34 | + if (pressed) { | |
35 | + this.baseId = button.text; | |
36 | + this.loadTree('source'); | |
37 | + this.loadTree('destination'); | |
38 | + } | |
39 | + }, | |
103 | 40 | |
104 | - var menu = new Ext.menu.Menu({ | |
105 | - items: [{ | |
106 | - text: 'Delete Data' | |
107 | - }], | |
108 | - listeners: { | |
109 | - scope : this, | |
110 | - click : this.deleteMulti | |
111 | - } | |
112 | - }); | |
41 | + /* | |
42 | + * Real Load data base tree | |
43 | + */ | |
44 | + loadTree : function(type){ | |
45 | + var title = this.baseId; | |
46 | + if (type == 'source'){ | |
47 | + var store = this.srcTree.getStore(); | |
48 | + } | |
49 | + else { | |
50 | + var store = this.destTree.getStore(); | |
51 | + title = 'My '+ this.baseId; | |
52 | + } | |
53 | + // or RELOAD? | |
54 | + var root = store.getRootNode(); | |
55 | + store.load({ | |
56 | + node: root, | |
57 | + params: { | |
58 | + nodeType: type, | |
59 | + baseId: this.baseId | |
60 | + } | |
61 | + }); | |
62 | + root.set('text', title); | |
63 | + }, | |
113 | 64 | |
114 | - var tree = Ext.create('Ext.tree.Panel', { | |
115 | - store: store, | |
116 | - id : config.title, | |
117 | - flex: 1, | |
118 | - height: 400, | |
119 | - selModel: selMode, //{mode: 'SIMPLE'}, | |
120 | - viewConfig: { | |
121 | - plugins: { | |
122 | - ptype: 'treeviewdragdrop', | |
123 | - allowContainerDrops : true, | |
124 | - enableDrag: config.enableDrag, | |
125 | - enableDrop: config.enableDrop, | |
126 | - //TODO dataset drag/drop by parameters SELECTION | |
127 | - dragText : "{0} selected parameter{1}", | |
128 | - expandDelay : 100, | |
129 | - ddGroup : "RemoteTreeDD", | |
130 | - isValidDropPoint : function(){ | |
131 | - return true; | |
132 | - }, | |
133 | - onContainerOver : function() { | |
134 | - return this.dropAllowed; | |
135 | - | |
136 | - }, | |
137 | - onNodeOver : function() { | |
138 | - return this.dropAllowed; | |
139 | - }, | |
140 | - onNodeDrop : function(nodeData, dd, e, data) { | |
141 | - if (!data.records) | |
142 | - return false; | |
143 | - Ext.Array.each(data.records, this.onDrop, this); | |
144 | -// deselect source tree selection | |
145 | - data.view.getSelectionModel().deselectAll(); | |
146 | - return true; | |
147 | - }, | |
148 | - onContainerDrop : function(dd, e, data) { | |
149 | - | |
150 | - if (!data.records) | |
151 | - return false; | |
152 | - Ext.Array.each(data.records, this.onDrop, this); | |
153 | -// deselect source tree selection | |
154 | - data.view.getSelectionModel().deselectAll(); | |
155 | - return true; | |
156 | - }, | |
65 | + /* | |
66 | + * Store and tree creation | |
67 | + */ | |
68 | + initTree: function(config){ | |
69 | + if (this.baseId){ | |
70 | + var title = config.title == 'source' ? this.baseId : 'My '+ this.baseId; | |
71 | + } | |
72 | + else | |
73 | + var title = config.title; | |
74 | + | |
75 | + var selMode = config.title == 'source' ? {mode: 'SIMPLE'} : {mode: 'SINGLE'}; | |
157 | 76 | |
158 | - onDrop : function(record) { | |
159 | - | |
160 | - var root = tree.getRootNode(); | |
161 | - var srcNode = record; | |
162 | - var id = srcNode.get('id'); | |
163 | - | |
164 | - // Check if node exists already at destination | |
165 | - if (root.findChild('id',id, true)) return; | |
166 | - | |
167 | - var ddNode = srcNode; | |
168 | - // Array of parent nodes description | |
169 | - var Arr = []; | |
170 | - | |
171 | - while (!ddNode.isRoot()) { | |
172 | - ddNode = ddNode.parentNode; | |
173 | - Arr.push(ddNode); | |
77 | + var store = Ext.create('Ext.data.TreeStore', { | |
78 | + model: 'amdaModel.AmdaNode', | |
79 | + root: { | |
80 | + text: title, | |
81 | + nodeType : 'remoteParam', | |
82 | + expanded: true | |
83 | + }, | |
84 | + listeners: { | |
85 | + scope : this, | |
86 | + beforeload: function(store, operation){ | |
87 | + store.proxy.extraParams = { | |
88 | + nodeType: config.title, | |
89 | + baseId: this.baseId | |
90 | + } | |
91 | + }} | |
92 | + }); | |
93 | + | |
94 | + var menu = new Ext.menu.Menu({ | |
95 | + items: [{ | |
96 | + text: 'Delete Data' | |
97 | + }], | |
98 | + listeners: { | |
99 | + scope : this, | |
100 | + click : this.deleteMulti | |
174 | 101 | } |
175 | - // start with the highest node | |
176 | - Arr.reverse(); | |
177 | - | |
178 | - // create parent nodes if they do not exist | |
179 | - var parentNode = root; | |
180 | - Ext.Array.each(Arr,function(srcNode, index){ | |
181 | - if (index > 0) { | |
182 | - var nodeId = srcNode.get('id'); | |
183 | - var node = root.findChild('id',nodeId, true); | |
184 | - if (!node) { | |
185 | - node = srcNode.copy(); | |
186 | - parentNode.appendChild(node); | |
187 | - parentNode.expand(); | |
188 | - node.setDirty(); | |
189 | - } | |
190 | - parentNode = node; | |
191 | - } | |
192 | - }); | |
193 | - | |
194 | - // Add new node to correct location | |
195 | - parentNode.expand(!this.isDataSet, function(res){ | |
196 | - var newNode = srcNode.copy(); | |
197 | - parentNode.appendChild(newNode); | |
198 | - //to sync treeStore | |
199 | - newNode.setDirty(); | |
200 | - //expand the whole subtree of added node | |
201 | - tree.selectPath(newNode.getPath( 'id', '|'), 'id', '|'); | |
202 | - }); | |
203 | - return true; | |
204 | - }, | |
205 | - | |
206 | - onViewRender : function(view) { | |
207 | - var me = this; | |
102 | + }); | |
103 | + | |
104 | + var tree = Ext.create('Ext.tree.Panel', { | |
105 | + store: store, | |
106 | + id : config.title, | |
107 | + flex: 1, | |
108 | + height: 500, | |
109 | + selModel: selMode, //{mode: 'SIMPLE'}, | |
110 | + viewConfig: { | |
111 | + plugins:{ | |
112 | + ptype: 'treeviewdragdrop', | |
113 | + allowContainerDrops : true, | |
114 | + enableDrag: config.enableDrag, | |
115 | + enableDrop: config.enableDrop, | |
116 | + //TODO dataset drag/drop by parameters SELECTION | |
117 | + dragText : "{0} selected parameter{1}", | |
118 | + expandDelay : 100, | |
119 | + ddGroup : "RemoteTreeDD", | |
120 | + | |
121 | + isValidDropPoint : function(){ | |
122 | + return true; | |
123 | + }, | |
124 | + | |
125 | + onContainerOver : function() { | |
126 | + return this.dropAllowed; | |
127 | + }, | |
128 | + | |
129 | + onNodeOver : function() { | |
130 | + return this.dropAllowed; | |
131 | + }, | |
132 | + | |
133 | + onNodeDrop : function(nodeData, dd, e, data){ | |
134 | + if (!data.records) | |
135 | + return false; | |
136 | + Ext.Array.each(data.records, this.onDrop, this); | |
137 | + // deselect source tree selection | |
138 | + data.view.getSelectionModel().deselectAll(); | |
139 | + | |
140 | + return true; | |
141 | + }, | |
142 | + | |
143 | + onContainerDrop : function(dd, e, data){ | |
144 | + if (!data.records) | |
145 | + return false; | |
146 | + Ext.Array.each(data.records, this.onDrop, this); | |
147 | + // deselect source tree selection | |
148 | + data.view.getSelectionModel().deselectAll(); | |
149 | + | |
150 | + return true; | |
151 | + }, | |
152 | + | |
153 | + onDrop : function(record) { | |
154 | + var root = tree.getRootNode(); | |
155 | + var srcNode = record; | |
156 | + var id = srcNode.get('id'); | |
157 | + // Check if node exists already at destination | |
158 | + if (root.findChild('id',id, true)) { | |
159 | + myDesktopApp.infoMsg('This parameter exists already in your treee'); | |
160 | + return; | |
161 | + } | |
162 | + var ddNode = srcNode; | |
163 | + // Array of parent nodes description | |
164 | + var Arr = []; | |
165 | + while (!ddNode.isRoot()) { | |
166 | + ddNode = ddNode.parentNode; | |
167 | + Arr.push(ddNode); | |
168 | + } | |
169 | + // start with the highest node | |
170 | + Arr.reverse(); | |
171 | + // create parent nodes if they do not exist | |
172 | + var parentNode = root; | |
173 | + Ext.Array.each(Arr,function(srcNode, index) { | |
174 | + if (index > 0) { | |
175 | + var nodeId = srcNode.get('id'); | |
176 | + var node = root.findChild('id',nodeId, true); | |
177 | + if (!node) { | |
178 | + node = srcNode.copy(); | |
179 | + parentNode.appendChild(node); | |
180 | + parentNode.expand(); | |
181 | + node.setDirty(); | |
182 | + } | |
183 | + parentNode = node; | |
184 | + } | |
185 | + }); | |
208 | 186 | |
209 | - if (me.enableDrag) { | |
210 | - me.dragZone = Ext.create('Ext.tree.ViewDragZone', { | |
211 | - view: view, | |
212 | - ddGroup: me.dragGroup || me.ddGroup, | |
213 | - dragText: me.dragText | |
214 | - }); | |
215 | - } | |
187 | + // Add new node to correct location | |
188 | + parentNode.expand(!this.isDataSet, function(res){ | |
189 | + var newNode = srcNode.copy(); | |
190 | + parentNode.appendChild(newNode); | |
191 | + //to sync treeStore | |
192 | + newNode.setDirty(); | |
193 | + //expand the whole subtree of added node | |
194 | + tree.selectPath(newNode.getPath( 'id', '|'), 'id', '|'); | |
195 | + }); | |
196 | + return true; | |
197 | + }, | |
198 | + | |
199 | + onViewRender : function(view){ | |
200 | + var me = this; | |
216 | 201 | |
217 | - if (me.enableDrop) { | |
218 | - me.dropZone = Ext.create('Ext.tree.ViewDropZone', { | |
219 | - view: view, | |
220 | - ddGroup: me.dropGroup || me.ddGroup, | |
221 | - allowContainerDrops: me.allowContainerDrops, | |
222 | - expandDelay: me.expandDelay, | |
223 | - isValidDropPoint : me.isValidDropPoint, | |
224 | - onContainerDrop : me.onContainerDrop, | |
225 | - onNodeDrop : me.onNodeDrop, | |
226 | - onContainerOver : me.onContainerOver, | |
227 | - onNodeOver : me.onNodeOver, | |
228 | - onDrop : me.onDrop, | |
229 | - onSimpleDrop : me.onSimpleDrop | |
230 | - }); | |
231 | - } | |
232 | - } | |
233 | - } | |
234 | - }, | |
235 | - listeners: { | |
236 | - afterrender: function(comp){ | |
237 | - var view = comp.getView(); | |
238 | - view.tip = Ext.create('Ext.tip.ToolTip', { | |
239 | - // The overall target element. | |
240 | - target: view.el, | |
241 | - // Each grid row causes its own seperate show and hide. | |
242 | - delegate: view.itemSelector, | |
243 | - // Moving within the row should not hide the tip. | |
244 | - trackMouse: true, | |
245 | - autoRender: true, | |
202 | + if (me.enableDrag){ | |
203 | + me.dragZone = Ext.create('Ext.tree.ViewDragZone', { | |
204 | + view: view, | |
205 | + ddGroup: me.dragGroup || me.ddGroup, | |
206 | + dragText: me.dragText | |
207 | + }); | |
208 | + } | |
209 | + | |
210 | + if (me.enableDrop){ | |
211 | + me.dropZone = Ext.create('Ext.tree.ViewDropZone', { | |
212 | + view: view, | |
213 | + ddGroup: me.dropGroup || me.ddGroup, | |
214 | + allowContainerDrops: me.allowContainerDrops, | |
215 | + expandDelay: me.expandDelay, | |
216 | + isValidDropPoint : me.isValidDropPoint, | |
217 | + onContainerDrop : me.onContainerDrop, | |
218 | + onNodeDrop : me.onNodeDrop, | |
219 | + onContainerOver : me.onContainerOver, | |
220 | + onNodeOver : me.onNodeOver, | |
221 | + onDrop : me.onDrop, | |
222 | + onSimpleDrop : me.onSimpleDrop | |
223 | + }); | |
224 | + } | |
225 | + } | |
226 | + } | |
227 | + }, | |
228 | + | |
246 | 229 | listeners: { |
247 | - // Change content dynamically depending on which element triggered the show. | |
248 | - beforeshow: function updateTipBody(tip) { | |
249 | - var trigger = view.getRecord(tip.triggerElement); | |
250 | - if (trigger) { | |
251 | - var info = trigger.get('info'); | |
252 | - if (!info || info == '') { | |
253 | - tip.addCls('hide'); | |
254 | - } | |
255 | - else { | |
256 | - tip.removeCls('hide'); | |
257 | - tip.update(info); | |
258 | - } | |
230 | + afterrender: function(comp) { | |
231 | + var view = comp.getView(); | |
232 | + view.tip = Ext.create('Ext.tip.ToolTip', { | |
233 | + // The overall target element. | |
234 | + target: view.el, | |
235 | + // Each grid row causes its own seperate show and hide. | |
236 | + delegate: view.itemSelector, | |
237 | + // Moving within the row should not hide the tip. | |
238 | + trackMouse: true, | |
239 | + autoRender: true, | |
240 | + listeners: { | |
241 | + // Change content dynamically depending on which element triggered the show. | |
242 | + beforeshow: function updateTipBody(tip) { | |
243 | + var trigger = view.getRecord(tip.triggerElement); | |
244 | + if (trigger) { | |
245 | + var info = trigger.get('info'); | |
246 | + if (!info || info == '') { | |
247 | + tip.addCls('hide'); | |
248 | + } | |
249 | + else { | |
250 | + tip.removeCls('hide'); | |
251 | + tip.update(info); | |
252 | + } | |
253 | + } | |
254 | + } | |
255 | + } | |
256 | + }); | |
257 | + }, | |
258 | + | |
259 | + itemmouseenter: function(view, record, item){ | |
260 | + if(record.get('allowDrag') && view.ownerCt.id == 'source'){ | |
261 | + var el = Ext.get(item), | |
262 | + td = el.down('td > div'); | |
263 | + td.setStyle('cursor', 'crosshair'); | |
264 | + } | |
265 | + }, | |
266 | + | |
267 | + beforeselect: function(selmodel, record, index) { | |
268 | + if (!(record.get('isRemoteDataSet') || record.get('isParameter')) && tree.id == 'source') return false; | |
269 | + }, | |
270 | + | |
271 | + select: function(selmodel, record, index){ | |
272 | + if (record.get('isRemoteDataSet') && tree.id == 'source' && record.isExpanded()) { | |
273 | + var toSelect = selmodel.getCount() !== record.childNodes.length + 1; | |
274 | + var alreadySelected = selmodel.isSelected(record.firstChild); | |
275 | + | |
276 | + selmodel.deselectAll(); | |
277 | + | |
278 | + if (toSelect && !alreadySelected) | |
279 | + selmodel.select(record.childNodes); | |
280 | + } | |
281 | + }, | |
282 | + | |
283 | + itemcontextmenu: function(view, rec, item, index, e) | |
284 | + { | |
285 | + e.preventDefault();//stopEvent(); | |
286 | + if (tree.id == 'destination' && rec.getDepth() > 0) | |
287 | + menu.showAt(e.getXY()); | |
259 | 288 | } |
260 | - } | |
261 | - } | |
262 | - }); | |
263 | - }, | |
264 | - | |
265 | - itemmouseenter: function(view, record, item){ | |
266 | - if(record.get('allowDrag') && view.ownerCt.id == 'source'){ | |
267 | - var el = Ext.get(item), | |
268 | - td = el.down('td > div'); | |
269 | - td.setStyle('cursor', 'crosshair'); | |
270 | - } | |
271 | - }, | |
289 | + } | |
290 | + }); | |
291 | + return tree; | |
292 | + }, | |
293 | + | |
294 | + // for the moment SINGLE! | |
295 | + deleteMulti: function(){ | |
296 | + var selected = this.destTree.getSelectionModel().getSelection(); | |
297 | + Ext.Array.each(selected, function(rec){ | |
298 | + rec.deleteData(); | |
299 | + }); | |
272 | 300 | |
273 | - beforeselect: function(selmodel, record, index) { | |
274 | - if (!(record.get('isRemoteDataSet') || record.get('isParameter')) && tree.id == 'source') return false; | |
275 | - }, | |
276 | - | |
277 | - select: function(selmodel, record, index) { | |
278 | - | |
279 | - if (record.get('isRemoteDataSet') && tree.id == 'source' && record.isExpanded()) { | |
280 | - var toSelect = selmodel.getCount() !== record.childNodes.length + 1; | |
281 | - var alreadySelected = selmodel.isSelected(record.firstChild); | |
282 | - | |
283 | - selmodel.deselectAll(); | |
284 | - | |
285 | - if (toSelect && !alreadySelected) selmodel.select(record.childNodes); | |
286 | - } | |
287 | - }, | |
288 | - | |
289 | - itemcontextmenu: function(view, rec, item, index, e){ | |
290 | - e.preventDefault();//stopEvent(); | |
291 | - if (tree.id == 'destination' && rec.getDepth() > 0) | |
292 | - menu.showAt(e.getXY()); | |
293 | - } | |
294 | - } | |
295 | - }); | |
296 | - return tree; | |
297 | - }, | |
298 | -// for the moment SINGLE! | |
299 | - deleteMulti: function(){ | |
300 | - var selected = this.destTree.getSelectionModel().getSelection(); | |
301 | - Ext.Array.each(selected, function(rec){ | |
302 | - rec.deleteData(); | |
303 | - }); | |
304 | - }, | |
305 | - | |
306 | - | |
307 | - successCallBack : function(batch, options) { | |
308 | - this.hasModifs = true; | |
309 | - loadMask.hide(); | |
310 | - var createdNodes = options.operations.update; | |
311 | - | |
312 | -// define Pathes to the created nodes | |
313 | - var Arr = []; | |
314 | - Ext.Array.each(createdNodes,function(item){ | |
315 | - if (item.getDepth() == 4) { // parameter level | |
316 | - Arr.push(item.getPath('id', '|')); | |
317 | - } | |
318 | - }); | |
319 | - | |
320 | -// reload destination tree and expand created nodes | |
321 | - var panel = this.destTree; | |
322 | - var store = this.destTree.getStore(); | |
323 | - var root = store.getRootNode(); | |
324 | - store.load({ node : root, | |
325 | - params : { nodeType: 'destination', | |
326 | - baseId: this.baseId }, | |
327 | - callback : function(){ | |
328 | - for (var i = 0; i < Arr.length; i++){ | |
329 | - panel.selectPath(Arr[i], 'id', '|'); | |
330 | - } | |
331 | - } | |
332 | - }); | |
333 | - | |
334 | - | |
335 | - }, | |
336 | - | |
337 | - failureCallBack : function(batch, options) { | |
338 | - //TODO message error | |
339 | - alert('FAILURE!'); | |
340 | - loadMask.hide(); | |
341 | - this.loadTree('destination'); | |
342 | - }, | |
343 | - | |
344 | - /* | |
345 | - * Panel Trees generation | |
346 | - */ | |
347 | - | |
348 | - init: function(config) { | |
349 | - | |
350 | - if (config.baseId && config.baseId != 'root') | |
351 | - this.baseId = config.baseId; | |
352 | - | |
353 | - this.srcTree = this.initTree(this.configSrc); | |
354 | - this.destTree = this.initTree(this.configDest); | |
301 | + // reload destination tree and expand created nodes | |
302 | + var store = this.destTree.getStore(); | |
303 | + var root = store.getRootNode(); | |
304 | + store.load({ node : root, | |
305 | + params : { nodeType: 'destination', | |
306 | + baseId : this.baseId } | |
307 | + }); | |
308 | + }, | |
309 | + | |
310 | + successCallBack : function(batch, options) { | |
311 | + loadMask.hide(); | |
312 | + var createdNodes = options.operations.create; | |
313 | + // define Pathes to the created nodes | |
314 | + Arr = []; | |
315 | + Ext.Array.each(createdNodes,function(item){ | |
316 | + // if (item.getDepth() == 5) { // parameter level | |
317 | + if (item.get('isParameter')){ // parameter level | |
318 | + Arr.push(item.getPath('id', '|')); | |
319 | + } | |
320 | + }); | |
321 | + // reload destination tree and expand created nodes | |
322 | + var panel = this.destTree; | |
323 | + var store = this.destTree.getStore(); | |
324 | + var root = store.getRootNode(); | |
325 | + store.load({ node : root, | |
326 | + params : { nodeType: 'destination', | |
327 | + baseId : this.baseId }, | |
328 | + scope : this, | |
329 | + callback : function(){ | |
330 | + for (var i = 0; i < Arr.length; i++){ | |
331 | + panel.selectPath(Arr[i], 'id', '|'); | |
332 | + } | |
333 | + } | |
334 | + }); | |
335 | + | |
336 | + this.updateUserTree(); | |
337 | + }, | |
338 | + | |
339 | + failureCallBack : function(batch, options) { | |
340 | + myDesktopApp.errorMsg('Error while saving modifs'); | |
341 | + loadMask.hide(); | |
342 | + this.loadTree('destination'); | |
343 | + }, | |
344 | + | |
345 | + /* | |
346 | + * Update User Tree in Explorer after the the modifs | |
347 | + */ | |
348 | + updateUserTree : function() { | |
349 | + // reload RemoteParam Tree in explorer | |
350 | + var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
351 | + if (explorerTree) | |
352 | + { | |
353 | + var explorerTreeStore = explorerTree.getStore(); | |
354 | + var explorerRoot = explorerTreeStore.getRootNode(); | |
355 | + var explorerPath = '/root/parameters-treeBase/myRemoteData-treeRootNode/'; | |
356 | + | |
357 | + explorerTreeStore.load( { node : explorerRoot, | |
358 | + params : { nodeType: 'resources'}, | |
359 | + callback : function(){ | |
360 | + explorerTree.selectPath(explorerPath); | |
361 | + } | |
362 | + }); | |
363 | + } | |
364 | + myDesktopApp.infoMsg('Modifs have been saved'); | |
365 | + }, | |
366 | + | |
367 | + /* | |
368 | + * Panel Trees generation | |
369 | + */ | |
370 | + init: function(config) { | |
371 | + if (config.baseId && config.baseId != 'root') | |
372 | + this.baseId = config.baseId; | |
373 | + | |
374 | + this.srcTree = this.initTree(this.configSrc); | |
375 | + this.destTree = this.initTree(this.configDest); | |
355 | 376 | |
356 | -// synchron load of destination tree if the corresponding node exists | |
357 | - this.srcTree.on('itemexpand', function(node) { | |
358 | - var root = this.destTree.getRootNode(); | |
359 | - var destNode = root.findChild('id',node.get('id'),true); | |
360 | - if (destNode) destNode.expand(); | |
361 | - }, | |
362 | - this); | |
363 | -// toolbar | |
364 | - Ext.Array.each(this.basesNames, function(baseName,index){ | |
365 | - var isTheBase = false; | |
366 | - if (this.baseId && baseName == this.baseId) var isTheBase = true; | |
367 | - this.bases[index] = {text: baseName, toggleGroup: 'remoteBases', pressed: isTheBase, scope : this, toggleHandler: this.loadTrees} | |
368 | - }, this); | |
377 | + // synchron load of destination tree if the corresponding node exists | |
378 | + this.srcTree.on('itemexpand', function(node) { | |
379 | + var root = this.destTree.getRootNode(); | |
380 | + var destNode = root.findChild('id',node.get('id'),true); | |
381 | + if (destNode) destNode.expand(); | |
382 | + }, this); | |
383 | + | |
384 | + // toolbar | |
385 | + Ext.Array.each(this.basesNames, function(baseName,index){ | |
386 | + var isTheBase = false; | |
387 | + if (this.baseId && baseName == this.baseId) var isTheBase = true; | |
388 | + this.bases[index] = {text: baseName, toggleGroup: 'remoteBases', pressed: isTheBase, scope : this, toggleHandler: this.loadTrees} | |
389 | + }, this); | |
369 | 390 | |
370 | - var myConf = { | |
371 | - | |
372 | - id : 'rb_tab_panel', | |
373 | - title : 'Remote Data Base', | |
374 | - items: [ | |
375 | - this.srcTree, | |
376 | - this.destTree | |
377 | - ], | |
378 | - tbar: this.bases, | |
379 | - fbar: [ | |
380 | - { text: 'Save Modifs', | |
381 | - scope : this, | |
382 | - handler: function(){ | |
383 | - var store = this.destTree.getStore(); | |
384 | - | |
385 | - var removed = store.getRemovedRecords(); | |
386 | - var updated = store.getUpdatedRecords(); | |
387 | - // if only removed: no sync - already removed at Server by node.delete | |
388 | - //TODO is this condition OK?? | |
389 | - if (Ext.Array.union(removed,updated).length != removed.length) { | |
390 | - loadMask.show(); | |
391 | - store.sync({ success : this.successCallBack, failure: this.failureCallBack, scope : this}); | |
391 | + var myConf = { | |
392 | + id : 'rb_tab_panel', | |
393 | + title : 'Remote Data Base', | |
394 | + items: [ | |
395 | + this.srcTree, | |
396 | + this.destTree | |
397 | + ], | |
398 | + tbar: this.bases, | |
399 | + fbar: [ | |
400 | + { text: 'Save Modifs', | |
401 | + scope : this, | |
402 | + handler: function(){ | |
403 | + var store = this.destTree.getStore(); | |
404 | + var new_nodes = store.getNewRecords(); | |
405 | + var removed_nodes = store.getRemovedRecords(); | |
406 | + // if only removed: no sync - already removed at Server by node.delete | |
407 | + if ( new_nodes.length === 0 && removed_nodes.length > 0) this.updateUserTree(); | |
408 | + if ( new_nodes.length > 0 ){ | |
409 | + loadMask.show(); | |
410 | + store.sync({ success : this.successCallBack, failure: this.failureCallBack, scope : this}); | |
411 | + } | |
392 | 412 | } |
393 | - } | |
394 | - } | |
395 | - ], | |
396 | - listeners : { | |
397 | - scope : this, | |
398 | - destroy : function() { | |
399 | - if (this.hasModifs) { | |
400 | - // reload RemoteParam Tree in explorer | |
401 | - var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); | |
402 | - if (explorerTree) { | |
403 | - var explorerTreeStore = explorerTree.getStore(); | |
404 | - var explorerRoot = explorerTreeStore.getRootNode(); | |
405 | - var explorerPath = '/root/parameters-treeBase/myRemoteData-treeRootNode/'; | |
406 | - | |
407 | - explorerTreeStore.load( { node : explorerRoot, | |
408 | - params : { nodeType: 'resources'}, | |
409 | - callback : function(){ | |
410 | - explorerTree.selectPath(explorerPath); | |
411 | - } | |
412 | - }); | |
413 | - } | |
414 | - } | |
415 | - } | |
416 | - } | |
413 | + } | |
414 | + ] | |
417 | 415 | }; |
418 | - | |
419 | - Ext.apply(this, Ext.apply(arguments, myConf)); | |
420 | - | |
421 | - } | |
422 | - | |
423 | -}); | |
424 | 416 | \ No newline at end of file |
417 | + Ext.apply(this, Ext.apply(arguments, myConf)); | |
418 | + } | |
419 | +}); | |
... | ... |
... | ... | @@ -0,0 +1,35 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * @class CDAWEB | |
4 | + * @brief | |
5 | + */ | |
6 | + | |
7 | +class CDAWEB extends RemoteDataCenterClientClass | |
8 | +{ | |
9 | + | |
10 | + protected function dataset2dd($id) | |
11 | + { | |
12 | + return $id; | |
13 | + } | |
14 | + | |
15 | + public function getParamSize() | |
16 | + { | |
17 | + $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId; | |
18 | + $res = shell_exec($cmd); | |
19 | + | |
20 | + return $res; | |
21 | + } | |
22 | + | |
23 | + public function getParamComponents() | |
24 | + { | |
25 | + $cmd = "ncinfo_remote ".RemoteData.$this->baseID."/".$this->infoFile." ".$this->ParamId." 1"; | |
26 | + $res = shell_exec($cmd); | |
27 | + | |
28 | + return $res; | |
29 | + } | |
30 | + | |
31 | + public function setInfoFile() | |
32 | + { | |
33 | + $this->infoFile = strtolower($this->ViId).".nc"; | |
34 | + } | |
35 | +} | |
0 | 36 | \ No newline at end of file |
... | ... |
... | ... | @@ -0,0 +1,96 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * @class RemoteDataCenterClientClass | |
4 | + * @brief | |
5 | + * @details | |
6 | + */ | |
7 | +class RemoteDataCenterClientClass | |
8 | +{ | |
9 | + public $baseDom = null, $dataCenter = null; | |
10 | + public $baseDomName; | |
11 | + public $baseID = null; | |
12 | + public $ViId = null, $ParamId = null; | |
13 | + protected $client; | |
14 | + public $infoFile = null; | |
15 | + | |
16 | + /* | |
17 | + * @brief Constructor | |
18 | + */ | |
19 | + function __construct() | |
20 | + { | |
21 | + $this->baseID = get_class($this); | |
22 | + $this->baseDom = new DomDocument("1.0"); | |
23 | + $this->baseDomName = RemoteData.$this->baseID."/base.xml"; | |
24 | + | |
25 | + // if (!file_exists($this->baseDomName)) | |
26 | + // return -1; | |
27 | + // if (!$this->baseDom->load($this->baseDomName)) | |
28 | + // return -2; | |
29 | + $this->baseDom->load($this->baseDomName); | |
30 | + | |
31 | + date_default_timezone_set('UTC'); | |
32 | + | |
33 | + try { | |
34 | + $this->client = new SoapClient(DD_WSDL); | |
35 | + } | |
36 | + catch (SoapFault $exception) { | |
37 | + $msg = $exception->faultstring.PHP_EOL; | |
38 | + exit($msg); | |
39 | + } | |
40 | + | |
41 | + // return 0; | |
42 | + } | |
43 | + | |
44 | + public function param2dd($paramID) | |
45 | + { | |
46 | + $pairs = array(" " => "_","-" => "_","/" => "_","%" => "_","\\" => "_","$" => "_",":" => "_","+" =>"_", | |
47 | + "#" => "_","@" => "_","." => "_", ">" => "_", "<" => "_", "," => "_", ")" => "", "(" => "_"); | |
48 | + | |
49 | + return strtr($paramID,$pairs); | |
50 | + } | |
51 | + | |
52 | + | |
53 | + public function setViId($id) | |
54 | + { | |
55 | + $this->ViId = $id; | |
56 | + } | |
57 | + | |
58 | + public function setParamId($id) | |
59 | + { | |
60 | + $this->ParamId = $id; | |
61 | + } | |
62 | + | |
63 | + public function addViToDD() | |
64 | + { | |
65 | + if (!$this->ViId) return false; | |
66 | + | |
67 | + $this->setInfoFile(); | |
68 | + //check if VI already added | |
69 | + try { | |
70 | + $res = $this->client->isRemoteViAdded($this->baseID, strtolower($this->ViId)); | |
71 | + if (!$res) | |
72 | + { | |
73 | + // call to DD Server to create new VI | |
74 | + $command = 'AddVI '.$this->dataset2dd($this->ViId).' '.$this->ViId.' '.$this->baseID; | |
75 | + system($command, $err); | |
76 | + | |
77 | + return ($err == 0); | |
78 | + } | |
79 | + | |
80 | + return true; | |
81 | + } | |
82 | + catch (SoapFault $exception) { | |
83 | +// echo $this->client->__getLastRequest(); | |
84 | +// echo $this->client->__getLastResponse(); | |
85 | + $msg = $exception->faultstring.PHP_EOL; | |
86 | + return false; | |
87 | + } | |
88 | + } | |
89 | + | |
90 | + | |
91 | + protected function dataset2dd($id){} | |
92 | + public function setInfoFile(){} | |
93 | + public function getParamSize(){} | |
94 | + public function getParamComponents(){} | |
95 | +} | |
96 | +?> | |
... | ... |
... | ... | @@ -0,0 +1,295 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * @class RemoteParamManager | |
4 | + * @brief Manage Remote Data Centers via DDServer | |
5 | + */ | |
6 | + | |
7 | +class RemoteParamManager | |
8 | +{ | |
9 | + protected $Bases, $basesDom; | |
10 | + protected $baseDom; | |
11 | + | |
12 | + protected $center; | |
13 | + | |
14 | + public $xmlDom, $xmlName; | |
15 | + public $paramId, $remoteViId, $localInfo, $paramDom, $paramXML; | |
16 | + | |
17 | + function __construct() | |
18 | + { | |
19 | + if (!file_exists(RemoteData."Bases.xml")) | |
20 | + return array("err" => "No Remote Data Bases"); | |
21 | + | |
22 | + $this->basesDom = new DomDocument("1.0"); | |
23 | + if (!$this->basesDom->load(RemoteData."Bases.xml")) | |
24 | + return array("err" => "Can not load Remote Data Bases definitions"); | |
25 | + $bases = $this->basesDom->getElementsByTagName('dataCenter'); | |
26 | + | |
27 | + foreach ($bases as $base) | |
28 | + $this->Bases[] = $base->getAttribute('xml:id'); | |
29 | + | |
30 | + if (!file_exists(USERWSDIR."RemoteParams.xml")) | |
31 | + return array("err" => "No RemoteParams.xml"); | |
32 | + | |
33 | + $this->xmlName = USERWSDIR."RemoteParams.xml"; | |
34 | + $this->xmlDom = new DomDocument("1.0"); | |
35 | + $this->xmlDom->load($this->xmlName); | |
36 | + } | |
37 | + | |
38 | + /* | |
39 | + * get baseId from parameter descriptor | |
40 | + */ | |
41 | + protected function setBaseId($id) | |
42 | + { | |
43 | + foreach ($this->Bases as $base) { | |
44 | + // Special Themis case | |
45 | + if (substr($id,0,2) == "th") { | |
46 | + $baseId = "THEMIS"; | |
47 | + break; | |
48 | + } | |
49 | + if (strncmp($id, $base, strlen($base)) === 0) | |
50 | + { | |
51 | + $baseId = $base; | |
52 | + break; | |
53 | + } | |
54 | + } | |
55 | + | |
56 | + $this->center = new $baseId(); | |
57 | + } | |
58 | + | |
59 | +// <param xml:id="ace_r"><get><vi name="ace:orb:all"><baseParam name="R"/></vi></get> | |
60 | +// <process>$ace_orb_all_R/RADIUS_EARTH</process> | |
61 | +// <output/></param> | |
62 | + public function makeInternalParamXml() | |
63 | + { | |
64 | + if (!$this->center->ViId) return false; | |
65 | + if (!$this->center->ParamId) return false; | |
66 | + | |
67 | + $this->paramId = strtolower($this->center->baseID."_".$this->center->ViId."_".$this->center->ParamId); | |
68 | + $xml = new DomDocument("1.0"); | |
69 | + $paramNode = $xml->createElement("param"); | |
70 | + $xml->appendChild($paramNode); | |
71 | + | |
72 | + $paramNode->setAttribute("xml:id", $this->paramId); | |
73 | + $getNode = $xml->createElement("get"); | |
74 | + $viNode = $xml->createElement("vi"); | |
75 | + $baseParamNode = $xml->createElement("baseParam"); | |
76 | + $baseParamNode->setAttribute("name", $this->center->ParamId); | |
77 | + $viNode->setAttribute("name", strtolower(strtr($this->center->ViId,"_", ":"))); | |
78 | + $viNode->appendChild($baseParamNode); | |
79 | + $getNode->appendChild($viNode); | |
80 | + $paramNode->appendChild($getNode); | |
81 | + $paramNode->appendChild($xml->createElement("process")); | |
82 | + $paramNode->appendChild($xml->createElement("output")); | |
83 | + | |
84 | + return $xml->save(RemoteData.$this->center->baseID."/".$this->paramId.".xml"); | |
85 | + } | |
86 | + | |
87 | + // TODO not used - too complicated | |
88 | + protected function makeParamArgs() | |
89 | + { | |
90 | + $CURR_DIR = getcwd(); | |
91 | + rename($CURR_DIR ."/".$this->paramId.".xml", "/home/budnik/NEWMETA/final/".$this->paramId.".xml"); | |
92 | + chdir(NEWKERNEL_BASE_PATH."/app-generate-paraminfo"); | |
93 | + $cmd = NEWKERNEL_INSTALL_DIR."/bin/DDLogin budnik Sacre-Cour"; | |
94 | + $res = system($cmd); | |
95 | + $cmd = NEWKERNEL_INSTALL_DIR."/bin/amdaParameterInfo -p ".$this->paramId; | |
96 | + system($cmd, $res); | |
97 | + $info_name = "info_".$this->paramId.".xml"; | |
98 | + rename($info_name, $CURR_DIR."/".$info_name); | |
99 | + chdir($CURR_DIR); | |
100 | + | |
101 | + return $info_name; | |
102 | + } | |
103 | + | |
104 | +// protected function makeComponentsFromArgsFile($node, $info_file_name) | |
105 | +// { | |
106 | +// $xml = new DomDocument(); | |
107 | +// $xml->load($info_file_name); | |
108 | +// | |
109 | +// $components = $xml->getElementsByTagName('component'); | |
110 | +// if ($components->length > 0) | |
111 | +// { | |
112 | +// foreach ($components as $component) | |
113 | +// { | |
114 | +// $compNode = $this->xmlDom->createElement("component"); | |
115 | +// $compNode->setAttribute('xml:id',$this->paramId.'('.$component->getAttribute("index_1").')'); | |
116 | +// $component->setAttribute('name',$component->getAttribute("name")); // LABEL | |
117 | +// | |
118 | +// $node->appendChild($compNode); | |
119 | +// } | |
120 | +// } | |
121 | +// } | |
122 | + | |
123 | + protected function makeComponents($node, $size, $components) | |
124 | + { | |
125 | + $compArray = explode(";",$components); | |
126 | + | |
127 | + for ($i = 0; $i < $size; $i++) | |
128 | + { | |
129 | + $compNode = $this->xmlDom->createElement("component"); | |
130 | + $compNode->setAttribute('xml:id',$this->paramId."($i)"); | |
131 | + $compNode->setAttribute('name',strtolower($compArray[$i])); // LABEL | |
132 | + | |
133 | + $node->appendChild($compNode); | |
134 | + } | |
135 | + } | |
136 | + | |
137 | + protected function addNode($id) | |
138 | + { | |
139 | + // Node exists already | |
140 | + if ($this->xmlDom->getElementById($id)) return true; | |
141 | + | |
142 | + // Node to be added | |
143 | + $nodeRemote = $this->center->baseDom->getElementById($id); | |
144 | + | |
145 | + // No such node in base.xml | |
146 | + if (!$nodeRemote) return false; | |
147 | + | |
148 | + if ($nodeRemote->tagName == 'dataset') | |
149 | + { | |
150 | + $this->center->setViId($nodeRemote->getAttribute('name')); | |
151 | + $status = $this->center->addViToDD(); | |
152 | + // echo "STATUS $status".PHP_EOL; | |
153 | + if (!$status) return false; | |
154 | + $remoteDatasetInfo = "/home/budnik/DDBASE/INFO/bases/".$this->center->baseID."/".$this->center->infoFile; //TODO "http://apus.irap.omp.eu/ | |
155 | + $localDatasetInfo = RemoteData.$this->center->baseID."/".$this->center->infoFile; | |
156 | + | |
157 | + if (!copy($remoteDatasetInfo,$localDatasetInfo)) return false; | |
158 | + } | |
159 | + | |
160 | + $node = $this->xmlDom->importNode($nodeRemote); | |
161 | + | |
162 | + if ($nodeRemote->tagName == 'parameter') | |
163 | + { | |
164 | + $this->center->setParamId($nodeRemote->getAttribute('name')); | |
165 | + $this->center->setViId($nodeRemote->parentNode->getAttribute('name')); | |
166 | + $this->center->setInfoFile(); | |
167 | + | |
168 | + if (!$this->makeInternalParamXml()) return false; | |
169 | + | |
170 | + if (($size = $this->center->getParamSize()) > 1) | |
171 | + { | |
172 | + // make components and args | |
173 | + $components = $this->center->getParamComponents(); | |
174 | + $this->makeComponents($node, $size, $components); // return false; | |
175 | + } | |
176 | + | |
177 | +// if ($res) | |
178 | +// $info_file_name = $this->makeParamArgs(); | |
179 | +// | |
180 | +// if (!$this->makeComponentsFromArgsFile($node, $info_file_name)) return false; | |
181 | + | |
182 | + } | |
183 | + | |
184 | + $parentRemote= $nodeRemote->parentNode; | |
185 | + $parentRemoteId = $parentRemote->getAttribute('xml:id'); | |
186 | + | |
187 | + $parent = $this->xmlDom->getElementById($parentRemoteId); | |
188 | + | |
189 | + if (!$parent) | |
190 | + { | |
191 | + $parent = $this->xmlDom->importNode($parentRemote); | |
192 | + } | |
193 | + | |
194 | + $parent->appendChild($node); | |
195 | + | |
196 | + $toAddDataCentertToDoc = false; | |
197 | + | |
198 | + while ($parent->tagName != 'dataCenter') | |
199 | + { | |
200 | + $node = $parent; | |
201 | + $parentRemote = $parentRemote->parentNode; | |
202 | + $parentRemoteId = $parentRemote->getAttribute('xml:id'); | |
203 | + $parent = $this->xmlDom->getElementById($parentRemoteId); | |
204 | + | |
205 | + if (!$parent) | |
206 | + { | |
207 | + if ($parentRemote->tagName == 'dataCenter') | |
208 | + $toAddDataCenterToDoc = true; | |
209 | + $parent = $this->xmlDom->importNode($parentRemote); | |
210 | + $parent->appendChild($node); | |
211 | + } | |
212 | + } | |
213 | + | |
214 | + if ($toAddDataCenterToDoc) | |
215 | + { | |
216 | + //TODO if this is necessary ??? | |
217 | + // special bases 'hand-made' descriptions | |
218 | + $basesDom = new DomDocument("1.0"); | |
219 | + $basesDom -> load(RemoteData.'Bases.xml'); | |
220 | + $theBase = $basesDom->getElementById($parent->getAttribute('xml:id')); | |
221 | + | |
222 | + if ($theBase) $parent -> setAttribute('name', $theBase->getAttribute('name')); | |
223 | + $this->xmlDom->documentElement->appendChild($parent); | |
224 | + } | |
225 | + | |
226 | + return true; | |
227 | + } | |
228 | + | |
229 | +/* | |
230 | +* PUBLIC FUNCTIONS | |
231 | +*/ | |
232 | + public function saveTree($obj) | |
233 | + { | |
234 | + $r = print_r($obj, true); | |
235 | + if (count($obj) == 1) | |
236 | + { | |
237 | + $id = $obj->id; | |
238 | + | |
239 | + if ($id == 'root') return array('res' => 'ok'); | |
240 | + | |
241 | + $this->setBaseId($id); | |
242 | + $res = $this->addNode($id); | |
243 | + | |
244 | + if ($res === false) return array("err" => "Cannot add node : $id"); | |
245 | + } | |
246 | + else | |
247 | + { | |
248 | + foreach ($obj as $o) | |
249 | + { | |
250 | + $id = $o->id; | |
251 | + | |
252 | + if ($id == 'root') continue; | |
253 | + | |
254 | + if (!$this->baseId) $this->setBaseId($id); | |
255 | + $res = $this->addNode($id); | |
256 | + | |
257 | + if ($res === false) return array("err" => "Cannot add node : $id"); | |
258 | + | |
259 | + } | |
260 | + } | |
261 | + | |
262 | + if (!$this->xmlDom->save($this->xmlName)) | |
263 | + return array("err" => "Cannot save RemoteParams.xml"); | |
264 | + | |
265 | + return array('res' => 'ok'); | |
266 | + } | |
267 | + | |
268 | + public function deleteFromTree($obj) | |
269 | + { | |
270 | + $id = $obj->id; | |
271 | + $nodeToDelete = $this->xmlDom->getElementById($id); | |
272 | + | |
273 | + if (!$nodeToDelete) | |
274 | + return array("err" => "No such id : $id"); | |
275 | + | |
276 | + $tagName = $nodeToDelete->tagName; | |
277 | + | |
278 | + while ( $tagName != "dataRoot" ) // "dataCenter" ? | |
279 | + { | |
280 | + $parentNode = $nodeToDelete->parentNode; | |
281 | + $parentNode->removeChild($nodeToDelete); | |
282 | + $otherChildren = $parentNode->getElementsByTagName($tagName); | |
283 | + | |
284 | + if ( $otherChildren->length > 0 ) | |
285 | + break; | |
286 | + | |
287 | + $nodeToDelete = $parentNode; | |
288 | + $tagName = $nodeToDelete->tagName; | |
289 | + } | |
290 | + $this->xmlDom->save($this->xmlName); | |
291 | + | |
292 | + return array('res'=> $obj->id); | |
293 | + } | |
294 | +} | |
295 | +?> | |
0 | 296 | \ No newline at end of file |
... | ... |
php/classes/ParamMgr.php deleted
... | ... | @@ -1,415 +0,0 @@ |
1 | -<?php | |
2 | -/** | |
3 | - * @class ParamMgr | |
4 | - * @version $Id: ParamMgr.php 1947 2013-11-28 15:10:46Z elena $ | |
5 | - * | |
6 | - */ | |
7 | - | |
8 | - class ParamMgr { | |
9 | - | |
10 | - | |
11 | - protected $Bases, $basesDom; | |
12 | - protected $baseDom; | |
13 | - public $xmlDom, $xmlName; | |
14 | - public $baseId, $paramId, $remoteViId, $localInfo, $paramDom, $paramXML; | |
15 | - | |
16 | - function __construct() { | |
17 | -//TODO check if files exist.... | |
18 | - $this->basesDom = new DomDocument("1.0"); | |
19 | - $this->basesDom->load(RemoteData.'Bases.xml'); | |
20 | - $bases = $this->basesDom->getElementsByTagName('dataCenter'); | |
21 | - foreach ($bases as $base) $this->Bases[] = $base->getAttribute('xml:id'); | |
22 | - | |
23 | - $this->xmlName = USERWSDIR.'RemoteParams.xml'; | |
24 | - $this->xmlDom = new DomDocument("1.0"); | |
25 | - $this->xmlDom->load($this->xmlName); | |
26 | - | |
27 | - } | |
28 | - | |
29 | -/* | |
30 | -* | |
31 | -*/ | |
32 | - protected function param2dd($paramID) { | |
33 | - | |
34 | - $pairs = array("%" => "_","\\" => "_","$" => "_",":" => "_","+" =>"_","-" => "_","#" => "_","@" => "_","." => "_", ">" => "_", "<" => "_"); | |
35 | - return strtr($paramID,$pairs); | |
36 | - } | |
37 | - | |
38 | -/* | |
39 | -* Make Aliases - Remote data set ID -> DD data set ID (xxxx_xxxx_xxxx) | |
40 | -*/ | |
41 | - public function dataset2dd($remVIID) { | |
42 | - // TODO method of ???? class | |
43 | - | |
44 | - $ddVIID = $remVIID; | |
45 | - return $ddVIID; | |
46 | - } | |
47 | - | |
48 | -/* | |
49 | -* get baseId from parameter descriptor | |
50 | -*/ | |
51 | - protected function setBaseId($id) { | |
52 | - | |
53 | - foreach ($this->Bases as $base) { | |
54 | -// Special Themis case | |
55 | - if (substr($id,0,2) == "th") { | |
56 | - $this->baseId = "THEMIS"; | |
57 | - break; | |
58 | - } | |
59 | - if (strncmp($id, $base, strlen($base)) === 0) { | |
60 | - $this->baseId = $base; | |
61 | - break; | |
62 | - } | |
63 | - } | |
64 | - | |
65 | - $this->baseDom = new DomDocument("1.0"); | |
66 | - $this->baseDom->load(RemoteData.$this->baseId.'/base.xml'); | |
67 | - } | |
68 | - | |
69 | -/* | |
70 | -* get Info File name | |
71 | -*/ | |
72 | -//TODO not to hardly code special stuff... | |
73 | - public function getInfoName($datasetId) { | |
74 | - | |
75 | - if ($this->baseId == 'CDAWEB') | |
76 | - return strtolower($datasetId)."_00000000_v01.cdf"; | |
77 | - return $datasetId.'.xml'; | |
78 | - | |
79 | - } | |
80 | - | |
81 | -/* | |
82 | -* | |
83 | -*/ | |
84 | - protected function getDatasetInfo() { | |
85 | - | |
86 | - $infoFileName = $this->getInfoName($this->remoteViId); | |
87 | - $this->localInfo = RemoteData.$this->baseId.'/'.$infoFileName; | |
88 | - if (file_exists($this->localInfo)) return true; | |
89 | - | |
90 | -// call to DD Server to create new VI | |
91 | - $command = OLD_CLASSPATH.'AddVI '.$this->dataset2dd($this->remoteViId).' '.$this->remoteViId.' '.$this->baseId; | |
92 | - system($command, $err); | |
93 | - | |
94 | - $remoteInfo = INFOSITE.'INFO/'.$this->baseId.'/DATASETS/'.$infoFileName; | |
95 | -// Get dataset info from DD Server if it doesn't yet exists locally | |
96 | -//TODO may be not neccessary to copy file? load from URL? | |
97 | - $res = copy($remoteInfo, $this->localInfo); | |
98 | - return $res; | |
99 | - } | |
100 | - | |
101 | -/* | |
102 | -* | |
103 | -*/ | |
104 | - public function getParamInfo() { | |
105 | - | |
106 | - if (!$this->localInfo) { | |
107 | - $infoFileName = $this->getInfoName($this->remoteViId); | |
108 | - $this->localInfo = RemoteData.$this->baseId.'/'.$infoFileName; | |
109 | - } | |
110 | - switch ($this->baseId) { | |
111 | -// CDAWEB specific function to parse master CDF - idl | |
112 | - case 'CDAWEB' : | |
113 | - $command = OLD_CLASSPATH.'cdfInfo '.$this->localInfo.' "'.$this->paramId.'"'; | |
114 | - $info = exec($command); | |
115 | - break; | |
116 | - case 'VEXGRAZ' : | |
117 | - case 'MAPSKP' : | |
118 | - $info = $this->getInfoSpase(); | |
119 | - break; | |
120 | - default: | |
121 | - | |
122 | - } | |
123 | - if ($info == "%-9999") return false; | |
124 | - return $info; | |
125 | - } | |
126 | - | |
127 | -/* | |
128 | -* | |
129 | -*/ | |
130 | - protected function getInfoSpase() { | |
131 | - | |
132 | - $xmlinfo = new DomDocument("1.0"); | |
133 | - $xmlinfo->load($this->localInfo); | |
134 | - $mission = $xmlinfo->getElementsByTagName("PARENT_MISSION"); | |
135 | - $instrument = $xmlinfo->getElementsByTagName("PARENT_INSTRUMENT"); | |
136 | - | |
137 | - $xp = new domxpath($xmlinfo); | |
138 | - $param = $xp->query("//PARAM_ID[.='".$this->paramId."']"); | |
139 | - $paramNode = $param->item(0)->parentNode; | |
140 | - if (!$paramNode) return false; | |
141 | - | |
142 | - $info = "paramID%" . $this->paramId . "&&"; | |
143 | - // Data Type | |
144 | - $tag = $paramNode->getElementsByTagName("DATA_TYPE"); | |
145 | - $value = $tag->item(0)->nodeValue; | |
146 | - switch ($value) { | |
147 | - case 'FLOAT' : $dataTypeS = '2'; break; | |
148 | - case 'DOUBLE': $dataTypeS = '3'; break; | |
149 | - case 'INT' : $dataTypeS = '1'; break; | |
150 | - case 'CHAR' : $dataTypeS = '0'; break; | |
151 | - default : $dataTypeS = '2' ; | |
152 | - } | |
153 | - $info = $info . "DATATYPE%" . $dataTypeS ."&&"; | |
154 | - $tag = $paramNode->getElementsByTagName("SIZES"); | |
155 | - $value = $tag->item(0)->nodeValue; | |
156 | - $info = $info . "DIMENSION%" . $value; | |
157 | - $tags=array("PARENT_MISSION", "PARENT_EXPERIMENT", "PARAMETER_SHORT_DESCRIPTION", "FILLVAL", "UNITS","DISPLAY_TYPE", "COORDINATE_SYSTEM", "TENSOR_ORDER_VALUE", "LABEL_I", "FIELDNAM"); | |
158 | - | |
159 | - foreach ($tags as $atag){ | |
160 | - $tag = $paramNode->getElementsByTagName($atag); | |
161 | - $value = $tag->length > 0 ? $tag->item(0)->nodeValue : -9999; | |
162 | - switch ($atag) { | |
163 | - case "LABEL_I" : $name = "LABLAXIS"; | |
164 | - $val_arr = array(); | |
165 | - for ($j = 0; $j < $tag->length; $j++) | |
166 | - $val_arr[$j] = $tag->item($j)->nodeValue; | |
167 | - $value = implode($val_arr, '$').'$'; break; | |
168 | - case "COORDINATE_SYSTEM" : $name = "FRAME"; break; | |
169 | - case "TENSOR_ORDER_VALUE" : $name = "TENSOR"; break; | |
170 | - case "PARAMETER_SHORT_DESCRIPTION" : $name = "DESCRIPTOR"; break; | |
171 | - case "PARENT_MISSION" : $name = "SOURCE_NAME"; | |
172 | - $value = $mission->item(0)->nodeValue; | |
173 | - break; | |
174 | - case "PARENT_EXPERIMENT" : $name = "DATA_TYPE"; | |
175 | - $value = $instrument->item(0)->nodeValue; | |
176 | - break; | |
177 | - case "FILLVAL": | |
178 | - $value = $tag->length > 0 ? $tag->item(0)->nodeValue : -1.e31; | |
179 | - $name = "FILLVAL"; | |
180 | - break; | |
181 | - default: $name = $atag; | |
182 | - } | |
183 | - $info = $info . "&&".$name."%". $value; | |
184 | - } | |
185 | - | |
186 | - return $info; | |
187 | - } | |
188 | -/* | |
189 | -* Create XML parameter descriptor in the generic_data/RemoteData/PARAMS dir | |
190 | -*/ | |
191 | - public function createParamXml($infoTotal) { | |
192 | - | |
193 | - $this->paramDom = new DomDocument("1.0"); | |
194 | - $this->paramDom->preserveWhiteSpace = false; | |
195 | - $this->paramDom->formatOutput = true; | |
196 | - | |
197 | - $param = $this->paramDom->createElement('PARAM'); | |
198 | - $param->appendChild($this->paramDom->createElement("baseID",$this->baseId)); | |
199 | - $param->appendChild($this->paramDom->createElement("viID",$this->remoteViId)); | |
200 | - | |
201 | - $info = explode("&&",$infoTotal); | |
202 | - for ($i = 0; $i < count($info); $i++){ | |
203 | - $attr = explode("%",$info[$i]); | |
204 | - try { | |
205 | - $param->appendChild($this->paramDom->createElement($attr[0],$attr[1])); | |
206 | - } | |
207 | - catch (Exception $e) { | |
208 | - return false; | |
209 | - } | |
210 | - } | |
211 | - $this->paramDom->appendChild($param); | |
212 | - if (!$this->paramDom->save($this->paramXML)) return false; | |
213 | - | |
214 | - return true; // NO ERROR | |
215 | - | |
216 | - } | |
217 | - | |
218 | -/* | |
219 | -* special themis case: componets from base.xml | |
220 | -*/ | |
221 | - public function makeThemisComponents($param) { | |
222 | - | |
223 | - $sizes = $param->getAttribute('size'); | |
224 | - if (!$sizes) return true; // scalar | |
225 | - | |
226 | - | |
227 | - $labels = $param->getAttribute('labels'); | |
228 | - $id = $param->getAttribute('xml:id'); | |
229 | - $name = $param->getAttribute('name'); | |
230 | - | |
231 | - if (!$labels) { | |
232 | - $param->setAttribute('needsArgs', true); | |
233 | - return true; | |
234 | - } | |
235 | - | |
236 | - $labelArr = explode("$",$labels); | |
237 | - for ($i = 0; $i < count($labelArr); $i++) | |
238 | - { | |
239 | - $component = $this->xmlDom->createElement('component'); | |
240 | - $component->setAttribute('xml:id',$id.'('.$i.')'); | |
241 | - | |
242 | - $component->setAttribute('name',$labelArr[$i]); | |
243 | - $param->appendChild($component); | |
244 | - } | |
245 | - return true; | |
246 | - | |
247 | - } | |
248 | - | |
249 | -/* | |
250 | -* | |
251 | -*/ | |
252 | - public function makeComponents($param) { | |
253 | - | |
254 | - $sizes = $this->paramDom->getElementsByTagName('DIMENSION')->item(0)->nodeValue; | |
255 | - $display = strtolower($this->paramDom->getElementsByTagName('DISPLAY_TYPE')->item(0)->nodeValue); | |
256 | - $units = $this->paramDom->getElementsByTagName('UNITS')->item(0)->nodeValue; | |
257 | - | |
258 | - if (!$units || ($units == "-9999")) $units = "no"; | |
259 | - $param->setAttribute("units", $units); | |
260 | - | |
261 | - if ($sizes == "1") return true; // Scalar - Nothing to do | |
262 | - | |
263 | - $id = $param->getAttribute('xml:id'); | |
264 | - $name = $param->getAttribute('name'); | |
265 | - // Not a Scalar - add components to user tree | |
266 | - $labels = $this->paramDom->getElementsByTagName('LABLAXIS')->item(0)->nodeValue; | |
267 | - | |
268 | - // No labels | |
269 | - if (!$labels || ($labels == "$") || (substr($display,0,6) == "spectr")) { | |
270 | - if (!$param->getAttribute('needsArgs')) { | |
271 | - $param->setAttribute('needsArgs', true); | |
272 | - if (substr($display,0,6) == "spectr") | |
273 | - $param->setAttribute('display_type', 'spectrogram'); | |
274 | - } | |
275 | - return true; | |
276 | - } | |
277 | - | |
278 | - $labelArr = explode("$",$labels); | |
279 | - for ($i = 0; $i < count($labelArr)-1; $i++) | |
280 | - { | |
281 | - $component = $this->xmlDom->createElement('component'); | |
282 | - $component->setAttribute('xml:id',$id.'('.$i.')'); | |
283 | - $component->setAttribute('name',$labelArr[$i]); | |
284 | - $param->appendChild($component); | |
285 | - } | |
286 | - return true; | |
287 | - } | |
288 | -/* | |
289 | -* | |
290 | -*/ | |
291 | - protected function addNode($id){ | |
292 | - | |
293 | -// NODE EXISTS | |
294 | - | |
295 | - if ($this->xmlDom->getElementById($id)) return true; | |
296 | - | |
297 | -// NODE TO BE ADD | |
298 | - $nodeRemote = $this->baseDom->getElementById($id); | |
299 | - | |
300 | - if (!$nodeRemote) return false; | |
301 | - | |
302 | - if ($nodeRemote->tagName == 'dataset') { | |
303 | - | |
304 | - $this->remoteViId = $nodeRemote->getAttribute('name'); | |
305 | - $datasetExists = $this->baseId != 'THEMIS' ? $this->getDatasetInfo() : true; | |
306 | - if (!$datasetExists) return false; | |
307 | - } | |
308 | - | |
309 | - $node = $this->xmlDom->importNode($nodeRemote); | |
310 | - | |
311 | - if ($nodeRemote->tagName == 'parameter') { | |
312 | - | |
313 | - $this->paramId = $nodeRemote->getAttribute('name'); | |
314 | - $this->remoteViId = $nodeRemote->parentNode->getAttribute('name'); | |
315 | - | |
316 | - $info = $this->baseId != 'THEMIS' ? $this->getParamInfo() : true; | |
317 | - if (!$info) return false; | |
318 | - | |
319 | - | |
320 | - // XML descriptor of the parameter; themis excluded | |
321 | - if ($this->baseId == 'THEMIS') { | |
322 | - | |
323 | - if (!$this->makeThemisComponents($node)) return false; | |
324 | - } | |
325 | - else { | |
326 | - | |
327 | - $paramGlobalId = $this->baseId.":".$this->dataset2dd($this->remoteViId).":".$this->param2dd($this->paramId); | |
328 | - $node->setAttribute('xml:id', $paramGlobalId); | |
329 | - $this->paramXML = RemoteData.'PARAMS/'.$paramGlobalId.'.xml'; | |
330 | - | |
331 | - if (!file_exists($this->paramXML) && !$this->createParamXml($info)) return false; | |
332 | - if (!$this->paramDom) { | |
333 | - $this->paramDom = new DomDocument("1.0"); | |
334 | - } | |
335 | - $this->paramDom->load($this->paramXML); | |
336 | - | |
337 | - if (!$this->makeComponents($node)) return false; | |
338 | - } | |
339 | - } | |
340 | - | |
341 | - $parentRemote= $nodeRemote->parentNode; | |
342 | - $parentRemoteId = $parentRemote->getAttribute('xml:id'); | |
343 | - | |
344 | - $parent = $this->xmlDom->getElementById($parentRemoteId); | |
345 | - if (!$parent) { | |
346 | - $parent = $this->xmlDom->importNode($parentRemote); | |
347 | - } | |
348 | - $parent -> appendChild($node); | |
349 | - | |
350 | - $toAddDataCentertToDoc = false; | |
351 | - | |
352 | - while ($parent->tagName != 'dataCenter') { | |
353 | - $node = $parent; | |
354 | - $parentRemote = $parentRemote->parentNode; | |
355 | - $parentRemoteId = $parentRemote->getAttribute('xml:id'); | |
356 | - $parent = $this->xmlDom->getElementById($parentRemoteId); | |
357 | - | |
358 | - if (!$parent) { | |
359 | - if ($parentRemote->tagName == 'dataCenter') $toAddDataCenterToDoc = true; | |
360 | - $parent = $this->xmlDom->importNode($parentRemote); | |
361 | - $parent -> appendChild($node); | |
362 | - } | |
363 | - } | |
364 | - | |
365 | - if ($toAddDataCenterToDoc) { | |
366 | -//TODO if this is neccessary ??? | |
367 | -// special bases 'hand-made' descriptions | |
368 | - $basesDom = new DomDocument("1.0"); | |
369 | - $basesDom -> load(RemoteData.'Bases.xml'); | |
370 | - $theBase = $basesDom -> getElementById($parent->getAttribute('xml:id')); | |
371 | - | |
372 | - if ($theBase) $parent -> setAttribute('name', $theBase->getAttribute('name')); | |
373 | - $this->xmlDom->documentElement->appendChild($parent); | |
374 | - } | |
375 | - return true; | |
376 | - } | |
377 | - | |
378 | -/* | |
379 | -* PUBLIC FUNCTIONS | |
380 | -*/ | |
381 | - public function saveTree($obj) { | |
382 | - | |
383 | - if (count($obj) == 1) { | |
384 | - $id = $obj->id; | |
385 | - $this->setBaseId($id); | |
386 | - $res = $this->addNode($id); | |
387 | - } | |
388 | - else { | |
389 | - foreach ($obj as $o) { | |
390 | - $id = $o->id; | |
391 | - if ($id == 'root') continue; | |
392 | - if (!$this->baseId) $this->setBaseId($id); | |
393 | - $res = $this->addNode($id); | |
394 | - } | |
395 | - } | |
396 | - | |
397 | - $this->xmlDom->save($this->xmlName); | |
398 | - return array('res' => 'ok'); | |
399 | - } | |
400 | - | |
401 | - public function deleteFromTree($obj) { | |
402 | - | |
403 | - $id = $obj->id; | |
404 | - $nodeToDelete = $this->xmlDom->getElementById($id); | |
405 | - if (!$nodeToDelete) return array('err' => 'NO SUCH ID'); | |
406 | - $nodeToDelete->parentNode->removeChild($nodeToDelete); | |
407 | - | |
408 | - $this->xmlDom->save($this->xmlName); | |
409 | - | |
410 | - return array('res'=> $obj->id); | |
411 | - } | |
412 | - | |
413 | -} | |
414 | - | |
415 | -?> | |
416 | 0 | \ No newline at end of file |
... | ... | @@ -0,0 +1,23 @@ |
1 | +/* $Id: AddVI.c,v 1.2 2012/10/29 08:03:14 budnik Exp $*/ | |
2 | +/*=========================================================================== | |
3 | + * DD SYSTEM CLIENT-SERVER | |
4 | + * AddVI.c | |
5 | + * v.1.0 | |
6 | + * Executable to add new VI to server | |
7 | + * List of changes: | |
8 | + * 17 Jun 2007: V.1.0 | |
9 | + ===========================================================================*/ | |
10 | + | |
11 | +#include <stdio.h> | |
12 | +#include <string.h> | |
13 | +#include <DD.h> | |
14 | + | |
15 | +main(int argc, char **argv) | |
16 | +{ | |
17 | + int Err; | |
18 | + | |
19 | + Err = DD_AddDataSet(argv[1],argv[2],argv[3]); | |
20 | + // printf("Err = %d\n",Err); | |
21 | + return Err; | |
22 | +} | |
23 | +/*===========================================================================*/ | |
... | ... |
php/src/Makefile
1 | -INC = -I/usr/include -I/usr/local/include -I${CDF_DIR}/include -I${CEF_DIR}/include -I${DD_INCLUDE} | |
2 | -LIB = -L/usr/lib64 -L/usr/local/lib64 -L${CDF_DIR}/lib -L${CEF_DIR}/lib -L${DD_LIB} | |
1 | +INC = -I/usr/include -I/usr/local/include -I/opt/local/include -I/opt/local/include/DDClientLibC | |
2 | +LIB = -L/usr/lib64 -L/usr/local/lib64 -L/opt/local/lib -L/opt/local/lib | |
3 | 3 | CFLAGS = -ggdb -DLINUX -m64 -march=core2 -fPIC -Dlinux -D_REENTRANT -malign-double |
4 | 4 | CC = gcc |
5 | 5 | |
6 | 6 | EXE = nctimestring2double nctimeinfo getncvars ncvarinfo \ |
7 | - cefstartstop cefvarinfo cefinfo cefsampling ceftimeinfo \ | |
8 | - cdfinfo cdfvarinfo cdfstartstopfromdata cdfsamplingfromdata | |
7 | + ncinfo_remote \ | |
8 | + cdfinfo cdfvarinfo cdfstartstopfromdata cdfsamplingfromdata \ | |
9 | + AddVI | |
9 | 10 | |
10 | 11 | lib: ${EXE} |
11 | 12 | |
12 | -nctimestring2double: nctimestring2double.o | |
13 | - ${CC} -o nctimestring2double nctimestring2double.o ${LIB} -lDDClientLibC -lnetcdf | |
13 | +AddVI: AddVI.c | |
14 | + ${CC} ${CFLAGS} -o AddVI AddVI.c ${INC} ${LIB} -lDDClientLibC | |
15 | + | |
16 | +ncinfo_remote: ncinfo_remote.c | |
17 | + ${CC} ${CFLAGS} -o ncinfo_remote ncinfo_remote.c ${INC} ${LIB} -lnetcdf | |
18 | + | |
19 | +nctimestring2double: nctimestring2double.c | |
20 | + ${CC} ${CFLAGS} -o nctimestring2double nctimestring2double.c ${INC} ${LIB} -lDDClientLibC -lnetcdf | |
14 | 21 | |
15 | -nctimestring2double.o: nctimestring2double.c | |
16 | - ${CC} ${CFLAGS} -c nctimestring2double.c ${INC} | |
22 | +nctimeinfo: nctimeinfo.c | |
23 | + ${CC} ${CFLAGS} -o nctimeinfo nctimeinfo.c ${INC} ${LIB} -lnetcdf | |
17 | 24 | |
18 | -nctimeinfo: nctimeinfo.o | |
19 | - ${CC} -o nctimeinfo nctimeinfo.o ${LIB} -lnetcdf | |
25 | +getncvars: getncvars.c | |
26 | + ${CC} ${CFLAGS} -o getncvars getncvars.c ${INC} ${LIB} -lnetcdf | |
20 | 27 | |
21 | -nctimeinfo.o: nctimeinfo.c | |
22 | - ${CC} ${CFLAGS} -c nctimeinfo.c ${INC} | |
28 | +ncvarinfo: ncvarinfo.c | |
29 | + ${CC} ${CFLAGS} -o ncvarinfo ncvarinfo.c ${INC} ${LIB} -lnetcdf | |
23 | 30 | |
24 | -getncvars: getncvars.o | |
25 | - ${CC} -o getncvars getncvars.o ${LIB} -lnetcdf | |
31 | +cefvarinfo: cefvarinfo.c | |
32 | + ${CC} ${CFLAGS} -o cefvarinfo cefvarinfo.c ${INC} ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
26 | 33 | |
27 | -getncvars.o: getncvars.c | |
28 | - ${CC} ${CFLAGS} -c getncvars.c ${INC} | |
34 | +cefinfo: cefinfo.c | |
35 | + ${CC} ${CFLAGS} -o cefinfo cefinfo.c ${INC} ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
29 | 36 | |
30 | -ncvarinfo: ncvarinfo.o | |
31 | - ${CC} -o ncvarinfo ncvarinfo.o ${LIB} -lnetcdf | |
37 | +cefstartstop: cefstartstop.c | |
38 | + ${CC} ${CFLAGS} -o cefstartstop cefstartstop.c ${INC} ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
32 | 39 | |
33 | -ncvarinfo.o: ncvarinfo.c | |
34 | - ${CC} ${CFLAGS} -c ncvarinfo.c ${INC} | |
40 | +cefsampling: cefsampling.c | |
41 | + ${CC} ${CFLAGS} -o cefsampling cefsampling.c ${INC} ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
35 | 42 | |
36 | -cefvarinfo: cefvarinfo.o | |
37 | - ${CC} -o cefvarinfo cefvarinfo.o ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
43 | +ceftimeinfo: ceftimeinfo.c | |
44 | + ${CC} ${CFLAGS} -o ceftimeinfo ceftimeinfo.c ${INC} ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
38 | 45 | |
39 | -cefvarinfo.o: cefvarinfo.c | |
40 | - ${CC} ${CFLAGS} -c cefvarinfo.c ${INC} | |
46 | +cdfinfo: cdfinfo.c | |
47 | + ${CC} ${CFLAGS} -o cdfinfo cdfinfo.c ${INC} ${LIB} -lcdf | |
41 | 48 | |
42 | -cefinfo: cefinfo.o | |
43 | - ${CC} -o cefinfo cefinfo.o ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
49 | +cdfvarinfo: cdfvarinfo.c | |
50 | + ${CC} ${CFLAGS} -o cdfvarinfo cdfvarinfo.c ${INC} ${LIB} -lcdf | |
44 | 51 | |
45 | -cefinfo.o: cefinfo.c | |
46 | - ${CC} ${CFLAGS} -c cefinfo.c ${INC} | |
52 | +cdfstartstopfromdata: cdfstartstopfromdata.c | |
53 | + ${CC} ${CFLAGS} -o cdfstartstopfromdata cdfstartstopfromdata.c ${INC} ${LIB} -lcdf | |
47 | 54 | |
48 | -cefstartstop: cefstartstop.o | |
49 | - ${CC} -o cefstartstop cefstartstop.o ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
50 | - | |
51 | -cefstartstop.o: cefstartstop.c | |
52 | - ${CC} ${CFLAGS} -c cefstartstop.c ${INC} | |
53 | - | |
54 | -cefsampling: cefsampling.o | |
55 | - ${CC} -o cefsampling cefsampling.o ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
56 | - | |
57 | -cefsampling.o: cefsampling.c | |
58 | - ${CC} ${CFLAGS} -c cefsampling.c ${INC} | |
59 | - | |
60 | -ceftimeinfo: ceftimeinfo.o | |
61 | - ${CC} -o ceftimeinfo ceftimeinfo.o ${LIB} -lm -lz -lCEF_gcc -lCIS_gcc | |
62 | - | |
63 | -ceftimeinfo.o: ceftimeinfo.c | |
64 | - ${CC} ${CFLAGS} -c ceftimeinfo.c ${INC} | |
65 | - | |
66 | -cdfinfo: cdfinfo.o | |
67 | - ${CC} -o cdfinfo cdfinfo.o ${LIB} -lcdf | |
68 | - | |
69 | -cdfinfo.o: cdfinfo.c | |
70 | - ${CC} ${CFLAGS} -c cdfinfo.c ${INC} | |
71 | - | |
72 | -cdfvarinfo: cdfvarinfo.o | |
73 | - ${CC} -o cdfvarinfo cdfvarinfo.o ${LIB} -lcdf | |
74 | - | |
75 | -cdfvarinfo.o: cdfvarinfo.c | |
76 | - ${CC} ${CFLAGS} -c cdfvarinfo.c ${INC} | |
77 | - | |
78 | -cdfstartstopfromdata: cdfstartstopfromdata.o | |
79 | - ${CC} -o cdfstartstopfromdata cdfstartstopfromdata.o ${LIB} -lcdf | |
80 | - | |
81 | -cdfstartstopfromdata.o: cdfstartstopfromdata.c | |
82 | - ${CC} ${CFLAGS} -c cdfstartstopfromdata.c ${INC} | |
83 | - | |
84 | -cdfsamplingfromdata: cdfsamplingfromdata.o | |
85 | - ${CC} -o cdfsamplingfromdata cdfsamplingfromdata.o ${LIB} -lcdf | |
86 | - | |
87 | -cdfsamplingfromdata.o: cdfsamplingfromdata.c | |
88 | - ${CC} ${CFLAGS} -c cdfsamplingfromdata.c ${INC} | |
55 | +cdfsamplingfromdata: cdfsamplingfromdata.c | |
56 | + ${CC} ${CFLAGS} -o cdfsamplingfromdata cdfsamplingfromdata.c ${INC} ${LIB} -lcdf | |
89 | 57 | |
90 | 58 | install: |
91 | 59 | install -d -m a+rx,ug+w ${IHM_DIR}/php/bin |
... | ... |
... | ... | @@ -0,0 +1,96 @@ |
1 | + #include <stdio.h> | |
2 | +#include <stdlib.h> | |
3 | +#include <string.h> | |
4 | +#include <netcdf.h> | |
5 | + | |
6 | +void check(int stat) | |
7 | +{ | |
8 | + if (stat != NC_NOERR) | |
9 | + { | |
10 | + printf("NetCDF error: %s\n", nc_strerror(stat)); | |
11 | + exit(1); | |
12 | + } | |
13 | +} | |
14 | + | |
15 | +main(int argc, char **argv) | |
16 | +{ | |
17 | + int ncID, varID, labelID, ndims, dimids[NC_MAX_DIMS]; | |
18 | + size_t i, k; | |
19 | +// char varname[NC_MAX_NAME]; | |
20 | + int stat = 0; | |
21 | + nc_type xtype; | |
22 | + size_t start[] = {0, 0}; | |
23 | + size_t count[] = {1, 0}; | |
24 | + size_t size, length; | |
25 | + | |
26 | + if (argc <= 2) { | |
27 | + printf("Incorrect number of arguments\n"); | |
28 | + exit(1); | |
29 | + } | |
30 | + | |
31 | + stat = nc_open(argv[1],NC_WRITE|NC_SHARE,&ncID); check(stat); | |
32 | + | |
33 | + stat = nc_inq_varid(ncID, argv[2], &varID); check(stat); | |
34 | + | |
35 | + stat = nc_inq_varndims(ncID, varID, &ndims); check(stat); | |
36 | + | |
37 | + stat = nc_inq_vardimid(ncID, varID, dimids); check(stat); | |
38 | + | |
39 | + size_t len = 0; | |
40 | + if (ndims > 1) | |
41 | + for (i = 1; i < ndims; i++) { | |
42 | + stat = nc_inq_dimlen(ncID, dimids[i], &len); check(stat); | |
43 | + if (argc == 3) | |
44 | + { | |
45 | + fprintf(stdout, "%d ", len); | |
46 | + } | |
47 | + } | |
48 | + else | |
49 | + if (argc == 3) | |
50 | + { | |
51 | + fprintf(stdout,"%d ", len); | |
52 | + } | |
53 | + | |
54 | + if (argc == 4) | |
55 | + { | |
56 | + size_t attlen = 0; | |
57 | + stat = nc_inq_attlen(ncID, varID, "LABL_PTR_1", &attlen); check(stat); | |
58 | + // stat = nc_inq_atttype(ncID, varID, "LABL_PTR_1", &xtype); check(stat); | |
59 | + | |
60 | + unsigned char *string_attr = (unsigned char *)malloc(attlen * sizeof(char*)); | |
61 | + stat = nc_get_att(ncID, varID, "LABL_PTR_1", string_attr); check(stat); | |
62 | + | |
63 | + // printf("attribute = %s\n", string_attr); | |
64 | + stat = nc_inq_varid(ncID, string_attr, &labelID); check(stat); | |
65 | + // stat = nc_inq_vartype(ncID, labelID, &xtype); check(stat); | |
66 | + | |
67 | + // printf("%d \n", xtype); | |
68 | + | |
69 | + stat = nc_inq_varndims(ncID, labelID, &ndims); check(stat); | |
70 | + | |
71 | + stat = nc_inq_vardimid(ncID, labelID, dimids); check(stat); | |
72 | + | |
73 | + for (i = 0; i < ndims; i++) { | |
74 | + stat = nc_inq_dimlen(ncID, dimids[i], &len); check(stat); | |
75 | + // printf("%d \n", len); | |
76 | + if (i == 0) size = len; | |
77 | + if (i == 1) length = len; | |
78 | + } | |
79 | + count[1] = length; | |
80 | + | |
81 | + unsigned char *string_var = (unsigned char *)malloc(length * sizeof(char*)); | |
82 | + for (i = 0; i < size; i++) | |
83 | + { | |
84 | + stat = nc_get_vara(ncID, labelID, start, count, string_var); check(stat); | |
85 | + fprintf(stdout, "%s;", string_var); | |
86 | + start[0]++; | |
87 | + } | |
88 | + free(string_attr); | |
89 | + free(string_var); | |
90 | + } | |
91 | + | |
92 | + stat = nc_close(ncID); | |
93 | + exit(0); | |
94 | +} | |
95 | + | |
96 | + | |
... | ... |