diff --git a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java index 6f923e79e..f83ef3fb4 100644 --- a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java +++ b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java @@ -74,6 +74,7 @@ import net.sf.openrocket.logging.Markers; import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.ComponentChangeEvent; import net.sf.openrocket.rocketcomponent.ComponentChangeListener; +import net.sf.openrocket.rocketcomponent.PodSet; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.startup.Application; @@ -295,7 +296,30 @@ public class BasicFrame extends JFrame { im.put(KeyStroke.getKeyStroke(KeyEvent.VK_O, SHORTCUT_KEY), null); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, SHORTCUT_KEY), null); + // Visually select all child components of a stage/rocket/podset when it is selected + componentSelectionModel.addTreeSelectionListener(new TreeSelectionListener() { + @Override + public void valueChanged(TreeSelectionEvent e) { + TreePath selPath = e.getNewLeadSelectionPath(); + if (selPath == null) return; + RocketComponent c = (RocketComponent) selPath.getLastPathComponent(); + if (c instanceof AxialStage || c instanceof Rocket || c instanceof PodSet) { + if (rocketpanel == null) return; + + List children = new LinkedList<>(); + for (RocketComponent child : c) { + children.add(child); + } + + // Select all the child components + if (rocketpanel.getFigure() != null && rocketpanel.getFigure3d() != null) { + rocketpanel.getFigure().setSelection(children.toArray(new RocketComponent[0])); + rocketpanel.getFigure3d().setSelection(children.toArray(new RocketComponent[0])); + } + } + } + }); // Double-click opens config dialog MouseListener ml = new MouseAdapter() { diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index c7b48bc35..92df95906 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -421,6 +421,10 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change return figure; } + public RocketFigure3d getFigure3d() { + return figure3d; + } + public AerodynamicCalculator getAerodynamicCalculator() { return aerodynamicCalculator; }