Merge pull request #1732 from SiboVG/issue-1731

[#1731] Catch out-of-range sim table click earlier on
This commit is contained in:
Sibo Van Gool 2022-10-10 20:49:26 +02:00 committed by GitHub
commit 304289350a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -183,22 +183,19 @@ public class SimulationPanel extends JPanel {
@Override
public void mouseClicked(MouseEvent e) {
int selectedRow = simulationTable.getSelectedRow();
int row = simulationTable.rowAtPoint(e.getPoint());
int column = simulationTable.columnAtPoint(e.getPoint());
// Clear the table selection when clicked outside the table rows.
if (row == -1 || column == -1 || selectedRow == -1) {
simulationTable.clearSelection();
return;
}
if (e.getButton() == MouseEvent.BUTTON1) {
// Clear the table selection when clicked outside the table rows.
if (e.getClickCount() == 1) {
int row = simulationTable.rowAtPoint(e.getPoint());
int column = simulationTable.columnAtPoint(e.getPoint());
if (row == -1 || column == -1) {
simulationTable.clearSelection();
}
}
// Edit the simulation or plot/export
else if (e.getClickCount() == 2) {
if (e.getClickCount() == 2) {
int selected = simulationTable.convertRowIndexToModel(selectedRow);
int column = simulationTable.columnAtPoint(e.getPoint());
if (column == 0) {
SimulationWarningDialog.showWarningDialog(SimulationPanel.this, document.getSimulations().get(selected));
} else {