Clean up code
This commit is contained in:
parent
68d2236654
commit
9a0bec1370
@ -185,7 +185,7 @@ public class BasicFrame extends JFrame {
|
|||||||
// Create RocketActions
|
// Create RocketActions
|
||||||
actions = new RocketActions(document, selectionModel, this, simulationPanel);
|
actions = new RocketActions(document, selectionModel, this, simulationPanel);
|
||||||
}
|
}
|
||||||
designPanel = new DesignPanel(this, rocketpanel, document, tree);
|
designPanel = new DesignPanel(this, document, tree);
|
||||||
flightConfigurationPanel = new FlightConfigurationPanel(this, document);
|
flightConfigurationPanel = new FlightConfigurationPanel(this, document);
|
||||||
tabbedPane = new JTabbedPane();
|
tabbedPane = new JTabbedPane();
|
||||||
tabbedPane.addTab(trans.get("BasicFrame.tab.Rocketdesign"), null, designPanel);
|
tabbedPane.addTab(trans.get("BasicFrame.tab.Rocketdesign"), null, designPanel);
|
||||||
|
@ -51,8 +51,7 @@ public class DesignPanel extends JSplitPane {
|
|||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private final Component tree;
|
private final Component tree;
|
||||||
|
|
||||||
public DesignPanel(final BasicFrame parent, final RocketPanel rocketpanel, final OpenRocketDocument document,
|
public DesignPanel(final BasicFrame parent, final OpenRocketDocument document, final ComponentTree tree) {
|
||||||
final ComponentTree tree) {
|
|
||||||
super(JSplitPane.HORIZONTAL_SPLIT, true);
|
super(JSplitPane.HORIZONTAL_SPLIT, true);
|
||||||
setResizeWeight(0.5);
|
setResizeWeight(0.5);
|
||||||
this.tree = tree;
|
this.tree = tree;
|
||||||
@ -75,10 +74,10 @@ public class DesignPanel extends JSplitPane {
|
|||||||
@Override
|
@Override
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
public void valueChanged(TreeSelectionEvent e) {
|
||||||
if (tree == null || tree.getSelectionPaths() == null || tree.getSelectionPaths().length == 0
|
if (tree == null || tree.getSelectionPaths() == null || tree.getSelectionPaths().length == 0
|
||||||
|| rocketpanel == null) return;
|
|| parent.getRocketPanel() == null) return;
|
||||||
|
|
||||||
// Get all the components that need to be selected = currently selected components + children of stages/boosters/podsets
|
// Get all the components that need to be selected = currently selected components + children of stages/boosters/podsets
|
||||||
List<RocketComponent> children = new ArrayList<>(Arrays.asList(rocketpanel.getFigure().getSelection()));
|
List<RocketComponent> children = new ArrayList<>(Arrays.asList(parent.getRocketPanel().getFigure().getSelection()));
|
||||||
for (TreePath p : tree.getSelectionPaths()) {
|
for (TreePath p : tree.getSelectionPaths()) {
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
RocketComponent c = (RocketComponent) p.getLastPathComponent();
|
RocketComponent c = (RocketComponent) p.getLastPathComponent();
|
||||||
@ -93,9 +92,9 @@ public class DesignPanel extends JSplitPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Select all the child components
|
// Select all the child components
|
||||||
if (rocketpanel.getFigure() != null && rocketpanel.getFigure3d() != null) {
|
if (parent.getRocketPanel().getFigure() != null && parent.getRocketPanel().getFigure3d() != null) {
|
||||||
rocketpanel.getFigure().setSelection(children.toArray(new RocketComponent[0]));
|
parent.getRocketPanel().getFigure().setSelection(children.toArray(new RocketComponent[0]));
|
||||||
rocketpanel.getFigure3d().setSelection(children.toArray(new RocketComponent[0]));
|
parent.getRocketPanel().getFigure3d().setSelection(children.toArray(new RocketComponent[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user