mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-73527 IOOBE at com.intellij.ui.tabs.FileColorSettingsTable$ModelAdapter.exchangeRows
This commit is contained in:
@@ -43,7 +43,15 @@ public class TableRowsDnDSupport {
|
||||
if (cellEditor != null) {
|
||||
cellEditor.stopCellEditing();
|
||||
}
|
||||
return new DnDDragStartBean(Integer.valueOf(table.rowAtPoint(p)));
|
||||
return new DnDDragStartBean(new TableRowDragInfo(table, Integer.valueOf(table.rowAtPoint(p))));
|
||||
}
|
||||
})
|
||||
.setTargetChecker(new DnDTargetChecker() {
|
||||
@Override
|
||||
public boolean update(DnDEvent event) {
|
||||
final Object o = event.getAttachedObject();
|
||||
event.setDropPossible(o instanceof TableRowDragInfo && ((TableRowDragInfo)o).table == table);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.setDropHandler(new DnDDropHandler() {
|
||||
@@ -51,8 +59,8 @@ public class TableRowsDnDSupport {
|
||||
public void drop(DnDEvent event) {
|
||||
final Object o = event.getAttachedObject();
|
||||
final Point p = event.getPoint();
|
||||
if (o instanceof Integer) {
|
||||
int oldIndex = ((Integer)o).intValue();
|
||||
if (o instanceof TableRowDragInfo && ((TableRowDragInfo)o).table == table) {
|
||||
int oldIndex = ((TableRowDragInfo)o).row;
|
||||
if (oldIndex == -1) return;
|
||||
int newIndex = table.rowAtPoint(p);
|
||||
if (newIndex == -1) {
|
||||
@@ -66,7 +74,8 @@ public class TableRowsDnDSupport {
|
||||
min++;
|
||||
}
|
||||
table.getSelectionModel().setSelectionInterval(min, min);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
while (max > min) {
|
||||
model.exchangeRows(max, max - 1);
|
||||
max--;
|
||||
@@ -77,4 +86,14 @@ public class TableRowsDnDSupport {
|
||||
}
|
||||
}).install();
|
||||
}
|
||||
|
||||
static class TableRowDragInfo {
|
||||
public final JTable table;
|
||||
public final int row;
|
||||
|
||||
TableRowDragInfo(JTable table, int row) {
|
||||
this.table = table;
|
||||
this.row = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user