From c75716f11372e287c710ec4efbc120b733800730 Mon Sep 17 00:00:00 2001 From: "XUFENG-PC\\xufeng" <1277032935@qq.com> Date: Fri, 7 Aug 2020 19:27:00 +0800 Subject: [PATCH 01/30] =?UTF-8?q?=E8=B0=83=E6=95=B4pom=E6=96=87=E4=BB=B6ja?= =?UTF-8?q?r=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 5ebf011..bd21e61 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xwintop xcore - 0.0.6 + 0.0.6-jdk11 jar xcore @@ -12,8 +12,8 @@ https://gitee.com/xwintop/xcore - 1.8 - 1.8 + 11 + 11 UTF-8 @@ -47,6 +47,42 @@ + + org.openjfx + javafx-controls + 11.0.2 + + + org.openjfx + javafx-base + 11.0.2 + + + org.openjfx + javafx-graphics + 11.0.2 + + + org.openjfx + javafx-fxml + 11.0.2 + + + org.openjfx + javafx-swing + 11.0.2 + + + org.openjfx + javafx-media + 11.0.2 + + + org.openjfx + javafx-web + 11.0.2 + + junit junit @@ -83,13 +119,13 @@ org.controlsfx controlsfx - 8.40.16 + 11.0.2 com.jfoenix jfoenix - 8.0.9 + 9.0.10 @@ -200,6 +236,11 @@ -Dfile.encoding=UTF-8 + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + -- Gitee From 450f8ced0b432f67495f9bad8dc45ae06f911f12 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Sun, 16 Aug 2020 16:30:13 +0800 Subject: [PATCH 02/30] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- pom.xml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 29ed5a8..17c7c39 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /data /log/ /target/ -/.idea \ No newline at end of file +/.idea +C: \ No newline at end of file diff --git a/pom.xml b/pom.xml index bd21e61..89b88e2 100644 --- a/pom.xml +++ b/pom.xml @@ -181,7 +181,7 @@ org.projectlombok lombok - 1.18.6 + 1.18.12 provided -- Gitee From 13aebc687a58b7c8ad7bd010578cf0e2efeeb505 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Mon, 21 Dec 2020 16:42:27 +0800 Subject: [PATCH 03/30] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E5=92=8C=20JDK=20=E7=89=88=E6=9C=AC=E5=88=B0?= =?UTF-8?q?=20java15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 133 ++++++++++++++++++++++---------------------------------- 1 file changed, 53 insertions(+), 80 deletions(-) diff --git a/pom.xml b/pom.xml index 89b88e2..e47f28b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xwintop xcore - 0.0.6-jdk11 + 0.0.6-jdk15-SNAPSHOT jar xcore @@ -12,9 +12,10 @@ https://gitee.com/xwintop/xcore - 11 - 11 UTF-8 + true + 15 + 15 @@ -22,65 +23,28 @@ aliyunmaven http://maven.aliyun.com/nexus/content/groups/public/ - - spring-snapshots - http://repo.spring.io/snapshot - - true - - - - spring-milestones - http://repo.spring.io/milestone - - - apache.snapshots - Apache Development Snapshot Repository - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - org.openjfx javafx-controls - 11.0.2 - - - org.openjfx - javafx-base - 11.0.2 - - - org.openjfx - javafx-graphics - 11.0.2 + 15 org.openjfx javafx-fxml - 11.0.2 + 15 org.openjfx javafx-swing - 11.0.2 - - - org.openjfx - javafx-media - 11.0.2 + 15 org.openjfx javafx-web - 11.0.2 + 15 @@ -89,11 +53,13 @@ 4.12 test + ch.qos.logback logback-classic 1.2.3 + provided @@ -113,13 +79,14 @@ org.quartz-scheduler quartz 2.3.1 + provided org.controlsfx controlsfx - 11.0.2 + 11.0.3 @@ -208,39 +175,45 @@ - - - xwintop-maven - file:C:/gitFiles/maven/repository/ - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.2 - - UTF-8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.20 - - true - once - -Dfile.encoding=UTF-8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - + + + dev-local + + + xwintop-maven + file:C:/gitFiles/maven/repository/ + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + UTF-8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + true + once + -Dfile.encoding=UTF-8 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + + + + -- Gitee From 4054d294a8e0c572ad7eae44d5227eea4821d5d9 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Mon, 21 Dec 2020 18:44:05 +0800 Subject: [PATCH 04/30] =?UTF-8?q?FxAlerts=20=E6=B7=BB=E5=8A=A0=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 12 +++-- .../xwintop/xcore/javafx/dialog/FxAlerts.java | 51 +++++++++++++++---- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 17c7c39..46fd667 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ # Default ignored files #/.gitignore -/xcore.iml -/data -/log/ -/target/ -/.idea +data +log/ +target/ +.idea/ +.mvnd/ +*.iml + C: \ No newline at end of file diff --git a/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java b/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java index 96ce31a..26d6290 100644 --- a/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java +++ b/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java @@ -1,21 +1,31 @@ package com.xwintop.xcore.javafx.dialog; import com.xwintop.xcore.javafx.FxApp; -import java.util.Optional; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; import javafx.scene.control.TextArea; import javafx.scene.layout.GridPane; import javafx.scene.layout.Priority; import javafx.stage.Stage; +import javafx.stage.Window; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import java.util.Optional; + /** * 系统对话框封装 */ public class FxAlerts { + public static void info(String title, String message) { + alert(Alert.AlertType.INFORMATION, title, message); + } + + public static void warn(String title, String message) { + alert(Alert.AlertType.WARNING, title, message); + } + public static void error(String message) { alert(Alert.AlertType.ERROR, "错误", message); } @@ -24,21 +34,25 @@ public class FxAlerts { alert(Alert.AlertType.ERROR, title, message); } + public static void error(Window owner, String title, String message) { + alert(owner, Alert.AlertType.ERROR, title, message); + } + public static void error(String title, Throwable throwable) { boolean noMessage = StringUtils.isBlank(throwable.getMessage()); String message = noMessage ? throwable.toString() : throwable.getMessage(); error(title, message, ExceptionUtils.getStackTrace(throwable)); } - public static void info(String title, String message) { - alert(Alert.AlertType.INFORMATION, title, message); + public static void error(Window owner, String title, Throwable throwable) { + boolean noMessage = StringUtils.isBlank(throwable.getMessage()); + String message = noMessage ? throwable.toString() : throwable.getMessage(); + error(owner, title, message, ExceptionUtils.getStackTrace(throwable)); } - public static void warn(String title, String message) { - alert(Alert.AlertType.WARNING, title, message); - } + public static void alert(Alert.AlertType alertType, String title, String message) {} - public static void alert(Alert.AlertType alertType, String title, String message) { + public static void alert(Window owner, Alert.AlertType alertType, String title, String message) { FxApp.runLater(() -> { try { Alert alert = new Alert(alertType, message, ButtonType.OK); @@ -47,7 +61,12 @@ public class FxAlerts { Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); FxApp.setupIcon(stage); - FxApp.setupModality(alert); + + if (owner != null) { + stage.initOwner(owner); + } else { + FxApp.setupModality(alert); + } alert.showAndWait(); } catch (Exception e) { @@ -58,10 +77,15 @@ public class FxAlerts { // 打开一个展示了详细错误信息的错误对话框 public static void error(String title, String message, String details) { - FxApp.runLater(() -> error0(title, message, details)); + FxApp.runLater(() -> error0(null, title, message, details)); } - private static void error0(String title, String message, String details) { + // 打开一个展示了详细错误信息的错误对话框 + public static void error(Window owner, String title, String message, String details) { + FxApp.runLater(() -> error0(owner, title, message, details)); + } + + private static void error0(Window owner, String title, String message, String details) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(title); alert.setHeaderText(null); @@ -84,7 +108,12 @@ public class FxAlerts { Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); FxApp.setupIcon(stage); - FxApp.setupModality(alert); + + if (owner != null) { + stage.initOwner(owner); + } else { + FxApp.setupModality(alert); + } alert.showAndWait(); } -- Gitee From 2b4effa2a6b642bed8cf3b9de4f1368f29e1a639 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Thu, 24 Dec 2020 15:21:14 +0800 Subject: [PATCH 05/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20ListCellFactory,=20T?= =?UTF-8?q?reeCellFactory,=20ComboBoxDecorator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 31 +++- .../xcore/javafx/cells/ListCellFactory.java | 135 ++++++++++++++++++ .../xcore/javafx/cells/TreeCellFactory.java | 91 ++++++++++++ .../javafx/decorator/ComboBoxDecorator.java | 103 +++++++++++++ 4 files changed, 355 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/xwintop/xcore/javafx/cells/ListCellFactory.java create mode 100644 src/main/java/com/xwintop/xcore/javafx/cells/TreeCellFactory.java create mode 100644 src/main/java/com/xwintop/xcore/javafx/decorator/ComboBoxDecorator.java diff --git a/.editorconfig b/.editorconfig index af32f61..ba60bec 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,30 @@ -[*] +root = true + +[*.{txt, java, xml, md, properties}] charset = utf-8 -end_of_line = lf -insert_final_newline = false indent_style = space +end_of_line = lf + +[*.{txt, java, xml}] indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +insert_final_newline = false +trim_trailing_whitespace = false + +[*.java] +ij_java_blank_lines_around_field = 1 +ij_java_blank_lines_after_class_header = 1 +ij_java_doc_add_blank_line_after_return = true +ij_java_doc_add_blank_line_after_param_comments = true +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_keep_empty_parameter_tag = false +ij_java_doc_keep_empty_return_tag = false +ij_java_doc_keep_empty_throws_tag = false + +[*.properties] +ij_properties_keep_blank_lines = true +ij_properties_spaces_around_key_value_delimiter = true -[*.{html, xml, yaml}] -indent_size = 2 diff --git a/src/main/java/com/xwintop/xcore/javafx/cells/ListCellFactory.java b/src/main/java/com/xwintop/xcore/javafx/cells/ListCellFactory.java new file mode 100644 index 0000000..b7cc5ec --- /dev/null +++ b/src/main/java/com/xwintop/xcore/javafx/cells/ListCellFactory.java @@ -0,0 +1,135 @@ +package com.xwintop.xcore.javafx.cells; + +import javafx.beans.value.ObservableValue; +import javafx.scene.Node; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.util.Callback; + +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * 封装对列表节点的配置 + * + * @author yiding.he + */ +public class ListCellFactory implements Callback, ListCell> { + + private Function textFunction; + + private Function> textProperty; + + private Function graphicFunction; + + private Function> graphicProperty; + + private Consumer> cellInitializer; + + /** + * 对 ListCell 的额外配置 + */ + public ListCellFactory setCellInitializer(Consumer> cellInitializer) { + this.cellInitializer = cellInitializer; + return this; + } + + /** + * 设置列表项文本 + */ + public ListCellFactory withTextFunction(Function toStringFunction) { + if (this.textProperty != null) { + throw new IllegalStateException("You have already assigned textProperty."); + } + this.textFunction = toStringFunction; + return this; + } + + /** + * 绑定列表项文本为一个自动更新的属性 + */ + public ListCellFactory withTextProperty(Function> toStringProperty) { + if (this.textFunction != null) { + throw new IllegalStateException("You have already assigned textFunction."); + } + this.textProperty = toStringProperty; + return this; + } + + /** + * 设置列表项图标 + */ + public ListCellFactory withGraphicFunction(Function graphicFunction) { + if (this.graphicProperty != null) { + throw new IllegalStateException("You have already assigned graphicProperty."); + } + this.graphicFunction = graphicFunction; + return this; + } + + /** + * 绑定列表项图标为一个自动更新的属性 + */ + public ListCellFactory withGraphicProperty(Function> graphicProperty) { + if (this.graphicFunction != null) { + throw new IllegalStateException("You have already assigned graphicFunction."); + } + this.graphicProperty = graphicProperty; + return this; + } + + @Override + public ListCell call(ListView param) { + + ListCell listCell = new ListCell() { + @Override + protected void updateItem(T item, boolean empty) { + super.updateItem(item, empty); + + if (textProperty().isBound()) { + textProperty().unbind(); + } + if (graphicProperty().isBound()) { + graphicProperty().unbind(); + } + + if (empty) { + setText(null); + setGraphic(null); + } else { + setCellText(this, item); + setCellGraphic(this, item); + } + } + }; + + if (cellInitializer != null) { + cellInitializer.accept(listCell); + } + + return listCell; + } + + private void setCellGraphic(ListCell cell, T item) { + if (graphicFunction != null) { + cell.setGraphic(graphicFunction.apply(item)); + } + if (graphicProperty != null) { + cell.graphicProperty().unbind(); + cell.graphicProperty().bind(graphicProperty.apply(item)); + } + } + + private void setCellText(ListCell cell, T item) { + if (textFunction != null) { + cell.setText(textFunction.apply(item)); + } + if (textProperty != null) { + cell.textProperty().unbind(); + cell.textProperty().bind(textProperty.apply(item)); + } + if (textFunction == null && textProperty == null) { + cell.setText(String.valueOf(item)); + } + } +} diff --git a/src/main/java/com/xwintop/xcore/javafx/cells/TreeCellFactory.java b/src/main/java/com/xwintop/xcore/javafx/cells/TreeCellFactory.java new file mode 100644 index 0000000..8755272 --- /dev/null +++ b/src/main/java/com/xwintop/xcore/javafx/cells/TreeCellFactory.java @@ -0,0 +1,91 @@ +package com.xwintop.xcore.javafx.cells; + +import javafx.scene.control.TreeCell; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeView; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.util.Callback; + +import java.util.function.Consumer; +import java.util.function.Function; + +/** + * 封装对 TreeView 的配置过程 + * + * @author yiding.he + */ +public class TreeCellFactory implements Callback, TreeCell> { + + private Consumer onDoubleClick; + + private Function toString; + + private Function, Image> iconSupplier; + + /** + * 设置当双击树节点时要做的事 + */ + public TreeCellFactory setOnDoubleClick(Consumer onDoubleClick) { + this.onDoubleClick = onDoubleClick; + return this; + } + + /** + * 设置树节点文本 + */ + public TreeCellFactory setToString(Function toString) { + this.toString = toString; + return this; + } + + /** + * 设置树节点图标 + */ + public TreeCellFactory setIconSupplier(Function, Image> iconSupplier) { + this.iconSupplier = iconSupplier; + return this; + } + + @Override + public TreeCell call(TreeView param) { + TreeCell treeCell = new TreeCell() { + @Override + protected void updateItem(T item, boolean empty) { + super.updateItem(item, empty); + + if (empty) { + setText(null); + setGraphic(null); + } else { + setCellText(item); + setCellIcon(this.getTreeItem()); + } + } + + private void setCellIcon(TreeItem treeItem) { + if (iconSupplier != null) { + Image image = iconSupplier.apply(treeItem); + ImageView imageView = new ImageView(image); + imageView.setFitWidth(16); + imageView.setFitHeight(16); + setGraphic(imageView); + } + } + + private void setCellText(T item) { + setText(toString != null ? toString.apply(item) : String.valueOf(item)); + } + }; + + if (onDoubleClick != null) { + treeCell.setOnMouseClicked(event -> { + if (!treeCell.isEmpty() && event.getClickCount() == 2) { + onDoubleClick.accept(treeCell.getItem()); + } + }); + } + + return treeCell; + } +} diff --git a/src/main/java/com/xwintop/xcore/javafx/decorator/ComboBoxDecorator.java b/src/main/java/com/xwintop/xcore/javafx/decorator/ComboBoxDecorator.java new file mode 100644 index 0000000..d9d72a2 --- /dev/null +++ b/src/main/java/com/xwintop/xcore/javafx/decorator/ComboBoxDecorator.java @@ -0,0 +1,103 @@ +package com.xwintop.xcore.javafx.decorator; + +import com.xwintop.xcore.javafx.cells.ListCellFactory; +import javafx.scene.control.ComboBox; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.control.cell.ComboBoxListCell; +import javafx.util.Callback; +import javafx.util.StringConverter; + +import java.util.Collection; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; + +/** + * 封装对 ComboBox 的配置 + */ +@SuppressWarnings("unchecked") +public class ComboBoxDecorator { + + public static ComboBoxDecorator of(ComboBox comboBox) { + return new ComboBoxDecorator<>(comboBox); + } + + private ComboBox comboBox; + + private ComboBoxDecorator(ComboBox comboBox) { + this.comboBox = comboBox; + } + + /** + * 设置下拉选项和当前选项的文本 + */ + public ComboBoxDecorator setToStringFunction(Function toString) { + setCellFactory(new ListCellFactory().withTextFunction(toString)); + return this; + } + + /** + * 设置下拉选项的 CellFactory + */ + public ComboBoxDecorator setCellFactory(Callback, ListCell> cellFactory) { + this.comboBox.setCellFactory(cellFactory); + this.comboBox.setButtonCell(cellFactory.call(null)); + return this; + } + + /** + * 设置当前选项的文本 + */ + public ComboBoxDecorator setButtonCellToStringFunction(Function toStringFunction) { + this.comboBox.setButtonCell(new ComboBoxListCell<>(new StringConverter() { + @Override + public String toString(T object) { + return toStringFunction.apply(object); + } + + @Override + public T fromString(String string) { + return null; + } + })); + return this; + } + + /** + * 设置选项列表 + */ + public ComboBoxDecorator setItems(Collection tCollection) { + this.comboBox.getItems().setAll(tCollection); + return this; + } + + /** + * 设置选项列表 + */ + @SafeVarargs + public final ComboBoxDecorator setItems(T... tCollection) { + this.comboBox.getItems().setAll(tCollection); + return this; + } + + /** + * 根据指定规则设置当前选项 + */ + public ComboBoxDecorator setInitialValue(Predicate valueMatcher) { + this.comboBox.getSelectionModel().select( + this.comboBox.getItems().stream().filter(valueMatcher).findFirst().orElse(null) + ); + return this; + } + + /** + * 设置当选项变化时的处理 + */ + public ComboBoxDecorator setOnChange(Consumer newValueConsumer) { + this.comboBox.getSelectionModel().selectedItemProperty().addListener( + (_ob, _old, _new) -> newValueConsumer.accept(_new) + ); + return this; + } +} -- Gitee From 36354daa8b4a1895b0d5266cb45097a678b9d84b Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Sat, 5 Sep 2020 22:07:48 +0800 Subject: [PATCH 06/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 +- .../xwintop/xcore/util/javafx/ActionJob.java | 13 ++ .../xcore/util/javafx/ActionScheduleUtil.java | 145 ++++++++++++++++++ 3 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/xwintop/xcore/util/javafx/ActionJob.java create mode 100644 src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java diff --git a/README.md b/README.md index 620c533..782b7ef 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ com.xwintop xcore - 0.0.3-SNAPSHOT + 0.0.6 provided @@ -43,4 +43,7 @@ git 托管 maven可参考教程(若无法下载请拉取项目自行编译)。[ - 0.0.4-SNAPSHOT 2020-03-16 1. 优化界面布局 - 0.0.5 2020-03-16 - 1. 添加进度条对话框 \ No newline at end of file + 1. 添加进度条对话框 +- 0.0.6 2020-07-04 + 1. 添加历史输入框功能封装 + 2. 优化部分功能代码 \ No newline at end of file diff --git a/src/main/java/com/xwintop/xcore/util/javafx/ActionJob.java b/src/main/java/com/xwintop/xcore/util/javafx/ActionJob.java new file mode 100644 index 0000000..8206892 --- /dev/null +++ b/src/main/java/com/xwintop/xcore/util/javafx/ActionJob.java @@ -0,0 +1,13 @@ +package com.xwintop.xcore.util.javafx; + +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +public class ActionJob implements Job { + @Override + public void execute(JobExecutionContext context) throws JobExecutionException { + Runnable runnable = (Runnable) context.getMergedJobDataMap().get("runnable"); + runnable.run(); + } +} diff --git a/src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java new file mode 100644 index 0000000..d7e24bd --- /dev/null +++ b/src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java @@ -0,0 +1,145 @@ +package com.xwintop.xcore.util.javafx; + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.geometry.Pos; +import javafx.scene.control.*; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.quartz.*; +import org.quartz.impl.StdSchedulerFactory; + +/** + * @ClassName: ScheduleManager + * @Description: 自动任务管理类 + * @author: xufeng + * @date: 2018/1/25 16:35 + */ + +@Getter +@Setter +@Slf4j +public class ActionScheduleUtil { + private static final String[] quartzChoiceBoxStrings = new String[]{"简单表达式", "Cron表达式"}; + private SchedulerFactory sf = new StdSchedulerFactory(); + private String schedulerKeyGroup = "x"; + private String schedulerKeyName = "x"; + + private TextField cronTextField; + private ChoiceBox quartzChoiceBox; + private Spinner intervalSpinner; + private Spinner repeatCountSpinner; + + private Runnable runnable; + + //添加调度控件 + public void setScheduleNode(Pane pane) { + quartzChoiceBox = new ChoiceBox(); + quartzChoiceBox.setPrefWidth(100); + quartzChoiceBox.getItems().addAll(quartzChoiceBoxStrings); + quartzChoiceBox.getSelectionModel().select(0); + StackPane stackPane = new StackPane(); + cronTextField = new TextField("* * * * * ?"); + cronTextField.setVisible(false); + stackPane.getChildren().add(cronTextField); + HBox simpleScheduleAnchorPane = new HBox(); + simpleScheduleAnchorPane.setAlignment(Pos.CENTER_LEFT); + simpleScheduleAnchorPane.setSpacing(5); + stackPane.getChildren().add(simpleScheduleAnchorPane); + intervalSpinner = new Spinner<>(); + intervalSpinner.setEditable(true); + intervalSpinner.setPrefWidth(66); + intervalSpinner.setTooltip(new Tooltip("单位为秒")); + repeatCountSpinner = new Spinner<>(); + repeatCountSpinner.setEditable(true); + repeatCountSpinner.setPrefWidth(66); + repeatCountSpinner.setTooltip(new Tooltip("-1为永久任务")); + simpleScheduleAnchorPane.getChildren().add(new Label("间隔")); + simpleScheduleAnchorPane.getChildren().add(intervalSpinner); + simpleScheduleAnchorPane.getChildren().add(new Label("次数")); + simpleScheduleAnchorPane.getChildren().add(repeatCountSpinner); + JavaFxViewUtil.setSpinnerValueFactory(intervalSpinner, 1, Integer.MAX_VALUE); + JavaFxViewUtil.setSpinnerValueFactory(repeatCountSpinner, -1, Integer.MAX_VALUE); + quartzChoiceBox.valueProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, String oldValue, String newValue) { + if (quartzChoiceBoxStrings[0].equals(newValue)) { + cronTextField.setVisible(false); + simpleScheduleAnchorPane.setVisible(true); + } else if (quartzChoiceBoxStrings[1].equals(newValue)) { + cronTextField.setVisible(true); + simpleScheduleAnchorPane.setVisible(false); + } + } + }); + Button runQuartzButton = new Button("定时运行"); + runQuartzButton.setOnAction(event -> { + if ("定时运行".equals(runQuartzButton.getText())) { + try { + ActionScheduleUtil.this.runQuartzAction(); + runQuartzButton.setText("停止运行"); + } catch (Exception e) { + log.error("运行错误!", e); + TooltipUtil.showToast("运行错误:" + e.getMessage()); + } + } else { + try { + ActionScheduleUtil.this.stopQuartzAction(); + runQuartzButton.setText("定时运行"); + } catch (Exception e) { + log.error("停止错误!", e); + TooltipUtil.showToast("停止错误:" + e.getMessage()); + } + } + }); + pane.getChildren().add(quartzChoiceBox); + pane.getChildren().add(stackPane); + pane.getChildren().add(runQuartzButton); + } + + //设置调度执行事件 + public void setJobAction(Runnable runnable) { + this.runnable = runnable; + } + + public void runQuartzAction() throws Exception { +// schedulerKeyGroup = jobClass.toString(); + schedulerKeyName = schedulerKeyGroup + System.currentTimeMillis(); + JobDetail jobDetail = JobBuilder.newJob(ActionJob.class).withIdentity(schedulerKeyName, schedulerKeyGroup).build(); + jobDetail.getJobDataMap().put("runnable", runnable); + ScheduleBuilder scheduleBuilder = null; + if (quartzChoiceBoxStrings[0].equals(quartzChoiceBox.getValue())) { + scheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(intervalSpinner.getValue())// 时间间隔 + .withRepeatCount(repeatCountSpinner.getValue());// 重复次数 + } else if (quartzChoiceBoxStrings[1].equals(quartzChoiceBox.getValue())) { + if (StringUtils.isEmpty(cronTextField.getText())) { + throw new Exception("cron表达式不能为空。"); + } + scheduleBuilder = CronScheduleBuilder.cronSchedule(cronTextField.getText()); + } + // 描叙触发Job执行的时间触发规则,Trigger实例化一个触发器 + Trigger trigger = TriggerBuilder.newTrigger()// 创建一个新的TriggerBuilder来规范一个触发器 + .withIdentity(schedulerKeyName, schedulerKeyGroup)// 给触发器一个名字和组名 + .startNow()// 立即执行 + .withSchedule(scheduleBuilder).build();// 产生触发器 + + // 运行容器,使用SchedulerFactory创建Scheduler实例 + Scheduler scheduler = sf.getScheduler(); + // 向Scheduler添加一个job和trigger + scheduler.scheduleJob(jobDetail, trigger); + if (!scheduler.isStarted()) { + scheduler.start(); + } + } + + public void stopQuartzAction() throws Exception { + Scheduler sched = sf.getScheduler(); + sched.unscheduleJob(new TriggerKey(schedulerKeyName, schedulerKeyGroup)); + sched.deleteJob(new JobKey(schedulerKeyName, schedulerKeyGroup)); + } +} -- Gitee From 34ad78e83b4bb8287e7b1469281e768666cfaf75 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Tue, 19 Jan 2021 13:57:54 +0800 Subject: [PATCH 07/30] =?UTF-8?q?=E8=BF=98=E5=8E=9FAlertUtil=E4=B8=AD?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xwintop/xcore/util/javafx/AlertUtil.java | 56 +++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/xwintop/xcore/util/javafx/AlertUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/AlertUtil.java index 5916833..ab33c40 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/AlertUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/AlertUtil.java @@ -6,13 +6,14 @@ import static com.xwintop.xcore.javafx.helper.LayoutHelper.vbox; import com.xwintop.xcore.javafx.FxApp; import com.xwintop.xcore.javafx.dialog.FxDialog; import com.xwintop.xcore.javafx.helper.LayoutHelper; + +import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; import javafx.geometry.Insets; import javafx.geometry.Pos; -import javafx.scene.control.Button; -import javafx.scene.control.ButtonType; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; +import javafx.scene.control.*; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import javafx.scene.text.Font; import javafx.stage.Modality; @@ -164,4 +165,51 @@ public class AlertUtil { newStage.showAndWait(); return isOk.get(); } + + @Deprecated + public static String showInputAlert(String message) { + return showInputAlertDefaultValue(message, null); + } + + public static String[] showInputAlert(String message, String... names) { + return showInputAlertMore(message, names); + } + + public static String[] showInputAlertMore(String message, String... names) { + return showInputAlertMore(message, names, new String[names.length]); + } + + public static String[] showInputAlertMore(String message, String[] names, String[] defaultValue) { + GridPane page1Grid = new GridPane(); + page1Grid.setVgap(10); + page1Grid.setHgap(10); + + TextField[] textFields = new TextField[names.length]; + for (int i = 0; i < names.length; i++) { + TextField textField = new TextField(); + textField.setText(defaultValue[i]); + textField.setMinWidth(100); + textField.prefColumnCountProperty().bind(textField.textProperty().length()); + GridPane.setHgrow(textField, Priority.ALWAYS); + page1Grid.add(new Label(names[i]), 0, i); + page1Grid.add(textField, 1, i); + textFields[i] = textField; + } + + Alert alert = new Alert(Alert.AlertType.NONE, null, new ButtonType("取消", ButtonBar.ButtonData.NO), + new ButtonType("确定", ButtonBar.ButtonData.YES)); + alert.setTitle(message); + alert.setGraphic(page1Grid); + alert.setWidth(200); + Optional _buttonType = alert.showAndWait(); + // 根据点击结果返回 + if (_buttonType.get().getButtonData().equals(ButtonBar.ButtonData.YES)) { + String[] stringS = new String[names.length]; + for (int i = 0; i < textFields.length; i++) { + stringS[i] = textFields[i].getText(); + } + return stringS; + } + return null; + } } -- Gitee From 80c2f689d00e67791ce30631161b4e002434f338 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Mon, 25 Jan 2021 19:01:50 +0800 Subject: [PATCH 08/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9B=BE=E6=A0=87=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xwintop/xcore/util/javafx/ImageUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java index 1a46f92..409d33f 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java @@ -3,12 +3,15 @@ package com.xwintop.xcore.util.javafx; import com.xwintop.xcore.util.FileUtil; import javafx.embed.swing.SwingFXUtils; import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import lombok.Getter; import lombok.Setter; import org.apache.commons.imaging.ImageFormats; import org.apache.commons.imaging.Imaging; import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.File; @@ -92,4 +95,17 @@ public class ImageUtil { ImageIO.write(bufferedImage, FileUtil.getFileSuffixName(file),file); } } + + //获取文件图标 + public static ImageView getFileIconImage(File file) { + Icon icon = FileSystemView.getFileSystemView().getSystemIcon(file); + BufferedImage bufferedImage = new BufferedImage( + icon.getIconWidth(), + icon.getIconHeight(), + BufferedImage.TYPE_INT_ARGB + ); + icon.paintIcon(null, bufferedImage.getGraphics(), 0, 0); + Image fxImage = SwingFXUtils.toFXImage(bufferedImage, null); + return new ImageView(fxImage); + } } -- Gitee From 9f27580b6091881e9684939d22e1529cf26adf86 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Mon, 25 Jan 2021 19:03:17 +0800 Subject: [PATCH 09/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=9B=BE=E6=A0=87=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xwintop/xcore/util/javafx/ImageUtil.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java index 409d33f..b8540d1 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java @@ -29,6 +29,7 @@ public class ImageUtil { /** * 获取图片BufferedImage + * * @param path 图片路径 */ public static BufferedImage getBufferedImage(String path) { @@ -51,6 +52,7 @@ public class ImageUtil { /** * 获取javafx图片 + * * @param path 图片路径 */ public static Image getFXImage(String path) { @@ -80,22 +82,28 @@ public class ImageUtil { /** * 保存图片 + * * @param image * @param file */ - public static void writeImage(Image image, File file) throws Exception{ - writeImage(SwingFXUtils.fromFXImage(image, null),file); + public static void writeImage(Image image, File file) throws Exception { + writeImage(SwingFXUtils.fromFXImage(image, null), file); } - public static void writeImage(BufferedImage bufferedImage, File file) throws Exception{ + public static void writeImage(BufferedImage bufferedImage, File file) throws Exception { try { - Imaging.writeImage(bufferedImage,file, ImageFormats.valueOf(FileUtil.getFileSuffixName(file).toUpperCase()),null); + Imaging.writeImage(bufferedImage, file, ImageFormats.valueOf(FileUtil.getFileSuffixName(file).toUpperCase()), null); } catch (Exception e) { e.printStackTrace(); - ImageIO.write(bufferedImage, FileUtil.getFileSuffixName(file),file); + ImageIO.write(bufferedImage, FileUtil.getFileSuffixName(file), file); } } + //获取文件夹图标 + public static ImageView getDirectoryIconImage() { + return getFileIconImage(FileSystemView.getFileSystemView().getHomeDirectory()); + } + //获取文件图标 public static ImageView getFileIconImage(File file) { Icon icon = FileSystemView.getFileSystemView().getSystemIcon(file); -- Gitee From 187afc2a48eece251e7b0c30aee90c2c50a43f36 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Thu, 4 Mar 2021 10:50:13 +0800 Subject: [PATCH 10/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Jpro=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 141 +++++++++--------- .../xcore/util/javafx/JavaFxSystemUtil.java | 8 +- .../xcore/util/javafx/JavaFxViewUtil.java | 10 +- 3 files changed, 84 insertions(+), 75 deletions(-) diff --git a/pom.xml b/pom.xml index e47f28b..d2482a1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xwintop xcore - 0.0.6-jdk15-SNAPSHOT + 0.0.7 jar xcore @@ -12,10 +12,9 @@ https://gitee.com/xwintop/xcore + 1.8 + 1.8 UTF-8 - true - 15 - 15 @@ -23,43 +22,46 @@ aliyunmaven http://maven.aliyun.com/nexus/content/groups/public/ + + spring-snapshots + http://repo.spring.io/snapshot + + true + + + + spring-milestones + http://repo.spring.io/milestone + + + apache.snapshots + Apache Development Snapshot Repository + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + jpro - sandec repository + https://sandec.bintray.com/repo + - - org.openjfx - javafx-controls - 15 - - - org.openjfx - javafx-fxml - 15 - - - org.openjfx - javafx-swing - 15 - - - org.openjfx - javafx-web - 15 - - junit junit 4.12 test - ch.qos.logback logback-classic 1.2.3 - provided @@ -79,20 +81,26 @@ org.quartz-scheduler quartz 2.3.1 - provided org.controlsfx controlsfx - 11.0.3 + 8.40.16 com.jfoenix jfoenix - 9.0.10 + 8.0.9 + + + + + com.sandec.jpro + jpro-webapi + 2019.2.7 @@ -148,7 +156,7 @@ org.projectlombok lombok - 1.18.12 + 1.18.6 provided @@ -175,45 +183,34 @@ - - - dev-local - - - xwintop-maven - file:C:/gitFiles/maven/repository/ - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.2 - - UTF-8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.20 - - true - once - -Dfile.encoding=UTF-8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - - - - + + + xwintop-maven + file:C:/gitFiles/maven/repository/ + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + UTF-8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + true + once + -Dfile.encoding=UTF-8 + + + + diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java index c7d9cc6..ece99aa 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java @@ -5,6 +5,8 @@ import java.awt.Dimension; import java.awt.Toolkit; import java.io.File; import java.io.IOException; + +import com.jpro.webapi.WebAPI; import javafx.geometry.Rectangle2D; import javafx.stage.Screen; import javafx.stage.Stage; @@ -21,6 +23,7 @@ public class JavaFxSystemUtil { /** * 打开目录 + * * @param directoryPath 目录路径 */ public static void openDirectory(String directoryPath) { @@ -31,14 +34,17 @@ public class JavaFxSystemUtil { } } - /** * 获取屏幕尺寸 + * * @param width 宽度比 * @param height 高度比 * @return 屏幕尺寸 */ public static double[] getScreenSizeByScale(double width, double height) { + if (WebAPI.isBrowser()) { + return new double[]{1280, 900}; + } Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); double screenWidth = screenSize.width * width; double screenHeight = screenSize.height * height; diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java index a535731..d3b9a61 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java @@ -3,6 +3,7 @@ package com.xwintop.xcore.util.javafx; import cn.hutool.cache.impl.TimedCache; import cn.hutool.core.lang.Singleton; import com.jfoenix.controls.JFXDecorator; +import com.jpro.webapi.WebAPI; import com.xwintop.xcore.javafx.FxApp; import javafx.collections.ObservableList; import javafx.event.ActionEvent; @@ -210,8 +211,13 @@ public class JavaFxViewUtil { public static void openNewWindow(String title, String iconUrl, Parent root, double width, double height, boolean fullScreen, boolean max, boolean min) { Stage newStage = getNewStageNull(title, iconUrl, root, width, height, fullScreen, max, min); - newStage.initModality(Modality.APPLICATION_MODAL); - newStage.show(); + if (WebAPI.isBrowser()) { + WebAPI webAPI = WebAPI.getWebAPI(JavaFxSystemUtil.mainStage); + webAPI.openStageAsTab(newStage); + } else { + newStage.initModality(Modality.APPLICATION_MODAL); + newStage.show(); + } } //获取一个新窗口 -- Gitee From a843dff72fa6fcec52f7ec3bbb96c2fef725ab7b Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Wed, 10 Mar 2021 13:32:44 +0800 Subject: [PATCH 11/30] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E5=8A=9F=E8=83=BD=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcore/util/javafx/JavaFxViewUtil.java | 78 +++++++++---------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java index d3b9a61..bfe24e0 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java @@ -333,29 +333,25 @@ public class JavaFxViewUtil { */ public static void addTableViewOnMouseRightClickMenu(TableView> tableView) { tableView.setEditable(true); - tableView.setOnMouseClicked(event -> { - if (event.getButton() == MouseButton.SECONDARY) { - MenuItem menuAdd = new MenuItem("添加行"); - menuAdd.setOnAction(event1 -> { - tableView.getItems().add(new HashMap()); - }); - MenuItem menu_Copy = new MenuItem("复制选中行"); - menu_Copy.setOnAction(event1 -> { - Map map = tableView.getSelectionModel().getSelectedItem(); - Map map2 = new HashMap(map); - tableView.getItems().add(tableView.getSelectionModel().getSelectedIndex(), map2); - }); - MenuItem menu_Remove = new MenuItem("删除选中行"); - menu_Remove.setOnAction(event1 -> { - tableView.getItems().remove(tableView.getSelectionModel().getSelectedIndex()); - }); - MenuItem menu_RemoveAll = new MenuItem("删除所有"); - menu_RemoveAll.setOnAction(event1 -> { - tableView.getItems().clear(); - }); - tableView.setContextMenu(new ContextMenu(menuAdd, menu_Copy, menu_Remove, menu_RemoveAll)); - } + MenuItem menuAdd = new MenuItem("添加行"); + menuAdd.setOnAction(event1 -> { + tableView.getItems().add(new HashMap()); + }); + MenuItem menu_Copy = new MenuItem("复制选中行"); + menu_Copy.setOnAction(event1 -> { + Map map = tableView.getSelectionModel().getSelectedItem(); + Map map2 = new HashMap(map); + tableView.getItems().add(tableView.getSelectionModel().getSelectedIndex(), map2); + }); + MenuItem menu_Remove = new MenuItem("删除选中行"); + menu_Remove.setOnAction(event1 -> { + tableView.getItems().remove(tableView.getSelectionModel().getSelectedIndex()); + }); + MenuItem menu_RemoveAll = new MenuItem("删除所有"); + menu_RemoveAll.setOnAction(event1 -> { + tableView.getItems().clear(); }); + tableView.setContextMenu(new ContextMenu(menuAdd, menu_Copy, menu_Remove, menu_RemoveAll)); } /** @@ -365,28 +361,24 @@ public class JavaFxViewUtil { public static void addListViewOnMouseRightClickMenu(ListView listView) { listView.setEditable(true); listView.setCellFactory(TextFieldListCell.forListView()); - listView.setOnMouseClicked(event -> { - if (event.getButton() == MouseButton.SECONDARY) { - MenuItem menuAdd = new MenuItem("添加行"); - menuAdd.setOnAction(event1 -> { - listView.getItems().add(""); - }); - MenuItem menu_Copy = new MenuItem("复制选中行"); - menu_Copy.setOnAction(event1 -> { - listView.getItems().add(listView.getSelectionModel().getSelectedIndex(), - listView.getSelectionModel().getSelectedItem()); - }); - MenuItem menu_Remove = new MenuItem("删除选中行"); - menu_Remove.setOnAction(event1 -> { - listView.getItems().remove(listView.getSelectionModel().getSelectedIndex()); - }); - MenuItem menu_RemoveAll = new MenuItem("删除所有"); - menu_RemoveAll.setOnAction(event1 -> { - listView.getItems().clear(); - }); - listView.setContextMenu(new ContextMenu(menuAdd, menu_Copy, menu_Remove, menu_RemoveAll)); - } + MenuItem menuAdd = new MenuItem("添加行"); + menuAdd.setOnAction(event1 -> { + listView.getItems().add(""); + }); + MenuItem menu_Copy = new MenuItem("复制选中行"); + menu_Copy.setOnAction(event1 -> { + listView.getItems().add(listView.getSelectionModel().getSelectedIndex(), + listView.getSelectionModel().getSelectedItem()); + }); + MenuItem menu_Remove = new MenuItem("删除选中行"); + menu_Remove.setOnAction(event1 -> { + listView.getItems().remove(listView.getSelectionModel().getSelectedIndex()); + }); + MenuItem menu_RemoveAll = new MenuItem("删除所有"); + menu_RemoveAll.setOnAction(event1 -> { + listView.getItems().clear(); }); + listView.setContextMenu(new ContextMenu(menuAdd, menu_Copy, menu_Remove, menu_RemoveAll)); } /** -- Gitee From 0c387dbe194a03350f0013d818f56546a80f15b0 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Sun, 11 Jul 2021 12:01:06 +0800 Subject: [PATCH 12/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=E4=B8=AD=E5=A4=9A=E9=80=89=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcore/util/javafx/FileChooserUtil.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/xwintop/xcore/util/javafx/FileChooserUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/FileChooserUtil.java index 8794db9..c6c36ca 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/FileChooserUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/FileChooserUtil.java @@ -10,6 +10,7 @@ import javafx.stage.FileChooser.ExtensionFilter; import javax.swing.filechooser.FileSystemView; import java.io.File; +import java.util.List; /** * 文件选择工具 @@ -20,6 +21,22 @@ public class FileChooserUtil { public static final File HOME_DIRECTORY = FileSystemView.getFileSystemView().getHomeDirectory(); + //选择多个文件 + public static List chooseFiles() { + return chooseFiles(null); + } + + public static List chooseFiles(ExtensionFilter... extensionFilter) { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("请选择文件"); + fileChooser.setInitialDirectory(HOME_DIRECTORY); + + if (extensionFilter != null) { + fileChooser.getExtensionFilters().addAll(extensionFilter); + } + return fileChooser.showOpenMultipleDialog(null); + } + public static File chooseFile() { return chooseFile(null); } -- Gitee From d8590bacaa14275a056c9f89ead1af1bcea249aa Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Sat, 25 Sep 2021 21:12:11 +0800 Subject: [PATCH 13/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Image=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xwintop/xcore/util/javafx/ImageUtil.java | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java index b8540d1..44340b4 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/ImageUtil.java @@ -2,8 +2,8 @@ package com.xwintop.xcore.util.javafx; import com.xwintop.xcore.util.FileUtil; import javafx.embed.swing.SwingFXUtils; +import javafx.scene.image.*; import javafx.scene.image.Image; -import javafx.scene.image.ImageView; import lombok.Getter; import lombok.Setter; import org.apache.commons.imaging.ImageFormats; @@ -12,6 +12,7 @@ import org.apache.commons.imaging.Imaging; import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.filechooser.FileSystemView; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.File; @@ -116,4 +117,73 @@ public class ImageUtil { Image fxImage = SwingFXUtils.toFXImage(bufferedImage, null); return new ImageView(fxImage); } + + /** + * 根据传入类型变化图片像素 + */ + public static javafx.scene.image.Image pixWithImage(int type, javafx.scene.image.Image image) { + PixelReader pixelReader = image.getPixelReader(); + if (image.getWidth() > 0 && image.getHeight() > 0) { + WritableImage wImage; + wImage = new WritableImage((int) image.getWidth(), (int) image.getHeight()); + PixelWriter pixelWriter = wImage.getPixelWriter(); + + for (int y = 0; y < image.getHeight(); y++) { + for (int x = 0; x < image.getWidth(); x++) { + javafx.scene.paint.Color color = pixelReader.getColor(x, y); + switch (type) { + case 1: + // 颜色变轻 + color = color.brighter(); + break; + case 2: + // 颜色变深 + color = color.darker(); + break; + case 3: + // 灰度化 + color = color.grayscale(); + break; + case 4: + // 颜色反转 + color = color.invert(); + break; + case 5: + // 颜色饱和 + color = color.saturate(); + break; + case 6: + // 颜色不饱和 + color = color.desaturate(); + break; + case 7: + // 颜色灰度化后反转(字黑体,背景鲜亮,可用于强字弱景) + color = color.grayscale(); + color = color.invert(); + break; + case 8: + // 颜色透明 + if (color.getOpacity() == 0) { + color = new javafx.scene.paint.Color(color.getRed(), color.getGreen(), color.getBlue(), 0); + } else { + color = new javafx.scene.paint.Color(color.getRed(), color.getGreen(), color.getBlue(), 0.5); + } + break; + default: + break; + } + + pixelWriter.setColor(x, y, color); + } + } + return wImage; + } + return null; + } + + //将javafx中Color转换为awt中Color + public static java.awt.Color getAwtColor(javafx.scene.paint.Color color) { + java.awt.Color colorw = new Color((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue(), (float) color.getOpacity()); + return colorw; + } } -- Gitee From 4fd7eaf1069753c1e6ebf632286dae65060df7a2 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Tue, 28 Sep 2021 16:31:49 +0800 Subject: [PATCH 14/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=BA=8F=E5=8F=B7=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcore/util/javafx/JavaFxViewUtil.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java index bfe24e0..c92bb2e 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java @@ -381,6 +381,28 @@ public class JavaFxViewUtil { listView.setContextMenu(new ContextMenu(menuAdd, menu_Copy, menu_Remove, menu_RemoveAll)); } + /** + * @Title: setTableColumnIndex + * @Description: 设置表格属性为序号 + */ + public static void setTableColumnIndex(TableColumn tableColumn) { + tableColumn.setCellFactory((col) -> { + TableCell cell = new TableCell() { + @Override + public void updateItem(Object item, boolean empty) { + super.updateItem(item, empty); + this.setText(null); + this.setGraphic(null); + if (!empty) { + int rowIndex = this.getIndex() + 1; + this.setText(String.valueOf(rowIndex)); + } + } + }; + return cell; + }); + } + /** * @Title: setSpinnerValueFactory * @Description: 初始化表格属性 -- Gitee From b0cc23dfc22554b10ee3059d7a5fb6f7a87232a6 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Tue, 28 Dec 2021 17:17:09 +0800 Subject: [PATCH 15/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E8=87=AA=E5=AE=9A=E4=B9=89=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcore/util/javafx/JavaFxDragResizer.java | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 src/main/java/com/xwintop/xcore/util/javafx/JavaFxDragResizer.java diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxDragResizer.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxDragResizer.java new file mode 100644 index 0000000..c742ac8 --- /dev/null +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxDragResizer.java @@ -0,0 +1,127 @@ +package com.xwintop.xcore.util.javafx; + +import javafx.scene.Cursor; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.Region; + +/** + * @ClassName: JavaFxDragResizer + * @Description: 设置控件自定义大小 + * @author: xufeng + * @date: 2021/12/25 14:40 + */ + +public class JavaFxDragResizer { + + /** + * The margin around the control that a user can click in to start resizing + * the region. + */ + private static final int RESIZE_MARGIN = 10; + private final Region region; + private double y; + private double x; + private boolean initMinHeight; + private boolean initMinWidth; + private boolean draggableZoneX, draggableZoneY; + private boolean dragging; + private boolean draggableX = true; + private boolean draggableY = true; + + private JavaFxDragResizer(Region aRegion) { + region = aRegion; + this.setOnMouse(); + } + + private JavaFxDragResizer(Region aRegion, boolean draggableX, boolean draggableY) { + region = aRegion; + this.draggableX = draggableX; + this.draggableY = draggableY; + this.setOnMouse(); + } + + public static void makeResizableX(Region region) { + new JavaFxDragResizer(region, true, false); + } + + public static void makeResizableY(Region region) { + new JavaFxDragResizer(region, false, true); + } + + public static void makeResizable(Region region) { + new JavaFxDragResizer(region); + } + + protected void setOnMouse() { + region.setOnMousePressed(event -> this.mousePressed(event)); + region.setOnMouseDragged(event -> this.mouseDragged(event)); + region.setOnMouseMoved(event -> this.mouseOver(event)); + region.setOnMouseReleased(event -> this.mouseReleased(event)); + } + + protected void mouseReleased(MouseEvent event) { + dragging = false; + region.setCursor(Cursor.DEFAULT); + } + + protected void mouseOver(MouseEvent event) { + if (isInDraggableZone(event) || dragging) { + if (draggableZoneY && draggableZoneX) { + region.setCursor(Cursor.SE_RESIZE); + } else if (draggableZoneY) { + region.setCursor(Cursor.S_RESIZE); + } else if (draggableZoneX) { + region.setCursor(Cursor.E_RESIZE); + } + } else { + region.setCursor(Cursor.DEFAULT); + } + } + + + //had to use 2 variables for the controll, tried without, had unexpected behaviour (going big was ok, going small nope.) + protected boolean isInDraggableZone(MouseEvent event) { + draggableZoneY = draggableY && (boolean) (event.getY() > (region.getHeight() - RESIZE_MARGIN)); + draggableZoneX = draggableX && (boolean) (event.getX() > (region.getWidth() - RESIZE_MARGIN)); + return (draggableZoneY || draggableZoneX); + } + + protected void mouseDragged(MouseEvent event) { + if (!dragging) { + return; + } + if (draggableY && draggableZoneY) { + double mousey = event.getY(); + double newHeight = region.getMinHeight() + (mousey - y); + region.setMinHeight(newHeight); + y = mousey; + } + if (draggableX && draggableZoneX) { + double mousex = event.getX(); + double newWidth = region.getMinWidth() + (mousex - x); + region.setMinWidth(newWidth); + x = mousex; + } + } + + protected void mousePressed(MouseEvent event) { + // ignore clicks outside of the draggable margin + if (!isInDraggableZone(event)) { + return; + } + dragging = true; + // make sure that the minimum height is set to the current height once, + // setting a min height that is smaller than the current height will + // have no effect + if (!initMinHeight) { + region.setMinHeight(region.getHeight()); + initMinHeight = true; + } + y = event.getY(); + if (!initMinWidth) { + region.setMinWidth(region.getWidth()); + initMinWidth = true; + } + x = event.getX(); + } +} \ No newline at end of file -- Gitee From f71525e5b5eccf35882233974178593aedd2af78 Mon Sep 17 00:00:00 2001 From: "XUFENG-PC\\xufeng" <1277032935@qq.com> Date: Fri, 7 Aug 2020 19:27:00 +0800 Subject: [PATCH 16/30] =?UTF-8?q?=E8=B0=83=E6=95=B4pom=E6=96=87=E4=BB=B6ja?= =?UTF-8?q?r=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 62 ++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index d2482a1..bd21e61 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xwintop xcore - 0.0.7 + 0.0.6-jdk11 jar xcore @@ -12,8 +12,8 @@ https://gitee.com/xwintop/xcore - 1.8 - 1.8 + 11 + 11 UTF-8 @@ -44,13 +44,45 @@ true - - jpro - sandec repository - https://sandec.bintray.com/repo - + + org.openjfx + javafx-controls + 11.0.2 + + + org.openjfx + javafx-base + 11.0.2 + + + org.openjfx + javafx-graphics + 11.0.2 + + + org.openjfx + javafx-fxml + 11.0.2 + + + org.openjfx + javafx-swing + 11.0.2 + + + org.openjfx + javafx-media + 11.0.2 + + + org.openjfx + javafx-web + 11.0.2 + + junit junit @@ -87,20 +119,13 @@ org.controlsfx controlsfx - 8.40.16 + 11.0.2 com.jfoenix jfoenix - 8.0.9 - - - - - com.sandec.jpro - jpro-webapi - 2019.2.7 + 9.0.10 @@ -211,6 +236,11 @@ -Dfile.encoding=UTF-8 + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + -- Gitee From 7bee80c8f048caea0f8f74f6060188985d5c0d12 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Sun, 16 Aug 2020 16:30:13 +0800 Subject: [PATCH 17/30] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bd21e61..89b88e2 100644 --- a/pom.xml +++ b/pom.xml @@ -181,7 +181,7 @@ org.projectlombok lombok - 1.18.6 + 1.18.12 provided -- Gitee From 8c1b7005104804c871f30d04884c119c83c60191 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Mon, 14 Feb 2022 22:07:16 +0800 Subject: [PATCH 18/30] =?UTF-8?q?=E4=BF=AE=E6=94=B9pom=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 497 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 254 insertions(+), 243 deletions(-) diff --git a/pom.xml b/pom.xml index 89b88e2..10e8f69 100644 --- a/pom.xml +++ b/pom.xml @@ -1,246 +1,257 @@ - 4.0.0 - - com.xwintop - xcore - 0.0.6-jdk11 - jar - - xcore - xcore核心jar包 - https://gitee.com/xwintop/xcore - - - 11 - 11 - UTF-8 - - - - - aliyunmaven - http://maven.aliyun.com/nexus/content/groups/public/ - - - spring-snapshots - http://repo.spring.io/snapshot - - true - - - - spring-milestones - http://repo.spring.io/milestone - - - apache.snapshots - Apache Development Snapshot Repository - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - - - - - - org.openjfx - javafx-controls - 11.0.2 - - - org.openjfx - javafx-base - 11.0.2 - - - org.openjfx - javafx-graphics - 11.0.2 - - - org.openjfx - javafx-fxml - 11.0.2 - - - org.openjfx - javafx-swing - 11.0.2 - - - org.openjfx - javafx-media - 11.0.2 - - - org.openjfx - javafx-web - 11.0.2 - - - - junit - junit - 4.12 - test - - - - ch.qos.logback - logback-classic - 1.2.3 - - - - - org.dom4j - dom4j - 2.1.1 - - - jaxen - jaxen - 1.2.0 - - - - - org.quartz-scheduler - quartz - 2.3.1 - - - - - org.controlsfx - controlsfx - 11.0.2 - - - - com.jfoenix - jfoenix - 9.0.10 - - - - - commons-codec - commons-codec - 1.12 - - - commons-configuration - commons-configuration - 1.10 - - - commons-io - commons-io - 2.6 - - - org.apache.commons - commons-lang3 - 3.9 - - - org.apache.commons - commons-collections4 - 4.4 - - - org.apache.commons - commons-text - 1.8 - - - commons-beanutils - commons-beanutils - 1.9.3 - - - org.apache.commons - commons-imaging - 1.0-alpha1 - - - - - com.squareup.okhttp3 - okhttp - 4.5.0 - - - - - org.projectlombok - lombok - 1.18.12 - provided - - - - - cn.hutool - hutool-all - 5.3.1 - - - - - com.alibaba - fastjson - 1.2.68 - - - - - org.yaml - snakeyaml - 1.26 - - - - - - - xwintop-maven - file:C:/gitFiles/maven/repository/ - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.0.2 - - UTF-8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.20 - - true - once - -Dfile.encoding=UTF-8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - + 4.0.0 + + com.gitee.xwintop + xcore + 0.0.6-jdk11 + jar + + xcore + xcore核心jar包 + https://gitee.com/xwintop/xcore + + + 11 + 11 + UTF-8 + + + + + aliyunmaven + http://maven.aliyun.com/nexus/content/groups/public/ + + + spring-snapshots + http://repo.spring.io/snapshot + + true + + + + spring-milestones + http://repo.spring.io/milestone + + + apache.snapshots + Apache Development Snapshot Repository + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + jpro - sandec repository + https://sandec.bintray.com/repo + + + + + + org.openjfx + javafx-controls + 11.0.2 + + + org.openjfx + javafx-base + 11.0.2 + + + org.openjfx + javafx-graphics + 11.0.2 + + + org.openjfx + javafx-fxml + 11.0.2 + + + org.openjfx + javafx-swing + 11.0.2 + + + org.openjfx + javafx-media + 11.0.2 + + + org.openjfx + javafx-web + 11.0.2 + + + + junit + junit + 4.12 + test + + + + ch.qos.logback + logback-classic + 1.2.3 + + + + + org.dom4j + dom4j + 2.1.1 + + + jaxen + jaxen + 1.2.0 + + + + + org.quartz-scheduler + quartz + 2.3.1 + + + + + org.controlsfx + controlsfx + 11.0.2 + + + + com.jfoenix + jfoenix + 9.0.10 + + + + + com.sandec.jpro + jpro-webapi + 2019.2.7 + + + + + commons-codec + commons-codec + 1.12 + + + commons-configuration + commons-configuration + 1.10 + + + commons-io + commons-io + 2.6 + + + org.apache.commons + commons-lang3 + 3.9 + + + org.apache.commons + commons-collections4 + 4.4 + + + org.apache.commons + commons-text + 1.8 + + + commons-beanutils + commons-beanutils + 1.9.3 + + + org.apache.commons + commons-imaging + 1.0-alpha1 + + + + + com.squareup.okhttp3 + okhttp + 4.5.0 + + + + + org.projectlombok + lombok + 1.18.12 + provided + + + + + cn.hutool + hutool-all + 5.3.1 + + + + + com.alibaba + fastjson + 1.2.68 + + + + + org.yaml + snakeyaml + 1.26 + + + + + + + xwintop-maven + file:C:/gitFiles/maven/repository/ + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + UTF-8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + true + once + -Dfile.encoding=UTF-8 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + -- Gitee From 20ce00801b42fffe6a634b2fea7400e967a0cc02 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Tue, 15 Feb 2022 09:03:47 +0800 Subject: [PATCH 19/30] =?UTF-8?q?=E4=BF=AE=E6=94=B9pom=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=89=88=E6=9C=AC=E4=B8=BAjdk17?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 10e8f69..78d6499 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.gitee.xwintop xcore - 0.0.6-jdk11 + 0.0.6-jdk17 jar xcore @@ -12,8 +12,8 @@ https://gitee.com/xwintop/xcore - 11 - 11 + 17 + 17 UTF-8 @@ -54,37 +54,37 @@ org.openjfx javafx-controls - 11.0.2 + 17.0.2 org.openjfx javafx-base - 11.0.2 + 17.0.2 org.openjfx javafx-graphics - 11.0.2 + 17.0.2 org.openjfx javafx-fxml - 11.0.2 + 17.0.2 org.openjfx javafx-swing - 11.0.2 + 17.0.2 org.openjfx javafx-media - 11.0.2 + 17.0.2 org.openjfx javafx-web - 11.0.2 + 17.0.2 @@ -123,7 +123,7 @@ org.controlsfx controlsfx - 11.0.2 + 11.1.1 -- Gitee From d7f2a891c6b29b084e0ea9f1923bd6c503784705 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Wed, 16 Feb 2022 12:40:06 +0800 Subject: [PATCH 20/30] =?UTF-8?q?=E6=B7=BB=E5=8A=A0table=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=BA=8F=E5=88=97=E6=96=B9=E6=B3=95=E4=B8=AD=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=80=BC=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 28 ++----------------- .../xcore/util/javafx/JavaFxViewUtil.java | 5 +++- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index 78d6499..1785922 100644 --- a/pom.xml +++ b/pom.xml @@ -22,31 +22,9 @@ aliyunmaven http://maven.aliyun.com/nexus/content/groups/public/ - - spring-snapshots - http://repo.spring.io/snapshot - - true - - - - spring-milestones - http://repo.spring.io/milestone - - - apache.snapshots - Apache Development Snapshot Repository - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - jpro - sandec repository - https://sandec.bintray.com/repo + https://sandec.jfrog.io/artifactory/repo @@ -136,7 +114,7 @@ com.sandec.jpro jpro-webapi - 2019.2.7 + 2021.2.3 @@ -192,7 +170,7 @@ org.projectlombok lombok - 1.18.12 + 1.18.22 provided diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java index c92bb2e..d5af275 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java @@ -5,6 +5,8 @@ import cn.hutool.core.lang.Singleton; import com.jfoenix.controls.JFXDecorator; import com.jpro.webapi.WebAPI; import com.xwintop.xcore.javafx.FxApp; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.Event; @@ -22,7 +24,6 @@ import javafx.scene.control.cell.TextFieldListCell; import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.scene.layout.BorderPane; import javafx.scene.layout.StackPane; @@ -59,6 +60,7 @@ public class JavaFxViewUtil { * @param fullScreenButton 是否显示全屏按钮 * @param maximizeButton 是否显示最大化按钮 * @param minimizeButton 是否显示最小化按钮 + * * @return 新建的窗体对象 */ public static Stage jfxStage( @@ -386,6 +388,7 @@ public class JavaFxViewUtil { * @Description: 设置表格属性为序号 */ public static void setTableColumnIndex(TableColumn tableColumn) { + tableColumn.setCellValueFactory((Callback) param -> new SimpleObjectProperty<>(String.valueOf(param.getTableView().getItems().indexOf(param.getValue()) + 1))); tableColumn.setCellFactory((col) -> { TableCell cell = new TableCell() { @Override -- Gitee From 17342e8545b3f40e0e96ad7a6ce7912638c30da5 Mon Sep 17 00:00:00 2001 From: xwintop <864381832@qq.com> Date: Sun, 20 Feb 2022 22:27:26 +0800 Subject: [PATCH 21/30] =?UTF-8?q?=E7=A7=BB=E9=99=A4jro-webai=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 18 ++++++++++++------ .../xcore/util/javafx/JavaFxSystemUtil.java | 7 +++---- .../xcore/util/javafx/JavaFxViewUtil.java | 11 +++++------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 1785922..7b950e4 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ aliyunmaven - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/repository/public jpro - sandec repository @@ -82,7 +82,7 @@ org.dom4j dom4j - 2.1.1 + 2.1.3 jaxen @@ -110,13 +110,19 @@ 9.0.10 - - com.sandec.jpro - jpro-webapi - 2021.2.3 + io.github.palexdev + materialfx + 11.13.2 + + + + + + + commons-codec diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java index ece99aa..7fd8c27 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java @@ -6,7 +6,6 @@ import java.awt.Toolkit; import java.io.File; import java.io.IOException; -import com.jpro.webapi.WebAPI; import javafx.geometry.Rectangle2D; import javafx.stage.Screen; import javafx.stage.Stage; @@ -42,9 +41,9 @@ public class JavaFxSystemUtil { * @return 屏幕尺寸 */ public static double[] getScreenSizeByScale(double width, double height) { - if (WebAPI.isBrowser()) { - return new double[]{1280, 900}; - } +// if (WebAPI.isBrowser()) { +// return new double[]{1280, 900}; +// } Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); double screenWidth = screenSize.width * width; double screenHeight = screenSize.height * height; diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java index d5af275..bd5a87b 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java @@ -3,7 +3,6 @@ package com.xwintop.xcore.util.javafx; import cn.hutool.cache.impl.TimedCache; import cn.hutool.core.lang.Singleton; import com.jfoenix.controls.JFXDecorator; -import com.jpro.webapi.WebAPI; import com.xwintop.xcore.javafx.FxApp; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ObservableValue; @@ -213,13 +212,13 @@ public class JavaFxViewUtil { public static void openNewWindow(String title, String iconUrl, Parent root, double width, double height, boolean fullScreen, boolean max, boolean min) { Stage newStage = getNewStageNull(title, iconUrl, root, width, height, fullScreen, max, min); - if (WebAPI.isBrowser()) { - WebAPI webAPI = WebAPI.getWebAPI(JavaFxSystemUtil.mainStage); - webAPI.openStageAsTab(newStage); - } else { +// if (WebAPI.isBrowser()) { +// WebAPI webAPI = WebAPI.getWebAPI(JavaFxSystemUtil.mainStage); +// webAPI.openStageAsTab(newStage); +// } else { newStage.initModality(Modality.APPLICATION_MODAL); newStage.show(); - } +// } } //获取一个新窗口 -- Gitee From b7f46c010fe39fd30d27e2a5cfc950e12636d824 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Tue, 1 Mar 2022 21:17:29 +0800 Subject: [PATCH 22/30] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=8C=85=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 7b950e4..1e162e8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.gitee.xwintop xcore - 0.0.6-jdk17 + 0.0.7 jar xcore @@ -15,6 +15,7 @@ 17 17 UTF-8 + 17.0.2 @@ -32,37 +33,37 @@ org.openjfx javafx-controls - 17.0.2 + ${javafx.version} org.openjfx javafx-base - 17.0.2 + ${javafx.version} org.openjfx javafx-graphics - 17.0.2 + ${javafx.version} org.openjfx javafx-fxml - 17.0.2 + ${javafx.version} org.openjfx javafx-swing - 17.0.2 + ${javafx.version} org.openjfx javafx-media - 17.0.2 + ${javafx.version} org.openjfx javafx-web - 17.0.2 + ${javafx.version} @@ -127,7 +128,7 @@ commons-codec commons-codec - 1.12 + 1.15 commons-configuration @@ -137,12 +138,12 @@ commons-io commons-io - 2.6 + 2.11.0 org.apache.commons commons-lang3 - 3.9 + 3.12.0 org.apache.commons @@ -152,24 +153,24 @@ org.apache.commons commons-text - 1.8 + 1.9 commons-beanutils commons-beanutils - 1.9.3 + 1.9.4 org.apache.commons commons-imaging - 1.0-alpha1 + 1.0-alpha2 com.squareup.okhttp3 okhttp - 4.5.0 + 4.9.3 @@ -184,21 +185,21 @@ cn.hutool hutool-all - 5.3.1 + 5.7.20 com.alibaba fastjson - 1.2.68 + 1.2.79 org.yaml snakeyaml - 1.26 + 1.30 -- Gitee From e8dc44be2a3186cb2e12e8bd0932a1d683bdbad8 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Thu, 24 Mar 2022 22:29:00 +0800 Subject: [PATCH 23/30] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=8C=85=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 1e162e8..b147816 100644 --- a/pom.xml +++ b/pom.xml @@ -23,10 +23,10 @@ aliyunmaven https://maven.aliyun.com/repository/public - - jpro - sandec repository - https://sandec.jfrog.io/artifactory/repo - + + + + @@ -69,14 +69,14 @@ junit junit - 4.12 + 4.13.2 test ch.qos.logback logback-classic - 1.2.3 + 1.2.11 @@ -111,11 +111,11 @@ 9.0.10 - - io.github.palexdev - materialfx - 11.13.2 - + + + + + -- Gitee From 6cbfeba46ab46da8637a1fd1b7e99e5f79fe2051 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Sat, 26 Mar 2022 18:55:49 +0800 Subject: [PATCH 24/30] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E5=8C=85=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 12 ++++++------ .../java/com/xwintop/xcore/info/package-info.java | 8 -------- .../java/com/xwintop/xcore/log/package-info.java | 8 -------- 3 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 src/main/java/com/xwintop/xcore/info/package-info.java delete mode 100644 src/main/java/com/xwintop/xcore/log/package-info.java diff --git a/pom.xml b/pom.xml index b147816..2d4f100 100644 --- a/pom.xml +++ b/pom.xml @@ -95,7 +95,7 @@ org.quartz-scheduler quartz - 2.3.1 + 2.3.2 @@ -185,14 +185,14 @@ cn.hutool hutool-all - 5.7.20 + 5.7.22 com.alibaba fastjson - 1.2.79 + 1.2.80 @@ -217,7 +217,7 @@ org.apache.maven.plugins maven-resources-plugin - 3.0.2 + 3.2.0 UTF-8 @@ -225,7 +225,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.20 + 2.22.2 true once @@ -235,7 +235,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.10.0 diff --git a/src/main/java/com/xwintop/xcore/info/package-info.java b/src/main/java/com/xwintop/xcore/info/package-info.java deleted file mode 100644 index b501c9b..0000000 --- a/src/main/java/com/xwintop/xcore/info/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author Administrator - * - */ -package com.xwintop.xcore.info; \ No newline at end of file diff --git a/src/main/java/com/xwintop/xcore/log/package-info.java b/src/main/java/com/xwintop/xcore/log/package-info.java deleted file mode 100644 index 47acf58..0000000 --- a/src/main/java/com/xwintop/xcore/log/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author Administrator - * - */ -package com.xwintop.xcore.log; \ No newline at end of file -- Gitee From 9f780a9cc4c1dad840f5c6d8dbfc62a00f077dca Mon Sep 17 00:00:00 2001 From: Gitea Date: Mon, 28 Mar 2022 15:20:34 +0800 Subject: [PATCH 25/30] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=92=8C=E5=8D=B8=E8=BD=BD=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=EF=BC=8C=E6=96=B9=E4=BE=BF=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E8=87=AA=E8=BA=AB=E7=9A=84=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=92=8C=E5=8D=B8=E8=BD=BD=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xwintop/xcore/plugin/PluginEvent.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/xwintop/xcore/plugin/PluginEvent.java diff --git a/src/main/java/com/xwintop/xcore/plugin/PluginEvent.java b/src/main/java/com/xwintop/xcore/plugin/PluginEvent.java new file mode 100644 index 0000000..80e9463 --- /dev/null +++ b/src/main/java/com/xwintop/xcore/plugin/PluginEvent.java @@ -0,0 +1,29 @@ +package com.xwintop.xcore.plugin; + +import javafx.event.Event; +import javafx.event.EventTarget; +import javafx.event.EventType; + +/** + * 插件生命周期相关事件,可在插件 root 节点中接收事件 + */ +public class PluginEvent extends Event { + + /** + * 插件在框架中完成初始化,即完成 FXMLLoader.load() + */ + public static final EventType PLUGIN_INITIALIZED = new EventType<>(Event.ANY, "PLUGIN_INITIALIZED"); + + /** + * 插件即将被卸载 + */ + public static final EventType PLUGIN_UNLOADING = new EventType<>(Event.ANY, "PLUGIN_UNLOADING"); + + public PluginEvent(Object source, EventTarget target, EventType eventType) { + super(source, target, eventType); + } + + public PluginEvent(Object source, EventType eventType) { + super(source, null, eventType); + } +} -- Gitee From 47f8f6020057a5d7a2f4c4dda6e694bea266f9dd Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Mon, 28 Mar 2022 16:18:19 +0800 Subject: [PATCH 26/30] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java | 4 +++- src/main/java/com/xwintop/xcore/util/SystemInfoUtil.java | 2 +- .../com/xwintop/xcore/util/javafx/ActionScheduleUtil.java | 4 +++- .../com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java | 5 +++-- .../java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java | 5 +++-- .../xcore/util/javafx/TextFieldInputHistoryDialog.java | 6 ++++-- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 2d4f100..a739f15 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ 17 17 UTF-8 + true 17.0.2 diff --git a/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java b/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java index 26d6290..c8eb69f 100644 --- a/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java +++ b/src/main/java/com/xwintop/xcore/javafx/dialog/FxAlerts.java @@ -50,7 +50,9 @@ public class FxAlerts { error(owner, title, message, ExceptionUtils.getStackTrace(throwable)); } - public static void alert(Alert.AlertType alertType, String title, String message) {} + public static void alert(Alert.AlertType alertType, String title, String message) { + alert(null, alertType, title, message); + } public static void alert(Window owner, Alert.AlertType alertType, String title, String message) { FxApp.runLater(() -> { diff --git a/src/main/java/com/xwintop/xcore/util/SystemInfoUtil.java b/src/main/java/com/xwintop/xcore/util/SystemInfoUtil.java index c51d6d3..67278fd 100644 --- a/src/main/java/com/xwintop/xcore/util/SystemInfoUtil.java +++ b/src/main/java/com/xwintop/xcore/util/SystemInfoUtil.java @@ -22,7 +22,7 @@ public class SystemInfoUtil { } else { fileName = "C://WINDOWS//system32//drivers//etc//hosts"; } - log.info("获取hosts文件路径:"+fileName); +// log.info("获取hosts文件路径:"+fileName); return fileName; } diff --git a/src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java index d7e24bd..a7d25e1 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/ActionScheduleUtil.java @@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.quartz.*; import org.quartz.impl.StdSchedulerFactory; +import org.slf4j.Logger; /** * @ClassName: ScheduleManager @@ -23,8 +24,9 @@ import org.quartz.impl.StdSchedulerFactory; @Getter @Setter -@Slf4j +//@Slf4j public class ActionScheduleUtil { + private static Logger log = org.slf4j.LoggerFactory.getLogger(ActionScheduleUtil.class); private static final String[] quartzChoiceBoxStrings = new String[]{"简单表达式", "Cron表达式"}; private SchedulerFactory sf = new StdSchedulerFactory(); private String schedulerKeyGroup = "x"; diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java index 7fd8c27..5248d84 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxSystemUtil.java @@ -10,10 +10,11 @@ import javafx.geometry.Rectangle2D; import javafx.stage.Screen; import javafx.stage.Stage; import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; -@Slf4j +//@Slf4j public class JavaFxSystemUtil { - + private static Logger log = org.slf4j.LoggerFactory.getLogger(JavaFxSystemUtil.class); /** * @deprecated 使用 {@link com.xwintop.xcore.javafx.FxApp#primaryStage} */ diff --git a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java index bd5a87b..e8eb294 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/JavaFxViewUtil.java @@ -36,6 +36,7 @@ import javafx.util.StringConverter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.MethodUtils; +import org.slf4j.Logger; import java.lang.reflect.Method; import java.net.URL; @@ -46,9 +47,9 @@ import java.util.function.Consumer; import static com.xwintop.xcore.javafx.helper.LayoutHelper.iconView; -@Slf4j +//@Slf4j public class JavaFxViewUtil { - + private static Logger log = org.slf4j.LoggerFactory.getLogger(JavaFxViewUtil.class); /** * 创建对话框窗体 * diff --git a/src/main/java/com/xwintop/xcore/util/javafx/TextFieldInputHistoryDialog.java b/src/main/java/com/xwintop/xcore/util/javafx/TextFieldInputHistoryDialog.java index e9b4e51..4ea8265 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/TextFieldInputHistoryDialog.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/TextFieldInputHistoryDialog.java @@ -9,6 +9,7 @@ import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; import org.yaml.snakeyaml.Yaml; import java.io.File; @@ -28,8 +29,9 @@ import java.util.function.Function; @Getter @Setter -@Slf4j +//@Slf4j public class TextFieldInputHistoryDialog { + private static Logger log = org.slf4j.LoggerFactory.getLogger(TextFieldInputHistoryDialog.class); private ObservableList> tableData = FXCollections.observableArrayList(); private String saveFilePath = null; private String[] tableColumns = null; @@ -86,7 +88,7 @@ public class TextFieldInputHistoryDialog { try { File CONFIG_FILE = new File(saveFilePath); Yaml yaml = new Yaml(); - FileUtils.writeStringToFile(CONFIG_FILE, yaml.dump(this.getTableData()), "UTF-8"); + FileUtils.writeStringToFile(CONFIG_FILE, yaml.dump(this.tableData), "UTF-8"); TooltipUtil.showToast("保存配置成功,保存在:" + CONFIG_FILE.getPath()); } catch (Exception e) { log.error("保存配置失败", e); -- Gitee From 90c3c877f271edbd4d2726121b1f3a3576fcd905 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Mon, 28 Mar 2022 19:27:51 +0800 Subject: [PATCH 27/30] =?UTF-8?q?=E4=B8=BA=E5=B0=86=E6=9D=A5=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=8C=96=E9=87=8D=E6=9E=84=E5=81=9A=E5=87=86=E5=A4=87?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xwintop/xcore/javafx/dialog/FxDialog.java | 36 +++++++++++++------ .../xwintop/xcore/util/javafx/FxmlUtil.java | 26 ++++++++++++-- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java b/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java index f0e2e15..41c5360 100644 --- a/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java +++ b/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java @@ -3,13 +3,6 @@ package com.xwintop.xcore.javafx.dialog; import com.xwintop.xcore.XCoreException; import com.xwintop.xcore.javafx.FxApp; import com.xwintop.xcore.util.javafx.FxmlUtil; -import java.util.HashMap; -import java.util.Map; -import java.util.ResourceBundle; -import java.util.function.BiConsumer; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; import javafx.event.ActionEvent; import javafx.event.Event; import javafx.fxml.FXMLLoader; @@ -29,6 +22,14 @@ import javafx.stage.Window; import javafx.stage.WindowEvent; import org.apache.commons.lang3.ArrayUtils; +import java.util.HashMap; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; + /** * 自定义对话框 * @@ -48,6 +49,8 @@ public class FxDialog { private Window owner; + private ClassLoader bodyFxmlClassLoader; + private String bodyFxmlPath; private Parent body; @@ -62,6 +65,11 @@ public class FxDialog { private ResourceBundle resourceBundle; + public FxDialog setBodyFxmlClassLoader(ClassLoader bodyFxmlClassLoader) { + this.bodyFxmlClassLoader = bodyFxmlClassLoader; + return this; + } + public FxDialog setResizable(boolean resizable) { this.resizable = resizable; return this; @@ -130,9 +138,12 @@ public class FxDialog { public T show() { if (this.bodyFxmlPath != null) { + ClassLoader classLoader = + this.bodyFxmlClassLoader == null ? FxDialog.class.getClassLoader() : this.bodyFxmlClassLoader; + FXMLLoader fxmlLoader = resourceBundle == null? - FxmlUtil.loadFxmlFromResource(this.bodyFxmlPath): - FxmlUtil.loadFxmlFromResource(this.bodyFxmlPath, resourceBundle); + FxmlUtil.loadFxmlFromResource(classLoader, this.bodyFxmlPath): + FxmlUtil.loadFxmlFromResource(classLoader, this.bodyFxmlPath, resourceBundle); Stage stage = createStage(fxmlLoader.getRoot()); stage.show(); @@ -151,9 +162,12 @@ public class FxDialog { public T showAndWait() { if (this.bodyFxmlPath != null) { + ClassLoader classLoader = + this.bodyFxmlClassLoader == null ? FxDialog.class.getClassLoader() : this.bodyFxmlClassLoader; + FXMLLoader fxmlLoader = resourceBundle == null? - FxmlUtil.loadFxmlFromResource(this.bodyFxmlPath): - FxmlUtil.loadFxmlFromResource(this.bodyFxmlPath, resourceBundle); + FxmlUtil.loadFxmlFromResource(classLoader, this.bodyFxmlPath): + FxmlUtil.loadFxmlFromResource(classLoader, this.bodyFxmlPath, resourceBundle); Stage stage = createStage(fxmlLoader.getRoot()); stage.showAndWait(); diff --git a/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java index b3d77cd..e3db3cc 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java @@ -1,20 +1,40 @@ package com.xwintop.xcore.util.javafx; import com.xwintop.xcore.XCoreException; +import javafx.fxml.FXMLLoader; + import java.io.IOException; import java.util.ResourceBundle; -import javafx.fxml.FXMLLoader; +/** + * 调用者最好自己提供 ClassLoader 用于加载自身的资源文件, + * 否则使用 xcore 的 ClassLoader 加载可能会由于安全原因而失败 + */ public class FxmlUtil { + /** + * @deprecated Use {@link #loadFxmlFromResource(ClassLoader, String)} )} instead. + */ public static FXMLLoader loadFxmlFromResource(String resourcePath) { - return loadFxmlFromResource(resourcePath, null); + return loadFxmlFromResource(FxmlUtil.class.getClassLoader(), resourcePath, null); } + /** + * @deprecated Use {@link #loadFxmlFromResource(ClassLoader, String, ResourceBundle)} instead. + */ public static FXMLLoader loadFxmlFromResource(String resourcePath, ResourceBundle resourceBundle) { + return loadFxmlFromResource(FxmlUtil.class.getClassLoader(), resourcePath, resourceBundle); + } + + public static FXMLLoader loadFxmlFromResource(ClassLoader classLoader, String resourcePath) { + return loadFxmlFromResource(classLoader, resourcePath, null); + } + + public static FXMLLoader loadFxmlFromResource( + ClassLoader classLoader, String resourcePath, ResourceBundle resourceBundle) { try { FXMLLoader fxmlLoader = new FXMLLoader(); - fxmlLoader.setLocation(FxmlUtil.class.getResource(resourcePath)); + fxmlLoader.setLocation(classLoader.getResource(resourcePath)); fxmlLoader.setResources(resourceBundle); fxmlLoader.load(); return fxmlLoader; -- Gitee From f29cdec05abc2d33e522e5032e3b1db0077152f3 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Tue, 29 Mar 2022 09:52:44 +0800 Subject: [PATCH 28/30] =?UTF-8?q?=E4=B8=BA=E5=B0=86=E6=9D=A5=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=8C=96=E9=87=8D=E6=9E=84=E5=81=9A=E5=87=86=E5=A4=87?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xwintop/xcore/javafx/dialog/FxDialog.java | 15 ++ .../xwintop/xcore/util/javafx/FxmlUtil.java | 3 +- .../xcore/javafx/dialog/FxDialogTest.java | 142 +++++++++--------- 3 files changed, 90 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java b/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java index 41c5360..b688218 100644 --- a/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java +++ b/src/main/java/com/xwintop/xcore/javafx/dialog/FxDialog.java @@ -75,6 +75,12 @@ public class FxDialog { return this; } + public FxDialog setPrefSize(double prefWidth, double prefHeight) { + this.prefWidth = prefWidth; + this.prefHeight = prefHeight; + return this; + } + public FxDialog setPrefHeight(double prefHeight) { this.prefHeight = prefHeight; return this; @@ -100,6 +106,15 @@ public class FxDialog { return this; } + public FxDialog setBodyFxml(ClassLoader classLoader, String bodyFxmlPath) { + this.bodyFxmlClassLoader = classLoader; + this.bodyFxmlPath = bodyFxmlPath; + return this; + } + + /** + * @deprecated Use {@link #setBodyFxml(ClassLoader, String)} )} instead + */ public FxDialog setBodyFxml(String bodyFxmlPath) { this.bodyFxmlPath = bodyFxmlPath; return this; diff --git a/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java b/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java index e3db3cc..c04aaec 100644 --- a/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java +++ b/src/main/java/com/xwintop/xcore/util/javafx/FxmlUtil.java @@ -2,6 +2,7 @@ package com.xwintop.xcore.util.javafx; import com.xwintop.xcore.XCoreException; import javafx.fxml.FXMLLoader; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.util.ResourceBundle; @@ -34,7 +35,7 @@ public class FxmlUtil { ClassLoader classLoader, String resourcePath, ResourceBundle resourceBundle) { try { FXMLLoader fxmlLoader = new FXMLLoader(); - fxmlLoader.setLocation(classLoader.getResource(resourcePath)); + fxmlLoader.setLocation(classLoader.getResource(StringUtils.removeStart(resourcePath, "/"))); fxmlLoader.setResources(resourceBundle); fxmlLoader.load(); return fxmlLoader; diff --git a/src/test/java/com/xwintop/xcore/javafx/dialog/FxDialogTest.java b/src/test/java/com/xwintop/xcore/javafx/dialog/FxDialogTest.java index 85adf98..889e2ef 100644 --- a/src/test/java/com/xwintop/xcore/javafx/dialog/FxDialogTest.java +++ b/src/test/java/com/xwintop/xcore/javafx/dialog/FxDialogTest.java @@ -1,7 +1,5 @@ package com.xwintop.xcore.javafx.dialog; -import static com.xwintop.xcore.javafx.helper.LayoutHelper.button; - import com.xwintop.xcore.javafx.FxApp; import com.xwintop.xcore.javafx.helper.LayoutHelper; import javafx.application.Application; @@ -10,75 +8,81 @@ import javafx.scene.control.ButtonType; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; -public class FxDialogTest extends Application { - - public static void main(String[] args) { - launch(args); - } - - @Override - public void start(Stage primaryStage) throws Exception { - FxApp.init(primaryStage, "/icon.png"); - - primaryStage.setScene(new Scene(new BorderPane( - LayoutHelper.vbox(10, 10, - button("打开带按钮的对话框", () -> openDialog(primaryStage)), - button("打开不带按钮的对话框", () -> openDialog2(primaryStage)), - button("不可通过顶部按钮关闭的对话框", () -> openDialog3(primaryStage)) - ) - ), 400, 300)); - primaryStage.show(); - } - - private void openDialog(Stage primaryStage) { - - // 创建对话框 - FxDialog dialog = new FxDialog() - .setOwner(primaryStage) - .setBodyFxml("/sample-dialog-body.fxml") - .setTitle("对话框标题") - .setButtonTypes(ButtonType.OK, ButtonType.CANCEL); - - // 通过 Controller 对象初始化对话框内容 - FxDialogTestController controller = dialog.show(); - controller.initName("这是一个名字"); - - // 用户如果修改了对话框内容,仍然通过 Controller 来获取 - // 这样避免了父窗体代码直接访问子窗体元素,职责混乱 - dialog.setButtonHandler(ButtonType.OK, (actionEvent, stage) -> { - System.out.println("新的名字:" + controller.getName()); - stage.close(); - }); - - dialog.setButtonHandler(ButtonType.CANCEL, (actionEvent, stage) -> { - - }); - } - - private void openDialog2(Stage primaryStage) { +import static com.xwintop.xcore.javafx.helper.LayoutHelper.button; +import static javafx.application.Application.launch; - // 创建不带按钮的对话框 - FxDialog dialog = new FxDialog() - .setOwner(primaryStage) - .setBodyFxml("/sample-dialog-body.fxml") - .setTitle("对话框标题"); +public class FxDialogTest { - // 通过 Controller 对象初始化对话框内容 - FxDialogTestController controller = dialog.show(); - controller.initName("这是一个名字"); + public static void main(String[] args) { + launch(FxDialogTextApp.class, args); } - private void openDialog3(Stage primaryStage) { - - // 创建不带按钮的对话框 - FxDialog dialog = new FxDialog() - .setOwner(primaryStage) - .setCloseable(false) - .setBodyFxml("/sample-dialog-body.fxml") - .setButtonTypes(ButtonType.CLOSE) - .setButtonHandler(ButtonType.CLOSE, (event, stage) -> stage.close()) - .setTitle("对话框"); - - dialog.show(); + public static class FxDialogTextApp extends Application { + + @Override + public void start(Stage primaryStage) throws Exception { + FxApp.init(primaryStage, "/icon.png"); + + primaryStage.setScene(new Scene(new BorderPane( + LayoutHelper.vbox(10, 10, + button("打开带按钮的对话框", () -> openDialog(primaryStage)), + button("打开不带按钮的对话框", () -> openDialog2(primaryStage)), + button("不可通过顶部按钮关闭的对话框", () -> openDialog3(primaryStage)) + ) + ), 400, 300)); + primaryStage.show(); + } + + private void openDialog(Stage primaryStage) { + + // 创建对话框 + FxDialog dialog = new FxDialog() + .setOwner(primaryStage) + .setBodyFxml(getClass().getClassLoader(), "/sample-dialog-body.fxml") + .setTitle("对话框标题") + .setButtonTypes(ButtonType.OK, ButtonType.CANCEL); + + // 通过 Controller 对象初始化对话框内容 + FxDialogTestController controller = dialog.show(); + controller.initName("这是一个名字"); + + // 用户如果修改了对话框内容,仍然通过 Controller 来获取 + // 这样避免了父窗体代码直接访问子窗体元素,职责混乱 + dialog.setButtonHandler(ButtonType.OK, (actionEvent, stage) -> { + System.out.println("新的名字:" + controller.getName()); + stage.close(); + }); + + dialog.setButtonHandler(ButtonType.CANCEL, (actionEvent, stage) -> { + + }); + } + + private void openDialog2(Stage primaryStage) { + + // 创建不带按钮的对话框 + FxDialog dialog = new FxDialog() + .setOwner(primaryStage) + .setBodyFxml(getClass().getClassLoader(), "/sample-dialog-body.fxml") + .setTitle("对话框标题"); + + // 通过 Controller 对象初始化对话框内容 + FxDialogTestController controller = dialog.show(); + controller.initName("这是一个名字"); + } + + private void openDialog3(Stage primaryStage) { + + // 创建不带按钮的对话框 + FxDialog dialog = new FxDialog() + .setOwner(primaryStage) + .setCloseable(false) + .setBodyFxml(getClass().getClassLoader(), "/sample-dialog-body.fxml") + .setButtonTypes(ButtonType.CLOSE) + .setButtonHandler(ButtonType.CLOSE, (event, stage) -> stage.close()) + .setTitle("对话框"); + + dialog.show(); + } } -} \ No newline at end of file +} -- Gitee From e940c6a2c5e98f459869805ef4f31f47c508f960 Mon Sep 17 00:00:00 2001 From: Yiding He Date: Tue, 29 Mar 2022 10:48:10 +0800 Subject: [PATCH 29/30] =?UTF-8?q?KeyValue=20=E6=94=B9=E4=B8=BA=E5=8F=AF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=90=8C=E6=97=B6=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=88=9B=E5=BB=BA=E5=8F=AA=E8=AF=BB=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xwintop/xcore/util/KeyValue.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/com/xwintop/xcore/util/KeyValue.java b/src/main/java/com/xwintop/xcore/util/KeyValue.java index 562c0b4..2215d2a 100644 --- a/src/main/java/com/xwintop/xcore/util/KeyValue.java +++ b/src/main/java/com/xwintop/xcore/util/KeyValue.java @@ -2,6 +2,9 @@ package com.xwintop.xcore.util; import java.util.Objects; +/** + * 键值对,默认是可修改的,可以通过 {@link #unmodifiable()} 方法获取不可修改的键值对。 + */ public class KeyValue { private K key; @@ -28,6 +31,31 @@ public class KeyValue { return value; } + public void setKey(K key) { + this.key = key; + } + + public void setValue(V value) { + this.value = value; + } + + /** + * 创建一个只读实例 + */ + public KeyValue unmodifiable() { + return new KeyValue<>(this) { + @Override + public void setKey(K key) { + throw new UnsupportedOperationException(); + } + + @Override + public void setValue(V value) { + throw new UnsupportedOperationException(); + } + }; + } + @Override public String toString() { return String.valueOf(key); -- Gitee From a6a63434c7010100d6d3e9c53af5ead00a2b8dc0 Mon Sep 17 00:00:00 2001 From: xufeng <1277032935@qq.com> Date: Tue, 29 Mar 2022 17:37:04 +0800 Subject: [PATCH 30/30] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E4=B8=BA0.0.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++++---- src/main/java/module-info.java.bak | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 src/main/java/module-info.java.bak diff --git a/README.md b/README.md index 782b7ef..be32437 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,16 @@ ``` - xwintop-maven - https://xwintop.gitee.io/maven/repository + jitpack.io + https://jitpack.io - com.xwintop + com.gitee.xwintop xcore - 0.0.6 + 0.0.7 provided @@ -46,4 +46,7 @@ git 托管 maven可参考教程(若无法下载请拉取项目自行编译)。[ 1. 添加进度条对话框 - 0.0.6 2020-07-04 1. 添加历史输入框功能封装 + 2. 优化部分功能代码 +- 0.0.7 2022-03-29 + 1. 升级jdk版本为17 2. 优化部分功能代码 \ No newline at end of file diff --git a/src/main/java/module-info.java.bak b/src/main/java/module-info.java.bak new file mode 100644 index 0000000..3c9c665 --- /dev/null +++ b/src/main/java/module-info.java.bak @@ -0,0 +1,26 @@ +open module com.xwintop.xcore { + exports com.xwintop.xcore; + requires java.base; + requires java.desktop; + requires javafx.base; + requires javafx.controls; + requires javafx.fxml; + requires javafx.graphics; + requires javafx.web; + requires org.apache.commons.lang3; + requires org.apache.commons.io; + requires hutool.all; + requires com.jfoenix; + requires lombok; + requires org.slf4j; + requires logback.classic; + requires logback.core; + requires okhttp3; + requires dom4j; + requires org.yaml.snakeyaml; + requires quartz; + requires org.apache.commons.collections4; + requires javafx.swing; + requires org.apache.commons.imaging; + requires org.controlsfx.controls; +} -- Gitee