~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/ext/source/widgets/grid/GridDD.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Ext JS Library 2.2
 
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
 
4
 * licensing@extjs.com
 
5
 * 
 
6
 * http://extjs.com/license
 
7
 */
 
8
 
 
9
/**
 
10
 * @class Ext.grid.GridDragZone
 
11
 * @extends Ext.dd.DragZone
 
12
 * <p>A customized implementation of a {@link Ext.dd.DragZone DragZone} which provides default implementations of two of the
 
13
 * template methods of DragZone to enable dragging of the selected rows of a GridPanel.</p>
 
14
 * <p>A cooperating {@link Ext.dd.DropZone DropZone} must be created who's template method implementations of
 
15
 * {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
 
16
 * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop}</p> are able
 
17
 * to process the {@link #getDragData data} which is provided.
 
18
 */
 
19
Ext.grid.GridDragZone = function(grid, config){
 
20
    this.view = grid.getView();
 
21
    Ext.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
 
22
    if(this.view.lockedBody){
 
23
        this.setHandleElId(Ext.id(this.view.mainBody.dom));
 
24
        this.setOuterHandleElId(Ext.id(this.view.lockedBody.dom));
 
25
    }
 
26
    this.scroll = false;
 
27
    this.grid = grid;
 
28
    this.ddel = document.createElement('div');
 
29
    this.ddel.className = 'x-grid-dd-wrap';
 
30
};
 
31
 
 
32
Ext.extend(Ext.grid.GridDragZone, Ext.dd.DragZone, {
 
33
    ddGroup : "GridDD",
 
34
 
 
35
    /**
 
36
     * <p>The provided implementation of the getDragData method which collects the data to be dragged from the GridPanel on mousedown.</p>
 
37
     * <p>This data is available for processing in the {@link Ext.dd.DropZone#onNodeEnter onNodeEnter}, {@link Ext.dd.DropZone#onNodeOver onNodeOver},
 
38
     * {@link Ext.dd.DropZone#onNodeOut onNodeOut} and {@link Ext.dd.DropZone#onNodeDrop onNodeDrop} methods of a cooperating {@link Ext.dd.DropZone DropZone}.</p>
 
39
     * <p>The data object contains the following properties:<ul>
 
40
     * <li><b>grid</b> : Ext.Grid.GridPanel<div class="sub-desc">The GridPanel from which the data is being dragged.</div></li>
 
41
     * <li><b>ddel</b> : htmlElement<div class="sub-desc">An htmlElement which provides the "picture" of the data being dragged.</div></li>
 
42
     * <li><b>rowIndex</b> : Number<div class="sub-desc">The index of the row which receieved the mousedown gesture which triggered the drag.</div></li>
 
43
     * <li><b>selections</b> : Array<div class="sub-desc">An Array of the selected Records which are being dragged from the GridPanel.</div></li>
 
44
     * </ul></p>
 
45
     */
 
46
    getDragData : function(e){
 
47
        var t = Ext.lib.Event.getTarget(e);
 
48
        var rowIndex = this.view.findRowIndex(t);
 
49
        if(rowIndex !== false){
 
50
            var sm = this.grid.selModel;
 
51
            if(!sm.isSelected(rowIndex) || e.hasModifier()){
 
52
                sm.handleMouseDown(this.grid, rowIndex, e);
 
53
            }
 
54
            return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
 
55
        }
 
56
        return false;
 
57
    },
 
58
 
 
59
    /**
 
60
     * <p>The provided implementation of the onInitDrag method. Sets the <tt>innerHTML</tt> of the drag proxy which provides the "picture"
 
61
     * of the data being dragged.</p>
 
62
     * <p>The <tt>innerHTML</tt> data is found by calling the owning GridPanel's {@link Ext.grid.GridPanel#getDragDropText getDragDropText}.</p>
 
63
     */
 
64
    onInitDrag : function(e){
 
65
        var data = this.dragData;
 
66
        this.ddel.innerHTML = this.grid.getDragDropText();
 
67
        this.proxy.update(this.ddel);
 
68
        // fire start drag?
 
69
    },
 
70
 
 
71
    /**
 
72
     * An empty immplementation. Implement this to provide behaviour after a repair of an invalid drop. An implementation might highlight
 
73
     * the selected rows to show that they have not been dragged.
 
74
     */
 
75
    afterRepair : function(){
 
76
        this.dragging = false;
 
77
    },
 
78
 
 
79
    /**
 
80
     * <p>An empty implementation. Implement this to provide coordinates for the drag proxy to slide back to after an invalid drop.</p>
 
81
     * <p>Called before a repair of an invalid drop to get the XY to animate to.</p>
 
82
     * @param {EventObject} e The mouse up event
 
83
     * @return {Array} The xy location (e.g. [100, 200])
 
84
     */
 
85
    getRepairXY : function(e, data){
 
86
        return false;
 
87
    },
 
88
 
 
89
    onEndDrag : function(data, e){
 
90
        // fire end drag?
 
91
    },
 
92
 
 
93
    onValidDrop : function(dd, e, id){
 
94
        // fire drag drop?
 
95
        this.hideProxy();
 
96
    },
 
97
 
 
98
    beforeInvalidDrop : function(e, id){
 
99
 
 
100
    }
 
101
});