52: Create embarrassing simple Evelyn Mission Control in JavaFX
This commit is contained in:
@@ -12,6 +12,7 @@ fi
|
||||
CLASSPATH=$(IFS=:; echo "${jars[*]}")
|
||||
|
||||
exec java \
|
||||
--enable-native-access=javafx.graphics \
|
||||
--enable-preview \
|
||||
-Dlog4j.configurationFile=conf/log4j2.xml \
|
||||
-cp "$CLASSPATH" \
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.r35157.evelyn.emc;
|
||||
|
||||
public interface EvelynMissionControl {
|
||||
void start();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.r35157.evelyn.emc.impl.ref;
|
||||
|
||||
import com.r35157.evelyn.emc.EvelynMissionControl;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class EvelynMissionControlImpl/*<T>*/ implements EvelynMissionControl {
|
||||
|
||||
public EvelynMissionControlImpl(/*T evelyn*/) {
|
||||
//this.evelyn = Objects.requireNonNull(evelyn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
Platform.startup(() -> {
|
||||
TextArea text = new TextArea("""
|
||||
Evelyn Mission Control
|
||||
|
||||
Evelyn is running.
|
||||
Connected to: %s
|
||||
""".formatted("Test123"/*evelyn.getClass().getName())*/));
|
||||
text.setEditable(false);
|
||||
|
||||
Stage window = new Stage();
|
||||
window.setTitle("Evelyn Mission Control");
|
||||
window.setScene(new Scene(text, 600, 400));
|
||||
window.show();
|
||||
});
|
||||
}
|
||||
|
||||
//private final T evelyn;
|
||||
}
|
||||
@@ -7,6 +7,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface NenjimHub {
|
||||
/**
|
||||
* Start the NenjimHub - This is the first thing to do
|
||||
*/
|
||||
void start() throws Exception;
|
||||
|
||||
/**
|
||||
* Starts a process based on the provided fully qualified interface name.
|
||||
* The actual implementation that is run is binded according to the Context.
|
||||
|
||||
@@ -25,7 +25,8 @@ public class Main {
|
||||
|
||||
// TODO: Consider if we really need a Main class or we just need to move the main method to NenjimHubImpl?
|
||||
static void main(String[] args) throws Exception {
|
||||
NenjimHubImpl nenjimHub = new NenjimHubImpl();
|
||||
NenjimHub nenjimHub = new NenjimHubImpl();
|
||||
nenjimHub.start();
|
||||
|
||||
/*SolanaBlockChain sbc = new SolanaBlockChainImpl();
|
||||
JupiterPerpsService jupiter = new AnchorIdlJupiterPerpsServiceImpl(sbc);
|
||||
@@ -39,7 +40,6 @@ public class Main {
|
||||
ΩUSDCAmountΩ a = pos.borrowFeesDue();
|
||||
}*/
|
||||
//int i = 0;
|
||||
nenjimHub.awaitShutdown();
|
||||
|
||||
/* try {
|
||||
log.info("Auto-starting 2 Nenjim application(s)...");
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.r35157.nenjim.hubd.impl.ref;
|
||||
|
||||
import com.r35157.evelyn.emc.EvelynMissionControl;
|
||||
import com.r35157.evelyn.emc.impl.ref.EvelynMissionControlImpl;
|
||||
import com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl;
|
||||
import com.r35157.nenjim.hubd.NenjimHub;
|
||||
import com.r35157.nenjim.hubd.journal.Journal;
|
||||
@@ -17,13 +19,16 @@ public class NenjimHubImpl implements NenjimHub {
|
||||
nextProcessId = 1;
|
||||
//processesScope = new StructuredTaskScope.ShutdownOnFailure();
|
||||
processes = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
log.info("Starting autorun processes:");
|
||||
startAutoRunProcesses();
|
||||
waitForAndShutdown();
|
||||
}
|
||||
|
||||
private void waitForAndShutdown() {
|
||||
private void waitForAndShutdown() throws InterruptedException {
|
||||
System.out.println("Done - Now online!");
|
||||
|
||||
/*
|
||||
@@ -32,14 +37,17 @@ public class NenjimHubImpl implements NenjimHub {
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
processesScope.close();
|
||||
*/
|
||||
|
||||
awaitShutdown();
|
||||
|
||||
System.out.println("Nenjim is now shutdown (stopped all processes)!");
|
||||
}
|
||||
|
||||
private void startAutoRunProcesses() throws Exception {
|
||||
startJupiterPerpsAlarm(); // TODO: Hardcoded/hacky way to auto-start but good enough for now.
|
||||
startEvelynMissionControl();
|
||||
|
||||
// TODO: Old but more correct way to auto start plugins - but it is currently broken.
|
||||
/*
|
||||
@@ -96,7 +104,7 @@ public class NenjimHubImpl implements NenjimHub {
|
||||
System.out.println("NenjimHub command: 'noop'");
|
||||
}
|
||||
|
||||
public void awaitShutdown() throws InterruptedException {
|
||||
private void awaitShutdown() throws InterruptedException {
|
||||
shutdownLatch.await();
|
||||
}
|
||||
|
||||
@@ -115,6 +123,21 @@ public class NenjimHubImpl implements NenjimHub {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private void startEvelynMissionControl() {
|
||||
Thread thread = new Thread(() -> {
|
||||
try {
|
||||
EvelynMissionControl emc = new EvelynMissionControlImpl();
|
||||
emc.start();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}, "Nenjim Plugin - Evelyn Mission Control");
|
||||
|
||||
thread.setDaemon(false);
|
||||
thread.start();
|
||||
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class);
|
||||
private final CountDownLatch shutdownLatch = new CountDownLatch(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user