mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -04:00
debugUi: show warning on close, add status bar at bottom of window
This commit is contained in:
parent
747139cad1
commit
2f5fcc1a68
@ -16,15 +16,20 @@ package de.bixilon.minosoft.debug.gui;
|
||||
import de.bixilon.minosoft.debug.handling.DebugUIHandler;
|
||||
import de.bixilon.minosoft.protocol.network.Connection;
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DebugMainWindow extends Application {
|
||||
static DebugUIHandler handler;
|
||||
@ -52,6 +57,33 @@ public class DebugMainWindow extends Application {
|
||||
DebugMainWindow.connection = connection;
|
||||
}
|
||||
|
||||
private static void showCloseConfirmation() {
|
||||
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
|
||||
alert.setTitle("Disconnect?");
|
||||
alert.setHeaderText("Do you want to disconnect from the server?");
|
||||
|
||||
ButtonType yes = new ButtonType("Yes");
|
||||
ButtonType no = new ButtonType("No");
|
||||
ButtonType cancel = new ButtonType("Cancel");
|
||||
|
||||
alert.getButtonTypes().clear();
|
||||
|
||||
alert.getButtonTypes().addAll(yes, no, cancel);
|
||||
|
||||
Optional<ButtonType> option = alert.showAndWait();
|
||||
if (option.isEmpty()) {
|
||||
// no selection
|
||||
return;
|
||||
}
|
||||
if (option.get() == no) {
|
||||
stage.close();
|
||||
} else if (option.get() == yes) {
|
||||
connection.disconnect();
|
||||
stage.close();
|
||||
}
|
||||
// else return
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
|
||||
@ -60,7 +92,6 @@ public class DebugMainWindow extends Application {
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("Minosoft DebugUI");
|
||||
stage.getIcons().add(new Image(DebugMainWindow.class.getResourceAsStream("/icons/windowIcon.png")));
|
||||
stage.show();
|
||||
|
||||
// listen for enter in text field
|
||||
TextField chatToSend = ((TextField) scene.lookup("#chatToSend"));
|
||||
@ -72,6 +103,18 @@ public class DebugMainWindow extends Application {
|
||||
}
|
||||
});
|
||||
|
||||
Text statusBarServerAddress = (Text) scene.lookup("#statusBarServerAddress");
|
||||
statusBarServerAddress.setText(String.format(statusBarServerAddress.getText(), connection.getHost(), connection.getPort()));
|
||||
|
||||
|
||||
stage.setOnCloseRequest(event -> {
|
||||
event.consume();
|
||||
showCloseConfirmation();
|
||||
});
|
||||
|
||||
|
||||
Platform.setImplicitExit(false);
|
||||
stage.show();
|
||||
DebugMainWindow.stage = stage;
|
||||
initialized = true;
|
||||
handler.initializedCallback();
|
||||
|
@ -5,23 +5,33 @@
|
||||
<?import javafx.scene.control.TabPane?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.text.TextFlow?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml/1" prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8.0.171">
|
||||
<AnchorPane prefHeight="666.0" prefWidth="998.0" VBox.vgrow="ALWAYS">
|
||||
<TabPane prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0"
|
||||
<TabPane prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="20.0"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<Tab text="Chat">
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||
<ScrollPane layoutX="441.0" layoutY="184.0" AnchorPane.bottomAnchor="28.0"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<content>
|
||||
<TextFlow id="chat" prefWidth="635.0"/>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<TextField id="chatToSend" promptText="<Enter Chat Message>" AnchorPane.bottomAnchor="0.0"
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="339.0"/>
|
||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"/>
|
||||
</AnchorPane>
|
||||
</Tab>
|
||||
</TabPane>
|
||||
<AnchorPane prefHeight="20.0" prefWidth="640.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0">
|
||||
<Text id="statusBarServerAddress" layoutX="408.0" layoutY="15.0" strokeType="OUTSIDE" strokeWidth="0.0"
|
||||
text="Connected to %s:%d" AnchorPane.bottomAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
||||
AnchorPane.topAnchor="0.0">
|
||||
<font>
|
||||
<Font size="12.0"/>
|
||||
</font>
|
||||
</Text>
|
||||
</AnchorPane>
|
||||
</AnchorPane>
|
||||
</VBox>
|
||||
|
Loading…
x
Reference in New Issue
Block a user