gef中拖动拽动原理以及实现(二)
?? 最近学习gef源代码AbstractEditPartViewer发现其实拖拽功能可以不用自己实现的。
?
?
?
由gef中源代码AbstractEditPartViewer可知:
针对拖动目标和拖动源可以分别采用如下代理:
public class DelegatingDragAdapter
??? extends org.eclipse.jface.util.DelegatingDragAdapter;
?
public class DelegatingDropAdapter
??? extends org.eclipse.jface.util.DelegatingDropAdapter;
?
使用如下:
声明:
private DragSource dragSource;
private org.eclipse.gef.dnd.DelegatingDragAdapter dragAdapter = new org.eclipse.gef.dnd.DelegatingDragAdapter();
?
private DropTarget dropTarget;
private org.eclipse.gef.dnd.DelegatingDropAdapter dropAdapter = new org.eclipse.gef.dnd.DelegatingDropAdapter();
使用如下:
/**
?* Called whenever the {@link #getDragSource() drag source} is automatically created.
?*/
protected void hookDragSource() {
??? dragSource.addDragListener(getDelegatingDragAdapter());
}
/**
?* Called whenever the {@link #getDropTarget() drop target} is automatically created.
?*/
protected void hookDropTarget() {
??? getDropTarget().addDropListener(getDelegatingDropAdapter());
}
?
1 楼 guhanjie 2011-08-16 你的这段代码发在何处啊? 2 楼 longgangbai 2011-08-17 guhanjie 写道你的这段代码发在何处啊?