Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.Skin;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
Expand Down Expand Up @@ -157,20 +160,9 @@ public void onCreateDirectory() {
return;

Path parent = currentDirectory.path;
Controllers.dialog(new InputDialogPane(
Controllers.prompt(
i18n("schematics.create_directory.prompt"),
"",
(result, handler) -> {
if (StringUtils.isBlank(result)) {
handler.reject(i18n("schematics.create_directory.failed.empty_name"));
return;
}

if (result.contains("/") || result.contains("\\") || !FileUtils.isNameValid(result)) {
handler.reject(i18n("schematics.create_directory.failed.invalid_name"));
return;
}

Path targetDir = parent.resolve(result);
if (Files.exists(targetDir)) {
handler.reject(i18n("schematics.create_directory.failed.already_exists"));
Expand All @@ -185,7 +177,7 @@ public void onCreateDirectory() {
LOG.warning("Failed to create directory: " + targetDir, e);
handler.reject(i18n("schematics.create_directory.failed", targetDir));
}
}));
}, "", new RequiredValidator(), new Validator(i18n("schematics.create_directory.failed.invalid_name"), FileUtils::isNameValid));
}

private DirItem loadAll(Path dir, @Nullable DirItem parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.construct.InputDialogPane;
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
import org.jackhuang.hmcl.ui.construct.RequiredValidator;
import org.jackhuang.hmcl.ui.construct.Validator;
import org.jackhuang.hmcl.ui.wizard.SinglePageWizardProvider;
import org.jackhuang.hmcl.util.StringUtils;
import org.jackhuang.hmcl.util.io.FileUtils;
Expand Down Expand Up @@ -89,20 +90,9 @@ public static void export(World world, FileChannel sessionLockChannel) {

public static void copyWorld(World world, Runnable runnable) {
Path worldPath = world.getFile();
Controllers.dialog(new InputDialogPane(
Controllers.prompt(
i18n("world.duplicate.prompt"),
"",
(result, handler) -> {
if (StringUtils.isBlank(result)) {
handler.reject(i18n("world.duplicate.failed.empty_name"));
return;
}

if (result.contains("/") || result.contains("\\") || !FileUtils.isNameValid(result)) {
handler.reject(i18n("world.duplicate.failed.invalid_name"));
return;
}

Path targetDir = worldPath.resolveSibling(result);
if (Files.exists(targetDir)) {
handler.reject(i18n("world.duplicate.failed.already_exists"));
Expand All @@ -125,7 +115,7 @@ public static void copyWorld(World world, Runnable runnable) {
}
})
.start();
}));
}, "", new RequiredValidator(), new Validator(i18n("world.duplicate.failed.invalid_name"), FileUtils::isNameValid));
}

public static void closeSessionLockChannel(World world, FileChannel sessionLockChannel) throws IOException {
Expand Down