Kevincosme / flexlib

Automatically exported from code.google.com/p/flexlib
0 stars 0 forks source link

TreeGrid Drag & Drop broken #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open the TreeGrid sample and add dragEnabled="true" to the first treegrid
2. Load up the sample in a page
3. Click and drag any of the items in the tree grid

What is the expected output? What do you see instead?
I expect that the grid would start the drag and drop process properly
(showing something is being dragged and so on).

Instead I receive the errors (one after the other, after dismissing them):
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
    at mx.managers.dragClasses::DragProxy/mouseUpHandler()
    at mx.managers.dragClasses::DragProxy/mouseLeaveHandler()
    at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio
n()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()
    at
mx.controls.listClasses::ListBase/mx.controls.listClasses:ListBase::mouseMoveHan
dler()

TypeError: Error #1034: Type Coercion failed: cannot convert
mx.controls.dataGridClasses::DataGridListData@2c5bda11 to
flexlib.controls.treeGridClasses.TreeGridListData.
    at flexlib.controls.treeGridClasses::TreeGridItemRenderer/set listData()
    at
mx.controls.dataGridClasses::DataGridDragProxy/mx.controls.dataGridClasses:DataG
ridDragProxy::createChildren()
    at mx.core::UIComponent/initialize()
    at
mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::childAdded()
    at mx.core::UIComponent/addChild()
    at mx.managers::DragManagerImpl/doDrag()
    at mx.managers::DragManager$/doDrag()
    at
mx.controls.listClasses::ListBase/mx.controls.listClasses:ListBase::dragStartHan
dler()
    at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio
n()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()
    at
mx.controls.listClasses::ListBase/mx.controls.listClasses:ListBase::mouseMoveHan
dler()

What version of the product are you using? On what operating system?
This is on flexlib 1.6

Please provide any additional information below.
This happens on both the items that are trees (ones with branches), and
those that are not.

Original issue reported on code.google.com by jerry....@gmail.com on 6 Apr 2007 at 4:06

GoogleCodeExporter commented 8 years ago
I've done some more investigating on this. It seems that what happens is when 
you do
the drag and drop TreeGridItemRenderer's set listData function gets called:

public function set listData( value : BaseListData ) : void

The argument that ends up being passed in during the drag is an instance of
DataGridListData, but TreeGridItemRenderer casts it to a TreeGridListData 
instance
which causes the chain of errors in the original report.

You cannot just do a simple if (value is/instanceof TreeGridListData) do cast,
because then you get a bunch of other errors later on. One workaround that 
seems to
be working for me right now is to just have code like so:

public function set listData( value : BaseListData ) : void
{
    if( !value )
        return;
    if ( value is TreeGridListData) {
        _listData = TreeGridListData( value );
    } else if (value is DataGridListData) {
        // this is true when we're in a drag event
        var dataGridListData : DataGridListData = DataGridListData(value);
        _listData = new TreeGridListData(dataGridListData.label, 
                        dataGridListData.dataField, 
                        dataGridListData.columnIndex, 
                        dataGridListData.uid, 
                        dataGridListData.owner, 
                        dataGridListData.rowIndex);
    }
}

If you do this you then also need to change in the TreeGridItemRenderer, the
updateDisplayList method, at around line 314:

original
if(disclosureIcon.visible)
{
  //vertical item line (separated in 2 part, top of the icon and bottom of the icon)
  trunk.graphics.moveTo(startx - (disclosureIcon.width / 2), 0 -
_listData.trunkOffsetTop );
  trunk.graphics.lineTo(startx - (disclosureIcon.width / 2), disclosureIcon.y );

new
if(disclosureIcon && disclosureIcon.visible)
{
  //vertical item line (separated in 2 part, top of the icon and bottom of the icon)
  trunk.graphics.moveTo(startx - (disclosureIcon.width / 2), 0 -
_listData.trunkOffsetTop );
  trunk.graphics.lineTo(startx - (disclosureIcon.width / 2), disclosureIcon.y );

since this change results in disclosureIcon potentially being null.

This is not a good fix, but is a workaround that seems to work for my purposes 
(TBD).
I am not sure of the ramifications of this change.

Original comment by jerry....@gmail.com on 6 Apr 2007 at 6:56

GoogleCodeExporter commented 8 years ago
Thanks for the detailed report.  Assigning to Yaniv.

Original comment by darron.schall on 7 Apr 2007 at 12:05

GoogleCodeExporter commented 8 years ago

Original comment by dmcc...@gmail.com on 26 Dec 2007 at 11:45

GoogleCodeExporter commented 8 years ago
Are there any plans
on fixing this in the near future?

Original comment by pietro....@gmail.com on 17 Nov 2008 at 4:54