MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / update

Method update

src/main/java/fieldcef/plugins/Taps.java:98–215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96 this.properties.putToMap(Boxes.insideRunLoop, "main.__activate/deactivate__", this::update);
97 }
98
99 protected boolean update() {
100 if (selectionHasChanged) {
101 selectionHasChanged = false;
102 if (selectionWas != null) {
103 Binding wasBinding = selectionWas.properties.get(tapBinding);
104 if (wasBinding != null) {
105 deactivate(wasBinding);
106 }
107 selectionWas = null;
108 }
109
110 if (selection().count() == 1) {
111 Box next = selection().findFirst()
112 .get();
113
114 next.children.forEach( x-> {
115 Binding nextBinding = x.properties.get(tapBinding);
116 if (nextBinding != null) {
117 activate(nextBinding);
118 }
119 });
120
121 selectionWas = next;
122 }
123 }
124
125 List<Runnable> r = new ArrayList<>(queue.values());
126 queue.clear();
127 r.forEach(x -> x.run());
128
129
130 if (!editorLoaded && first(Watches.watches, both()).isPresent()) {
131 Optional<RemoteEditor> first = this.first(RemoteEditor.editor, both());
132 Log.log("tap", () -> "is the editor loaded yet ? " + first);
133
134 if (first.isPresent()) {
135 editorLoaded = true;
136 RemoteEditor editor = first.get();
137
138 editor.getServer()
139 .addHandlerLast(Predicate.isEqual("taps.activeset"), (s, socket, address, payload) -> {
140
141// Log.log("tap", () -> "tap.activeset recieved ");
142
143 System.out.println(" tap.activeset recieved ");
144
145 // the list of the active taps inside:
146 Box e = editor.getCurrentlyEditing();
147 if (e == null) {
148 Log.log("tap", () -> "nothing being edited");
149 return payload;
150 }
151
152 queue.put("updateTapsFrom", () -> {
153
154 // clean these out on demand
155

Callers

nothing calls this directly

Calls 15

deactivateMethod · 0.95
selectionMethod · 0.95
activateMethod · 0.95
logMethod · 0.95
getServerMethod · 0.95
getCurrentlyEditingMethod · 0.95
childrenMethod · 0.95
deleteMethod · 0.95
updatePositionMethod · 0.95
addWatchMethod · 0.95
countMethod · 0.80
isPresentMethod · 0.80

Tested by

no test coverage detected