sclass InterestingString extends Module { S theString; transient SimpleLiveValue lv = new(S); void update { lv.set(theString); } JComponent visualize() { ret centerLabel(jLiveValueLabel(lv)); } } sclass UpdateCycles extends Module { long value; transient SimpleLiveValue lv = new(S); void update { value = updateCycles; lv.set(str(value)); } JComponent visualize() { ret jSection("INTERNAL UPDATES", onLeftClick(centerLabel(makeBold(setFontSize(40, jLiveValueLabel(lv)))), rstUpdateModules)); } void enhanceFrame(JInternalFrame f) { internalFrameTitlePopupMenuItem(f, "Update", rstUpdateModules); } } sclass InputToInterestingString extends Module { transient java.util.Timer timer; transient S lastHello, lastTop; void start { timer = doEvery(1000, r { Hello h = findModule(Hello); S hello = h == null ? null : h.tf != null ? getText(h.tf) : h.text; S top = getText(tfTopInput); S value = null; if (neq(hello, lastHello)) value = hello; else if (neq(top, lastTop)) value = top; if (value == null) value = or2(top, hello); lastHello = hello; lastTop = top; startModule(csetAndReturn(uniq(InterestingString), theString := value)); }); } void cleanMeUp() { cancelTimer(timer); } } sclass ModuleCount extends Module { transient JLabel label; void update { if (label != null) setText(label, lstr(onModules())); } JComponent visualize() { ret jSection("MODULES", label = setFontSize(30, jcenteredlabel(lstr(onModules())))); } void unvisualize2() { label = null; } } sclass ModuleList extends StaticModule_CalculatedList { transient AutoCloseable listener; *() { listener = vmBus_onMessages(vmBus_modulesListChangeMessages(), rThread { //print("Updating module list"); update(); }); } void cleanMeUp_ml { closeAutoCloseable(listener); } Module getModule(S item) { ret getConcept(Module, parseFirstLong(item)); } S moduleName() { if (eq(getClass(), ModuleList)) ret "Loaded Modules"; ret super.moduleName(); } JComponent visualize() { super.visualize(); onDoubleClickOrEnter(list, voidfunc(fS s) { showModule(getModule(s)) }); listPopupMenuItemsThreaded(list, "Delete", voidfunc(fS s) { removeConcept(getModule(s)) }, "Show", voidfunc(fS s) { showModule(getModule(s)) }, "Hide", voidfunc(fS s) { hideModule(getModule(s)) }); listPopupMenu(list, voidfunc(JPopupMenu menu, S s) { final Module m = getModule(s); if (m cast DynamicModule) addMenuItem(menu, "Reload", rThread { m.reload() }); }); ret list; } L calc() { ret map(func(final Module m) -> S { //renderConcept(m) /* contains id as first int */ "[" + m.id + "] " + or2(pcallF(func -> S { m.moduleName() }), "?") }, modulesToList()); } L modulesToList() { ret onModules(); } } sclass InvisibleModules extends ModuleList { L modulesToList() { ret sortedByMethodIC('moduleName, filterByField(onModules(), visible := false)); } visualize { ret jSection("INVISIBLE MODULES", super.visualize()); } } sclass ModuleClasses extends Module { transient L> classes; void start() { classes = filter(func(Class c) -> bool { !isTrue(callOpt(c, 'needsParameters)) }, myNonAbstractClassesImplementing(Module)); } JComponent visualize() { JList list = jlist(map shortClassName(classes)); VF1 instantiate = voidfunc(fS s) { showModule((Module) nu(classForName("main$" + s))); }; VF1 defaultAction = voidfunc(fS s) { makeOrShowStaticModuleOfType(s); }; listPopupMenuItemsThreaded(list, "Instantiate", instantiate); listPopupMenu(list, voidfunc(JPopupMenu menu, S item) { Class c = classForName("main$" + item); final L l = staticModulesOfType(c); if (nempty(l)) addMenuItem(menu, l(l) == 1 ? "Show instance" : "Show all " + l(l) + " instances", r-thread { showModules(l) }); }); ret onDoubleClickThreaded(list, defaultAction); } } sclass DynamicModuleMaker extends Module { L uSearchData() { ret ll(pair("Add dynamic module", r doIt)); } void doIt { stefansOS_addDynamicModuleDialog(); } JComponent visualize() { ret jfullcenter(jbutton("Add dynamic module...", r doIt); } } sclass Hello extends Module { S text = "class main {}"; transient JTextField tf; void start { makeModule(InputToInterestingString); } JComponent visualize() { ret tf = setFontSize(20, jcenteredtextfield(text)); } void unvisualize2() { if (tf != null) cset(this, text := getText(tf)); tf = null; } void enhanceFrame(JInternalFrame f) { packInternalFrameVertically(700, f); centerInternalFrame(f); f.setLocation(f.getX(), 40); } void setText(S text) { temp enter(); cset(this, +text); main.setText(tf, text); } }