Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

SWTBot/GSOC dragndrop

< SWTBot
Revision as of 16:01, 4 July 2013 by Rohi0012.e.ntu.edu.sg (Talk | contribs) (DragSource and DropTarget object)

This page contains various thoughts/proposals/snippets developed in order to support Drag'n'Drop in SWTBot in a smart and efficient way. Most of this was produced by Rohit AGRAWAL as part of Google Summer of Code 2013. See Rohit's proposal.

Requirements

  • Usage must be consistent with current SWTBot APIs. We can expect a method on AbstractSWTBot.
  • Usage must be homogeneous in SWTBot, and must be the same for all possible controls and concepts
  • It must support SWT and GEF
  • This must be supported by Test Recorder and Generator (addition of rules)

Optional, if supported those features should be considered as secondary, and should not be necessary to deal with simple DND API.

  • It should support the concept of path (allow intermediary drags to before a drop)
  • Support for Transfer in order to test drops coming from external applications.

Main use-cases

So far, here are the 2 main use-cases that were identified based on community feedback:

  • Drag'n'Drop of Tree elements
  • Drag'n'Drop of GEF elements

Proposals

AbstractSWTBot<? extends Widget> dragAndDrop

This is a patch that was proposed early on https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271: Example:

final SWTBotTree sourceTree = bot.tree(0);
final SWTBotTree targetTree = bot.tree(1);
final SWTBotTreeItem sourceItem = sourceTree.getTreeItem("Drag Source name 0");
final SWTBotTreeItem targetItem = targetTree.getTreeItem("Drop Target name 0");
 
sourceItem.dragAndDrop(targetItem);

Requirements support:

  • Usage must be consistent with current SWTBot APIs. YES
  • Usage must be homogeneous in SWTBot, and must be the same for all possible controls and concepts YES
  • It must support SWT and GEF NO
  • This must be supported by Test Recorder and Generator (addition of rules) NO
  • It should support the concept of path (allow intermediary drags to before a drop) NO

DNDUtils

This is the workaround that has been extensively used so far. It's an utility class that is attached to https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271:

final SWTBotTree sourceTree = bot.tree(0);
final SWTBotTree targetTree = bot.tree(1);
final SWTBotTreeItem sourceItem = sourceTree.getTreeItem("Drag Source name 0");
final SWTBotTreeItem targetItem = targetTree.getTreeItem("Drop Target name 0");
 
DNDUtils.dragAndDrop(sourceItem, targetItem)

Requirements support:

  • Usage must be consistent with current SWTBot APIs. NO
  • Usage must be homogeneous in SWTBot, and must be the same for all possible controls and concepts YES
  • It must support SWT and GEF YES
  • This must be supported by Test Recorder and Generator (addition of rules) NO
  • It should support the concept of path (allow intermediary drags to before a drop) NO

DragSource and DropTarget object

This API is somewhat similar to how DND is implemented in SWT.

DragSource source = new DragSource(dragWidget, operations);
DropTarget target = new DropTarget(dropWidget, operations);
source.setTransfer(dragTransferType);
target.setTransfer(dropTransferType);
DragAndDrop(source,target);

Back to the top