123 lines
3.3 KiB
Java

package at.fos.ermodel.gui;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.GridPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class A7
extends Stage {
final KeyCombination keyCombinationALT_ENTER = new KeyCodeCombination(KeyCode.ENTER, KeyCombination.ALT_DOWN);
private final A7 thisActionMessageDialog;
private final TextArea textTA;
private final String holdName;
private boolean doNothing;
public A7(final A3 canvas, double xPos, double yPos, String name) {
String title = "Enter Name";
this.holdName = name;
this.doNothing = false;
this.thisActionMessageDialog = this;
setTitle(title);
initModality(Modality.APPLICATION_MODAL);
this.textTA = new TextArea(name);
this.textTA.setPrefWidth(350.0D);
this.textTA.setPrefHeight(100.0D);
this.textTA.setOnMouseEntered(event -> T3.fdssdf4354(A7.this.textTA, C2.MouseSelectedColor));
this.textTA.setOnMouseExited(event -> A7.this.textTA.setEffect(null));
this.textTA.setOnKeyPressed(event -> {
if (A7.this.keyCombinationALT_ENTER.match(event)) {
A7.this.textTA.appendText("\n");
event.consume();
return;
}
switch (event.getCode()) {
case ENTER -> {
event.consume();
A7.this.setDataAndLeave();
if (!canvas.getTabWithCanvas().getText().contains("*"))
canvas.getTabWithCanvas().setText(canvas.getTabWithCanvas().getText() + "*");
}
case ESCAPE -> A7.this.setNothingAndLeave();
}
});
GridPane fPane = new GridPane();
fPane.setPadding(new Insets(10.0D, 10.0D, 10.0D, 10.0D));
fPane.setHgap(4.0D);
fPane.add(new Label("ESC->Cancel, Alt-Enter->Linefeed"), 0, 0, 2, 1);
fPane.add(this.textTA, 0, 1);
initStyle(StageStyle.UNDECORATED);
Scene scene = new Scene(fPane, 370.0D, 150.0D);
setScene(scene);
setX(xPos);
setY(yPos);
if (yPos + scene.getHeight() > canvas.getView().getHeight() - 5.0D) {
setY(yPos - scene.getHeight() - 20.0D);
}
if (xPos + scene.getWidth() > canvas.getView().getWidth() - 5.0D) {
setX(xPos - scene.getWidth() - 20.0D);
}
this.textTA.requestFocus();
sizeToScene();
showAndWait();
}
private void setDataAndLeave() {
if (this.textTA.getText() == null || this.textTA.getText().length() == 0) {
this.textTA.setText("");
return;
}
this.thisActionMessageDialog.close();
}
private void setNothingAndLeave() {
this.textTA.setText(this.holdName);
this.doNothing = true;
this.thisActionMessageDialog.close();
}
public TextArea getTextTA() {
return this.textTA;
}
public boolean isDoNothing() {
return this.doNothing;
}
}