Bug 416342 - Error occur when using Drog&Drop in tableViewer
Summary: Error occur when using Drog&Drop in tableViewer
Status: RESOLVED WORKSFORME
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 2.2   Edit
Hardware: PC Windows 8
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2013-09-02 05:47 EDT by David Song CLA
Modified: 2014-01-09 06:34 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Song CLA 2013-09-02 05:47:29 EDT
the code is:

Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
DragSource source = new DragSource(sourseTable, DND.DROP_MOVE | DND.DROP_COPY);
		source.setTransfer(types);
		source.addDragListener(new DragSourceAdapter() {
		  public void dragSetData(DragSourceEvent event) {
		    DragSource ds = (DragSource) event.widget;
		    Table table = (Table) ds.getControl();
		    TableItem[] selection = table.getSelection();

		    StringBuffer buff = new StringBuffer();
		    for (int i = 0, n = selection.length; i < n; i++) {
		      buff.append(selection[i].getText());
		    }
		    event.data = buff.toString();
		  }
		});

DropTarget target = new DropTarget(targentTable, DND.DROP_MOVE | DND.DROP_COPY );
		target.setTransfer(types);
		target.addDropListener(new DropTargetAdapter(){
			public void dragEnter(DropTargetEvent event) {
				if (event.detail != DND.DROP_DEFAULT) {
					event.detail = (event.operations & DND.DROP_COPY) != 0 ? DND.DROP_COPY : DND.DROP_NONE;
				}
				for (int i = 0, n = event.dataTypes.length; i < n; i++) {
					if (TextTransfer.getInstance().isSupportedType(event.dataTypes[i])) {
						event.currentDataType = event.dataTypes[i];
					}
				}
			}
			
			public void dragOver(DropTargetEvent event) {
			    event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
			}

			public void drop(DropTargetEvent event) {
				  if (TextTransfer.getInstance().isSupportedType(event.currentDataType)) {
					  DropTarget target = (DropTarget) event.widget;
					  Table table = (Table) target.getControl();
					  String data = (String) event.data;
					  TableItem item = new TableItem(table, SWT.NONE);
					  item.setText(new String[] { data });
					  //remove the tableitem you drag
					  table.remove(table.getSelectionIndex());
				  }
			}
		});


and the error info is :

Error: TypeError: Object # has no method 'indexOf'

  Stack: TypeError: Object # has no method 'indexOf'
    at rwt.qx.Class.define.members._getScrollDirection (http://localhost:10080/rwt-resources/rap-client.js:54342:47)
    at rwt.qx.Class.define.members._onScrollTimer (http://localhost:10080/rwt-resources/rap-client.js:54353:25)
    at rwt.qx.Class.define.members._dispatchEvent (http://localhost:10080/rwt-resources/rap-client.js:6261:18)
    at rwt.qx.Class.define.members.dispatchEvent (http://localhost:10080/rwt-resources/rap-client.js:6191:12)
    at rwt.qx.Class.define.members._oninterval (http://localhost:10080/rwt-resources/rap-client.js:6902:16)
    at wrap (http://localhost:10080/rwt-resources/rap-client.js:5725:25)
  Debug: on
Comment 1 Ivan Furnadjiev CLA 2013-09-02 06:06:39 EDT
David, please attach a complete entry point class to start and reproduce it. Thanks.
Comment 2 Tim Buschtoens CLA 2013-09-25 08:32:52 EDT
Unabled to reproduce the client error, though the snippet code is probably broken:

//remove the tableitem you drag
table.remove(table.getSelectionIndex());

This actually removes the item in the target table that is selected, not the one that is dragged.

The error might be possible to be reproduced by disposing the table during the drag, but there is no dispose in that snippet, so that's not it. We really would need a full application.
Comment 3 Ivan Furnadjiev CLA 2013-10-31 08:43:05 EDT
David, any progress on complete self-running snippet/project to reproduce the issue?
Comment 4 Ivan Furnadjiev CLA 2014-01-09 06:34:36 EST
I will close it as WORKSFORME. Please reopen if you have more information (complete snippet) how to reproduce it.