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

Method RemoteEditor

src/main/java/fielded/RemoteEditor.java:116–936  ·  view source on GitHub ↗
(Server server, String sn, Watches watches, MessageQueue<Quad<Dict.Prop, Box, Object, Object>, String> queue)

Source from the content-addressed store, hash-verified

114 AtomicReference<String> completionHelp = new AtomicReference<>("");
115
116
117 public RemoteEditor(Server server, String sn, Watches watches, MessageQueue<Quad<Dict.Prop, Box, Object, Object>, String> queue) {
118 this.server = server;
119 this.socketName = sn; // we now let this vary on request
120 this.queue = queue;
121 this.watches = watches;
122 this.properties.put(editor, this);
123 this.properties.put(Boxes.dontSave, true);
124
125 this.properties.putToMap(Boxes.insideRunLoop, "main.__watch_service__", this::update);
126 this.properties.put(editorUtils, new EditorUtils(this));
127
128 watches.addWatch(Mouse.isSelected, "selection.changed");
129 watches.addWatch(LinuxWindowTricks.lostFocus, "focus.editor");
130
131 queue.register(Predicate.isEqual("selection.changed"), (c) -> {
132 Log.log("remote.trace", () -> " selection changed message ");
133 selectionHasChanged = true;
134 });
135
136 queue.register(Predicate.isEqual("focus.editor"), (c) -> {
137 Log.log("remote.trace", () -> " sending focus request ");
138 server.send(socketName, "_messageBus.publish('focus', {})");
139 });
140
141 server.addHandlerLast(x -> x.equals("log"), (s, socket, address, payload) -> {
142
143 if (logStack.size() > 0) logStack.get(logStack.size() - 1)
144 .accept("" + payload);
145
146 return payload;
147 });
148
149 server.addHandlerLast(x -> x.equals("error"), (s, socket, address, payload) -> {
150
151 if (logStack.size() > 0) errorStack.get(errorStack.size() - 1)
152 .accept("" + payload);
153
154 return payload;
155 });
156
157 server.addHandlerLast(Predicate.isEqual("focus.window"), () -> socketName, (s, socket, address, payload) -> {
158 find(Boxes.window, both()).findFirst()
159 .ifPresent(w -> w.requestRaise());
160 return payload;
161 });
162
163 this.properties.put(outputFactory, x -> newOutput(x, "box.output", (m) -> new JSONStringer().object()
164 .key("type")
165 .value("success")
166 .key("message")
167 .value(m)
168 .key("append")
169 .value(true)
170 .key("tick")
171 .value(RunLoop.getTick())
172 .endObject()
173 .toString()));

Callers

nothing calls this directly

Calls 15

logMethod · 0.95
requestRaiseMethod · 0.95
newOutputMethod · 0.95
getTickMethod · 0.95
findBoxByIDMethod · 0.95
callMethod · 0.95
parseDisabledRangesMethod · 0.95
incrementalUpdateMethod · 0.95
getExecutionMethod · 0.95
persistMethod · 0.95
boxFeedbackMethod · 0.95

Tested by

no test coverage detected