Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

200
LINES

< > BotCompany Repo | #1033411 // Standalone Gazelle V [HEAD]

JavaX source code (desktop) [tags: jar-with-libs no-compiler standalone use-pretranspiled]

Download Jar. Uses 2032K of libraries. Click here for Pure Java version (11053L/60K).

1  
/*       WELCOME!! This is THE PROGRAM YOU ARE LOOKING FOR.
2  
3  
COMPILE ISSUE is RESOLVED! Program can be run.
4  
5  
-Stefan Reich, 2021/10/29 08:40:03 UTC
6  
*/
7  
8  
!7
9  
10  
sS windowTitle = "Gazelle V 2020-10-28 .10";
11  
sS downloadURL = "https://botcompany.de/jar/1033411?withLibs=1&noCompiler=1";
12  
sS trayIconImageID = #1103047;
13  
static int borderSize = 5;
14  
static Color color1 = awtColor("ADD8E6");
15  
static Color color2 = awtColor("EEEEEE");
16  
static Color color3 = awtColor("A3C0AA");
17  
18  
lib 1400521 // FlatLAF
19  
20  
set flag PingV3.
21  
set flag NotifyingPrintLog.
22  
23  
static IF0<PingSource> ping_v3_pingSourceMaker() { ret () -> new PingSource; }
24  
25  
sclass Stem {
26  
  JFrame window;
27  
  
28  
  Rect getFrameRect() {
29  
    ret toRect(getBounds(window));
30  
  }
31  
}
32  
33  
static Stem stem;
34  
static GazelleV gazelle;
35  
static TrayIcon trayIcon;
36  
static JFrame mainWindow;
37  
static Set<S> argsSet;
38  
39  
svoid trayIconLeftClick {
40  
  activateFrame_v3(mainWindow);
41  
}
42  
43  
svoid makeTrayIcon {
44  
  pcall-short {
45  
    trayIcon_imageAutoSize = false;
46  
    trayIcon = installTrayIcon(trayIconImageID, windowTitle,
47  
      r trayIconLeftClick,
48  
      "Show Gazelle", r { activateFrame(mainWindow) },
49  
      "Exit Gazelle", r cleanExit
50  
    );
51  
  }
52  
}
53  
54  
p {
55  
  __javax = x30.class;
56  
  loadableUtils.utils.__setJavaX(x30.class);
57  
  vm_generalMap_put(stefansOS := mc());
58  
  __javax = x30.class;
59  
  x30.__javax = x30.class; // for hotwire
60  
  x30_pkg.x30_util.__setJavaX(x30.class);
61  
  x30.cleanKillMsg = "";
62  
  callOnLoadMethods(mc());
63  
  
64  
  argsSet = asSet(args);
65  
  
66  
  if (!argsSet.contains("noflatlaf"))
67  
    com.formdev.flatlaf.FlatLightLaf.setup();
68  
  
69  
  if (contains(args, "profile"))
70  
    profileToConsole(() -> actualMain(args));
71  
  else
72  
    actualMain(args);
73  
    
74  
  if (argsSet.contains("brexit")) System.exit(0);
75  
  
76  
  temp gazelle.enter();
77  
  gazelle.start();
78  
}
79  
80  
svoid actualMain(S... args) {
81  
  // Do the JavaX init
82  
  
83  
  System.out.println(hmsWithColonsAndMS() + ": Init");
84  
  //x30.coreInit();
85  
  
86  
  // Ready to roll
87  
  
88  
  if (containsOneOf(argsSet, "upgrade", "update"))
89  
    ret with upgradeGazelle();
90  
91  
  makeTrayIcon();
92  
  
93  
  printWithMS("new GazelleV");
94  
  gazelle = new GazelleV;
95  
  stem = new Stem;
96  
  gazelle._host = stem;
97  
  copyLocalLog(gazelle, mc());
98  
99  
  temp gazelle.enter();
100  
  printWithMS("Visualize");
101  
  var vis = swing(() -> gazelle.visualize());
102  
  
103  
  vis = makeWindowBorderAndTitle(vis, windowTitle);
104  
  printWithMS("Show frame");
105  
  //stem.window = showMainFrame("Gazella", vis);
106  
  JFrame frame = makeUndecoratedFrame(windowTitle, vis);
107  
  setFrameIcon(frame, trayIconImageID);
108  
  stem.window = mainWindow = frame;
109  
  onWindowClosing(stem.window, r cleanExit);
110  
  showWindow(stem.window);
111  
  printWithMS("Dudadoneski");
112  
}
113  
114  
svoid minimize {
115  
  if (trayIcon == null)
116  
    minimizeWindow(mainWindow);
117  
  else
118  
    hideWindow(mainWindow);
119  
}  
120  
121  
static JComponent makeWindowBorderAndTitle(JComponent contents, S title) {
122  
  //ret jCenteredSection_fontSizePlus(10, title, vis);
123  
  
124  
  var icons = jline();
125  
  icons.add(jbutton("Minimize", r minimize));
126  
  icons.add(jbutton("Close", r { disposeWindow(icons) }));
127  
  icons.add(jPopDownButton_noText(
128  
    "Update Gazelle", rThread upgradeGazelle,
129  
    "Dump threads", rThread { showText("User threads", renderUserThreadsWithStackTraces()); },
130  
  ));
131  
  
132  
  var actualTitle = fontSizePlus(7, jCenteredLabel(title));
133  
  var spacer = gazelle_wavySpacer();
134  
  var titleBarMain = setOpaqueBackground(color1,
135  
    westCenterAndEastWithMargin(
136  
      jImage_scaledToHeight(24, trayIconImageID),
137  
      actualTitle,
138  
      setOpaqueBackground(color2, spacer));
139  
  
140  
  installWindowDragger(actualTitle);
141  
  installWindowDragger(spacer);
142  
  
143  
  var titleBar = setBackground(color2, centerAndEast(
144  
    titleBarMain,
145  
    icons));
146  
  
147  
  var border =
148  
    // createBevelBorder();
149  
    BorderFactory.createLineBorder(color1, borderSize);
150  
    
151  
  var outerPanel = withBorder(border,
152  
    northAndCenter(titleBar, contents));
153  
    
154  
  installWindowResizeDraggerOnBorder(outerPanel);
155  
  ret outerPanel;
156  
}
157  
158  
sO dm_getStem(O moduleOrID) {
159  
  ret stem;
160  
}
161  
162  
sO resolveModule(O moduleOrID) { ret moduleOrID == stem ? gazelle : moduleOrID; }
163  
164  
svoid cleanExit {
165  
  System.exit(0);
166  
}
167  
168  
svoid upgradeGazelle {
169  
  File myJar = getBytecodePathForClass(mc());
170  
  print(+myJar);
171  
  
172  
  S javaCmd = or2(currentProcessCommand(), "java");
173  
  S date = ymdMinusHMS();
174  
  File f = javaxCodeDir("Downloaded Updates/" + "gazelle-" + date + ".jar");
175  
  infoBox("Downloading Update...");
176  
  loadBinaryPageToFile(downloadURL, f);
177  
  printFileInfo(f);
178  
  if (!isNonEmptySingleZip_byMagicHeader(f))
179  
    ret with  infoBox("Bad file downloaded... :(");
180  
    
181  
  bool replaced;
182  
  if (isFile(myJar)) {
183  
    print("Loaded " + nClasses(loadAllClassesInByteCodePath(myJar)));
184  
    print("Replacing with new version: " + myJar);
185  
    renameFile(myJar, appendToBaseName(myJar, ".bak." + date));
186  
    copyFile(f, myJar);
187  
    printFileInfo(myJar);
188  
    set replaced;
189  
  }
190  
    
191  
  infoBox(replaced
192  
    ? "Installed update, replaced " + f2s(myJar) + " - now starting"
193  
    : "Starting update, but could not replace originally downloaded jar");
194  
  S cmd = pqO(javaCmd) + " -jar " + pqO(replaced ? myJar : f);
195  
  print(cmd);
196  
  nohup(cmd);
197  
  cleanExit();
198  
}
199  
200  
!include early #1033508 // GazelleV

Author comment

Began life as a copy of #1033309

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033411
Snippet name: Standalone Gazelle V [HEAD]
Eternal ID of this version: #1033411/144
Text MD5: 02a6be6768e6dd844336684208d36070
Transpilation MD5: 1e2341d2fa707b3c457db45469e8e026
Author: stefan
Category: javax / screen recognition
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-30 14:57:51
Source code size: 5312 bytes / 200 lines
Pitched / IR pitched: No / No
Views / Downloads: 826 / 2471
Version history: 143 change(s)
Referenced in: [show references]