Fix multi-select for stages
This commit is contained in:
parent
7ee5a17af9
commit
d82058417a
@ -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]));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user