kopia lustrzana https://github.com/JOSM/MapWithAI
MapWithAIProvidersPanel: Avoid index error when clicking outside of table
Signed-off-by: Taylor Smock <tsmock@fb.com>pull/1/head
rodzic
2becd190c3
commit
d8fdc1683f
|
@ -485,6 +485,7 @@ public class MapWithAIProvidersPanel extends JPanel {
|
||||||
private static void clickListener(MouseEvent e) {
|
private static void clickListener(MouseEvent e) {
|
||||||
if (e.getSource() instanceof JTable) {
|
if (e.getSource() instanceof JTable) {
|
||||||
JTable table = (JTable) e.getSource();
|
JTable table = (JTable) e.getSource();
|
||||||
|
if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) {
|
||||||
int realCol = table.convertColumnIndexToModel(table.getSelectedColumn());
|
int realCol = table.convertColumnIndexToModel(table.getSelectedColumn());
|
||||||
int realRow = table.convertRowIndexToModel(table.getSelectedRow());
|
int realRow = table.convertRowIndexToModel(table.getSelectedRow());
|
||||||
String tableName = table.getModel().getColumnName(realCol);
|
String tableName = table.getModel().getColumnName(realCol);
|
||||||
|
@ -504,6 +505,7 @@ public class MapWithAIProvidersPanel extends JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the current bounds of the map and the area to select
|
* Set the current bounds of the map and the area to select
|
||||||
|
@ -843,12 +845,17 @@ public class MapWithAIProvidersPanel extends JPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
this.setEnabled(false);
|
||||||
MapWithAILayerInfo.getInstance().loadDefaults(true, MainApplication.worker, false, () -> {
|
MapWithAILayerInfo.getInstance().loadDefaults(true, MainApplication.worker, false, () -> {
|
||||||
GuiHelper.runInEDT(DEFAULT_MODEL::fireTableDataChanged);
|
// This needs to be run in a block to avoid race conditions.
|
||||||
GuiHelper.runInEDT(defaultTable.getSelectionModel()::clearSelection);
|
GuiHelper.runInEDT(() -> {
|
||||||
GuiHelper.runInEDT(defaultTableListener::clearMap);
|
defaultTable.getSelectionModel().clearSelection();
|
||||||
|
defaultTableListener.clearMap();
|
||||||
|
DEFAULT_MODEL.fireTableDataChanged();
|
||||||
/* loading new file may change active layers */
|
/* loading new file may change active layers */
|
||||||
GuiHelper.runInEDT(ACTIVE_MODEL::fireTableDataChanged);
|
ACTIVE_MODEL.fireTableDataChanged();
|
||||||
|
this.setEnabled(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue