~ubuntu-branches/ubuntu/raring/venkman/raring

« back to all changes in this revision

Viewing changes to chrome/content/venkman/tree-utils.js

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2006-11-25 13:09:12 UTC
  • mfrom: (2.1.5 feisty)
  • Revision ID: james.westby@ubuntu.com-20061125130912-lf5wuz22ijh0k8ed
Tags: 0.9.87-6
debian/postinst: Don't invoque chrome updaters (except iceape one) on
first installs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
2
 *
3
 
 * The contents of this file are subject to the Mozilla Public License
4
 
 * Version 1.1 (the "License"); you may not use this file except in
5
 
 * compliance with the License. You may obtain a copy of the License at
6
 
 * http://www.mozilla.org/MPL/ 
7
 
 * 
 
3
 * ***** BEGIN LICENSE BLOCK *****
 
4
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
5
 *
 
6
 * The contents of this file are subject to the Mozilla Public License Version
 
7
 * 1.1 (the "License"); you may not use this file except in compliance with
 
8
 * the License. You may obtain a copy of the License at
 
9
 * http://www.mozilla.org/MPL/
 
10
 *
8
11
 * Software distributed under the License is distributed on an "AS IS" basis,
9
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10
13
 * for the specific language governing rights and limitations under the
11
 
 * License. 
12
 
 *
13
 
 * The Original Code is The JavaScript Debugger
14
 
 * 
 
14
 * License.
 
15
 *
 
16
 * The Original Code is The JavaScript Debugger.
 
17
 *
15
18
 * The Initial Developer of the Original Code is
16
 
 * Netscape Communications Corporation
17
 
 * Portions created by Netscape are
18
 
 * Copyright (C) 1998 Netscape Communications Corporation.
19
 
 *
20
 
 * Alternatively, the contents of this file may be used under the
21
 
 * terms of the GNU Public License (the "GPL"), in which case the
22
 
 * provisions of the GPL are applicable instead of those above.
23
 
 * If you wish to allow use of your version of this file only
24
 
 * under the terms of the GPL and not to allow others to use your
25
 
 * version of this file under the MPL, indicate your decision by
26
 
 * deleting the provisions above and replace them with the notice
27
 
 * and other provisions required by the GPL.  If you do not delete
28
 
 * the provisions above, a recipient may use your version of this
29
 
 * file under either the MPL or the GPL.
 
19
 * Netscape Communications Corporation.
 
20
 * Portions created by the Initial Developer are Copyright (C) 1998
 
21
 * the Initial Developer. All Rights Reserved.
30
22
 *
31
23
 * Contributor(s):
32
 
 *  Robert Ginda, <rginda@netscape.com>, original author
33
 
 *
34
 
 */
 
24
 *   Robert Ginda, <rginda@netscape.com>, original author
 
25
 *
 
26
 * Alternatively, the contents of this file may be used under the terms of
 
27
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
28
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
29
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
30
 * of those above. If you wish to allow use of your version of this file only
 
31
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
32
 * use your version of this file under the terms of the MPL, indicate your
 
33
 * decision by deleting the provisions above and replace them with the notice
 
34
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
35
 * the provisions above, a recipient may use your version of this file under
 
36
 * the terms of any one of the MPL, the GPL or the LGPL.
 
37
 *
 
38
 * ***** END LICENSE BLOCK ***** */
35
39
 
36
40
/*
37
41
 * BasicOView provides functionality of tree whose elements have no children.
61
65
{
62
66
    var first = this.tree.getFirstVisibleRow();
63
67
    var last = this.tree.getLastVisibleRow();
64
 
    this.scrollToRow(line - total / 2);
 
68
    this.scrollToRow(line - (last - first + 1) / 2);
65
69
}
66
70
 
67
71
/* call this to set the association between column names and data columns */
87
91
{
88
92
    if (!this.tree)
89
93
        return;
90
 
    
 
94
 
91
95
    var headerRows = 1;
92
 
    
 
96
 
93
97
    var first = this.tree.getFirstVisibleRow();
94
98
    var last  = this.tree.getLastVisibleRow();
95
 
    var viz   = last - first - headerRows; /* total number of visible rows */
 
99
    var viz   = last - first + 1 - headerRows; /* total number of visible rows */
96
100
 
97
101
    /* all rows are visible, nothing to scroll */
98
 
    if (first == 0 && last > this.rowCount)
 
102
    if (first == 0 && last >= this.rowCount)
99
103
        return;
100
 
    
 
104
 
101
105
    /* tree lines are 0 based, we accept one based lines, deal with it */
102
106
    --line;
103
107
 
104
108
    /* safety clamp */
105
109
    if (line < 0)
106
110
        line = 0;
107
 
    if (line > this.rowCount)
108
 
        line = this.rowCount;    
 
111
    if (line >= this.rowCount)
 
112
        line = this.rowCount - 1;
109
113
 
110
114
    if (align < 0)
111
115
    {
112
 
        if (line > this.rowCount - viz) /* overscroll, can't put a row from */
 
116
        if (line > this.rowCount - viz)    /* overscroll, can't put a row from */
113
117
            line = this.rowCount - viz; /* last page at the top. */
114
118
        this.tree.scrollToRow(line);
115
119
    }
119
123
            line = 0;   /* at the bottom. */
120
124
        else
121
125
            line = line - viz + headerRows;
122
 
        
 
126
 
123
127
        this.tree.scrollToRow(line);
124
128
    }
125
129
    else
128
132
        /* lines past this line can't be centered without causing the tree
129
133
         * to show more rows than we have. */
130
134
        var lastCenterable = this.rowCount - half_viz;
131
 
        if (line > lastCenterable)
 
135
        if (line > half_viz)
132
136
            line = lastCenterable;
133
137
        /* lines before this can't be centered without causing the tree
134
138
         * to attempt to display negative rows. */
135
139
        else if (line < half_viz)
136
140
            line = half_viz;
 
141
        else
 
142
        /* round the vizible rows down to a whole number, or we try to end up
 
143
         * on a N + 0.5 row! */
 
144
            half_viz = Math.floor(half_viz);
 
145
 
137
146
        this.tree.scrollToRow(line - half_viz);
138
 
    }                    
139
 
}       
 
147
    }
 
148
}
140
149
 
141
150
BasicOView.prototype.__defineGetter__("selectedIndex", bov_getsel);
142
151
function bov_getsel()
143
152
{
144
 
    if (!this.tree || this.tree.selection.getRangeCount() < 1)
 
153
    if (!this.tree || this.tree.view.selection.getRangeCount() < 1)
145
154
        return -1;
146
155
 
147
156
    var min = new Object();
148
 
    this.tree.selection.getRangeAt(0, min, {});
 
157
    this.tree.view.selection.getRangeAt(0, min, {});
149
158
    return min.value;
150
159
}
151
160
 
153
162
function bov_setsel(i)
154
163
{
155
164
    if (i == -1)
156
 
        this.tree.selection.clearSelection();
 
165
        this.tree.view.selection.clearSelection();
157
166
    else
158
 
        this.tree.selection.timedSelect (i, 500);
 
167
        this.tree.view.selection.timedSelect (i, 500);
159
168
    return i;
160
169
}
161
170
 
166
175
BasicOView.prototype.rowCount = 0;
167
176
 
168
177
BasicOView.prototype.getCellProperties =
169
 
function bov_cellprops (row, colID, properties)
 
178
function bov_cellprops (row, col, properties)
170
179
{
171
180
}
172
181
 
173
182
BasicOView.prototype.getColumnProperties =
174
 
function bov_colprops (colID, elem, properties)
 
183
function bov_colprops (col, properties)
175
184
{
176
185
}
177
186
 
210
219
    return false;
211
220
}
212
221
 
213
 
BasicOView.prototype.canDropOn =
214
 
function bov_dropon (index)
215
 
{
216
 
    return false;
217
 
}
218
 
 
219
 
BasicOView.prototype.canDropBeforeAfter =
220
 
function bov_dropba (index, before)
 
222
BasicOView.prototype.canDrop =
 
223
function bov_drop (index, orientation)
221
224
{
222
225
    return false;
223
226
}
250
253
}
251
254
 
252
255
BasicOView.prototype.getImageSrc =
253
 
function bov_getimgsrc (row, colID)
 
256
function bov_getimgsrc (row, col)
254
257
{
255
258
}
256
259
 
257
260
BasicOView.prototype.getProgressMode =
258
 
function bov_getprgmode (row, colID)
 
261
function bov_getprgmode (row, col)
259
262
{
260
263
}
261
264
 
262
265
BasicOView.prototype.getCellValue =
263
 
function bov_getcellval (row, colID)
 
266
function bov_getcellval (row, col)
264
267
{
265
268
}
266
269
 
267
270
BasicOView.prototype.getCellText =
268
 
function bov_getcelltxt (row, colID)
 
271
function bov_getcelltxt (row, col)
269
272
{
270
273
    if (!this.columnNames)
271
274
        return "";
272
275
    
273
 
    var ary = colID.match (/:(.*)/);
 
276
    if (typeof col == "object")
 
277
        col = col.id;
 
278
 
 
279
    var ary = col.match (/:(.*)/);
274
280
    if (ary)
275
 
        colID = ary[1];
 
281
        col = ary[1];
276
282
 
277
 
    var col = this.columnNames[colID];
 
283
    var colName = this.columnNames[col];
278
284
    
279
 
    if (typeof col == "undefined")
 
285
    if (typeof colName == "undefined")
280
286
        return "";
281
287
    
282
 
    return this.data[row][col];
 
288
    return this.data[row][colName];
283
289
}
284
290
 
285
291
BasicOView.prototype.setTree =
294
300
}
295
301
 
296
302
BasicOView.prototype.cycleHeader =
297
 
function bov_cyclehdr (colID, elt)
 
303
function bov_cyclehdr (col)
298
304
{
299
305
}
300
306
 
304
310
}
305
311
 
306
312
BasicOView.prototype.cycleCell =
307
 
function bov_cyclecell (row, colID)
 
313
function bov_cyclecell (row, col)
308
314
{
309
315
}
310
316
 
311
317
BasicOView.prototype.isEditable =
312
 
function bov_isedit (row, colID)
 
318
function bov_isedit (row, col)
313
319
{
314
320
    return false;
315
321
}
316
322
 
 
323
BasicOView.prototype.setCellValue =
 
324
function bov_setct (row, col, value)
 
325
{
 
326
}
 
327
 
317
328
BasicOView.prototype.setCellText =
318
 
function bov_setct (row, colID, value)
 
329
function bov_setct (row, col, value)
319
330
{
320
331
}
321
332
 
339
350
    if (!("onRowCommand" in this) || event.target.localName != "treechildren")
340
351
        return;
341
352
 
342
 
    var rowIndex = this.tree.selection.currentIndex;
 
353
    var rowIndex = this.tree.view.selection.currentIndex;
343
354
    if (rowIndex == -1 || rowIndex > this.rowCount)
344
355
        return;
345
356
    var rec = this.childData.locateChildByVisualRow(rowIndex);
363
374
        if (!this.selection)
364
375
            return;
365
376
        
366
 
        rowIndex = this.tree.selection.currentIndex;
 
377
        rowIndex = this.tree.view.selection.currentIndex;
367
378
        if (rowIndex == -1 || rowIndex > this.rowCount)
368
379
            return;
369
380
        rec = this.childData.locateChildByVisualRow(rowIndex);
377
388
    }
378
389
    else if ("onKeyPress" in this)
379
390
    {
380
 
        rowIndex = this.tree.selection.currentIndex;
 
391
        rowIndex = this.tree.view.selection.currentIndex;
381
392
        if (rowIndex != -1 && rowIndex < this.rowCount)
382
393
        {
383
394
            rec = this.childData.locateChildByVisualRow(rowIndex);
425
436
{
426
437
    this._share = share;
427
438
    this.visualFootprint = 1;
428
 
    //this.childIndex = -1;
429
439
    this.isHidden = true; /* records are considered hidden until they are
430
440
                           * inserted into a live tree */
431
441
}
498
508
XULTreeViewRecord.prototype.__defineSetter__("childIndex", xtvr_setChildIndex);
499
509
function xtvr_setChildIndex ()
500
510
{
501
 
    dump ("xtvr: childIndex is read only, ignore attempt to write to it\n");
 
511
    dd("xtvr: childIndex is read only, ignore attempt to write to it\n");
502
512
    if (typeof getStackTrace == "function")
503
 
        dump (getStackTrace());
 
513
        dd(getStackTrace());
504
514
}
505
515
 
506
516
/* count the number of parents, not including the root node */
522
532
 * method will set up a get/set pair for the property name you specify which
523
533
 * will take care of updating the tree when the value changes.  DO NOT try
524
534
 * to change your mind later.  Do not attach a different name to the same colID,
525
 
 * and do no rename the colID.  You have been warned.
 
535
 * and do not rename the colID.  You have been warned.
526
536
 */
527
537
XULTreeViewRecord.prototype.setColumnPropertyName =
528
538
function xtvr_setcol (colID, propertyName)
534
544
    function xtvr_setValueShim (newValue)
535
545
    {
536
546
        this._colValues[colID] = newValue;
537
 
        /* XXX this.invalidate(); */
538
547
        return newValue;
539
548
    }
540
549
 
559
568
}
560
569
 
561
570
/*
562
 
 * set the default sort column and resort.
 
571
 * set the default sort column and reSort.
563
572
 */
564
573
XULTreeViewRecord.prototype.setSortColumn =
565
574
function xtvr_setcol (colID, dir)
567
576
    //dd ("setting sort column to " + colID);
568
577
    this._share.sortColumn = colID;
569
578
    this._share.sortDirection = (typeof dir == "undefined") ? 1 : dir;
570
 
    this.resort();
 
579
    this.reSort();
571
580
}
572
581
 
573
582
/*
631
640
}
632
641
 
633
642
/*
634
 
 * this method will cause all child records to be resorted.  any records
 
643
 * this method will cause all child records to be reSorted.  any records
635
644
 * with the default sortCompare method will be sorted by the colID passed to
636
645
 * setSortColumn.
637
646
 *
638
647
 * the local parameter is used internally to control whether or not the 
639
648
 * sorted rows are invalidated.  don't use it yourself.
640
649
 */
641
 
XULTreeViewRecord.prototype.resort =
 
650
XULTreeViewRecord.prototype.reSort =
642
651
function xtvr_resort (leafSort)
643
652
{
644
653
    if (!("childData" in this) || this.childData.length < 1 ||
654
663
    
655
664
    for (var i = 0; i < this.childData.length; ++i)
656
665
    {
657
 
        //this.childData[i].childIndex = i;
658
666
        if ("isContainerOpen" in this.childData[i] &&
659
667
            this.childData[i].isContainerOpen)
660
 
            this.childData[i].resort(true);
 
668
            this.childData[i].reSort(true);
661
669
        else
662
670
            this.childData[i].sortIsInvalid = true;
663
671
    }
677
685
                                       rowIndex + this.visualFootprint - 1);
678
686
        }
679
687
    }
680
 
    /*
681
 
    else
682
 
        dd("not a leafSort");
683
 
    */
684
688
    delete this.sortIsInvalid;
685
689
}
686
690
    
713
717
    
714
718
    child.isHidden = false;
715
719
    child.parentRecord = this;
716
 
    //child.childIndex = this.childData.length;
717
720
    this.childData.push(child);
718
721
    
719
722
    if ("isContainerOpen" in this && this.isContainerOpen)
723
726
        {
724
727
            var tree = this.findContainerTree();
725
728
            if (tree && tree.frozen)
726
 
                this.needsResort = true;
 
729
                this.needsReSort = true;
727
730
            else
728
 
                this.resort(true);  /* resort, don't invalidate.  we're going  
 
731
                this.reSort(true);  /* reSort, don't invalidate.  we're going  
729
732
                                     * to do that in the 
730
733
                                     * onVisualFootprintChanged call. */
731
734
        }
750
753
        child.isHidden = false;
751
754
        child.parentRecord = this;
752
755
        this.childData.push(child);
753
 
        // this.childData[idx] = child;
754
 
        //child.childIndex = idx++;
755
756
        delta += child.visualFootprint;
756
757
    }
757
758
    
759
760
    {
760
761
        if (this.calculateVisualRow() >= 0)
761
762
        {
762
 
            this.resort(true);  /* resort, don't invalidate.  we're going to do
 
763
            this.reSort(true);  /* reSort, don't invalidate.  we're going to do
763
764
                                 * that in the onVisualFootprintChanged call. */
764
765
        }
765
766
        this.onVisualFootprintChanged(this.childData[0].calculateVisualRow(),
768
769
}
769
770
 
770
771
/*
771
 
 * remove a child from this record. updates the tree too.  DONT call this with
 
772
 * remove a child from this record. updates the tree too.  DON'T call this with
772
773
 * an index not actually contained by this record.
773
774
 */
774
775
XULTreeViewRecord.prototype.removeChildAtIndex =
777
778
    if (!ASSERT(this.childData.length, "removing from empty childData"))
778
779
        return;
779
780
    
780
 
    //for (var i = index + 1; i < this.childData.length; ++i)
781
 
    //    --this.childData[i].childIndex;
782
 
    
783
781
    var orphan = this.childData[index];
784
782
    var fpDelta = -orphan.visualFootprint;
785
783
    var changeStart = orphan.calculateVisualRow();
786
 
    //this.childData[index].childIndex = -1;
787
784
    delete orphan.parentRecord;
788
785
    arrayRemoveAt (this.childData, index);
789
786
    
806
803
    var row = this.calculateVisualRow();
807
804
    this.invalidateCache();
808
805
    this.isHidden = true;
809
 
    /* go right to the parent so we don't muck with our own visualFoorptint
 
806
    /* go right to the parent so we don't muck with our own visualFootprint
810
807
     * record, we'll need it to be correct if we're ever unHidden. */
811
808
    if ("parentRecord" in this)
812
809
        this.parentRecord.onVisualFootprintChanged (row, -this.visualFootprint);
829
826
}
830
827
 
831
828
/*
832
 
 * open this record, exposing it's children.  DONT call this method if the
 
829
 * open this record, exposing it's children.  DON'T call this method if the
833
830
 * record has no children.
834
831
 */
835
832
XULTreeViewRecord.prototype.open =
849
846
            delta += this.childData[i].visualFootprint;
850
847
    }
851
848
 
852
 
    /* this resort should only happen if the sort column changed */
853
 
    this.resort(true);
 
849
    /* this reSort should only happen if the sort column changed */
 
850
    this.reSort(true);
854
851
    this.visualFootprint += delta;
855
852
    if ("parentRecord" in this)
856
853
    {
862
859
}
863
860
 
864
861
/*
865
 
 * close this record, hiding it's children.  DONT call this method if the record
 
862
 * close this record, hiding it's children.  DON'T call this method if the record
866
863
 * has no children, or if it is already closed.
867
864
 */
868
865
XULTreeViewRecord.prototype.close =
1070
1067
    return null;
1071
1068
}
1072
1069
 
1073
 
XTRootRecord.prototype.resort =
 
1070
XTRootRecord.prototype.reSort =
1074
1071
function torr_resort ()
1075
1072
{
1076
1073
    if ("_treeView" in this && this._treeView.frozen)
1077
1074
    {
1078
 
        this._treeView.needsResort = true;
 
1075
        this._treeView.needsReSort = true;
1079
1076
        return;
1080
1077
    }
1081
1078
    
1092
1089
    
1093
1090
    for (var i = 0; i < this.childData.length; ++i)
1094
1091
    {
1095
 
        //this.childData[i].childIndex = i;
1096
1092
        if ("isContainerOpen" in this.childData[i] &&
1097
1093
            this.childData[i].isContainerOpen)
1098
 
            this.childData[i].resort(true);
 
1094
            this.childData[i].reSort(true);
1099
1095
        else
1100
1096
            this.childData[i].sortIsInvalid = true;
1101
1097
    }
1213
1209
}
1214
1210
 
1215
1211
/*
1216
 
 * Reflect any changes to the tee content since the last freeze.
 
1212
 * Reflect any changes to the tree content since the last freeze.
1217
1213
 */
1218
1214
XULTreeView.prototype.thaw =
1219
1215
function xtv_thaw ()
1230
1226
                                                this.changeAmount);
1231
1227
    }
1232
1228
    
1233
 
    if ("needsResort" in this) {
1234
 
        this.childData.resort();
1235
 
        delete this.needsResort;
 
1229
    if ("needsReSort" in this) {
 
1230
        this.childData.reSort();
 
1231
        delete this.needsReSort;
1236
1232
    }
1237
1233
    
1238
1234
    
1290
1286
{
1291
1287
    var first = this.tree.getFirstVisibleRow();
1292
1288
    var last = this.tree.getLastVisibleRow();
1293
 
    this.scrollToRow(line - total / 2);
 
1289
    this.scrollToRow(line - (last - first + 1) / 2);
1294
1290
}
1295
1291
 
1296
1292
/*
1310
1306
function xtv_isctr (index)
1311
1307
{
1312
1308
    var row = this.childData.locateChildByVisualRow (index);
1313
 
    /*
1314
 
    ASSERT(row, "bogus row");
1315
 
    var rv = Boolean(row && row.childData);
1316
 
    dd ("isContainer: row " + index + " returning " + rv);
1317
 
    return rv;
1318
 
    */
1319
1309
 
1320
1310
    return Boolean(row && ("alwaysHasChildren" in row || "childData" in row));
1321
1311
}
1323
1313
XULTreeView.prototype.__defineGetter__("selectedIndex", xtv_getsel);
1324
1314
function xtv_getsel()
1325
1315
{
1326
 
    if (!this.tree || this.tree.selection.getRangeCount() < 1)
 
1316
    if (!this.tree || this.tree.view.selection.getRangeCount() < 1)
1327
1317
        return -1;
1328
1318
 
1329
1319
    var min = new Object();
1330
 
    this.tree.selection.getRangeAt(0, min, {});
 
1320
    this.tree.view.selection.getRangeAt(0, min, {});
1331
1321
    return min.value;
1332
1322
}
1333
1323
 
1334
1324
XULTreeView.prototype.__defineSetter__("selectedIndex", xtv_setsel);
1335
1325
function xtv_setsel(i)
1336
1326
{
1337
 
    this.tree.selection.clearSelection();
 
1327
    this.tree.view.selection.clearSelection();
1338
1328
    if (i != -1)
1339
 
        this.tree.selection.timedSelect (i, 500);
 
1329
        this.tree.view.selection.timedSelect (i, 500);
1340
1330
    return i;
1341
1331
}
1342
1332
 
1346
1336
function xtv_isctropen (index)
1347
1337
{
1348
1338
    var row = this.childData.locateChildByVisualRow (index);
1349
 
    /*
1350
 
    ASSERT(row, "bogus row");
1351
 
    var rv = Boolean(row && row.isContainerOpen);
1352
 
    dd ("isContainerOpen: row " + index + " returning " + rv);
1353
 
    return rv;
1354
 
    */
1355
1339
    return row && row.isContainerOpen;
1356
1340
}
1357
1341
 
1373
1357
function xtv_isctrempt (index)
1374
1358
{
1375
1359
    var row = this.childData.locateChildByVisualRow (index);
1376
 
    /*
1377
 
    ASSERT(row, "bogus row");
1378
 
    var rv = Boolean(row && (row.childData.length == 0));
1379
 
    dd ("isContainerEmpty: row " + index + " returning " + rv);
1380
 
    return rv;
1381
 
    */
1382
1360
    if ("alwaysHasChildren" in row)
1383
1361
        return false;
1384
1362
 
1401
1379
        return -1;
1402
1380
    
1403
1381
    var row = this.childData.locateChildByVisualRow (index);
1404
 
    //if (!ASSERT(row, "bogus row " + index))
1405
 
    //    return -1;
1406
1382
    
1407
1383
    var rv = row.parentRecord.calculateVisualRow();
1408
1384
    //dd ("getParentIndex: row " + index + " returning " + rv);
1413
1389
function xtv_hasnxtsib (rowIndex, afterIndex)
1414
1390
{
1415
1391
    var row = this.childData.locateChildByVisualRow (rowIndex);
1416
 
    /*
1417
 
    ASSERT(row, "bogus row");
1418
 
    rv = Boolean(row.childIndex < row.parentRecord.childData.length - 1);
1419
 
    dd ("hasNextSibling: row " + rowIndex + ", after " + afterIndex +
1420
 
        " returning " + rv);
1421
 
    return rv;
1422
 
    */
1423
1392
    return row.childIndex < row.parentRecord.childData.length - 1;
1424
1393
}
1425
1394
 
1427
1396
function xtv_getlvl (index)
1428
1397
{
1429
1398
    var row = this.childData.locateChildByVisualRow (index);
1430
 
    /*
1431
 
    ASSERT(row, "bogus row");
1432
 
    var rv = row.level;
1433
 
    dd ("getLevel: row " + index + " returning " + rv);
1434
 
    return rv;
1435
 
    */
1436
1399
    if (!row)
1437
1400
        return 0;
1438
1401
    
1440
1403
}
1441
1404
 
1442
1405
XULTreeView.prototype.getImageSrc =
1443
 
function xtv_getimgsrc (index, colID)
 
1406
function xtv_getimgsrc (index, col)
1444
1407
{
1445
1408
}
1446
1409
 
1447
1410
XULTreeView.prototype.getProgressMode =
1448
 
function xtv_getprgmode (index, colID)
 
1411
function xtv_getprgmode (index, col)
1449
1412
{
1450
1413
}
1451
1414
 
1452
1415
XULTreeView.prototype.getCellValue =
1453
 
function xtv_getcellval (index, colID)
 
1416
function xtv_getcellval (index, col)
1454
1417
{
1455
1418
}
1456
1419
 
1457
1420
XULTreeView.prototype.getCellText =
1458
 
function xtv_getcelltxt (index, colID)
 
1421
function xtv_getcelltxt (index, col)
1459
1422
{
1460
1423
    var row = this.childData.locateChildByVisualRow (index);
1461
1424
    //ASSERT(row, "bogus row " + index);
1462
1425
 
1463
 
    var ary = colID.match (/:(.*)/);
 
1426
    if (typeof col == "object")
 
1427
        col = col.id;
 
1428
 
 
1429
    var ary = col.match (/:(.*)/);
1464
1430
    if (ary)
1465
 
        colID = ary[1];
 
1431
        col = ary[1];
1466
1432
 
1467
 
    if (row && row._colValues && colID in row._colValues)
1468
 
        return row._colValues[colID];
 
1433
    if (row && row._colValues && col in row._colValues)
 
1434
        return row._colValues[col];
1469
1435
    else
1470
1436
        return "";
1471
1437
}
1472
1438
 
1473
1439
XULTreeView.prototype.getCellProperties =
1474
 
function xtv_cellprops (row, colID, properties)
 
1440
function xtv_cellprops (row, col, properties)
1475
1441
{}
1476
1442
 
1477
1443
XULTreeView.prototype.getColumnProperties =
1478
 
function xtv_colprops (colID, elem, properties)
 
1444
function xtv_colprops (col, properties)
1479
1445
{}
1480
1446
 
1481
1447
XULTreeView.prototype.getRowProperties =
1488
1454
    return false;
1489
1455
}
1490
1456
 
1491
 
XULTreeView.prototype.canDropOn =
1492
 
function xtv_dropon (index)
1493
 
{
1494
 
    var row = this.childData.locateChildByVisualRow (index);
1495
 
    //ASSERT(row, "bogus row " + index);
1496
 
    return (row && ("canDropOn" in row) && row.canDropOn());
1497
 
}
1498
 
 
1499
 
XULTreeView.prototype.canDropBeforeAfter =
1500
 
function xtv_dropba (index, before)
1501
 
{
1502
 
    var row = this.childData.locateChildByVisualRow (index);
1503
 
    //ASSERT(row, "bogus row " + index);
1504
 
    return (row && ("canDropBeforeAfter" in row) &&
1505
 
            row.canDropBeforeAfter(before));
 
1457
XULTreeView.prototype.canDrop =
 
1458
function xtv_drop (index, orientation)
 
1459
{
 
1460
    var row = this.childData.locateChildByVisualRow (index);
 
1461
    //ASSERT(row, "bogus row " + index);
 
1462
    return (row && ("canDrop" in row) && row.canDrop(orientation));
1506
1463
}
1507
1464
 
1508
1465
XULTreeView.prototype.drop =
1521
1478
}
1522
1479
 
1523
1480
XULTreeView.prototype.cycleHeader =
1524
 
function xtv_cyclehdr (colID, elt)
 
1481
function xtv_cyclehdr (col)
1525
1482
{
1526
1483
}
1527
1484
 
1531
1488
}
1532
1489
 
1533
1490
XULTreeView.prototype.cycleCell =
1534
 
function xtv_cyclecell (row, colID)
 
1491
function xtv_cyclecell (row, col)
1535
1492
{
1536
1493
}
1537
1494
 
1538
1495
XULTreeView.prototype.isEditable =
1539
 
function xtv_isedit (row, colID)
 
1496
function xtv_isedit (row, col)
1540
1497
{
1541
1498
    return false;
1542
1499
}
1543
1500
 
 
1501
XULTreeView.prototype.setCellValue =
 
1502
function xtv_setct (row, col, value)
 
1503
{
 
1504
}
 
1505
 
1544
1506
XULTreeView.prototype.setCellText =
1545
 
function xtv_setct (row, colID, value)
 
1507
function xtv_setct (row, col, value)
1546
1508
{
1547
1509
}
1548
1510
 
1581
1543
    if (!("onRowCommand" in this) || event.target.localName != "treechildren")
1582
1544
        return;
1583
1545
 
1584
 
    var rowIndex = this.tree.selection.currentIndex;
 
1546
    var rowIndex = this.tree.view.selection.currentIndex;
1585
1547
    if (rowIndex == -1 || rowIndex > this.rowCount)
1586
1548
        return;
1587
1549
    var rec = this.childData.locateChildByVisualRow(rowIndex);
1605
1567
        if (!this.selection)
1606
1568
            return;
1607
1569
        
1608
 
        rowIndex = this.tree.selection.currentIndex;
 
1570
        rowIndex = this.tree.view.selection.currentIndex;
1609
1571
        if (rowIndex == -1 || rowIndex > this.rowCount)
1610
1572
            return;
1611
1573
        rec = this.childData.locateChildByVisualRow(rowIndex);
1619
1581
    }
1620
1582
    else if ("onKeyPress" in this)
1621
1583
    {
1622
 
        rowIndex = this.tree.selection.currentIndex;
 
1584
        rowIndex = this.tree.view.selection.currentIndex;
1623
1585
        if (rowIndex != -1 && rowIndex < this.rowCount)
1624
1586
        {
1625
1587
            rec = this.childData.locateChildByVisualRow(rowIndex);