From 64ed73b319033e89f746b07db8d9978703fe588d Mon Sep 17 00:00:00 2001 From: "youhong.ai" Date: Fri, 7 Jul 2023 17:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/BuilderPackageEcology.java | 39 ++++++++++++++++++- .../java/builderpackage/FileTreeBuilder.java | 6 +++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index 82102f1..eedc19f 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -1,4 +1,5 @@ import aiyh.utils.Util; +import aiyh.utils.tool.cn.hutool.core.util.StrUtil; import builderpackage.FileCompressor; import builderpackage.FileInfo; import builderpackage.FileTreeBuilder; @@ -27,6 +28,9 @@ public class BuilderPackageEcology extends Application { private TreeView treeView; private TreeItem rootItem; + private TextField packageNumberTextField; + private TextField functionNameTextField; + @Override public void start(Stage primaryStage) { primaryStage.setTitle("EBU7部开发一部自动打包工具"); @@ -37,10 +41,29 @@ public class BuilderPackageEcology extends Application { treeView = new TreeView<>(rootItem); treeView.setShowRoot(false); treeView.setCellFactory(treeViewParam -> new CheckBoxTreeCell()); + treeView.setPadding(new Insets(10)); BorderPane root = new BorderPane(); root.setCenter(treeView); + // 添加输入框 + HBox topBox = new HBox(10); + topBox.setPadding(new Insets(10)); + topBox.setAlignment(Pos.CENTER); + + // 创建包编号标签和输入框 + Label packageNumberLabel = new Label("包编号:"); + packageNumberTextField = new TextField(); + packageNumberTextField.setPromptText("请输入包编号"); + + // 创建功能名称标签和输入框 + Label functionNameLabel = new Label("功能名称:"); + functionNameTextField = new TextField(); + functionNameTextField.setPromptText("请输入功能名称"); + + topBox.getChildren().addAll(packageNumberLabel, packageNumberTextField, functionNameLabel, functionNameTextField); + root.setTop(topBox); + HBox buttonBox = new HBox(); buttonBox.setSpacing(10); buttonBox.setPadding(new Insets(10)); @@ -49,7 +72,13 @@ public class BuilderPackageEcology extends Application { Button button = new Button("生成升级包"); button.setOnAction(event -> { FileChooser fileChooser = new FileChooser(); - fileChooser.setInitialFileName("sh_ebu_dev_1_ecology.zip"); + String defaultName = FileTreeBuilder.zipDefaultName; + if (StrUtil.isBlank(defaultName)) { + defaultName = "sh_ebu_dev_1_ecology.zip"; + } + + fileChooser.setInitialFileName(defaultName); + // fileChooser.setInitialDirectory(); File outputFile = fileChooser.showSaveDialog(primaryStage); if (outputFile != null) { try { @@ -70,6 +99,12 @@ public class BuilderPackageEcology extends Application { updateTreeView(); showSuccessAlert("升级包制作成功!"); System.out.println("压缩包位置: " + outputFile.getPath()); + + // 输出包编号和功能名称的值 + String packageNumber = packageNumberTextField.getText(); + String functionName = functionNameTextField.getText(); + System.out.println("包编号: " + packageNumber); + System.out.println("功能名称: " + functionName); } catch (IOException e) { throw new RuntimeException(e); } @@ -87,9 +122,11 @@ public class BuilderPackageEcology extends Application { checkBoxBox.getChildren().add(checkBox); + buttonBox.getChildren().addAll(button, checkBoxBox); root.setBottom(buttonBox); + Scene scene = new Scene(root, 600, 400); scene.getStylesheets().add("style.css"); // 加载自定义的 CSS 文件 primaryStage.setScene(scene); diff --git a/src/test/java/builderpackage/FileTreeBuilder.java b/src/test/java/builderpackage/FileTreeBuilder.java index bbffa20..5b7e1a7 100644 --- a/src/test/java/builderpackage/FileTreeBuilder.java +++ b/src/test/java/builderpackage/FileTreeBuilder.java @@ -16,6 +16,10 @@ public class FileTreeBuilder { public static String classPath; + public static String zipDefaultName; + + public static String defaultDir; + public static FileInfo buildFileTree() { String directoryPath = "target"; String classRootPath = ""; @@ -40,6 +44,8 @@ public class FileTreeBuilder { } classRootPath = properties.getProperty("classRootPath"); classPath = classRootPath; + zipDefaultName = properties.getProperty("zipDefaultName"); + defaultDir = properties.getProperty("defaultDir"); List blacklistPrefixes = Arrays.asList( directoryPath + "generated-sources", directoryPath + "generated-test-sources",