Я добавил DragListener в просмотрщик GridTable и DropListener в таблицу nat, но когда я выбираю любой просмотрщик сетки строк и удаляю его из таблицы nat;выбранные данные не удаляются. Фрагмент кода прикреплен ниже
Перетащите прослушиватель источника в GridTableViewer
Transfer[] transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer() };
this.gridTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, transferTypes, new DragSourceListener() {
@Override
public void dragStart(final DragSourceEvent event) {
System.out.println(transferTypes);
event.doit = !ShowListDialog.this.gridTableViewer.getStructuredSelection().isEmpty();
}
@Override
public void dragSetData(final DragSourceEvent event) {
if(LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
LocalSelectionTransfer.getTransfer()
.setSelection(ShowListDialog.this.gridTableViewer.getStructuredSelection());
LocalSelectionTransfer.getTransfer().setSelectionSetTime(event.time & 0xFFFF);
}
}
@Override
public void dragFinished(final DragSourceEvent dragsourceevent) {
// LocalSelectionTransfer.getTransfer().setSelection(null);
// LocalSelectionTransfer.getTransfer().setSelectionSetTime(0);
}
});
DropTargetListener в NatTable
Transfer[] transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer() };
this.natTable.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, transferTypes, new DropTargetListener() {
@Override
public void dragEnter(final DropTargetEvent event) {
event.detail = DND.DROP_COPY | DND.DROP_MOVE;
event.currentDataType = event.dataTypes[0];
}
@Override
public void dragOperationChanged(final DropTargetEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void dragOver(final DropTargetEvent event) {
event.detail = DND.DROP_COPY | DND.DROP_MOVE;
}
@Override
public void drop(final DropTargetEvent event) {
StructuredSelection structuredSelection = (StructuredSelection) event.data;
final Object selectedElement = structuredSelection.getFirstElement();
// for (Object selectedElement : structuredSelection.toList()) {
if (selectedElement instanceof String) {
}
}
@Override
public void dropAccept(final DropTargetEvent event) {
}
@Override
public void dragLeave(final DropTargetEvent droptargetevent) {
// TODO Auto-generated method stub
}
});