Blame view

js/app/models/DerivedParamNode.js 4.18 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
/** 
 * Project  : AMDA-NG4
 * Name     : DerivedParamNode.js
 * @class   amdaModel.DerivedParamNode
 * @extends amdaModel.InteractiveNode
 * @brief   Model of Node corresponding to a derived parameter
 * @author  CDA
 * @version $Id: DerivedParamNode.js 2544 2014-10-03 10:21:56Z elena $
16035364   Benjamin Renard   First commit
9
10
 */

bf776dc8   Benjamin Renard   working
11
Ext.define('amdaModel.DerivedParamComponentNode', {
0cefcae2   Benjamin Renard   il reste click droit
12
        extend: 'amdaModel.InteractiveNode',
bf776dc8   Benjamin Renard   working
13
14
15
16
17
18
19
20
21
22
        
        text: '',
        
        constructor : function(config)
        {
            this.callParent(arguments);
            this.set('text', config && config.text ? config.text : this.text);
            this.set('iconCls', 'icon-scalar');
            this.set('leaf',true);
            this.set('isParameter',true);
0cefcae2   Benjamin Renard   il reste click droit
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        },
         localMenuItems : function(){  
    var menuItems=
    [{
            fnId : 'leaf-plotParam',
            text : 'Plot Parameter',
            hidden : true
        }, {
            fnId : 'leaf-downParam',
            text : 'Download Parameter',
            hidden : true
        }]
    return menuItems;
 },
  getAllContextMenuItems: function(){
    return  this.localMenuItems ();
},  
bf776dc8   Benjamin Renard   working
40
41
});

16035364   Benjamin Renard   First commit
42
Ext.define('amdaModel.DerivedParamNode', {
16035364   Benjamin Renard   First commit
43
44
    extend: 'amdaModel.InteractiveNode',
    
8ba47f72   Benjamin Renard   rest actualisatio...
45
46
    requires:[],

eb0ba55f   Benjamin Renard   reste refreche ar...
47
48
49
50
51
    fields : [ 
        { name : 'dim_1', type:'number', defaultValue:1,  persist:  false},
        { name : 'dim_2', type:'number', defaultValue:1,  persist: false}
    ],

16035364   Benjamin Renard   First commit
52
53
54
55
56
    statics:{
        nodeType: 'derivedParam',
        objectName: 'Parameter'
    },
 
8ba47f72   Benjamin Renard   rest actualisatio...
57
    constructor : function(config){	
3a5f60a1   elena   proper use os sta...
58
        this.callParent(arguments);       
16035364   Benjamin Renard   First commit
59
60
61
        this.set('moduleId',myDesktopApp.dynamicModules.param.id);
        this.set('objectDataModel',amdaModel.Parameter.$className);
        this.set('ownerTreeId',amdaUI.ExplorerUI.RESRC_TAB.TREE_ID);
eb0ba55f   Benjamin Renard   reste refreche ar...
62
        this.updateIcon();
bf776dc8   Benjamin Renard   working
63
        this.updateComponents();
eb0ba55f   Benjamin Renard   reste refreche ar...
64
65
66
67
    },
    
    updateIcon: function() {
         if (this.get('isParameter')) {
8ba47f72   Benjamin Renard   rest actualisatio...
68
69
            if( (this.get('dim_1') == 3 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 3)){
                this.set('iconCls', 'icon-vector');
bf776dc8   Benjamin Renard   working
70
71
72
            } else if( (this.get('dim_1') == 2 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 2)){
                this.set('iconCls', 'icon-vector');
                 
8ba47f72   Benjamin Renard   rest actualisatio...
73
74
            } else if ( (this.get('dim_1') > 1 && this.get('dim_2') >=1)|| (this.get('dim_1') >=1 &&  this.get('dim_2') >1))  {
                this.set('iconCls','icon-spectra');
bf776dc8   Benjamin Renard   working
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
                  } else {
                this.set('iconCls', 'icon-scalar'); 
                    }
        }
    },
    
    updateComponents: function()  {
        this.removeAll();
        if (!this.get('isParameter')) {
            return;
        } 
        
        if( (this.get('dim_1') == 3 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 3) ||
              (this.get('dim_1') == 2 && this.get('dim_2') == 1) || (this.get('dim_1') == 1 && this.get('dim_2') == 2)) {
          for (var i = 0; i < this.get('dim_1') *this.get('dim_2'); ++i) {
0cefcae2   Benjamin Renard   il reste click droit
90
91
92
              var ch=new amdaModel.DerivedParamComponentNode({text: this.get('text') + '(' + i + ')'
              });
              
bf776dc8   Benjamin Renard   working
93
94
95
              ch.set('nodeType','derivedParam');
              this.appendChild(ch);
          }
8ba47f72   Benjamin Renard   rest actualisatio...
96
        }
16035364   Benjamin Renard   First commit
97
    },
8ba47f72   Benjamin Renard   rest actualisatio...
98
localMenuItems : function() {
0cefcae2   Benjamin Renard   il reste click droit
99
100
        var menuItems =
                [{
16035364   Benjamin Renard   First commit
101
                    fnId : 'leaf-plotParam',
0cefcae2   Benjamin Renard   il reste click droit
102
103
104
105
106
107
108
109
110
                    text : 'Plot Parameter',
                    hidden : true
                }, {
                    fnId : 'leaf-downParam',
                    text : 'Download Parameter',
                    hidden : true
                }];     
        return menuItems;
    },
16035364   Benjamin Renard   First commit
111
    
0cefcae2   Benjamin Renard   il reste click droit
112
    getAllContextMenuItems: function(){
16035364   Benjamin Renard   First commit
113
        
0cefcae2   Benjamin Renard   il reste click droit
114
115
        var menuItems = this.allMenuItems();
        var locMenuItems = this.localMenuItems();
16035364   Benjamin Renard   First commit
116
        
0cefcae2   Benjamin Renard   il reste click droit
117
118
        return  Ext.Array.merge(menuItems,locMenuItems);       
    },
16035364   Benjamin Renard   First commit
119
    
8ba47f72   Benjamin Renard   rest actualisatio...
120
121
122
123
124
isParameter : function(){
    return this.get('isParameter');
},
    
specialUpdate : function(res, timeUpdate) {
eb0ba55f   Benjamin Renard   reste refreche ar...
125
126
127
128
129
130
131
132
    if (res && res.dim_1) {
        this.set('dim_1', res.dim_1);
    }
    if (res && res.dim_2) {
        this.set('dim_2', res.dim_2);
    }
    
    this.updateIcon();
bf776dc8   Benjamin Renard   working
133
    this.updateComponents();
8ba47f72   Benjamin Renard   rest actualisatio...
134
}
16035364   Benjamin Renard   First commit
135
136

});