lib 1400521 // FlatLAF set flag PingV3. set flag NotifyingPrintLog. svoid standaloneInit { __javax = x30.class; x30.__javax = x30.class; // for hotwire x30_pkg.x30_util.__setJavaX(x30.class); x30.cleanKillMsg = ""; callOnLoadMethods(mc()); } sclass GazelleHost { S windowTitle = "November Gazelle v1"; S downloadURL = "https://botcompany.de/jar/" + psI(programID()) + "?withLibs=1&noCompiler=1"; sS trayIconImageID = #1103047; int borderSize = 5; Color color1 = awtColor("ADD8E6"); Color color2 = awtColor("EEEEEE"); Color color3 = awtColor("A3C0AA"); IF0 moduleMaker; *() {} *(IF0 *moduleMaker) {} IF0 ping_v3_pingSourceMaker() { ret () -> new PingSource; } class Stem { JFrame window; Rect getFrameRect() { ret toRect(getBounds(window)); } } Stem stem; DynModule gazelle; TrayIcon trayIcon; JFrame mainWindow; Set argsSet; void trayIconLeftClick { activateFrame_v3(mainWindow); } void makeTrayIcon { pcall-short { trayIcon_imageAutoSize = false; trayIcon = installTrayIcon(trayIconImageID, windowTitle, r trayIconLeftClick, "Show Gazelle", r { activateFrame(mainWindow) }, "Exit Gazelle", r cleanExit ); } } void run(S[] args) { argsSet = asSet(args); if (!argsSet.contains("noflatlaf")) com.formdev.flatlaf.FlatLightLaf.setup(); if (contains(args, "profile")) profileToConsole(() -> actualMain(args)); else actualMain(args); if (argsSet.contains("brexit")) System.exit(0); temp gazelle.enter(); gazelle.start(); } void actualMain(S... args) { // Do the JavaX init vm_generalMap_put(stefansOS := this); System.out.println(hmsWithColonsAndMS() + ": Init"); //x30.coreInit(); // Ready to roll if (containsOneOf(argsSet, "upgrade", "update")) ret with upgradeGazelle(); makeTrayIcon(); makeModule(); stem = new Stem; gazelle._host = stem; copyLocalLog(gazelle, mc()); temp gazelle.enter(); printWithMS("Visualize"); var vis = swing(() -> gazelle.visualize()); vis = makeWindowBorderAndTitle(vis, windowTitle); printWithMS("Show frame"); //stem.window = showMainFrame("Gazella", vis); JFrame frame = makeUndecoratedFrame(windowTitle, vis); setFrameIcon(frame, trayIconImageID); stem.window = mainWindow = frame; onWindowClosing(stem.window, r cleanExit); showWindow(stem.window); printWithMS("Dudadoneski"); } void minimize { if (trayIcon == null) minimizeWindow(mainWindow); else hideWindow(mainWindow); } JComponent makeWindowBorderAndTitle(JComponent contents, S title) { //ret jCenteredSection_fontSizePlus(10, title, vis); var icons = jline(); icons.add(jbutton("Minimize", r minimize)); icons.add(jbutton("Close", r { disposeWindow(icons) })); icons.add(jPopDownButton_noText( "Update Gazelle", rThread upgradeGazelle, "Dump threads", rThread { showText("User threads", renderUserThreadsWithStackTraces()); }, )); var actualTitle = fontSizePlus(7, jCenteredLabel(title)); var spacer = gazelle_wavySpacer(); var titleBarMain = setOpaqueBackground(color1, westCenterAndEastWithMargin( jImage_scaledToHeight(24, trayIconImageID), actualTitle, setOpaqueBackground(color2, spacer)); installWindowDragger(actualTitle); installWindowDragger(spacer); var titleBar = setBackground(color2, centerAndEast( titleBarMain, icons)); var border = // createBevelBorder(); BorderFactory.createLineBorder(color1, borderSize); var outerPanel = withBorder(border, northAndCenter(titleBar, contents)); installWindowResizeDraggerOnBorder(outerPanel); ret outerPanel; } O dm_getStem(O moduleOrID) { ret stem; } O resolveModule(O moduleOrID) { ret moduleOrID == stem ? gazelle : moduleOrID; } void cleanExit { System.exit(0); } void upgradeGazelle { File myJar = getBytecodePathForClass(this); print(+myJar); S javaCmd = or2(currentProcessCommand(), "java"); S date = ymdMinusHMS(); File f = javaxCodeDir("Downloaded Updates/" + "gazelle-" + date + ".jar"); infoBox("Downloading Update..."); loadBinaryPageToFile(downloadURL, f); printFileInfo(f); if (!isNonEmptySingleZip_byMagicHeader(f)) ret with infoBox("Bad file downloaded... :("); bool replaced; if (isFile(myJar)) { print("Loaded " + nClasses(loadAllClassesInByteCodePath(myJar))); print("Replacing with new version: " + myJar); renameFile(myJar, appendToBaseName(myJar, ".bak." + date)); copyFile(f, myJar); printFileInfo(myJar); set replaced; } infoBox(replaced ? "Installed update, replaced " + f2s(myJar) + " - now starting" : "Starting update, but could not replace originally downloaded jar"); S cmd = pqO(javaCmd) + " -jar " + pqO(replaced ? myJar : f); print(cmd); nohup(cmd); cleanExit(); } void makeModule() { if (gazelle == null) gazelle = callF(moduleMaker); } }