Commit d29e2a29dde6da2888bcea4638ed415628836fba

Authored by Elena.Budnik
1 parent 436488e4

BASE NODE_ITEM_KIND, no context menu

Showing 2 changed files with 183 additions and 184 deletions   Show diff stats
js/app/models/AmdaNode.js
... ... @@ -5,193 +5,191 @@
5 5 * @extends Ext.data.Model
6 6 * @brief Generic Model of Node for AMDA project
7 7 * @author CDA
8   - * @version $Id: AmdaNode.js 2544 2014-10-03 10:21:56Z elena $
9   - * @todo
10   - *******************************************************************************
11   - * FT Id : Date : Name - Description
12   - *******************************************************************************
13   - * : :08/06/2011: CDA - Migration extjs4
14 8 */
15 9 Ext.define('amdaModel.AmdaNode', {
16   - extend: 'Ext.data.TreeModel',
17   -
18   - requires: ['amdaReader.ExplorerReader'],
19   -
20   - fields: [
21   - {name: 'leaf', type: 'boolean'},
22   - {name: 'nodeType',type:'string'},
23   - {name: 'id', type: 'string'},
24   - {name:'text',type: 'string'},
25   - {name:'info',type: 'string'},
26   - {name: 'help', type: 'string', defaultValue: ''},
27   - {name:'rootNode', persist: false},
28   - {name: 'ownerTreeId', persist: false},
29   - {name: 'ownerTree', persist: false},
30   - {name: 'checked', defaultValue: null, persist: false}
31   - ],
32   -
33   - statics : {
34   - NEW_DIR_NAME : 'new Folder',
35   - MULTI_PREFIX : 'mult'
36   - },
37   -
38   - /**
39   - * @cfg proxy used to load nodes
40   - */
41   - proxy: {
42   - type: 'direct',
43   - // directFn: AmdaAction.getTree,
44   - api :
45   - {
46   - read: AmdaAction.getTree,
47   - update: AmdaAction.saveTree,
48   - create: AmdaAction.saveTree,
49   - destroy: AmdaAction.doNothing
  10 + extend: 'Ext.data.TreeModel',
  11 +
  12 + requires: ['amdaReader.ExplorerReader'],
  13 +
  14 + fields: [
  15 + {name: 'leaf', type: 'boolean'},
  16 + {name: 'nodeType',type:'string'},
  17 + {name: 'id', type: 'string'},
  18 + {name:'text',type: 'string'},
  19 + {name:'info',type: 'string'},
  20 + {name: 'help', type: 'string', defaultValue: ''},
  21 + {name:'rootNode', persist: false},
  22 + {name: 'ownerTreeId', persist: false},
  23 + {name: 'ownerTree', persist: false},
  24 + {name: 'checked', defaultValue: null, persist: false}
  25 + ],
  26 +
  27 + statics : {
  28 + NEW_DIR_NAME : 'new Folder',
  29 + MULTI_PREFIX : 'mult'
50 30 },
51   - paramsAsHash : true,
52   - reader: {
53   - type: 'explorer'
54   - }
55   - },
56   -
57   - /**
58   - * Abstract getter of complete array of item context menu
59   - * @return {Ext.Array} the complete array of item context menu
60   - */
61   - getAllContextMenuItems: Ext.emptyFn,
62   -
63   - /**
64   - * Abstract method call on click on item of context menu
65   - */
66   - onMenuItemClick: Ext.emptyFn,
67   -
68   - /**
69   - * Abstract Update Data method
70   - */
71   - update : Ext.emptyFn,
72   -
73   - /**
74   - * Abstract Rename Data method
75   - */
76   - rename : Ext.emptyFn,
77   -
78   - /**
79   - * Abstract Rename D&D Data method
80   - */
81   - renameDD : Ext.emptyFn,
82   -
83   - /**
84   - * Abstract Create Data method
85   - */
86   - create : Ext.emptyFn,
87   -
88   - /**
89   - * filtering method of context menu
90   - * @param {String} itemKind the kind of right clicked node
91   - * @return {Ext.Array} the Array of filtered item menu
92   - */
93   - getFilteredContextMenu : function(itemKind) {
94   - var menuitems = this.getAllContextMenuItems();
95   - if (menuitems && menuitems.length){
96   - for ( var i = 0; i < menuitems.length; i++) {
97   - var currentItem = menuitems[i];
98   - var myItemKind = Ext.util.Format.substr(currentItem.fnId, 0, 4);
99   - if (myItemKind === itemKind) {
100   - currentItem.hidden = false;
101   - }
102   - else {
103   - currentItem.hidden = true;
104   - }
105   - }
106   - return menuitems;
107   - } else {
108   - return null;
109   - }
110   - },
111   -
112   - getMultiContextMenu : function(){
113   - var menuitems = this.getMultiContextMenuItems();
114   - if (menuitems && menuitems.length){
115   - return menuitems;
116   - } else {
117   - return null;
118   - }
119   - },
120   -
121   - /**
122   - * get the kind of this node
123   - * @returns itemKind string
124   - */
125   - getNodeKind : function() {
126   - var itemKind;
127   - // if id of this node have root subcategory suffix
128   - if (this.id && Ext.util.Format.substr(this.id, -(amdaUI.ExplorerUI.ROOT_SUFFIX.length), this.id.length) === amdaUI.ExplorerUI.ROOT_SUFFIX ) {
129   - itemKind = amdaUI.ExplorerUI.ITEM_KIND_ROOT;
130   - }
131   - // if this node is a leaf and have no child
132   - else if (this.isLeaf()) {
133   - itemKind = amdaUI.ExplorerUI.ITEM_KIND_LEAF;
134   - }
135   - else if (this.get('isParameter')) {
136   - itemKind = amdaUI.ExplorerUI.ITEM_KIND_PARA;
137   - }
138   - else if (this.get('rank')) {
139   - itemKind = amdaUI.ExplorerUI.ITEM_KIND_MISS;
140   - }
141   - // other case
142   - else {
143   - itemKind = amdaUI.ExplorerUI.ITEM_KIND_DIRE;
144   - }
145   - return itemKind;
  31 +
  32 + /**
  33 + * @cfg proxy used to load nodes
  34 + */
  35 + proxy: {
  36 + type: 'direct',
  37 + api :
  38 + {
  39 + read: AmdaAction.getTree,
  40 + update: AmdaAction.saveTree,
  41 + create: AmdaAction.saveTree,
  42 + destroy: AmdaAction.doNothing
  43 + },
  44 + paramsAsHash : true,
  45 + reader: {
  46 + type: 'explorer'
  47 + }
  48 + },
  49 +
  50 + /**
  51 + * Abstract getter of complete array of item context menu
  52 + * @return {Ext.Array} the complete array of item context menu
  53 + */
  54 + getAllContextMenuItems: Ext.emptyFn,
  55 +
  56 + /**
  57 + * Abstract method call on click on item of context menu
  58 + */
  59 + onMenuItemClick: Ext.emptyFn,
  60 +
  61 + /**
  62 + * Abstract Update Data method
  63 + */
  64 + update : Ext.emptyFn,
  65 +
  66 + /**
  67 + * Abstract Rename Data method
  68 + */
  69 + rename : Ext.emptyFn,
  70 +
  71 + /**
  72 + * Abstract Rename D&D Data method
  73 + */
  74 + renameDD : Ext.emptyFn,
  75 +
  76 + /**
  77 + * Abstract Create Data method
  78 + */
  79 + create : Ext.emptyFn,
  80 +
  81 + /**
  82 + * filtering method of context menu
  83 + * @param {String} itemKind the kind of right clicked node
  84 + * @return {Ext.Array} the Array of filtered item menu
  85 + */
  86 + getFilteredContextMenu : function(itemKind) {
  87 + var menuitems = this.getAllContextMenuItems();
  88 + if (menuitems && menuitems.length){
  89 + for ( var i = 0; i < menuitems.length; i++) {
  90 + var currentItem = menuitems[i];
  91 + var myItemKind = Ext.util.Format.substr(currentItem.fnId, 0, 4);
  92 + if (myItemKind === itemKind) {
  93 + currentItem.hidden = false;
  94 + }
  95 + else {
  96 + currentItem.hidden = true;
  97 + }
  98 + }
  99 + return menuitems;
  100 + } else {
  101 + return null;
  102 + }
  103 + },
  104 +
  105 + getMultiContextMenu : function(){
  106 + var menuitems = this.getMultiContextMenuItems();
  107 + if (menuitems && menuitems.length){
  108 + return menuitems;
  109 + } else {
  110 + return null;
  111 + }
  112 + },
  113 +
  114 + /**
  115 + * get the kind of this node
  116 + * @returns itemKind string
  117 + */
  118 + getNodeKind : function() {
  119 + var itemKind;
  120 + // if id of this node have root subcategory suffix
  121 + if (this.id && Ext.util.Format.substr(this.id, -(amdaUI.ExplorerUI.ROOT_SUFFIX.length), this.id.length) === amdaUI.ExplorerUI.ROOT_SUFFIX ) {
  122 + itemKind = amdaUI.ExplorerUI.ITEM_KIND_ROOT;
  123 + }
  124 + // if this node is a leaf and have no child
  125 + else if (this.isLeaf()) {
  126 + itemKind = amdaUI.ExplorerUI.ITEM_KIND_LEAF;
  127 + }
  128 + else if (this.get('isParameter')) {
  129 + itemKind = amdaUI.ExplorerUI.ITEM_KIND_PARA;
  130 + }
  131 + else if (this.get('rank')) {
  132 + itemKind = amdaUI.ExplorerUI.ITEM_KIND_MISS;
  133 + }
  134 + // base
  135 + else if (this.id && Ext.util.Format.substr(this.id, -(amdaUI.ExplorerUI.BASE_SUFFIX.length), this.id.length) === amdaUI.ExplorerUI.BASE_SUFFIX ) {
  136 + itemKind = amdaUI.ExplorerUI.ITEM_KIND_BASE;
  137 + }
  138 + // other case
  139 + else {
  140 + itemKind = amdaUI.ExplorerUI.ITEM_KIND_DIRE;
  141 + }
  142 +
  143 + return itemKind;
  144 + },
  145 +
  146 + /**
  147 + * Getter on context menu of this node
  148 + * @returns {Ext.menu.Menu} the contextMenu of this node
  149 + */
  150 + getContextMenuItems : function() {
  151 + // set the node kind
  152 + var itemKind = this.getNodeKind();
  153 + // filter the global context menu by node kind
  154 + var menuItems = this.getFilteredContextMenu(itemKind);
  155 + // return the context menu for this node
  156 + return menuItems;
  157 + },
  158 +
  159 + getContextMenuMultiItems : function() {
  160 + return this.getMultiContextMenu();
  161 + },
  162 +
  163 + /**
  164 + * Method to retrieve the root node corresponding to the nodeType of this node
  165 + * @return {amdaModel.AmdaNode} the root node of category of this node
  166 + */
  167 + getRootNode : function() {
  168 + if (!this.get('rootNode')) {
  169 + // if this node is the root of its category
  170 + if(this.getNodeKind() == amdaUI.ExplorerUI.ITEM_KIND_ROOT) {
  171 + this.set('rootNode',this);
  172 + } else {
  173 + // get resources tree panel
  174 + var tree = this.myGetOwnerTree();
  175 + var treeRoot = tree.getRootNode();
  176 + var rootNodeId = this.get('nodeType')+amdaUI.ExplorerUI.ROOT_SUFFIX;
  177 +
  178 + this.set('rootNode',treeRoot.findChild( 'id', rootNodeId, true));
  179 + }
  180 + }
  181 + return this.get('rootNode');
146 182 },
147 183  
148   - /**
149   - * Getter on context menu of this node
150   - * @returns {Ext.menu.Menu} the contextMenu of this node
151   - */
152   - getContextMenuItems : function() {
153   - // set the node kind
154   - var itemKind = this.getNodeKind();
155   - // filter the global context menu by node kind
156   - var menuItems = this.getFilteredContextMenu(itemKind);
157   - // return the context menu for this node
158   - return menuItems;
159   - },
160   -
161   - getContextMenuMultiItems : function() {
162   - return this.getMultiContextMenu();
163   - },
164   -
165   - /**
166   - * Method to retrieve the root node corresponding to the nodeType of this node
167   - * @return {amdaModel.AmdaNode} the root node of category of this node
168   - */
169   - getRootNode : function() {
170   - if (!this.get('rootNode')) {
171   - // if this node is the root of its category
172   - if(this.getNodeKind() == amdaUI.ExplorerUI.ITEM_KIND_ROOT) {
173   - this.set('rootNode',this);
174   - } else {
175   - // get resources tree panel
176   - var tree = this.myGetOwnerTree();
177   - var treeRoot = tree.getRootNode();
178   - var rootNodeId = this.get('nodeType')+amdaUI.ExplorerUI.ROOT_SUFFIX;
179   -
180   - this.set('rootNode',treeRoot.findChild( 'id', rootNodeId, true));
181   - }
182   - }
183   - return this.get('rootNode');
184   - },
185   -
186   - /**
187   - * getter on ownerTree (use ownerTreeId property)
188   - * @return {Ext.tree.Panel} the tree which contains this node
189   - */
190   - myGetOwnerTree : function() {
191   - if (!this.get('ownerTree')) {
192   - this.set('ownerTree',Ext.getCmp(this.get('ownerTreeId')));
193   - }
194   - return this.get('ownerTree');
195   - }
  184 + /**
  185 + * getter on ownerTree (use ownerTreeId property)
  186 + * @return {Ext.tree.Panel} the tree which contains this node
  187 + */
  188 + myGetOwnerTree : function() {
  189 + if (!this.get('ownerTree')) {
  190 + this.set('ownerTree',Ext.getCmp(this.get('ownerTreeId')));
  191 + }
  192 + return this.get('ownerTree');
  193 + }
196 194  
197 195 });
... ...
js/app/views/ExplorerUI.js
... ... @@ -96,7 +96,8 @@ Ext.define(&#39;amdaUI.ExplorerUI&#39;, {
96 96 CAT_SUFFIX: '-treeBase',
97 97 ROOT_SUFFIX: '-treeRootNode',
98 98 SUB_ROOT_SUFFIX : 'RootNode',
99   -
  99 +
  100 + ITEM_KIND_BASE : 'treeBase',
100 101 ITEM_KIND_ROOT : 'root',
101 102 ITEM_KIND_LEAF : 'leaf',
102 103 ITEM_KIND_DIRE : 'dire',
... ...