~cdparra/gelee/trunk

« back to all changes in this revision

Viewing changes to webui/runtime/InstanceLayout.js

  • Committer: parra
  • Date: 2010-03-15 15:56:56 UTC
  • Revision ID: svn-v4:ac5bba68-f036-4e09-846e-8f32731cc928:trunk/gelee:1448
merged gelee at svn

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
InstanceLayout=function(params)
 
2
{
 
3
        //setting Layout Properties
 
4
        this.id= params.id;
 
5
        this.sourceEl = params.sourceEl;
 
6
        this.targetEl = params.targetEl;
 
7
        this.instanceMgr = new InstanceManager();
 
8
 
 
9
        this.canvas = new GCanvas({
 
10
                                targetEl : 'canvas',
 
11
                                scrollEl : 'canvas-container',
 
12
                                panning  : true,
 
13
                                toggle   : true,
 
14
                                readOnly : true
 
15
 
 
16
                                });
 
17
 
 
18
        var canvas = this.canvas;
 
19
        this.canvas.listeners = {
 
20
                        onDoubleClick : function (type, phase) {
 
21
                                canvas.setActivePhase(phase);
 
22
                        }
 
23
        }
 
24
 
 
25
        var mgr = this.instanceMgr;
 
26
 
 
27
        this.tools = new ToolWidget({ id: this.id + '.tools',
 
28
                                       orientation: 'vertical', 
 
29
                                      tools: [ { class : 'add',  label: 'New Instance', handler : function() {alert('New Instanace is a ToDo!')}},
 
30
                                               { class : 'share', label: 'Share',  handler : function() { alert('Share is a ToDo!') }} ]
 
31
                                    });
 
32
 
 
33
        this.client = new GClient(guser.getSession());
 
34
        var client = this.client;
 
35
 
 
36
        // We configure the actions to take when a instance is selected
 
37
        this.instanceList = new InstanceListWidget({ listeners : {  rowselect: function(sm, rowIdx, r) {
 
38
                                                                        mgr.instance = r.data;
 
39
                                                                        var modelRef = r.data.modelversion.modelref.href;
 
40
                                                                        var modelId = modelRef.substring(modelRef.lastIndexOf('/')+1);
 
41
                                                                        var modelVersion = r.data.modelversion.version;
 
42
                                                                        mgr.model = client.getModel(modelId, modelVersion, 
 
43
                                                                                    function (obj) {
 
44
                                                                                          canvas.load(obj, r.data.id_trace.value);        
 
45
                                                                                    }
 
46
                                                                        
 
47
                                                                        ); 
 
48
                                                                        
 
49
                                                                        //diag.model = r.data;
 
50
                                                                }
 
51
                                                           }
 
52
                                             });
 
53
 
 
54
        var instanceList = this.instanceList;                                            
 
55
 
 
56
        this.instanceMgr.listeners = {
 
57
                onDelete : function () { 
 
58
                                     //we should sync this visually instead of performing calls..
 
59
                                    client.getInstanceList(function(obj) { 
 
60
                                            instanceList.load(obj.model);
 
61
                                    });        
 
62
                 }
 
63
        }
 
64
}
 
65
 
 
66
InstanceLayout.prototype.render = function(){
 
67
        //document.getElementById(this.targetEl).innerHTML = document.getElementById(this.sourceEl).innerHTML;
 
68
        this.tools.render('w_toolbar');
 
69
        var widget = this;
 
70
        this.client.getInstanceList(function(obj) { 
 
71
                                                 widget.instanceList.load(obj.instanceList);
 
72
                                                 widget.instanceList.render('content-work');
 
73
                                            });
 
74
        
 
75
}