~dongpo-deng/sahana-eden/test

« back to all changes in this revision

Viewing changes to static/scripts/ext/src/widgets/grid/AbstractSelectionModel.js

  • Committer: Deng Dongpo
  • Date: 2010-08-01 09:29:44 UTC
  • Revision ID: dongpo@dhcp-21193.iis.sinica.edu.tw-20100801092944-8t9obt4xtl7otesb
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
 * Ext JS Library 3.2.1
 
3
 * Copyright(c) 2006-2010 Ext JS, Inc.
 
4
 * licensing@extjs.com
 
5
 * http://www.extjs.com/license
 
6
 */
 
7
/**
 
8
 * @class Ext.grid.AbstractSelectionModel
 
9
 * @extends Ext.util.Observable
 
10
 * Abstract base class for grid SelectionModels.  It provides the interface that should be
 
11
 * implemented by descendant classes.  This class should not be directly instantiated.
 
12
 * @constructor
 
13
 */
 
14
Ext.grid.AbstractSelectionModel = Ext.extend(Ext.util.Observable,  {
 
15
    /**
 
16
     * The GridPanel for which this SelectionModel is handling selection. Read-only.
 
17
     * @type Object
 
18
     * @property grid
 
19
     */
 
20
 
 
21
    constructor : function(){
 
22
        this.locked = false;
 
23
        Ext.grid.AbstractSelectionModel.superclass.constructor.call(this);
 
24
    },
 
25
 
 
26
    /** @ignore Called by the grid automatically. Do not call directly. */
 
27
    init : function(grid){
 
28
        this.grid = grid;
 
29
        if(this.lockOnInit){
 
30
            delete this.lockOnInit;
 
31
            this.locked = false;
 
32
            this.lock();
 
33
        }
 
34
        this.initEvents();
 
35
    },
 
36
 
 
37
    /**
 
38
     * Locks the selections.
 
39
     */
 
40
    lock : function(){
 
41
        if(!this.locked){
 
42
            this.locked = true;
 
43
            // If the grid has been set, then the view is already initialized.
 
44
            var g = this.grid;
 
45
            if(g){
 
46
                g.getView().on({
 
47
                    scope: this,
 
48
                    beforerefresh: this.sortUnLock,
 
49
                    refresh: this.sortLock
 
50
                });
 
51
            }else{
 
52
                this.lockOnInit = true;
 
53
            }
 
54
        }
 
55
    },
 
56
 
 
57
    // set the lock states before and after a view refresh
 
58
    sortLock : function() {
 
59
        this.locked = true;
 
60
    },
 
61
 
 
62
    // set the lock states before and after a view refresh
 
63
    sortUnLock : function() {
 
64
        this.locked = false;
 
65
    },
 
66
 
 
67
    /**
 
68
     * Unlocks the selections.
 
69
     */
 
70
    unlock : function(){
 
71
        if(this.locked){
 
72
            this.locked = false;
 
73
            var g = this.grid,
 
74
                gv;
 
75
                
 
76
            // If the grid has been set, then the view is already initialized.
 
77
            if(g){
 
78
                gv = g.getView();
 
79
                gv.un('beforerefresh', this.sortUnLock, this);
 
80
                gv.un('refresh', this.sortLock, this);    
 
81
            }else{
 
82
                delete this.lockOnInit;
 
83
            }
 
84
        }
 
85
    },
 
86
 
 
87
    /**
 
88
     * Returns true if the selections are locked.
 
89
     * @return {Boolean}
 
90
     */
 
91
    isLocked : function(){
 
92
        return this.locked;
 
93
    },
 
94
 
 
95
    destroy: function(){
 
96
        this.unlock();
 
97
        this.purgeListeners();
 
98
    }
 
99
});
 
 
b'\\ No newline at end of file'