[fixes #358] Implement deselection in RocketPanel multi-select
This commit is contained in:
parent
04b9332920
commit
d82c541464
@ -535,12 +535,16 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
// If the shift-button is held, add a newly clicked component to the selection path
|
// If the shift-button is held, add a newly clicked component to the selection path
|
||||||
if ((event.isShiftDown() || event.isMetaDown()) && event.getClickCount() == 1) {
|
if ((event.isShiftDown() || event.isMetaDown()) && event.getClickCount() == 1) {
|
||||||
List<TreePath> paths = new ArrayList<>(Arrays.asList(selectionModel.getSelectionPaths()));
|
List<TreePath> paths = new ArrayList<>(Arrays.asList(selectionModel.getSelectionPaths()));
|
||||||
for (RocketComponent component : clicked) {
|
for (int i = 0; i < clicked.length; i++) {
|
||||||
if (!selectedComponents.contains(component)) {
|
if (!selectedComponents.contains(clicked[i])) {
|
||||||
TreePath path = ComponentTreeModel.makeTreePath(component);
|
TreePath path = ComponentTreeModel.makeTreePath(clicked[i]);
|
||||||
paths.add(path);
|
paths.add(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// If all the clicked components are already in the selection, then deselect an object
|
||||||
|
if (i == clicked.length - 1) {
|
||||||
|
paths.removeIf(path -> path.getLastPathComponent() == clicked[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
selectionModel.setSelectionPaths(paths.toArray(new TreePath[0]));
|
selectionModel.setSelectionPaths(paths.toArray(new TreePath[0]));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user