Issue Details (XML | Word | Printable)

Key: UBA-7670
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Janak Mulani
Reporter: Janak Mulani
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
ULCBase

Dragging unuploaded rows in ULCTable will result in wrong transfer data

Created: 03/Feb/09 07:27 AM   Updated: 05/Feb/09 10:56 AM
Component/s: dnd
Affects Version/s: UltraLightClient '08 Update 1
Fix Version/s: UltraLightClient '08 Update 2

Issue Links:
Part
 
Reference
 


 Description  « Hide
Select all rows with Ctrl-A and drag. All rows in the model are selected so the transfer data includes null values for unuploaded values too.
import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ULCComponent;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCScrollPane;
import com.ulcjava.base.application.ULCTable;
import com.ulcjava.base.application.dnd.TransferHandler;
import com.ulcjava.base.application.dnd.Transferable;
import com.ulcjava.base.application.table.AbstractTableModel;
import com.ulcjava.base.client.UITable;
import com.ulcjava.base.client.dnd.AbstractDragGestureListener;
import com.ulcjava.base.client.dnd.AbstractDragSourceListener;
import com.ulcjava.base.client.dnd.DnDTableData;
import com.ulcjava.base.client.dnd.DragImage;
import com.ulcjava.base.client.dnd.IDnDData;
import com.ulcjava.base.development.DevelopmentRunner;

import java.awt.Point;

public class PR7670 extends AbstractApplication {
    
    public void start() {
        ULCTable table = new ULCTable();
        initGrid(table);
        ULCFrame frame = new ULCFrame();
        frame.add(new ULCScrollPane(table));
        frame.setSize(400, 300);
        frame.setVisible(true);
    }
    
    public static void main(String[] args) {
        DevelopmentRunner.setApplicationClass(PR7670.class);
        DevelopmentRunner.main(args);
    }
    
    
    private void initGrid(final ULCTable table) {
        AbstractTableModel model = new AbstractTableModel() {
            public int getRowCount() {
                return 50;
            }
            
            public int getColumnCount() {
                return 15;
            }
            
            public Object getValueAt(int row, int column) {
                return row + ":" + column;
            }
            
            public void setValueAt(Object value, int rowIndex, int columnIndex) {
                
            }
        };
        
        table.setModel(model);
        
        table.setDragEnabled(true);
        table.setTransferHandler(new TransferHandler() {
            public boolean importData(ULCComponent targetComponent, Transferable transferable) {
                return false;
            }
            
            public void exportDone(ULCComponent sourceComponent, Transferable transferable, int dropAction) {
            }
        });
    }
    
    public static class ULCFixedTable extends ULCTable {
        protected String typeString() {
            return UIFixedTable.class.getName();
        }
    }
    
    public static class UIFixedTable extends UITable {
        protected AbstractDragGestureListener createDragGestureListener(AbstractDragSourceListener dragSourceListener) {
            return new FixedTableDragGestureListener(dragSourceListener);
        }
        
        public class FixedTableDragGestureListener extends TableDragGestureListener {
            public FixedTableDragGestureListener(AbstractDragSourceListener dragSourceListener) {
                super(dragSourceListener);
            }
            
            protected DragImage createDragImage(Point dragOrigin) {
                if (getBasicTable().getSelectedRowCount() > 10) {
                    return null;
                } else {
                    return super.createDragImage(dragOrigin);
                }
            }
            
            protected IDnDData createDragData() {
                if (getBasicTable().getSelectedRowCount() > 100) {
                    return new DnDTableData(UIFixedTable.this, getBasicTable().getSelectedRows(), getBasicTable().getSelectedColumns(), "");
                } else {
                    return super.createDragData();
                }
            }
        }
    }
}


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Janak Mulani added a comment - 04/Feb/09 11:20 AM - edited
To build drag data consider only selected cells that already have been uploaded.