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

Class InternalCSS

src/main/java/fieldbox/boxes/plugins/InternalCSS.java:17–46  ·  view source on GitHub ↗

Created by marc on 4/15/15.

Source from the content-addressed store, hash-verified

15 * Created by marc on 4/15/15.
16 */
17public class InternalCSS extends Box {
18
19 static public final Dict.Prop<String> css = new Dict.Prop<>("css").toCanon();
20
21 static
22 {
23 IO.persist(css);
24 FieldBox.fieldBox.io.addFilespec("css", ".css", "css");
25 }
26
27 public InternalCSS()
28 {
29 properties.put(Commands.commands, () -> {
30 Map<Pair<String, String>, Runnable> m = new LinkedHashMap<>();
31 RemoteEditor ed = this.find(RemoteEditor.editor, both()).findFirst().get();
32
33 Box box = ed.getCurrentlyEditing();
34 Dict.Prop<String> cep = ed.getCurrentlyEditingProperty();
35
36 if (box == null) return m;
37
38 if (!cep.equals(css) && (box.first(css, box.upwards()).isPresent()))
39 m.put(new Pair<>("Edit <i>CSS</i>", "Switch to editing css file associated with this box. You can inject this css into a browser with `_.injectCSS(_.css)`. So, for example, `_.textEditor.injectCSS(_.css)` will dump the css in this box into the `_.textEditor`"), () -> {
40 ed.setCurrentlyEditingProperty(css);
41 });
42 return m;
43 });
44 }
45
46}

Callers

nothing calls this directly

Calls 3

persistMethod · 0.95
toCanonMethod · 0.80
addFilespecMethod · 0.80

Tested by

no test coverage detected