Use Controllers.dialog for AddAuthlibInjectorServerDialog
This commit is contained in:
@@ -21,6 +21,7 @@ import static org.jackhuang.hmcl.ui.FXUtils.loadFXML;
|
|||||||
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorServer;
|
||||||
import org.jackhuang.hmcl.setting.Settings;
|
import org.jackhuang.hmcl.setting.Settings;
|
||||||
@@ -32,16 +33,16 @@ import org.jackhuang.hmcl.ui.construct.SpinnerPane;
|
|||||||
import org.jackhuang.hmcl.util.NetworkUtils;
|
import org.jackhuang.hmcl.util.NetworkUtils;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXDialog;
|
|
||||||
import com.jfoenix.controls.JFXDialogLayout;
|
import com.jfoenix.controls.JFXDialogLayout;
|
||||||
import com.jfoenix.controls.JFXTextField;
|
import com.jfoenix.controls.JFXTextField;
|
||||||
|
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.Region;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
|
||||||
public class AddAuthlibInjectorServerDialog extends JFXDialog {
|
public class AddAuthlibInjectorServerPane extends StackPane {
|
||||||
|
|
||||||
@FXML private StackPane addServerContainer;
|
@FXML private StackPane addServerContainer;
|
||||||
@FXML private Label lblServerUrl;
|
@FXML private Label lblServerUrl;
|
||||||
@@ -54,11 +55,14 @@ public class AddAuthlibInjectorServerDialog extends JFXDialog {
|
|||||||
@FXML private SpinnerPane nextPane;
|
@FXML private SpinnerPane nextPane;
|
||||||
@FXML private JFXButton btnAddNext;
|
@FXML private JFXButton btnAddNext;
|
||||||
|
|
||||||
|
private Consumer<Region> finalization;
|
||||||
|
|
||||||
private TransitionHandler transitionHandler;
|
private TransitionHandler transitionHandler;
|
||||||
|
|
||||||
private AuthlibInjectorServer serverBeingAdded;
|
private AuthlibInjectorServer serverBeingAdded;
|
||||||
|
|
||||||
public AddAuthlibInjectorServerDialog() {
|
public AddAuthlibInjectorServerPane(Consumer<Region> finalization) {
|
||||||
|
this.finalization = finalization;
|
||||||
loadFXML(this, "/assets/fxml/authlib-injector-server-add.fxml");
|
loadFXML(this, "/assets/fxml/authlib-injector-server-add.fxml");
|
||||||
transitionHandler = new TransitionHandler(addServerContainer);
|
transitionHandler = new TransitionHandler(addServerContainer);
|
||||||
transitionHandler.setContent(addServerPane, ContainerAnimations.NONE.getAnimationProducer());
|
transitionHandler.setContent(addServerPane, ContainerAnimations.NONE.getAnimationProducer());
|
||||||
@@ -85,7 +89,7 @@ public class AddAuthlibInjectorServerDialog extends JFXDialog {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onAddCancel() {
|
private void onAddCancel() {
|
||||||
this.close();
|
finalization.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@@ -122,10 +126,10 @@ public class AddAuthlibInjectorServerDialog extends JFXDialog {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onAddFinish() {
|
private void onAddFinish() {
|
||||||
if (!Settings.INSTANCE.SETTINGS.authlibInjectorServers.contains(serverBeingAdded)) {
|
if (!Settings.SETTINGS.authlibInjectorServers.contains(serverBeingAdded)) {
|
||||||
Settings.INSTANCE.SETTINGS.authlibInjectorServers.add(serverBeingAdded);
|
Settings.SETTINGS.authlibInjectorServers.add(serverBeingAdded);
|
||||||
}
|
}
|
||||||
this.close();
|
finalization.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -63,9 +63,7 @@ public class AuthlibInjectorServersPage extends StackPane implements DecoratorPa
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void onAdd() {
|
private void onAdd() {
|
||||||
AddAuthlibInjectorServerDialog dialog = new AddAuthlibInjectorServerDialog();
|
Controllers.dialog(new AddAuthlibInjectorServerPane(Controllers::closeDialog));
|
||||||
dialog.setDialogContainer(this);
|
|
||||||
dialog.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
|
|||||||
@@ -9,58 +9,56 @@
|
|||||||
|
|
||||||
<fx:root xmlns="http://javafx.com/javafx"
|
<fx:root xmlns="http://javafx.com/javafx"
|
||||||
xmlns:fx="http://javafx.com/fxml"
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
type="JFXDialog">
|
type="StackPane">
|
||||||
<StackPane>
|
<StackPane fx:id="addServerContainer">
|
||||||
<StackPane fx:id="addServerContainer">
|
<JFXDialogLayout fx:id="addServerPane">
|
||||||
<JFXDialogLayout fx:id="addServerPane">
|
<heading>
|
||||||
<heading>
|
<Label text="%account.injector.add" />
|
||||||
<Label text="%account.injector.add" />
|
</heading>
|
||||||
</heading>
|
<body>
|
||||||
<body>
|
<JFXTextField fx:id="txtServerUrl" promptText="%account.injector.server_url">
|
||||||
<JFXTextField fx:id="txtServerUrl" promptText="%account.injector.server_url">
|
<validators>
|
||||||
<validators>
|
<URLValidator message="%input.url">
|
||||||
<URLValidator message="%input.url">
|
<protocols>
|
||||||
<protocols>
|
<String fx:value="http" />
|
||||||
<String fx:value="http" />
|
<String fx:value="https" />
|
||||||
<String fx:value="https" />
|
</protocols>
|
||||||
</protocols>
|
</URLValidator>
|
||||||
</URLValidator>
|
</validators>
|
||||||
</validators>
|
</JFXTextField>
|
||||||
</JFXTextField>
|
</body>
|
||||||
</body>
|
<actions>
|
||||||
<actions>
|
<Label fx:id="lblCreationWarning" />
|
||||||
<Label fx:id="lblCreationWarning" />
|
<JFXButton onMouseClicked="#onAddCancel" text="%button.cancel" styleClass="dialog-cancel" />
|
||||||
<JFXButton onMouseClicked="#onAddCancel" text="%button.cancel" styleClass="dialog-cancel" />
|
<SpinnerPane fx:id="nextPane" styleClass="small-spinner-pane">
|
||||||
<SpinnerPane fx:id="nextPane" styleClass="small-spinner-pane">
|
<JFXButton fx:id="btnAddNext" onMouseClicked="#onAddNext" text="%wizard.next" styleClass="dialog-accept" />
|
||||||
<JFXButton fx:id="btnAddNext" onMouseClicked="#onAddNext" text="%wizard.next" styleClass="dialog-accept" />
|
</SpinnerPane>
|
||||||
</SpinnerPane>
|
</actions>
|
||||||
</actions>
|
</JFXDialogLayout>
|
||||||
</JFXDialogLayout>
|
|
||||||
|
|
||||||
<JFXDialogLayout fx:id="confirmServerPane">
|
<JFXDialogLayout fx:id="confirmServerPane">
|
||||||
<heading>
|
<heading>
|
||||||
<Label text="%account.injector.add" />
|
<Label text="%account.injector.add" />
|
||||||
</heading>
|
</heading>
|
||||||
<body>
|
<body>
|
||||||
<GridPane vgap="15" hgap="15" style="-fx-padding: 15 0 0 0;">
|
<GridPane vgap="15" hgap="15" style="-fx-padding: 15 0 0 0;">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints maxWidth="100" />
|
<ColumnConstraints maxWidth="100" />
|
||||||
<ColumnConstraints />
|
<ColumnConstraints />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<Label text="%account.injector.server_url" GridPane.columnIndex="0" GridPane.rowIndex="0" />
|
<Label text="%account.injector.server_url" GridPane.columnIndex="0" GridPane.rowIndex="0" />
|
||||||
<Label text="%account.injector.server_name" GridPane.columnIndex="0" GridPane.rowIndex="1" />
|
<Label text="%account.injector.server_name" GridPane.columnIndex="0" GridPane.rowIndex="1" />
|
||||||
<Label fx:id="lblServerUrl" GridPane.columnIndex="1" GridPane.rowIndex="0" />
|
<Label fx:id="lblServerUrl" GridPane.columnIndex="1" GridPane.rowIndex="0" />
|
||||||
<Label fx:id="lblServerName" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
<Label fx:id="lblServerName" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||||
<Label fx:id="lblServerWarning" text="%account.injector.http" style="-fx-text-fill: red;"
|
<Label fx:id="lblServerWarning" text="%account.injector.http" style="-fx-text-fill: red;"
|
||||||
GridPane.rowIndex="2" GridPane.columnSpan="2" GridPane.columnIndex="0" />
|
GridPane.rowIndex="2" GridPane.columnSpan="2" GridPane.columnIndex="0" />
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</body>
|
</body>
|
||||||
<actions>
|
<actions>
|
||||||
<JFXButton onMouseClicked="#onAddPrev" text="%wizard.prev" styleClass="dialog-cancel" />
|
<JFXButton onMouseClicked="#onAddPrev" text="%wizard.prev" styleClass="dialog-cancel" />
|
||||||
<JFXButton onMouseClicked="#onAddCancel" text="%button.cancel" styleClass="dialog-cancel" />
|
<JFXButton onMouseClicked="#onAddCancel" text="%button.cancel" styleClass="dialog-cancel" />
|
||||||
<JFXButton onMouseClicked="#onAddFinish" text="%wizard.finish" styleClass="dialog-accept" />
|
<JFXButton onMouseClicked="#onAddFinish" text="%wizard.finish" styleClass="dialog-accept" />
|
||||||
</actions>
|
</actions>
|
||||||
</JFXDialogLayout>
|
</JFXDialogLayout>
|
||||||
</StackPane>
|
|
||||||
</StackPane>
|
</StackPane>
|
||||||
</fx:root>
|
</fx:root>
|
||||||
|
|||||||
Reference in New Issue
Block a user