Fix focus lost motors, recovery & stage

This commit is contained in:
SiboVG 2022-07-31 11:05:52 +02:00
parent 6ff6265c3a
commit e13c4baf25
5 changed files with 14 additions and 19 deletions

View File

@ -136,6 +136,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
synchronizePanelSelection(previousPanel, panel);
panel.updateButtonState();
panel.takeTheSpotlight();
panel.updateRocketViewSelection();
previousPanel = panel;
}
});
@ -397,12 +398,15 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
switch (tabs.getSelectedIndex()) {
case MOTOR_TAB_INDEX:
motorConfigurationPanel.takeTheSpotlight();
motorConfigurationPanel.updateRocketViewSelection();
break;
case RECOVERY_TAB_INDEX:
recoveryConfigurationPanel.takeTheSpotlight();
recoveryConfigurationPanel.updateRocketViewSelection();
break;
case SEPARATION_TAB_INDEX:
separationConfigurationPanel.takeTheSpotlight();
separationConfigurationPanel.updateRocketViewSelection();
break;
}
}

View File

@ -3,8 +3,6 @@ package net.sf.openrocket.gui.main.flightconfigpanel;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Arrays;
@ -186,19 +184,7 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
table.getColumnModel().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
updateComponentSelection(e);
}
});
table.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
updateComponentSelection(new ListSelectionEvent(this, 0, 0, false));
}
@Override
public void focusLost(FocusEvent e) {
updateRocketViewSelection(e);
}
});
}
@ -214,10 +200,15 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
table.clearSelection();
}
public void updateRocketViewSelection() {
ListSelectionEvent e = new ListSelectionEvent(this, 0, 0, false);
updateRocketViewSelection(e);
}
/**
* Update the selection in the rocket design view, based on the currently selected motor, recovery device, or stage.
*/
protected abstract void updateComponentSelection(ListSelectionEvent e);
public abstract void updateRocketViewSelection(ListSelectionEvent e);
protected T getSelectedComponent() {

View File

@ -253,7 +253,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
popupMenuFull.show(e.getComponent(), e.getX(), e.getY());
}
public void updateComponentSelection(ListSelectionEvent e) {
public void updateRocketViewSelection(ListSelectionEvent e) {
if (e.getValueIsAdjusting()) {
return;
}

View File

@ -245,7 +245,7 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
popupMenuFull.show(e.getComponent(), e.getX(), e.getY());
}
public void updateComponentSelection(ListSelectionEvent e) {
public void updateRocketViewSelection(ListSelectionEvent e) {
if (e.getValueIsAdjusting() || getSelectedComponents() == null) {
return;
}

View File

@ -255,7 +255,7 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
popupMenuFull.show(e.getComponent(), e.getX(), e.getY());
}
public void updateComponentSelection(ListSelectionEvent e) {
public void updateRocketViewSelection(ListSelectionEvent e) {
if (e.getValueIsAdjusting() || getSelectedComponents() == null) {
return;
}