summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/data/AbstractDataModel.js
blob: 092ea7563c66fcc5cc2d2708d083214d8bb60b43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
/**
 * @class YAHOO.ext.grid.AbstractDataModel
 * @extends YAHOO.ext.util.Observable
 * This abstract class provides default implementations of the events required by the Grid. 
 It takes care of the creating the CustomEvents and provides some convenient methods for firing the events. <br><br>
 * @constructor
*/
YAHOO.ext.grid.AbstractDataModel = function(){
    /** Fires when a cell is updated - fireDirect sig: (this, rowIndex, columnIndex)
     * @private
     * @type YAHOO.util.CustomEvent
     * @deprecated Use addListener instead of accessing directly
     */
    this.onCellUpdated = new YAHOO.util.CustomEvent('onCellUpdated');
    /** Fires when all data needs to be revalidated - fireDirect sig: (thisd)
     * @private
     * @type YAHOO.util.CustomEvent 
     * @deprecated Use addListener instead of accessing directly
     */
    this.onTableDataChanged = new YAHOO.util.CustomEvent('onTableDataChanged');
    /** Fires when rows are deleted - fireDirect sig: (this, firstRowIndex, lastRowIndex)
     * @private
     * @type YAHOO.util.CustomEvent 
     * @deprecated Use addListener instead of accessing directly
     */
    this.onRowsDeleted = new YAHOO.util.CustomEvent('onRowsDeleted');
    /** Fires when a rows are inserted - fireDirect sig: (this, firstRowIndex, lastRowIndex)
     * @private
     * @type YAHOO.util.CustomEvent 
     * @deprecated Use addListener instead of accessing directly
     */
    this.onRowsInserted = new YAHOO.util.CustomEvent('onRowsInserted');
    /** Fires when a rows are updated - fireDirect sig: (this, firstRowIndex, lastRowIndex)
     * @private
     * @type YAHOO.util.CustomEvent 
     * @deprecated Use addListener instead of accessing directly
     */
    this.onRowsUpdated = new YAHOO.util.CustomEvent('onRowsUpdated');
    /** Fires when a sort has reordered the rows - fireDirect sig: (this, sortColumnIndex, 
     * @private
     * sortDirection = 'ASC' or 'DESC')
     * @type YAHOO.util.CustomEvent 
     * @deprecated Use addListener instead of accessing directly
     */
    this.onRowsSorted = new YAHOO.util.CustomEvent('onRowsSorted');
    
    this.events = {
      /**
       * @event cellupdated
       * Fires when a cell is updated
       * @param {DataModel} this
       * @param {Number} rowIndex
       * @param {Number} columnIndex
       */
      'cellupdated' : this.onCellUpdated,
      /**
       * @event datachanged
       * Fires when the entire data structure has changed
       * @param {DataModel} this
       */
      'datachanged' : this.onTableDataChanged,
      /**
       * @event rowsdeleted
       * Fires  when a range of rows have been deleted
       * @param {DataModel} this
       * @param {Number} firstRowIndex
       * @param {Number} lastRowIndex
       */
      'rowsdeleted' : this.onRowsDeleted,
      /**
       * @event rowsinserted
       * Fires when a range of rows have been inserted
       * @param {DataModel} this
       * @param {Number} firstRowIndex
       * @param {Number} lastRowIndex
       */
      'rowsinserted' : this.onRowsInserted,
      /**
       * @event rowsupdated
       * Fires when a range of rows have been updated
       * @param {DataModel} this
       * @param {Number} firstRowIndex
       * @param {Number} lastRowIndex
       */
      'rowsupdated' : this.onRowsUpdated,
      /**
       * @event rowssorted
       * Fires when the data has been sorted
       * @param {DataModel} this
       */
      'rowssorted' : this.onRowsSorted
    };
};

YAHOO.ext.grid.AbstractDataModel.prototype = {
    
    fireEvent : YAHOO.ext.util.Observable.prototype.fireEvent,
    on : YAHOO.ext.util.Observable.prototype.on,
    addListener : YAHOO.ext.util.Observable.prototype.addListener,
    delayedListener : YAHOO.ext.util.Observable.prototype.delayedListener,
    removeListener : YAHOO.ext.util.Observable.prototype.removeListener,
    purgeListeners : YAHOO.ext.util.Observable.prototype.purgeListeners,
    bufferedListener : YAHOO.ext.util.Observable.prototype.bufferedListener,
    
    /**
     *  Notifies listeners that the value of the cell at [row, col] has been updated
     * @deprecated
     * @private
     */
    fireCellUpdated : function(row, col){
        this.onCellUpdated.fireDirect(this, row, col);
    },
    
    /**
     *  Notifies listeners that all data for the grid may have changed - use as a last resort. This 
     * also wipes out all selections a user might have made.
     * @deprecated
     * @private
     */
    fireTableDataChanged : function(){
        this.onTableDataChanged.fireDirect(this);
    },
    
    /**
     *  Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been deleted
     * @deprecated
     * @private
     */
    fireRowsDeleted : function(firstRow, lastRow){
        this.onRowsDeleted.fireDirect(this, firstRow, lastRow);
    },
    
    /**
     *  Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been inserted
     * @deprecated
     * @private
     */
    fireRowsInserted : function(firstRow, lastRow){
        this.onRowsInserted.fireDirect(this, firstRow, lastRow);
    },
    
    /**
     *  Notifies listeners that rows in the range [firstRow, lastRow], inclusive, have been updated
     * @deprecated
     * @private
     */
    fireRowsUpdated : function(firstRow, lastRow){
        this.onRowsUpdated.fireDirect(this, firstRow, lastRow);
    },
    
    /**
     *  Notifies listeners that rows have been sorted and any indexes may be invalid
     * @deprecated
     * @private
     */
    fireRowsSorted : function(sortColumnIndex, sortDir, noRefresh){
        this.onRowsSorted.fireDirect(this, sortColumnIndex, sortDir, noRefresh);
    },
    
    /**
     * Empty interface method - Classes which extend AbstractDataModel should implement this method.
     * See {@link YAHOO.ext.DefaultDataModel#sort} for an example implementation.
    * @private
      */
    sort : function(sortInfo, columnIndex, direction, suppressEvent){
    	
    },
    
    /**
     * Interface method to supply info regarding the Grid's current sort state - if overridden,
     * this should return an object like this {column: this.sortColumn, direction: this.sortDir}.
     * @return {Object} 
      */
    getSortState : function(){
    	return {column: this.sortColumn, direction: this.sortDir};
    },
    
    /**
     * Empty interface method - Classes which extend AbstractDataModel should implement this method.
     * See {@link YAHOO.ext.DefaultDataModel} for an example implementation.
     * @private
     */
    getRowCount : function(){
    	
    },
    
    /**
     * Empty interface method - Classes which extend AbstractDataModel should implement this method to support virtual row counts.
     * @private
     */
    getTotalRowCount : function(){
    	return this.getRowCount();
    },
    
    
    /**
     * Empty interface method - Classes which extend AbstractDataModel should implement this method.
     * See {@link YAHOO.ext.DefaultDataModel} for an example implementation.
    * @private
      */
    getRowId : function(rowIndex){
    	
    },
    
    /**
     * Empty interface method - Classes which extend AbstractDataModel should implement this method.
     * See {@link YAHOO.ext.DefaultDataModel} for an example implementation.
     * @private
     */
    getValueAt : function(rowIndex, colIndex){
    	
    },
    
    /**
     * Empty interface method - Classes which extend AbstractDataModel should implement this method.
     * See {@link YAHOO.ext.DefaultDataModel} for an example implementation.
     * @private
     */
    setValueAt : function(value, rowIndex, colIndex){
    	
    },
    
    isPaged : function(){
        return false;
    }
};