}
private void addDropSupport(Text field) {
int operations = DND.DROP_COPY | DND.DROP_DEFAULT;
DropTarget target = new DropTarget(field, operations);
final TextTransfer textTransfer = TextTransfer.getInstance();
Transfer[] types = new Transfer[] { textTransfer };
target.setTransfer(types);
target.addDropListener(new DropTargetListener() {
public void dragEnter(DropTargetEvent event) {
if (event.detail == DND.DROP_DEFAULT) {
if ((event.operations & DND.DROP_COPY) != 0) {
event.detail = DND.DROP_COPY;
} else {
event.detail = DND.DROP_NONE;
}
}
}
public void dragLeave(DropTargetEvent event) { }
public void dragOperationChanged(DropTargetEvent event) {
if (event.detail == DND.DROP_DEFAULT) {
if ((event.operations & DND.DROP_COPY) != 0) {
event.detail = DND.DROP_COPY;
} else {
event.detail = DND.DROP_NONE;
}
}
}
public void dragOver(DropTargetEvent event) {
event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
}
public void drop(DropTargetEvent event) {
if (textTransfer.isSupportedType(event.currentDataType)) {
parseCandidateUrl((String)event.data);
}
}
public void dropAccept(DropTargetEvent event) { }