(Box root)
| 20 | protected final Box root; |
| 21 | |
| 22 | public Delete(Box root) { |
| 23 | |
| 24 | this.properties.put(Planes.plane, "__root__ creation"); |
| 25 | |
| 26 | this.root = root; |
| 27 | this.properties.putToMap(Keyboard.onKeyDown, "__delete__", (event, key) -> { |
| 28 | if (event.properties.isTrue(Window.consumed, false)) return null; |
| 29 | if (event.after.isSuperDown() && key == GLFW_KEY_DELETE) { |
| 30 | { |
| 31 | Stream<Box> all = selected(); |
| 32 | all.forEach(bb -> Callbacks.delete(bb)); |
| 33 | } |
| 34 | { |
| 35 | Stream<Box> all = selected(); |
| 36 | all.forEach(bb -> bb.disconnectFromAll()); |
| 37 | } |
| 38 | Drawing.dirty(Delete.this); |
| 39 | } |
| 40 | return null; |
| 41 | }); |
| 42 | |
| 43 | properties.put(MarkingMenus.menuSpecs, (event) -> { |
| 44 | if (selected().findAny() |
| 45 | .isPresent()) { |
| 46 | MarkingMenus.MenuSpecification spec = new MarkingMenus.MenuSpecification(); |
| 47 | long count = selected().count(); |
| 48 | |
| 49 | MarkingMenus.MenuSpecification really = new MarkingMenus.MenuSpecification(); |
| 50 | really.items.put(MarkingMenus.Position.N2, new MarkingMenus.MenuItem( |
| 51 | "Really, delete " + count + " " + name(selected()) + (count == 1 ? "" : "es") + "?", () -> { |
| 52 | { |
| 53 | Stream<Box> all = selected(); |
| 54 | all.forEach(bb -> Callbacks.delete(bb)); |
| 55 | } |
| 56 | { |
| 57 | Stream<Box> all = selected(); |
| 58 | all.forEach(bb -> bb.disconnectFromAll()); |
| 59 | } |
| 60 | |
| 61 | find(Watches.watches, both()).forEach(w -> w.getQueue() |
| 62 | .accept("selection.changed", null)); |
| 63 | |
| 64 | Drawing.dirty(Delete.this); |
| 65 | })); |
| 66 | |
| 67 | spec.items.put(MarkingMenus.Position.S2, |
| 68 | new MarkingMenus.MenuItem("Delete " + count + " " + name(selected()) + (count == 1 ? "" : "es"), () -> { |
| 69 | }).setSubmenu(really)); |
| 70 | |
| 71 | // disconnected for now |
| 72 | { |
| 73 | List cc = selectedNoGroups().flatMap(x -> x.breadthFirst(x.downwards()) |
| 74 | .filter(y -> x != y)) |
| 75 | .filter(x -> !x.properties.isTrue(Box.hidden, false)) |
| 76 | .filter(x -> !x.properties.isTrue(Box.decorative, false)) |
| 77 | .collect(Collectors.toList()); |
| 78 | |
| 79 | long c = cc.size(); |
nothing calls this directly
no test coverage detected