delta= length;
st.replaceTextRange(fSelection.x + delta, length, ""); //$NON-NLS-1$
if (fTextDragAndDropToken == null) {
// Move in same editor - end compound change
IRewriteTarget target= (IRewriteTarget)getAdapter(IRewriteTarget.class);
if (target != null)
target.endCompoundChange();
}
}
} finally {
fTextDragAndDropToken= null;
}
}
});
// Install drag target
DropTargetListener dropTargetListener= new DropTargetAdapter() {
private Point fSelection;
public void dragEnter(DropTargetEvent event) {
fTextDragAndDropToken= null;
fSelection= st.getSelection();
// XXX: This is only a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=162192
if (!fIsTextDragAndDropEnabled) {
event.detail= DND.DROP_NONE;
event.feedback= DND.FEEDBACK_NONE;
return;
}
if (event.detail == DND.DROP_DEFAULT)
event.detail= DND.DROP_MOVE;
}
public void dragOperationChanged(DropTargetEvent event) {
if (!fIsTextDragAndDropEnabled) {
event.detail= DND.DROP_NONE;
event.feedback= DND.FEEDBACK_NONE;
return;
}
if (event.detail == DND.DROP_DEFAULT)
event.detail= DND.DROP_MOVE;
}
public void dragOver(DropTargetEvent event) {
// XXX: This is only a workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=162192
if (!fIsTextDragAndDropEnabled) {
event.feedback= DND.FEEDBACK_NONE;
return;
}
event.feedback |= DND.FEEDBACK_SCROLL;
}
public void drop(DropTargetEvent event) {
try {
if (!fIsTextDragAndDropEnabled)
return;
if (fTextDragAndDropToken != null && event.detail == DND.DROP_MOVE) {
// Move in same editor
int caretOffset= st.getCaretOffset();
if (fSelection.x <= caretOffset && caretOffset <= fSelection.y) {
event.detail= DND.DROP_NONE;
return;
}
// Start compound change
IRewriteTarget target= (IRewriteTarget)getAdapter(IRewriteTarget.class);
if (target != null)
target.beginCompoundChange();
}
if (!validateEditorInputState()) {
event.detail= DND.DROP_NONE;
return;