Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Error occur when using Drog&Drop in tableViewer
Error occur when using Drog&Drop in tableViewer [message #1099323] Sun, 01 September 2013 13:58 Go to next message
Song David is currently offline Song David
Messages: 190
Registered: April 2011
Senior Member
Hi,
my 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 code 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


Thanks
David
Re: Error occur when using Drog&amp;Drop in tableViewer [message #1099332 is a reply to message #1099323] Sun, 01 September 2013 14:18 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Hi David,
which RAP version are you using?
Best,
Ivan

On 9/1/2013 4:58 PM, Song David wrote:
> Hi,
> my 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 code 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
>
> Thanks
> David

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Error occur when using Drog&amp;Drop in tableViewer [message #1099595 is a reply to message #1099332] Mon, 02 September 2013 00:35 Go to previous messageGo to next message
Song David is currently offline Song David
Messages: 190
Registered: April 2011
Senior Member
Hi Ivan,
Sorry, I am using the ver 2.2 M1
Re: Error occur when using Drog&amp;amp;Drop in tableViewer [message #1099764 is a reply to message #1099595] Mon, 02 September 2013 07:11 Go to previous message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1846
Registered: July 2009
Senior Member
Hi David,
could you open a bugzilla with a complete self-running snippet to
reproduce the problem.
Thanks,
Ivan

On 9/2/2013 3:35 AM, Song David wrote:
> Hi Ivan,
> Sorry, I am using the ver 2.2 M1
>

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:DSL Editor in RAP (Xtext like)
Next Topic:TableViewer column divider click to resize
Goto Forum:
  


Current Time: Sat Nov 01 10:29:33 GMT 2014

Powered by FUDForum. Page generated in 0.07573 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software