Merge pull request #1499 from SiboVG/issue-1490
[#1490] Select recovery device/stage after config panel select
This commit is contained in:
commit
3444a968f3
@ -19,6 +19,7 @@ import java.net.URL;
|
|||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@ -300,23 +301,28 @@ public class BasicFrame extends JFrame {
|
|||||||
componentSelectionModel.addTreeSelectionListener(new TreeSelectionListener() {
|
componentSelectionModel.addTreeSelectionListener(new TreeSelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
public void valueChanged(TreeSelectionEvent e) {
|
||||||
TreePath selPath = e.getNewLeadSelectionPath();
|
if (tree == null || tree.getSelectionPaths() == null || tree.getSelectionPaths().length == 0
|
||||||
if (selPath == null) return;
|
|| rocketpanel == null) return;
|
||||||
RocketComponent c = (RocketComponent) selPath.getLastPathComponent();
|
|
||||||
|
|
||||||
if (c instanceof AxialStage || c instanceof Rocket || c instanceof PodSet) {
|
// Get all the components that need to be selected = currently selected components + children of stages/boosters/podsets
|
||||||
if (rocketpanel == null) return;
|
List<RocketComponent> children = new ArrayList<>(Arrays.asList(rocketpanel.getFigure().getSelection()));
|
||||||
|
for (TreePath p : tree.getSelectionPaths()) {
|
||||||
List<RocketComponent> children = new LinkedList<>();
|
if (p != null) {
|
||||||
for (RocketComponent child : c) {
|
RocketComponent c = (RocketComponent) p.getLastPathComponent();
|
||||||
children.add(child);
|
if (c instanceof AxialStage || c instanceof Rocket || c instanceof PodSet) {
|
||||||
|
Iterator<RocketComponent> iter = c.iterator(false);
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
RocketComponent child = iter.next();
|
||||||
|
children.add(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Select all the child components
|
// Select all the child components
|
||||||
if (rocketpanel.getFigure() != null && rocketpanel.getFigure3d() != null) {
|
if (rocketpanel.getFigure() != null && rocketpanel.getFigure3d() != null) {
|
||||||
rocketpanel.getFigure().setSelection(children.toArray(new RocketComponent[0]));
|
rocketpanel.getFigure().setSelection(children.toArray(new RocketComponent[0]));
|
||||||
rocketpanel.getFigure3d().setSelection(children.toArray(new RocketComponent[0]));
|
rocketpanel.getFigure3d().setSelection(children.toArray(new RocketComponent[0]));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package net.sf.openrocket.gui.main.flightconfigpanel;
|
package net.sf.openrocket.gui.main.flightconfigpanel;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
@ -162,6 +165,30 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
|||||||
return recoveryTable;
|
return recoveryTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installTableListener() {
|
||||||
|
super.installTableListener();
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void selectDeployment() {
|
public void selectDeployment() {
|
||||||
List<RecoveryDevice> devices = getSelectedComponents();
|
List<RecoveryDevice> devices = getSelectedComponents();
|
||||||
List<FlightConfigurationId> fcIds = getSelectedConfigurationIds();
|
List<FlightConfigurationId> fcIds = getSelectedConfigurationIds();
|
||||||
@ -239,6 +266,16 @@ public class RecoveryConfigurationPanel extends FlightConfigurablePanel<Recovery
|
|||||||
popupMenuFull.show(e.getComponent(), e.getX(), e.getY());
|
popupMenuFull.show(e.getComponent(), e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateComponentSelection(ListSelectionEvent e) {
|
||||||
|
if (e.getValueIsAdjusting() || getSelectedComponents() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<RocketComponent> components = new ArrayList<>(getSelectedComponents());
|
||||||
|
if (components.size() == 0) return;
|
||||||
|
|
||||||
|
flightConfigurationPanel.setSelectedComponents(components);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateButtonState() {
|
public void updateButtonState() {
|
||||||
boolean componentSelected = getSelectedComponent() != null;
|
boolean componentSelected = getSelectedComponent() != null;
|
||||||
selectDeploymentButton.setEnabled(componentSelected);
|
selectDeploymentButton.setEnabled(componentSelected);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package net.sf.openrocket.gui.main.flightconfigpanel;
|
package net.sf.openrocket.gui.main.flightconfigpanel;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
@ -27,6 +30,7 @@ import net.sf.openrocket.rocketcomponent.AxialStage;
|
|||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
|
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration.SeparationEvent;
|
import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration.SeparationEvent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
@ -170,6 +174,30 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
|||||||
return separationTable;
|
return separationTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installTableListener() {
|
||||||
|
super.installTableListener();
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void selectSeparation() {
|
public void selectSeparation() {
|
||||||
List<AxialStage> stages = getSelectedComponents();
|
List<AxialStage> stages = getSelectedComponents();
|
||||||
List<FlightConfigurationId> fcIds = getSelectedConfigurationIds();
|
List<FlightConfigurationId> fcIds = getSelectedConfigurationIds();
|
||||||
@ -248,6 +276,16 @@ public class SeparationConfigurationPanel extends FlightConfigurablePanel<AxialS
|
|||||||
popupMenuFull.show(e.getComponent(), e.getX(), e.getY());
|
popupMenuFull.show(e.getComponent(), e.getX(), e.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateComponentSelection(ListSelectionEvent e) {
|
||||||
|
if (e.getValueIsAdjusting() || getSelectedComponents() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<RocketComponent> components = new ArrayList<>(getSelectedComponents());
|
||||||
|
if (components.size() == 0) return;
|
||||||
|
|
||||||
|
flightConfigurationPanel.setSelectedComponents(components);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateButtonState() {
|
public void updateButtonState() {
|
||||||
boolean componentSelected = getSelectedComponent() != null;
|
boolean componentSelected = getSelectedComponent() != null;
|
||||||
selectSeparationButton.setEnabled(componentSelected);
|
selectSeparationButton.setEnabled(componentSelected);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user