diff --git a/src/test/java/BuilderPackageEcology.java b/src/test/java/BuilderPackageEcology.java index fc9c4e8..5dab3d7 100644 --- a/src/test/java/BuilderPackageEcology.java +++ b/src/test/java/BuilderPackageEcology.java @@ -6,11 +6,14 @@ import builderpackage.FileTreeBuilder; import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; +import javafx.scene.Cursor; +import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.*; +import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; @@ -36,6 +39,7 @@ public class BuilderPackageEcology extends Application { private TextField packageNumberTextField; private TextField functionNameTextField; + @Override public void start(Stage primaryStage) { primaryStage.setTitle("EBU7部开发一部自动打包工具"); @@ -80,6 +84,10 @@ public class BuilderPackageEcology extends Application { Date date = new Date(); param.put("date", simpleDateFormat.format(date)); Button button = new Button("生成升级包"); + button.setId("create-btn"); + button.setCursor(Cursor.HAND); + button.getStyleClass().add("but"); + button.getStyleClass().add("primary"); button.setOnAction(event -> { // 输出包编号和功能名称的值 String packageNumber = packageNumberTextField.getText(); @@ -136,10 +144,11 @@ public class BuilderPackageEcology extends Application { checkBoxBox.setAlignment(Pos.CENTER_RIGHT); CheckBox checkBox = new CheckBox("是否是信创环境"); + checkBox.setCursor(Cursor.HAND); + checkBox.getStyleClass().add("check-box"); checkBox.selectedProperty().addListener((observable, oldValue, newValue) -> { this.isEcology = newValue; }); - checkBoxBox.getChildren().add(checkBox); @@ -148,7 +157,7 @@ public class BuilderPackageEcology extends Application { Scene scene = new Scene(root, 600, 400); - scene.getStylesheets().add("style.css"); // 加载自定义的 CSS 文件 + scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm()); // 加载自定义的 CSS 文件 scene.getRoot().setStyle("-fx-font-family: 'serif'"); primaryStage.setScene(scene); primaryStage.show(); @@ -202,10 +211,11 @@ public class BuilderPackageEcology extends Application { public CheckBoxTreeCell() { checkBox = new CheckBox(); + checkBox.getStyleClass().add("check-box"); checkBox.selectedProperty().addListener((observable, oldValue, newValue) -> { - FileInfo fileInfo = getItem(); - fileInfo.setSelected(newValue); - String filePath = fileInfo.getFilePath(); + FileInfo item = getItem(); + item.setSelected(newValue); + String filePath = item.getFilePath(); if (newValue) { if (!filePaths.contains(filePath)) { filePaths.add(filePath); @@ -225,6 +235,35 @@ public class BuilderPackageEcology extends Application { } else { checkBox.setSelected(item.isSelected()); checkBox.setText(item.getFileName().replace("_", "__")); + if (item.isDirectory()) { + Node rootIcon = new ImageView( + new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream("icons/folder.png"))) + );// 定义一个图片类型节点对象 + + checkBox.setGraphic(rootIcon); + } else if (item.getFileName().endsWith(".jar")) { + Node fileIcon = new ImageView( + new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream("icons/jar.png"))) + ); + checkBox.setGraphic(fileIcon); + } else if (item.getFileName().endsWith(".class")) { + Node fileIcon = new ImageView( + new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream("icons/class.png"))) + ); + checkBox.setGraphic(fileIcon); + } else if (item.getFileName().endsWith(".properties")) { + Node fileIcon = new ImageView( + new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream("icons/code.png"))) + ); + checkBox.setGraphic(fileIcon); + } else { + Node fileIcon = new ImageView( + new javafx.scene.image.Image(Objects.requireNonNull(getClass().getResourceAsStream("icons/file.png"))) + ); + checkBox.setGraphic(fileIcon); + } + checkBox.setCursor(Cursor.HAND); + checkBox.setId("tree-checkbox"); setGraphic(checkBox); // setGraphic(folderIcon); } diff --git a/src/test/resources/cf-colors.css b/src/test/resources/cf-colors.css new file mode 100644 index 0000000..09e7599 --- /dev/null +++ b/src/test/resources/cf-colors.css @@ -0,0 +1,13 @@ +/*颜色*/ + +* { + -primary-color: #6690FF; + -success-color: #33C651; + -info-color: #52A8F9; + -warn-color: #FFA10A; + -danger-color: #FF4C3F; + + -text-color: #303133; + -border-color: #CDD0D6; + -base-color: #F2F3F5; +} \ No newline at end of file diff --git a/src/test/resources/icons/class.png b/src/test/resources/icons/class.png new file mode 100644 index 0000000..97352ea Binary files /dev/null and b/src/test/resources/icons/class.png differ diff --git a/src/test/resources/icons/code.png b/src/test/resources/icons/code.png new file mode 100644 index 0000000..275b427 Binary files /dev/null and b/src/test/resources/icons/code.png differ diff --git a/src/test/resources/icons/file.png b/src/test/resources/icons/file.png index 09b4c8e..55814fd 100644 Binary files a/src/test/resources/icons/file.png and b/src/test/resources/icons/file.png differ diff --git a/src/test/resources/icons/folder.png b/src/test/resources/icons/folder.png index b2b1ab8..e221438 100644 Binary files a/src/test/resources/icons/folder.png and b/src/test/resources/icons/folder.png differ diff --git a/src/test/resources/icons/jar.png b/src/test/resources/icons/jar.png new file mode 100644 index 0000000..d1bd1aa Binary files /dev/null and b/src/test/resources/icons/jar.png differ diff --git a/src/test/resources/style.css b/src/test/resources/style.css index d154fc6..1d86afe 100644 --- a/src/test/resources/style.css +++ b/src/test/resources/style.css @@ -1,22 +1,24 @@ +@import "cf-colors.css"; + + .tree-view { -fx-padding: 10px; + -fx-alignment: center; } .tree-cell { - -fx-padding: 5px; + -fx-padding: 6px; + -fx-font-size: 14px; } -.tree-cell .tree-disclosure-node { - -fx-graphic: url("icons/folder.png"); +.tree-cell.expanded { + -fx-alignment: center; } -.tree-cell .tree-disclosure-node.expanded { - -fx-graphic: url("icons/folder.png"); +.tree-cell:selected { + -fx-background-color: -primary-color; } -.tree-cell .tree-leaf { - -fx-graphic: url("icons/file.png"); -} .button-box { -fx-spacing: 10px; @@ -26,3 +28,248 @@ .checkbox-label { -fx-padding: 0 0 0 5px; } + + +.check-box { + -fx-cursor: hand; +} + +.check-box { + -fx-pref-height: 32px; +} + +.check-box .box { + -fx-pref-height: 16px; + -fx-pref-width: 16px; + -fx-border-radius: 3px; + -fx-border-color: -border-color; + -fx-background-color: transparent; + -fx-background-radius: 3px; +} + +.check-box .box .mark { + -fx-background-color: rgb(255, 255, 255); + -fx-background-insets: 3px 2px; + -fx-shape: "M369.792 704.32L930.304 128 1024 223.616 369.984 896l-20.288-20.864-0.128 0.128L0 516.8 96.128 423.68l273.664 280.64z"; +} + +.check-box .container { + -fx-text-fill: -text-color; + -fx-font-size: 14px; +} + +.check-box:focused { + -fx-border-color: -primary-color; +} + +.check-box:selected { + -fx-text-fill: -primary-color; +} + +.check-box:selected .box { + -fx-border-color: -primary-color; + -fx-background-color: -primary-color; +} + + +.but { + -fx-background-insets: 0; + -fx-border-radius: 3px; + /*-fx-border-color: transparent;*/ + -fx-background-radius: 3px; + -fx-pref-height: 32px; + /*-fx-min-height: 32px;*/ + -fx-padding: 0px 15px 0px 15px; + -fx-font-size: 14px; + -fx-font-weight: 500; + -fx-text-fill: rgb(255, 255, 255); + -fx-cursor: hand; +} + +.but > .ikonli-font-icon { + -fx-icon-size: 17px; + -fx-icon-color: rgb(255, 255, 255); +} + +.but.primary { + -fx-background-color: -primary-color; +} + +.but.success { + -fx-background-color: -success-color; +} + +.but.info { + -fx-background-color: -info-color; +} + +.but.warn { + -fx-background-color: -warn-color; +} + +.but.danger { + -fx-background-color: -danger-color; +} + +/*hover:*/ /*focused:*/ +.but.primary:hover, .but.primary:focused { + -fx-background-color: derive(-primary-color, 30%); +} + +.but.success:hover, .but.success:focused { + -fx-background-color: derive(-success-color, 30%); +} + +.but.info:hover, .but.info:focused { + -fx-background-color: derive(-info-color, 30%); +} + +.but.warn:hover, .but.warn:focused { + -fx-background-color: derive(-warn-color, 30%); +} + +.but.danger:hover, .but.danger:focused { + -fx-background-color: derive(-danger-color, 30%); +} + +/*pressed:*/ +.but.primary:pressed { + -fx-background-color: derive(-primary-color, -10%); +} + +.but.success:pressed { + -fx-background-color: derive(-success-color, -10%); +} + +.but.info:pressed { + -fx-background-color: derive(-info-color, -10%); +} + +.but.warn:pressed { + -fx-background-color: derive(-warn-color, -10%); +} + +.but.danger:pressed { + -fx-background-color: derive(-danger-color, -10%); +} + +/*圆角按钮*/ +.but.round { + -fx-border-radius: 16px; + -fx-background-radius: 16px; +} + +/*朴素按钮*/ +.but.plain, .but.plain:focused { + -fx-background-color: transparent; +} + +.but.primary.plain { + -fx-border-color: -primary-color; + -fx-text-fill: -primary-color; +} + +.but.success.plain { + -fx-border-color: -success-color; + -fx-text-fill: -success-color; +} + +.but.info.plain { + -fx-border-color: -info-color; + -fx-text-fill: -info-color; +} + +.but.warn.plain { + -fx-border-color: -warn-color; + -fx-text-fill: -warn-color; +} + +.but.danger.plain { + -fx-border-color: -danger-color; + -fx-text-fill: -danger-color; +} + +.but.primary.plain > .ikonli-font-icon { + -fx-icon-color: -primary-color; +} + +.but.success.plain > .ikonli-font-icon { + -fx-icon-color: -success-color; +} + +.but.info.plain > .ikonli-font-icon { + -fx-icon-color: -info-color; +} + +.but.warn.plain > .ikonli-font-icon { + -fx-icon-color: -warn-color; +} + +.but.danger.plain > .ikonli-font-icon { + -fx-icon-color: -danger-color; +} + +.but.primary.plain:hover > .ikonli-font-icon { + -fx-icon-color: rgb(255, 255, 255); +} + +.but.success.plain:hover > .ikonli-font-icon { + -fx-icon-color: rgb(255, 255, 255); +} + +.but.info.plain:hover > .ikonli-font-icon { + -fx-icon-color: rgb(255, 255, 255); +} + +.but.warn.plain:hover > .ikonli-font-icon { + -fx-icon-color: rgb(255, 255, 255); +} + +.but.danger.plain:hover > .ikonli-font-icon { + -fx-icon-color: rgb(255, 255, 255); +} + +.but.primary.plain:hover { + -fx-background-color: -primary-color; + -fx-text-fill: rgb(255, 255, 255); +} + +.but.success.plain:hover { + -fx-background-color: -success-color; + -fx-text-fill: rgb(255, 255, 255); +} + +.but.info.plain:hover { + -fx-background-color: -info-color; + -fx-text-fill: rgb(255, 255, 255); +} + +.but.warn.plain:hover { + -fx-background-color: -warn-color; + -fx-text-fill: rgb(255, 255, 255); +} + +.but.danger.plain:hover { + -fx-background-color: -danger-color; + -fx-text-fill: rgb(255, 255, 255); +} + +.but.primary.plain:pressed { + -fx-background-color: derive(-primary-color, -10%); +} + +.but.success.plain:pressed { + -fx-background-color: derive(-success-color, -10%); +} + +.but.info.plain:pressed { + -fx-background-color: derive(-info-color, -10%); +} + +.but.warn.plain:pressed { + -fx-background-color: derive(-warn-color, -10%); +} + +.but.danger.plain:pressed { + -fx-background-color: derive(-danger-color, -10%); +} \ No newline at end of file