Skip to content

Commit 8d539a5

Browse files
committed
Really should've committed more often
* Make OSX native app * Make Windows native app * Implement i18n * Remove nearly all Swing components
1 parent 8862305 commit 8d539a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+741
-587
lines changed

pom.xml

+68-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
<groupId>com.heliosdecompiler</groupId>
88
<artifactId>standalone-app</artifactId>
9-
<version>1.0.4</version>
9+
<version>1.0.5-SNAPSHOT</version>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<winVersion>1.0.5.0</winVersion>
1314
</properties>
1415

1516
<build>
@@ -51,6 +52,27 @@
5152
</replacements>
5253
</configuration>
5354
</plugin>
55+
<plugin>
56+
<groupId>sh.tak.appbundler</groupId>
57+
<artifactId>appbundle-maven-plugin</artifactId>
58+
<version>1.2.0</version>
59+
<configuration>
60+
<buildDirectory>${project.build.directory}</buildDirectory>
61+
<mainClass>com.heliosdecompiler.helios.Helios</mainClass>
62+
<bundleName>Helios Decompiler</bundleName>
63+
<iconFile>standalone-app.icns</iconFile>
64+
<generateDiskImageFile>true</generateDiskImageFile>
65+
<diskImageFile>${project.build.directory}/helios-standalone.dmg</diskImageFile>
66+
</configuration>
67+
<executions>
68+
<execution>
69+
<phase>package</phase>
70+
<goals>
71+
<goal>bundle</goal>
72+
</goals>
73+
</execution>
74+
</executions>
75+
</plugin>
5476
<plugin>
5577
<artifactId>maven-shade-plugin</artifactId>
5678
<version>2.4.2</version>
@@ -98,6 +120,51 @@
98120
</execution>
99121
</executions>
100122
</plugin>
123+
<plugin>
124+
<groupId>com.akathist.maven.plugins.launch4j</groupId>
125+
<artifactId>launch4j-maven-plugin</artifactId>
126+
<version>1.7.17</version>
127+
<executions>
128+
<execution>
129+
<id>l4j-clui</id>
130+
<phase>package</phase>
131+
<goals>
132+
<goal>launch4j</goal>
133+
</goals>
134+
<configuration>
135+
<headerType>gui</headerType>
136+
<jar>${project.build.directory}/helios-standalone.jar</jar>
137+
<outfile>${project.build.directory}/helios-standalone.exe</outfile>
138+
<downloadUrl>http://java.com/download</downloadUrl>
139+
<errTitle>Helios Decompiler</errTitle>
140+
<classPath>
141+
<mainClass>com.heliosdecompiler.helios.Helios</mainClass>
142+
</classPath>
143+
<customProcName>true</customProcName>
144+
<icon>standalone-app.ico</icon>
145+
<jre>
146+
<minVersion>1.8.0</minVersion>
147+
<jdkPreference>preferJre</jdkPreference>
148+
<opts>
149+
<opt>-Dfile.encoding=UTF-8</opt>
150+
</opts>
151+
</jre>
152+
<versionInfo>
153+
<fileVersion>${winVersion}</fileVersion>
154+
<txtFileVersion>${project.version}</txtFileVersion>
155+
<fileDescription>${project.name}</fileDescription>
156+
<copyright>2017 samczsun</copyright>
157+
<productName>${project.name}</productName>
158+
<productVersion>${winVersion}</productVersion>
159+
<txtProductVersion>${project.version}</txtProductVersion>
160+
<companyName>samczsun.com</companyName>
161+
<internalName>helios-standalone</internalName>
162+
<originalFilename>helios-standalone.exe</originalFilename>
163+
</versionInfo>
164+
</configuration>
165+
</execution>
166+
</executions>
167+
</plugin>
101168
</plugins>
102169
</build>
103170

src/main/java/com/heliosdecompiler/helios/BootSequence.java

-38
This file was deleted.

src/main/java/com/heliosdecompiler/helios/Constants.java

-4
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,14 @@ public class Constants {
2323
public static final String REPO_NAME = "Helios";
2424
public static final String REPO_VERSION = "unknown";
2525

26-
public static final String KRAKATAU_VERSION = "3eff49fe480efeca8a728936f6452ec6853cdc88";
2726
public static final String ENJARIFY_VERSION = "82d72ee92730e858b6ec3615d6dc74c9331e56e8";
2827

2928
public static final int MB = 1024 * 1024;
3029
public static final File DATA_DIR = new File(
3130
System.getProperty("user.home") + File.separator + "." + Constants.REPO_NAME.toLowerCase());
32-
public static final File KRAKATAU_DIR = new File(DATA_DIR,
33-
"Krakatau" + File.separator + Constants.KRAKATAU_VERSION);
3431
public static final File ENJARIFY_DIR = new File(DATA_DIR,
3532
"enjarify" + File.separator + Constants.ENJARIFY_VERSION);
3633
public static final File ADDONS_DIR = new File(DATA_DIR, "addons");
37-
public static final File SETTINGS_FILE = new File(DATA_DIR, "settings.json");
3834
public static final File SETTINGS_FILE_XML = new File(DATA_DIR, "settings.xml");
3935
public static final String NEWLINE = System.lineSeparator();
4036
private static final Runtime RUNTIME = Runtime.getRuntime();

src/main/java/com/heliosdecompiler/helios/Helios.java

+47-82
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@
1616

1717
package com.heliosdecompiler.helios;
1818

19-
import com.google.common.collect.Iterables;
2019
import com.google.common.eventbus.AsyncEventBus;
2120
import com.google.common.eventbus.EventBus;
2221
import com.google.inject.AbstractModule;
2322
import com.google.inject.Guice;
2423
import com.google.inject.Injector;
24+
import com.heliosdecompiler.helios.controller.LanguageController;
2525
import com.heliosdecompiler.helios.controller.PathController;
26-
import com.heliosdecompiler.helios.controller.RecentFileController;
2726
import com.heliosdecompiler.helios.controller.UpdateController;
2827
import com.heliosdecompiler.helios.controller.files.OpenedFileController;
2928
import com.heliosdecompiler.helios.controller.ui.UserInterfaceController;
3029
import com.heliosdecompiler.helios.controller.ui.impl.UnsupportedUIController;
31-
import com.heliosdecompiler.helios.gui.JavaFXGuiLauncher;
32-
import com.heliosdecompiler.helios.gui.model.Message;
33-
import com.heliosdecompiler.helios.ui.GuiLauncher;
30+
import com.heliosdecompiler.helios.ui.GraphicsProvider;
3431
import com.heliosdecompiler.helios.ui.MessageHandler;
3532
import com.heliosdecompiler.helios.utils.OSUtils;
36-
import com.heliosdecompiler.transformerapi.PackagedLibraryHelper;
3733
import org.apache.commons.cli.*;
3834
import org.apache.commons.configuration2.Configuration;
3935
import org.apache.commons.configuration2.XMLConfiguration;
@@ -51,112 +47,72 @@
5147
import java.nio.charset.Charset;
5248
import java.nio.charset.StandardCharsets;
5349
import java.util.ArrayList;
54-
import java.util.Collections;
5550
import java.util.List;
5651
import java.util.concurrent.Executors;
5752

5853
public class Helios {
59-
private static LocalSocket socket;
60-
6154
public static void main(String[] args) {
62-
System.setProperty("file.encoding", "UTF-8");
63-
6455
try {
56+
LanguageController languageController = new LanguageController(); // blehhhhhh
57+
Message.init(languageController);
58+
59+
GraphicsProvider launcher = getGraphicsProvider().newInstance();
60+
61+
launcher.startSplash();
62+
launcher.updateSplash(Message.STARTUP_PREPARING_ENVIRONMENT);
63+
6564
Field defaultCharset = Charset.class.getDeclaredField("defaultCharset");
6665
defaultCharset.setAccessible(true);
67-
defaultCharset.set(null, null);
68-
66+
defaultCharset.set(null, StandardCharsets.UTF_8);
6967
if (!Charset.defaultCharset().equals(StandardCharsets.UTF_8))
70-
throw new RuntimeException("Charset");
68+
throw new RuntimeException("Charset: " + Charset.defaultCharset());
7169
if (!Constants.DATA_DIR.exists() && !Constants.DATA_DIR.mkdirs())
7270
throw new RuntimeException("Could not create data directory");
7371
if (!Constants.ADDONS_DIR.exists() && !Constants.ADDONS_DIR.mkdirs())
7472
throw new RuntimeException("Could not create addons directory");
75-
if (!Constants.SETTINGS_FILE.exists() && !Constants.SETTINGS_FILE.createNewFile())
76-
throw new RuntimeException("Could not create settings file");
7773
if (Constants.DATA_DIR.isFile())
7874
throw new RuntimeException("Data directory is file");
7975
if (Constants.ADDONS_DIR.isFile())
8076
throw new RuntimeException("Addons directory is file");
81-
if (Constants.SETTINGS_FILE.isDirectory())
82-
throw new RuntimeException("Settings file is directory");
83-
84-
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
85-
86-
Splash splashScreen = new Splash();
87-
splashScreen.updateState(BootSequence.CHECKING_LIBRARIES);
88-
PackagedLibraryHelper.checkPackagedLibrary("enjarify", Constants.ENJARIFY_VERSION);
8977

90-
splashScreen.updateState(BootSequence.CLEANING_UPDATES);
91-
92-
String thisVersion = "helios-dev.jar";
93-
94-
for (File file : Constants.DATA_DIR.listFiles()) {
95-
if (file.getName().startsWith("helios-") && !file.getName().equals(thisVersion)) {
96-
file.delete();
97-
}
98-
}
78+
EventBus eventBus = new AsyncEventBus(Executors.newCachedThreadPool());
9979

100-
splashScreen.updateState(BootSequence.LOADING_SETTINGS);
10180
Configuration configuration = loadConfiguration();
102-
splashScreen.updateState(BootSequence.LOADING_ADDONS);
103-
// AddonHandler.registerPreloadedAddons();
104-
// for (File file : Constants.ADDONS_DIR.listFiles()) {
105-
// AddonHandler
106-
// .getAllHandlers()
107-
// .stream()
108-
// .filter(handler -> handler.accept(file))
109-
// .findFirst()
110-
// .ifPresent(handler -> {
111-
// handler.run(file);
112-
// });
113-
// }
114-
try {
115-
socket = new LocalSocket();
116-
} catch (IOException e) { // Maybe allow the user to force open a second instance?
117-
// ExceptionHandler.handle(e);
118-
}
119-
120-
splashScreen.updateState(BootSequence.COMPLETE);
81+
Class<? extends UserInterfaceController> uiController = getUIControllerImpl();
12182

122-
EventBus eventBus = new AsyncEventBus(Executors.newCachedThreadPool());
123-
124-
GuiLauncher launcher = new JavaFXGuiLauncher();
83+
Injector mainInjector = Guice.createInjector(
84+
new AbstractModule() {
85+
@Override
86+
protected void configure() {
87+
bind(MessageHandler.class).to(launcher.getMessageHandlerImpl());
88+
bind(UserInterfaceController.class).to(uiController);
89+
bind(Configuration.class).toInstance(configuration);
90+
bind(EventBus.class).toInstance(eventBus);
91+
}
92+
}
93+
);
12594

126-
Class<? extends UserInterfaceController> uiController = UnsupportedUIController.class;
95+
mainInjector.getInstance(UserInterfaceController.class).initialize();
12796

128-
if (OSUtils.getOS() == OSUtils.OS.WINDOWS) {
129-
uiController = (Class<? extends UserInterfaceController>) Class.forName("com.heliosdecompiler.helios.controller.ui.impl.WindowsUIController");
130-
}
97+
launcher.updateSplash(Message.STARTUP_LOADING_GRAPHICS);
98+
launcher.prepare(mainInjector);
13199

132-
Class<? extends UserInterfaceController> uiControllerFinal = uiController;
100+
launcher.updateSplash(Message.STARTUP_DONE);
101+
launcher.start();
133102

134-
Injector mainInjector = Guice.createInjector(
135-
Iterables.concat(
136-
launcher.getModules(),
137-
Collections.singleton(new AbstractModule() {
138-
@Override
139-
protected void configure() {
140-
bind(UserInterfaceController.class).to(uiControllerFinal);
141-
bind(RecentFileController.class);
142-
bind(PathController.class);
143-
bind(Configuration.class).toInstance(configuration);
144-
bind(EventBus.class).toInstance(eventBus);
145-
}
146-
})
147-
)
148-
);
149-
launcher.start(mainInjector, () -> {
150-
mainInjector.getInstance(PathController.class).reload();
151-
mainInjector.getInstance(UpdateController.class).doUpdate();
152-
handleCommandLine(args, mainInjector);
153-
});
103+
mainInjector.getInstance(PathController.class).reload();
104+
mainInjector.getInstance(UpdateController.class).doUpdate();
105+
handleCommandLine(args, mainInjector);
154106
} catch (Throwable t) {
155107
displayError(t);
156108
System.exit(1);
157109
}
158110
}
159111

112+
public static Class<? extends GraphicsProvider> getGraphicsProvider() throws ClassNotFoundException {
113+
return Class.forName(System.getProperty("com.heliosdecompiler.standaloneapp.GraphicsProvider", "com.heliosdecompiler.helios.gui.JavaFXGraphicsProvider")).asSubclass(GraphicsProvider.class);
114+
}
115+
160116
public static void displayError(Throwable t) {
161117
t.printStackTrace();
162118
StringWriter writer = new StringWriter();
@@ -165,6 +121,14 @@ public static void displayError(Throwable t) {
165121
JOptionPane.INFORMATION_MESSAGE);
166122
}
167123

124+
public static Class<? extends UserInterfaceController> getUIControllerImpl() throws ClassNotFoundException {
125+
if (OSUtils.getOS() == OSUtils.OS.WINDOWS) {
126+
return Class.forName("com.heliosdecompiler.helios.controller.ui.impl.WindowsUIController").asSubclass(UserInterfaceController.class);
127+
}
128+
129+
return UnsupportedUIController.class;
130+
}
131+
168132
private static Configuration loadConfiguration() throws IOException, ConfigurationException {
169133
Configurations configurations = new Configurations();
170134
File file = Constants.SETTINGS_FILE_XML;
@@ -201,8 +165,9 @@ public static void handleCommandLine(String[] args, Injector injector) {
201165

202166
for (File file : open)
203167
injector.getInstance(OpenedFileController.class).openFile(file);
168+
204169
} catch (ParseException e) {
205-
injector.getInstance(MessageHandler.class).handleException(Message.UNKNOWN_ERROR, e);
170+
injector.getInstance(MessageHandler.class).handleException(Message.ERROR_UNKNOWN_ERROR.format(), e);
206171
}
207172
}
208173
}

src/main/java/com/heliosdecompiler/helios/LocalSocket.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,22 @@
1717
package com.heliosdecompiler.helios;
1818

1919
import com.heliosdecompiler.helios.handler.ExceptionHandler;
20-
import org.apache.commons.io.IOUtils;
2120

2221
import java.io.IOException;
22+
import java.net.InetAddress;
2323
import java.net.ServerSocket;
2424
import java.net.Socket;
2525

2626
public class LocalSocket extends ServerSocket implements Runnable {
2727
public LocalSocket() throws IOException {
28-
super(21354);
28+
super(21354, 50, InetAddress.getLocalHost());
2929
new Thread(this, "Inter-Process Communications Socket").start();
3030
}
3131

3232
public void run() {
3333
while (true) {
3434
try {
3535
Socket socket = this.accept();
36-
String args = IOUtils.toString(socket.getInputStream(), "UTF-8");
37-
// Helios.getGui().getShell().getDisplay().asyncExec(() -> {
38-
// Helios.getGui().getShell().setFocus();
39-
// Helios.getGui().getShell().forceActive();
40-
// Helios.getGui().getShell().forceFocus();
41-
//// Helios.handleCommandLine(args.split(" "));
42-
// });
4336
} catch (Throwable e) {
4437
ExceptionHandler.handle(e);
4538
}

0 commit comments

Comments
 (0)