Fix selection issue in motor, recovery and stage table
This commit is contained in:
parent
78aaeed1b5
commit
7b54af2623
@ -194,10 +194,27 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
|
|||||||
configurationTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
configurationTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||||
configurationTable.setDefaultRenderer(Object.class, new MotorTableCellRenderer());
|
configurationTable.setDefaultRenderer(Object.class, new MotorTableCellRenderer());
|
||||||
|
|
||||||
|
ListSelectionListener listener = new ListSelectionListener() {
|
||||||
|
private int previousRow = -1;
|
||||||
|
private int previousColumn = -1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent event) {
|
||||||
|
if (table != null && (configurationTable.getSelectedRow() != previousRow ||
|
||||||
|
configurationTable.getSelectedColumn() != previousColumn)) {
|
||||||
|
updateButtonState();
|
||||||
|
previousRow = configurationTable.getSelectedRow();
|
||||||
|
previousColumn = configurationTable.getSelectedColumn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
configurationTable.getSelectionModel().addListSelectionListener(listener);
|
||||||
|
configurationTable.getColumnModel().getSelectionModel().addListSelectionListener(listener);
|
||||||
|
|
||||||
configurationTable.addMouseListener(new MouseAdapter() {
|
configurationTable.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
updateButtonState();
|
|
||||||
int selectedColumn = table.getSelectedColumn();
|
int selectedColumn = table.getSelectedColumn();
|
||||||
|
|
||||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||||
|
@ -17,6 +17,8 @@ import javax.swing.JTable;
|
|||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import net.sf.openrocket.formatting.RocketDescriptor;
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.dialogs.flightconfiguration.DeploymentSelectionDialog;
|
import net.sf.openrocket.gui.dialogs.flightconfiguration.DeploymentSelectionDialog;
|
||||||
@ -89,10 +91,28 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
|||||||
recoveryTable.getTableHeader().setReorderingAllowed(false);
|
recoveryTable.getTableHeader().setReorderingAllowed(false);
|
||||||
recoveryTable.setCellSelectionEnabled(true);
|
recoveryTable.setCellSelectionEnabled(true);
|
||||||
recoveryTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
recoveryTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||||
|
|
||||||
|
ListSelectionListener listener = new ListSelectionListener() {
|
||||||
|
private int previousRow = -1;
|
||||||
|
private int previousColumn = -1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent event) {
|
||||||
|
if (table != null && (recoveryTable.getSelectedRow() != previousRow ||
|
||||||
|
recoveryTable.getSelectedColumn() != previousColumn)) {
|
||||||
|
updateButtonState();
|
||||||
|
previousRow = recoveryTable.getSelectedRow();
|
||||||
|
previousColumn = recoveryTable.getSelectedColumn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
recoveryTable.getSelectionModel().addListSelectionListener(listener);
|
||||||
|
recoveryTable.getColumnModel().getSelectionModel().addListSelectionListener(listener);
|
||||||
|
|
||||||
recoveryTable.addMouseListener(new MouseAdapter() {
|
recoveryTable.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
updateButtonState();
|
|
||||||
int selectedColumn = table.getSelectedColumn();
|
int selectedColumn = table.getSelectedColumn();
|
||||||
|
|
||||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||||
@ -108,6 +128,7 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rocket.addComponentChangeListener(cce -> {
|
rocket.addComponentChangeListener(cce -> {
|
||||||
final RocketComponent source = cce.getSource();
|
final RocketComponent source = cce.getSource();
|
||||||
if(source instanceof FlightConfigurableComponent) {
|
if(source instanceof FlightConfigurableComponent) {
|
||||||
|
@ -17,6 +17,8 @@ import javax.swing.JTable;
|
|||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.event.ListSelectionEvent;
|
||||||
|
import javax.swing.event.ListSelectionListener;
|
||||||
|
|
||||||
import net.sf.openrocket.formatting.RocketDescriptor;
|
import net.sf.openrocket.formatting.RocketDescriptor;
|
||||||
import net.sf.openrocket.gui.dialogs.flightconfiguration.SeparationSelectionDialog;
|
import net.sf.openrocket.gui.dialogs.flightconfiguration.SeparationSelectionDialog;
|
||||||
@ -109,10 +111,28 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
|||||||
separationTable.getTableHeader().setReorderingAllowed(false);
|
separationTable.getTableHeader().setReorderingAllowed(false);
|
||||||
separationTable.setCellSelectionEnabled(true);
|
separationTable.setCellSelectionEnabled(true);
|
||||||
separationTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
separationTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||||
|
|
||||||
|
ListSelectionListener listener = new ListSelectionListener() {
|
||||||
|
private int previousRow = -1;
|
||||||
|
private int previousColumn = -1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void valueChanged(ListSelectionEvent event) {
|
||||||
|
if (table != null && (separationTable.getSelectedRow() != previousRow ||
|
||||||
|
separationTable.getSelectedColumn() != previousColumn)) {
|
||||||
|
updateButtonState();
|
||||||
|
previousRow = separationTable.getSelectedRow();
|
||||||
|
previousColumn = separationTable.getSelectedColumn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
separationTable.getSelectionModel().addListSelectionListener(listener);
|
||||||
|
separationTable.getColumnModel().getSelectionModel().addListSelectionListener(listener);
|
||||||
|
|
||||||
separationTable.addMouseListener(new MouseAdapter() {
|
separationTable.addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
updateButtonState();
|
|
||||||
int selectedColumn = table.getSelectedColumn();
|
int selectedColumn = table.getSelectedColumn();
|
||||||
|
|
||||||
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
|
||||||
@ -128,6 +148,7 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
separationTable.setDefaultRenderer(Object.class, new SeparationTableCellRenderer());
|
separationTable.setDefaultRenderer(Object.class, new SeparationTableCellRenderer());
|
||||||
|
|
||||||
return separationTable;
|
return separationTable;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user