fix: crash
This commit is contained in:
@@ -198,7 +198,7 @@ public final class LogWindow extends Stage {
|
|||||||
if (Desktop.isDesktopSupported()) {
|
if (Desktop.isDesktopSupported()) {
|
||||||
try {
|
try {
|
||||||
Desktop.getDesktop().open(logFile.toFile());
|
Desktop.getDesktop().open(logFile.toFile());
|
||||||
} catch (IOException ignored) {
|
} catch (IOException | IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.jackhuang.hmcl.ui.construct;
|
||||||
|
|
||||||
|
import com.jfoenix.validation.base.ValidatorBase;
|
||||||
|
import javafx.beans.NamedArg;
|
||||||
|
import javafx.scene.control.TextInputControl;
|
||||||
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
|
|
||||||
|
public class RequiredValidator extends ValidatorBase {
|
||||||
|
|
||||||
|
public RequiredValidator() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public RequiredValidator(@NamedArg("message") String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void eval() {
|
||||||
|
if (srcControl.get() instanceof TextInputControl) {
|
||||||
|
evalTextInputField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void evalTextInputField() {
|
||||||
|
TextInputControl textField = ((TextInputControl) srcControl.get());
|
||||||
|
|
||||||
|
hasErrors.set(StringUtils.isBlank(textField.getText()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.ui.export;
|
package org.jackhuang.hmcl.ui.export;
|
||||||
|
|
||||||
import com.jfoenix.controls.*;
|
import com.jfoenix.controls.*;
|
||||||
import com.jfoenix.validation.RequiredFieldValidator;
|
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
@@ -44,10 +43,7 @@ import org.jackhuang.hmcl.setting.Accounts;
|
|||||||
import org.jackhuang.hmcl.setting.VersionSetting;
|
import org.jackhuang.hmcl.setting.VersionSetting;
|
||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.construct.ComponentList;
|
import org.jackhuang.hmcl.ui.construct.*;
|
||||||
import org.jackhuang.hmcl.ui.construct.NumberValidator;
|
|
||||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
|
||||||
import org.jackhuang.hmcl.ui.construct.Validator;
|
|
||||||
import org.jackhuang.hmcl.ui.wizard.WizardController;
|
import org.jackhuang.hmcl.ui.wizard.WizardController;
|
||||||
import org.jackhuang.hmcl.ui.wizard.WizardPage;
|
import org.jackhuang.hmcl.ui.wizard.WizardPage;
|
||||||
import org.jackhuang.hmcl.util.StringUtils;
|
import org.jackhuang.hmcl.util.StringUtils;
|
||||||
@@ -218,9 +214,7 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
|||||||
txtModpackName.textProperty().bindBidirectional(skinnable.name);
|
txtModpackName.textProperty().bindBidirectional(skinnable.name);
|
||||||
txtModpackName.setLabelFloat(true);
|
txtModpackName.setLabelFloat(true);
|
||||||
txtModpackName.setPromptText(i18n("modpack.name"));
|
txtModpackName.setPromptText(i18n("modpack.name"));
|
||||||
RequiredFieldValidator validator = new RequiredFieldValidator();
|
txtModpackName.getValidators().add(new RequiredValidator(i18n("modpack.not_a_valid_name")));
|
||||||
validator.setMessage(i18n("modpack.not_a_valid_name"));
|
|
||||||
txtModpackName.getValidators().add(validator);
|
|
||||||
StackPane.setMargin(txtModpackName, insets);
|
StackPane.setMargin(txtModpackName, insets);
|
||||||
list.getContent().add(txtModpackName);
|
list.getContent().add(txtModpackName);
|
||||||
|
|
||||||
@@ -234,8 +228,7 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
|||||||
txtModpackFileApi.setPromptText(i18n("modpack.file_api"));
|
txtModpackFileApi.setPromptText(i18n("modpack.file_api"));
|
||||||
|
|
||||||
if (skinnable.options.isValidateFileApi()) {
|
if (skinnable.options.isValidateFileApi()) {
|
||||||
RequiredFieldValidator validator = new RequiredFieldValidator();
|
txtModpackFileApi.getValidators().add(new RequiredValidator());
|
||||||
txtModpackFileApi.getValidators().add(validator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
txtModpackFileApi.getValidators().add(new Validator(s -> {
|
txtModpackFileApi.getValidators().add(new Validator(s -> {
|
||||||
@@ -260,8 +253,7 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
|||||||
txtModpackAuthor.textProperty().bindBidirectional(skinnable.author);
|
txtModpackAuthor.textProperty().bindBidirectional(skinnable.author);
|
||||||
txtModpackAuthor.setLabelFloat(true);
|
txtModpackAuthor.setLabelFloat(true);
|
||||||
txtModpackAuthor.setPromptText(i18n("archive.author"));
|
txtModpackAuthor.setPromptText(i18n("archive.author"));
|
||||||
RequiredFieldValidator validator = new RequiredFieldValidator();
|
txtModpackAuthor.getValidators().add(new RequiredValidator());
|
||||||
txtModpackAuthor.getValidators().add(validator);
|
|
||||||
StackPane.setMargin(txtModpackAuthor, insets);
|
StackPane.setMargin(txtModpackAuthor, insets);
|
||||||
list.getContent().add(txtModpackAuthor);
|
list.getContent().add(txtModpackAuthor);
|
||||||
|
|
||||||
@@ -273,8 +265,7 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
|||||||
txtModpackVersion.textProperty().bindBidirectional(skinnable.version);
|
txtModpackVersion.textProperty().bindBidirectional(skinnable.version);
|
||||||
txtModpackVersion.setLabelFloat(true);
|
txtModpackVersion.setLabelFloat(true);
|
||||||
txtModpackVersion.setPromptText(i18n("archive.version"));
|
txtModpackVersion.setPromptText(i18n("archive.version"));
|
||||||
RequiredFieldValidator validator = new RequiredFieldValidator();
|
txtModpackVersion.getValidators().add(new RequiredValidator());
|
||||||
txtModpackVersion.getValidators().add(validator);
|
|
||||||
StackPane.setMargin(txtModpackVersion, insets);
|
StackPane.setMargin(txtModpackVersion, insets);
|
||||||
list.getContent().add(txtModpackVersion);
|
list.getContent().add(txtModpackVersion);
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
<?import com.jfoenix.validation.RequiredFieldValidator?>
|
<?import com.jfoenix.validation.RequiredFieldValidator?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import org.jackhuang.hmcl.ui.FXUtils?>
|
<?import javafx.scene.shape.SVGPath?>
|
||||||
|
<?import org.jackhuang.hmcl.ui.construct.RequiredValidator?>
|
||||||
<?import org.jackhuang.hmcl.ui.construct.SpinnerPane?>
|
<?import org.jackhuang.hmcl.ui.construct.SpinnerPane?>
|
||||||
|
<?import org.jackhuang.hmcl.ui.FXUtils?>
|
||||||
<fx:root xmlns:fx="http://javafx.com/fxml"
|
<fx:root xmlns:fx="http://javafx.com/fxml"
|
||||||
xmlns="http://javafx.com/javafx"
|
xmlns="http://javafx.com/javafx"
|
||||||
type="StackPane">
|
type="StackPane">
|
||||||
@@ -50,8 +52,8 @@
|
|||||||
<JFXTextField fx:id="txtUsername" GridPane.columnIndex="1" GridPane.rowIndex="2" GridPane.columnSpan="2"
|
<JFXTextField fx:id="txtUsername" GridPane.columnIndex="1" GridPane.rowIndex="2" GridPane.columnSpan="2"
|
||||||
FXUtils.validateWhileTextChanged="true" onAction="#onCreationAccept">
|
FXUtils.validateWhileTextChanged="true" onAction="#onCreationAccept">
|
||||||
<validators>
|
<validators>
|
||||||
<RequiredFieldValidator message="%input.not_empty">
|
<RequiredValidator message="%input.not_empty">
|
||||||
</RequiredFieldValidator>
|
</RequiredValidator>
|
||||||
</validators>
|
</validators>
|
||||||
</JFXTextField>
|
</JFXTextField>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user