This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/client/src/main/java/envoy/client/helper/ShutdownHelper.java

46 lines
1.2 KiB
Java
Raw Normal View History

package envoy.client.helper;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import envoy.client.data.*;
import envoy.client.event.EnvoyCloseEvent;
import dev.kske.eventbus.EventBus;
/**
* Contains methods that have a direct impact on the user.
*
* @author Leon Hofmeister
* @since Envoy Client v0.2-beta
*/
public class ShutdownHelper {
private ShutdownHelper() {}
/**
* Exits Envoy or minimizes it, depending on the current state of
* {@link Settings#isHideOnClose()}.
*
* @since Envoy Client v0.2-beta
*/
public static void exit() { exit(Settings.getInstance().isHideOnClose(), true); }
/**
* Exits the currently open Envoy application or minimizes it.
* Does not necessarily shutdown VM.
*
* @param minimize whether Envoy should be minimized instead of closed
* @param shutdownVM whether the JVM should shutdown
* @since Envoy Client v0.2-beta
*/
public static void exit(boolean minimize, boolean shutdownVM) {
if (minimize) Context.getInstance().getStage().setIconified(true);
else {
EventBus.getInstance().dispatch(new EnvoyCloseEvent());
if (shutdownVM) System.exit(0);
}
}
}