Merge branch 'client/fix-idea-debugging' into 'main'

Fix JavaFX dependencies not working in IDEA Run/Debug configuration

See merge request cse1105/2025-2026/teams/csep-team-76!40
This commit is contained in:
Zhongheng Liu 2026-01-06 18:25:23 +01:00
commit ae05675e27
2 changed files with 31 additions and 31 deletions

View file

@ -15,37 +15,8 @@
*/
package client;
import static com.google.inject.Guice.createInjector;
import client.scenes.MainCtrl;
import client.scenes.FoodpalApplicationCtrl;
import client.utils.ServerUtils;
import com.google.inject.Injector;
import javafx.application.Application;
import javafx.stage.Stage;
public class Main extends Application {
private static final Injector INJECTOR = createInjector(new MyModule());
private static final MyFXML FXML = new MyFXML(INJECTOR);
public class Main {
public static void main(String[] args){
launch();
}
@Override
public void start(Stage primaryStage) throws Exception {
var serverUtils = INJECTOR.getInstance(ServerUtils.class);
if (!serverUtils.isServerAvailable()) {
var msg = "Server needs to be started before the client, but it does not seem to be available. Shutting down.";
System.err.println(msg);
return;
}
var foodpal = FXML.load(FoodpalApplicationCtrl.class, "client", "scenes", "FoodpalApplication.fxml");
var mainCtrl = INJECTOR.getInstance(MainCtrl.class);
mainCtrl.setup(primaryStage, foodpal);
UI.launch(UI.class, args);
}
}

View file

@ -0,0 +1,29 @@
package client;
import client.scenes.FoodpalApplicationCtrl;
import client.scenes.MainCtrl;
import client.utils.ServerUtils;
import com.google.inject.Injector;
import javafx.application.Application;
import javafx.stage.Stage;
import static com.google.inject.Guice.createInjector;
public class UI extends Application {
private static final Injector INJECTOR = createInjector(new MyModule());
private static final MyFXML FXML = new MyFXML(INJECTOR);
@Override
public void start(Stage primaryStage) throws Exception {
var serverUtils = INJECTOR.getInstance(ServerUtils.class);
if (!serverUtils.isServerAvailable()) {
var msg = "Server needs to be started before the client, but it does not seem to be available. Shutting down.";
System.err.println(msg);
return;
}
var foodpal = FXML.load(FoodpalApplicationCtrl.class, "client", "scenes", "FoodpalApplication.fxml");
var mainCtrl = INJECTOR.getInstance(MainCtrl.class);
mainCtrl.setup(primaryStage, foodpal);
}
}