(Box root, String filename)
| 57 | public DefaultMenus(Box root, String filename) { |
| 58 | this.root = root; |
| 59 | this.filename = filename; |
| 60 | properties.put(MarkingMenus.menuSpecs, (event) -> { |
| 61 | if (isNothingSelected()) { |
| 62 | |
| 63 | MarkingMenus.MenuSpecification spec = new MarkingMenus.MenuSpecification(); |
| 64 | |
| 65 | MarkingMenus.MenuSpecification saveMenu = new MarkingMenus.MenuSpecification(); |
| 66 | saveMenu.items.put(MarkingMenus.Position.E, new MarkingMenus.MenuItem("Save", () -> { |
| 67 | save(); |
| 68 | })); |
| 69 | |
| 70 | saveMenu.items.put(MarkingMenus.Position.S, new MarkingMenus.MenuItem(saveOnExit ? "Save on exit (toggle)" : "Don't save on exit (toggle)", () -> { |
| 71 | saveOnExit = !saveOnExit; |
| 72 | })); |
| 73 | |
| 74 | spec.items.put(MarkingMenus.Position.E, new MarkingMenus.MenuItem("Save...", () -> { |
| 75 | save(); |
| 76 | }).setSubmenu(saveMenu)); |
| 77 | spec.items.put(MarkingMenus.Position.N, new MarkingMenus.MenuItem("New Box", () -> { |
| 78 | Vec2 at = convertCoordinateSystem(event.after); |
| 79 | newBox(at, root); |
| 80 | })); |
| 81 | |
| 82 | return spec; |
| 83 | } |
| 84 | return null; |
| 85 | }); |
| 86 | |
| 87 | properties.putToMap(Keyboard.onCharTyped, "__hotkeymenus__", (e, k) -> { |
| 88 | if (e.properties.isTrue(Window.consumed, false)) return; |
| 89 | |
| 90 | if (k == 'n') |
| 91 | newBox(convertCoordinateSystem(e.after.mouseState), root); |
| 92 | }); |
| 93 | |
| 94 | properties.put(setClass, (box, clazz) -> { |
| 95 | |
| 96 | if (!Box.class.isAssignableFrom(clazz)) |
| 97 | throw new ClassCastException(" class '" + clazz + "' isn't a Box subclass"); |
| 98 | |
| 99 | if (box.getClass().equals(clazz)) // nothing to do |
| 100 | return box; |
| 101 | |
| 102 | Set<Box> c = new LinkedHashSet<>(box.children()); |
| 103 | Set<Box> p = new LinkedHashSet<>(box.parents()); |
| 104 | |
| 105 | try { |
| 106 | Box newBox = DragToCopy.duplicateBox(box, clazz, Collections.emptyList()); |
| 107 | |
| 108 | for (Box cc : c) |
| 109 | newBox.connect(cc); |
| 110 | for (Box pp : p) |
| 111 | pp.connect(newBox); |
| 112 | |
| 113 | box.disconnectFromAll(); |
| 114 | |
| 115 | return newBox; |
| 116 | } catch (NullPointerException e) { |
nothing calls this directly
no test coverage detected