[fix] prevented exception when you remove a optimization row while editing it.

This commit is contained in:
Daniel_M_Williams 2020-07-26 16:41:12 -04:00
parent 28ba049975
commit d7c0e9d8ac

View File

@ -249,7 +249,8 @@ public class GeneralOptimizationDialog extends JDialog {
return selectedModifiers.get(row).getUnitGroup(); return selectedModifiers.get(row).getUnitGroup();
} }
}); });
selectedModifierTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
disableComponents.add(selectedModifierTable); disableComponents.add(selectedModifierTable);
selectedModifierTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { selectedModifierTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@ -291,6 +292,9 @@ public class GeneralOptimizationDialog extends JDialog {
} else { } else {
log.error("Attempting to add simulation modifier when none is selected"); log.error("Attempting to add simulation modifier when none is selected");
} }
if (selectedModifierTable.isEditing()) {
selectedModifierTable.getCellEditor().stopCellEditing();
}
} }
}); });
disableComponents.add(addButton); disableComponents.add(addButton);
@ -306,6 +310,11 @@ public class GeneralOptimizationDialog extends JDialog {
log.error("Attempting to remove simulation modifier when none is selected"); log.error("Attempting to remove simulation modifier when none is selected");
return; return;
} }
if (selectedModifierTable.isEditing()) {
selectedModifierTable.getCellEditor().stopCellEditing();
}
removeModifier(mod); removeModifier(mod);
clearHistory(); clearHistory();
} }