diff --git a/.gitignore b/.gitignore
index eb68f493e738eb6e3417eb7ad47a1d5183c002c0..47fa028e9763adbc073c260252a6486bd999cf46 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,15 @@
# Default ignored files
#/.gitignore
-/.idea
-/xJavaFxTool.iml
-/logs
-/target
+.idea/
+*.iml
+logs/
+target/
libs/
+
system_plugin_list.json
RUNNING_PID
+gradle
+.gradle
+build
+out
diff --git a/README.md b/README.md
index f35a1f48be3580f95f65e1be9f16d77c171b6bed..1d8c6a472b7de405a028cd34b863e5d4cea20481 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,13 @@
**腾讯云开发平台地址:**[xJavaFxTool](https://dev.tencent.com/u/xwintop/p/xJavaFxTool)
-   
+[](https://www.apache.org/licenses/LICENSE-2.0.html)
+[](https://www.oracle.com/technetwork/java/javase/downloads/index.html)
+[](https://maven.apache.org)
+[](https://gitee.com/xwintop/xJavaFxTool/stargazers)
+[](https://github.com/864381832/xJavaFxTool)
[](https://www.jetbrains.com/?from=xJavaFxTool)
+
[英文说明/English Documentation](README_EN.md)
@@ -18,7 +23,7 @@ xJavaFxTool是使用javaFx开发的实用小工具集,利用业余时间把工
由于SpringBoot的火热,项目已经出SpringBoot-javafx版本,[xJavaFxTool-spring](https://gitee.com/xwintop/xJavaFxTool-spring) 欢迎参考,谢谢。
#### 下载试用地址:
-- 可直接运行的jar包(本地需要有jdk1.8环境)[xJavaFxTool-0.2.3.jar](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3.jar)
+- 可直接运行的jar包(本地需要有jdk17环境)[xJavaFxTool-0.2.3-jdk11.jar](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3-jdk11.jar)
- Windows x86安装包(兼容xp、windows7、8、10等系统)(请在下面网盘中下载)
- Windows x64安装包(兼容xp、windows7、8、10等系统)[xJavaFxTool-0.2.3-windows-x64.exe](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3-windows-x64.exe)
- Linux x64 (请在下面网盘中下载)
@@ -35,13 +40,13 @@ xJavaFxTool是使用javaFx开发的实用小工具集,利用业余时间把工
- [相关小游戏](https://gitee.com/xwintop/xJavaFxTool-Games)
#### 环境搭建说明:
-- 开发环境为jdk1.8,基于maven构建
-- 使用eclipase或Intellij Idea开发,推荐使用[Intellij Idea](https://www.jetbrains.com/?from=xJavaFxTool)
+- 开发环境为jdk17,基于maven3.6.3构建
+- 使用eclipase或Intellij Idea开发,推荐使用[Intellij Idea](https://www.jetbrains.com/idea/?from=xJavaFxTool)
- 本项目使用了[lombok](https://projectlombok.org/),在查看本项目时如果您没有下载lombok 插件,请先安装,不然找不到get/set等方法
- 依赖的[xcore包](https://gitee.com/xwintop/xcore)已上传至git托管的maven平台,git托管maven可参考教程(若无法下载请拉取项目自行编译)。[教程地址:点击进入](http://blog.csdn.net/u011747754/article/details/78574026)
-- 使用[javafx-maven-plugin](https://github.com/javafx-maven-plugin/javafx-maven-plugin)插件进行打包操作(可打包windows、Linux、Mac安装包)
-- 使用[exe4j](https://www.ej-technologies.com/download/exe4j/files)将jar包转成exe执行文件(仅供参考,可使用其它程序打包)
+- 使用[javapackager](https://github.com/fvarrui/JavaPackager)插件进行打包操作(可打包windows、Linux、Mac安装包)
- 使用[InnoSetup](http://www.jrsoftware.org/)可进行制作windows安装包
+- jdk11启动需添加参数java --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.zipfs/jdk.nio.zipfs=ALL-UNNAMED -jar xJavaFxTool.jar [参考](https://blog.csdn.net/fighting_boss/article/details/91043555)
#### 目前集成的小工具有(点击中文名可进入对应小工具的开源地址):
| 序号 | 英文名 | 中文名 | 简介 |
diff --git a/README_EN.md b/README_EN.md
index 17c89c69719fb6cd7f58836868d48b3b8672f647..09f81bcd1dd6b02982ea119a99fcae10a0b5483c 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -4,20 +4,12 @@
**Tencent Cloud Development Platform Address:**[xJavaFxTool](https://dev.tencent.com/u/xwintop/p/xJavaFxTool)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+[](https://www.apache.org/licenses/LICENSE-2.0.html)
+[](https://www.oracle.com/technetwork/java/javase/downloads/index.html)
+[](https://maven.apache.org)
+[](https://gitee.com/xwintop/xJavaFxTool/stargazers)
+[](https://github.com/864381832/xJavaFxTool)
+[](https://www.jetbrains.com/?from=xJavaFxTool)
[中文说明/Chinese Documentation](README.md)
@@ -40,7 +32,7 @@ Due to the hot SpringBoot, the project has been released SpringBoot-javafx versi
the plug-in jar package can be automatically loaded under the root directory libs (see the open source project [xJavaFxTool-plugin](https://gitee.com/xwintop/xJavaFxTool-plugin) for plug-in development examples , and the next step is to split the gadget into each plug-in and load it as needed. Currently, the plug-in function is not perfect, follow-up Split each function into modules and load them as needed to reduce the size of the jar package);
#### Environmental construction instructions:
-- The development environment is jdk1.8, based on maven build
+- The development environment is jdk17, based on maven3.6.3 build
- Developed with eclipase or Intellij Idea (Recommended to use [Intellij Idea](https://www.jetbrains.com/idea/) )
- This project uses [lombok](https://projectlombok.org/) . If you have not downloaded the lombok plugin when viewing this project, please install it first, otherwise you can't find the get/set method.
- The dependent [xcore](https://gitee.com/xwintop/xcore) package has been uploaded to the git-hosted maven platform. The git hosting maven can refer to the tutorial (if you can't download it, please pull the project to compile it yourself ). Tutorial address: Click to enter
diff --git a/assets/linux/xJavaFxTool.png b/assets/linux/xJavaFxTool.png
new file mode 100644
index 0000000000000000000000000000000000000000..1a58fdd65ac5ad8297daf332e16c20c1ed4ddde3
Binary files /dev/null and b/assets/linux/xJavaFxTool.png differ
diff --git a/assets/mac/xJavaFxTool.icns b/assets/mac/xJavaFxTool.icns
new file mode 100644
index 0000000000000000000000000000000000000000..9c433da283392920a1bb07de88d09d4835ac3ae0
Binary files /dev/null and b/assets/mac/xJavaFxTool.icns differ
diff --git a/assets/windows/xJavaFxTool.ico b/assets/windows/xJavaFxTool.ico
new file mode 100644
index 0000000000000000000000000000000000000000..0c93826acadc11506faa1fa0275e16bb0bc95e58
Binary files /dev/null and b/assets/windows/xJavaFxTool.ico differ
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..fabe58bec91afc8cb92674adc6a208b377b7ea23
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,72 @@
+buildscript {
+ repositories {
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
+ }
+ dependencies {
+ classpath 'org.openjfx:javafx-plugin:0.0.12'
+ }
+}
+
+plugins {
+ id 'java'
+ id 'application'
+ id 'maven-publish'
+ id 'org.openjfx.javafxplugin' version '0.0.12'
+ id 'org.beryx.jlink' version '2.24.4'
+}
+
+apply plugin: 'org.openjfx.javafxplugin'
+
+repositories {
+ mavenLocal()
+ maven {
+ url = uri('https://maven.aliyun.com/repository/public')
+ }
+
+ maven {
+ url = uri('https://jitpack.io')
+ }
+}
+
+dependencies {
+ implementation 'org.openjfx:javafx-controls:17.0.2'
+ implementation 'org.openjfx:javafx-base:17.0.2'
+ implementation 'org.openjfx:javafx-graphics:17.0.2'
+ implementation 'org.openjfx:javafx-fxml:17.0.2'
+ implementation 'org.openjfx:javafx-swing:17.0.2'
+ implementation 'org.openjfx:javafx-media:17.0.2'
+ implementation 'org.openjfx:javafx-web:17.0.2'
+ implementation 'org.openjfx:javafx-graphics:17.0.2'
+ implementation 'org.openjfx:javafx-graphics:17.0.2'
+ implementation 'org.openjfx:javafx-graphics:17.0.2'
+ implementation 'io.github.classgraph:classgraph:4.8.100'
+ implementation 'com.gitee.xwintop:xcore:0.0.6-jdk17'
+ implementation 'com.github.oshi:oshi-core:5.7.5'
+ testImplementation 'junit:junit:4.12'
+ compileOnly 'org.projectlombok:lombok:1.18.22'
+}
+
+group = 'com.xwintop'
+version = '0.2.3-jdk17'
+description = 'xJavaFxTool'
+sourceCompatibility = '17'
+
+javafx {
+ version = "17.0.2"
+ modules = ['javafx.controls', 'javafx.fxml', 'javafx.media', 'javafx.swing', 'javafx.web']
+ configuration = 'compileOnly'
+}
+
+jlink {
+// mergedModule {
+// requires 'java.naming'
+// requires 'java.xml'
+// }
+ launcher{
+ name = 'xJavaFxTool'
+ mainClassName = 'com.xwintop.xJavaFxTool.XJavaFxToolMain'
+ jvmArgs = ['-Dlogback.configurationFile=./logback.xml']
+ }
+}
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000000000000000000000000000000000000..4f906e0c811fc9e230eb44819f509cd0627f2600
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000000000000000000000000000000000000..107acd32c4e687021ef32db511e8a206129b88ec
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/pom.xml b/pom.xml
index 944033170fb1da4d4815db0212102c9daffebbc7..ba48e21c8e2a8b7aafac0611fda66cab70041171 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1,20 +1,25 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.xwintop
xJavaFxTool
- 0.2.3
+ 0.3.1
jar
xJavaFxTool
基于JavaFx搭建的实用小工具集合
+
+ xwintop
+ https://gitee.com/xwintop
+
https://gitee.com/xwintop/xJavaFxTool
UTF-8
true
- 1.8
- 1.8
+ 17
+ 17
+ 17.0.2
@@ -25,65 +30,49 @@
jitpack.io
https://jitpack.io
-
- spring-snapshots
- http://repo.spring.io/snapshot
-
- true
-
-
-
- spring-milestones
- http://repo.spring.io/milestone
-
junit
junit
- 4.12
+ 4.13.2
test
+
com.gitee.xwintop
xcore
- 0.0.6
+ 0.0.7
org.projectlombok
lombok
- 1.18.6
+ 1.18.22
true
provided
-
-
- jaxen
- jaxen
- 1.2.0
-
-
+
+
- com.github.oshi
- oshi-core
- 3.9.1
+ io.github.classgraph
+ classgraph
+ 4.8.100
-
org.apache.maven.plugins
maven-assembly-plugin
- 2.5.5
+ 3.3.0
xJavaFxTool
false
utf-8
- com.xwintop.xJavaFxTool.Main
+ com.xwintop.xJavaFxTool.XJavaFxToolMain
@@ -100,37 +89,46 @@
+
+
+
+
+
+
+
+
- com.zenjava
- javafx-maven-plugin
- 8.8.3
+ io.github.fvarrui
+ javapackager
+ 1.6.5
- com.xwintop.xJavaFxTool.Main
- xwintop
- xJavaFxTool
+ true
+ com.xwintop.xJavaFxTool.XJavaFxToolMain
+ true
+ auto
+ true
+ true
+
+
+ true
+ false
+
+ installForAllUsers
+ true
+ false
+ false
+ false
+ false
+ false
+
+ compiler:Default.isl
+ compiler:Languages\English.isl
+
+
+
+
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 3.1.1
-
- private
- true
-
- -Xdoclint:none
-
-
-
-
- attach-javadocs
-
- jar
-
-
-
-
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..2cda093ed4757f6539ead2bbd970f0b0eb4732f2
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,5 @@
+/*
+ * This file was generated by the Gradle 'init' task.
+ */
+
+rootProject.name = 'xJavaFxTool'
diff --git a/src/main/java/com/xwintop/xJavaFxTool/Main.java b/src/main/java/com/xwintop/xJavaFxTool/XJavaFxToolApplication.java
similarity index 56%
rename from src/main/java/com/xwintop/xJavaFxTool/Main.java
rename to src/main/java/com/xwintop/xJavaFxTool/XJavaFxToolApplication.java
index 6f2ba1304f5cb6af04436fb2f3c42c3ed5a9bc4d..553814030366a5233dd4e6fada943566f49b98e8 100644
--- a/src/main/java/com/xwintop/xJavaFxTool/Main.java
+++ b/src/main/java/com/xwintop/xJavaFxTool/XJavaFxToolApplication.java
@@ -1,16 +1,12 @@
package com.xwintop.xJavaFxTool;
-import com.jfoenix.controls.JFXDecorator;
import com.xwintop.xJavaFxTool.controller.IndexController;
import com.xwintop.xJavaFxTool.utils.Config;
import com.xwintop.xJavaFxTool.utils.Config.Keys;
import com.xwintop.xJavaFxTool.utils.StageUtils;
-import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
+import com.xwintop.xJavaFxTool.utils.VersionChecker;
import com.xwintop.xcore.javafx.FxApp;
import com.xwintop.xcore.javafx.dialog.FxAlerts;
-import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
-import java.io.IOException;
-import java.util.ResourceBundle;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.Event;
@@ -20,14 +16,14 @@ import javafx.scene.Scene;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
+import java.io.IOException;
+import java.util.ResourceBundle;
+
/**
- * @ClassName: Main
- * @Description: 启动类
- * @author: xufeng
- * @date: 2017年11月10日 下午4:34:11
+ * JavaFX 入口,从 Java 9+ 开始入口类不应再包含 main 方法。
*/
@Slf4j
-public class Main extends Application {
+public class XJavaFxToolApplication extends Application {
public static final String LOGO_PATH = "/images/icon.jpg";
@@ -35,61 +31,40 @@ public class Main extends Application {
private static Stage stage;
- public static void main(String[] args) {
-
- XJavaFxSystemUtil.initSystemLocal(); // 初始化本地语言
- XJavaFxSystemUtil.addJarByLibs(); // 添加外部jar包
-
- launch(args);
- }
-
@Override
public void start(Stage primaryStage) throws Exception {
stage = primaryStage;
// 初始化 JavaFX 全局设置
FxApp.init(primaryStage, LOGO_PATH);
- FxApp.setupIcon(primaryStage);
- FxApp.styleSheets.add(Main.class.getResource("/css/jfoenix-main.css").toExternalForm());
+ FxApp.styleSheets.add(XJavaFxToolApplication.class.getResource("/css/jfoenix-main.css").toExternalForm());
+
+// if (SystemUtil.getOsInfo().isMac()) {
+ //Mac下设置dock栏图标
+// Taskbar.getTaskbar().setIconImage(ImageIO.read(XJavaFxToolApplication.class.getResourceAsStream(LOGO_PATH)));
+// }
primaryStage.setResizable(true);
primaryStage.setTitle(RESOURCE_BUNDLE.getString("Title") + Config.xJavaFxToolVersions);
primaryStage.setOnCloseRequest(this::confirmExit);
- if (Config.getBoolean(Keys.NewLauncher, false)) {
- loadNewUI(primaryStage);
- } else {
- loadClassicUI(primaryStage);
- }
+ // 只启用新UI,因为:
+ // 1. 新UI启动时不扫描插件目录,启动更快;
+ // 2. 新UI使用独立的ClassLoader加载插件,兼容性更好;
+ // 3. 新UI本身体验较好。
+ loadClassicUI(primaryStage);
StageUtils.loadPrimaryStageBound(primaryStage);
+ primaryStage.setOnShown(windowEvent -> {
+ VersionChecker.checkNewVersion();
+ });
primaryStage.show();
- StageUtils.updateStageStyle(primaryStage);
- }
-
- private void loadNewUI(Stage primaryStage) throws IOException {
- FXMLLoader fxmlLoader = new FXMLLoader();
- fxmlLoader.setLocation(Main.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/newui/main.fxml"));
- fxmlLoader.setResources(RESOURCE_BUNDLE);
-
- Parent root = fxmlLoader.load();
- primaryStage.setScene(new Scene(root));
}
private void loadClassicUI(Stage primaryStage) throws IOException {
FXMLLoader fXMLLoader = IndexController.getFXMLLoader();
Parent root = fXMLLoader.load();
-
- JFXDecorator decorator = JavaFxViewUtil.getJFXDecorator(
- primaryStage,
- RESOURCE_BUNDLE.getString("Title") + Config.xJavaFxToolVersions,
- LOGO_PATH,
- root
- );
- decorator.setOnCloseButtonAction(() -> confirmExit(null));
-
- Scene scene = JavaFxViewUtil.getJFXDecoratorScene(decorator);
- primaryStage.setScene(scene);
+ primaryStage.setScene(new Scene(root));
}
private void confirmExit(Event event) {
@@ -115,6 +90,6 @@ public class Main extends Application {
}
public static void setStage(Stage stage) {
- Main.stage = stage;
+ XJavaFxToolApplication.stage = stage;
}
}
diff --git a/src/main/java/com/xwintop/xJavaFxTool/XJavaFxToolMain.java b/src/main/java/com/xwintop/xJavaFxTool/XJavaFxToolMain.java
new file mode 100644
index 0000000000000000000000000000000000000000..7d25db2f36c28a6150acb6e01308ac3ae10042cf
--- /dev/null
+++ b/src/main/java/com/xwintop/xJavaFxTool/XJavaFxToolMain.java
@@ -0,0 +1,17 @@
+package com.xwintop.xJavaFxTool;
+
+import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
+import javafx.application.Application;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 程序入口
+ */
+@Slf4j
+public class XJavaFxToolMain {
+
+ public static void main(String[] args) {
+ XJavaFxSystemUtil.initSystemLocal(); // 初始化本地语言
+ Application.launch(XJavaFxToolApplication.class, args);
+ }
+}
diff --git a/src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java b/src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java
index 0910b2e8ca145df1ab143ba9609aaecc87385b5a..8fe8e0ac188d4163c5f5d8c70eea17e07f68b5f6 100644
--- a/src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java
+++ b/src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java
@@ -1,52 +1,42 @@
package com.xwintop.xJavaFxTool.controller;
-import static com.xwintop.xJavaFxTool.Main.RESOURCE_BUNDLE;
-import static com.xwintop.xJavaFxTool.utils.Config.Keys.NotepadEnabled;
-
+import com.xwintop.xJavaFxTool.XJavaFxToolApplication;
import com.xwintop.xJavaFxTool.controller.index.PluginManageController;
-import com.xwintop.xJavaFxTool.model.ToolFxmlLoaderConfiguration;
+import com.xwintop.xJavaFxTool.event.AppEvents;
+import com.xwintop.xJavaFxTool.event.PluginEvent;
+import com.xwintop.xJavaFxTool.model.PluginJarInfo;
+import com.xwintop.xJavaFxTool.newui.PluginCategoryController;
+import com.xwintop.xJavaFxTool.newui.PluginItemController;
import com.xwintop.xJavaFxTool.plugin.PluginManager;
+import com.xwintop.xJavaFxTool.plugin.PluginParser;
import com.xwintop.xJavaFxTool.services.IndexService;
-import com.xwintop.xJavaFxTool.services.index.PluginManageService;
import com.xwintop.xJavaFxTool.services.index.SystemSettingService;
import com.xwintop.xJavaFxTool.utils.Config;
import com.xwintop.xJavaFxTool.view.IndexView;
+import com.xwintop.xcore.javafx.FxApp;
+import com.xwintop.xcore.javafx.dialog.FxDialog;
import com.xwintop.xcore.util.ConfigureUtil;
import com.xwintop.xcore.util.HttpClientUtil;
import com.xwintop.xcore.util.javafx.AlertUtil;
import com.xwintop.xcore.util.javafx.JavaFxSystemUtil;
-import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
-import javafx.scene.Parent;
-import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
+import javafx.scene.control.Tab;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang3.time.DateFormatUtils;
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.io.SAXReader;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.File;
+import java.net.URL;
+import java.util.*;
/**
* @ClassName: IndexController
@@ -58,184 +48,147 @@ import org.dom4j.io.SAXReader;
@Getter
@Setter
public class IndexController extends IndexView {
-
public static final String QQ_URL = "https://support.qq.com/product/127577";
public static final String STATISTICS_URL = "https://xwintop.gitee.io/maven/tongji/xJavaFxTool.html";
- private Map menuMap = new HashMap<>();
+ public static final String FAVORITE_CATEGORY_NAME = XJavaFxToolApplication.RESOURCE_BUNDLE.getString("favoriteCategory");
private Map menuItemMap = new HashMap<>();
private IndexService indexService = new IndexService(this);
- private ContextMenu contextMenu = new ContextMenu();
+ // 实现搜索用
+ private List pluginItemControllers = new ArrayList<>();
+
+ private Map categoryControllers = new HashMap<>();
public static FXMLLoader getFXMLLoader() {
- URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/Index.fxml");
- return new FXMLLoader(url, RESOURCE_BUNDLE);
+ URL url = IndexController.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/Index.fxml");
+ return new FXMLLoader(url, XJavaFxToolApplication.RESOURCE_BUNDLE);
}
@Override
public void initialize(URL location, ResourceBundle resources) {
this.bundle = resources;
-
initView();
initEvent();
initService();
initNotepad();
-
- this.indexService.addWebView(RESOURCE_BUNDLE.getString("feedback"), QQ_URL, null);
- this.tongjiWebView.getEngine().load(STATISTICS_URL);
}
private void initNotepad() {
- if (Config.getBoolean(NotepadEnabled, true)) {
- addNodepadAction(null);
- }
+// if (Config.getBoolean(Config.Keys.NotepadEnabled, true)) {
+// addNodepadAction(null);
+// }
}
private void initView() {
- menuMap.put("toolsMenu", toolsMenu);
- menuMap.put("moreToolsMenu", moreToolsMenu);
- File libPath = new File("libs/");
- // 获取所有的.jar和.zip文件
- File[] jarFiles = libPath.listFiles((dir, name) -> name.endsWith(".jar"));
- if (jarFiles != null) {
- for (File jarFile : jarFiles) {
- if (!PluginManageService.isPluginEnabled(jarFile.getName())) {
- continue;
- }
- try {
- this.addToolMenu(jarFile);
- } catch (Exception e) {
- log.error("加载工具出错:", e);
- }
- }
- }
+ this.indexService.addWebView(XJavaFxToolApplication.RESOURCE_BUNDLE.getString("feedback"), QQ_URL, null);
+ this.tongjiWebView.getEngine().load(STATISTICS_URL);
+ this.tabPaneMain.getSelectionModel().select(0);
}
private void initEvent() {
+ mainMenuBar.setUseSystemMenuBar(true);
myTextField.textProperty().addListener((observable, oldValue, newValue) -> selectAction(newValue));
- myButton.setOnAction(arg0 -> {
- selectAction(myTextField.getText());
- });
}
private void initService() {
+ loadPlugins(); // 加载插件列表到界面上
+ AppEvents.addEventHandler(PluginEvent.PLUGIN_DOWNLOADED, pluginEvent -> {
+ loadPlugins();
+ });
}
- public void addToolMenu(File file) throws Exception {
- Map toolMap = new HashMap<>();
- List toolList = new ArrayList<>();
-
- try (JarFile jarFile = new JarFile(file)) {
- JarEntry entry = jarFile.getJarEntry("config/toolFxmlLoaderConfiguration.xml");
- if (entry == null) {
- return;
- }
- InputStream input = jarFile.getInputStream(entry);
- SAXReader saxReader = new SAXReader();
- Document document = saxReader.read(input);
- Element root = document.getRootElement();
- List elements = root.elements("ToolFxmlLoaderConfiguration");
- for (Element configurationNode : elements) {
- ToolFxmlLoaderConfiguration toolFxmlLoaderConfiguration = new ToolFxmlLoaderConfiguration();
- List attributes = configurationNode.attributes();
- for (Attribute configuration : attributes) {
- BeanUtils.copyProperty(toolFxmlLoaderConfiguration, configuration.getName(), configuration.getValue());
- }
- List childrenList = configurationNode.elements();
- for (Element configuration : childrenList) {
- BeanUtils.copyProperty(toolFxmlLoaderConfiguration, configuration.getName(), configuration.getStringValue());
- }
- if (StringUtils.isEmpty(toolFxmlLoaderConfiguration.getMenuParentId())) {
- toolFxmlLoaderConfiguration.setMenuParentId("moreToolsMenu");
- }
- if (toolFxmlLoaderConfiguration.getIsMenu()) {
- if (menuMap.get(toolFxmlLoaderConfiguration.getMenuId()) == null) {
- toolMap.putIfAbsent(toolFxmlLoaderConfiguration.getMenuId(), toolFxmlLoaderConfiguration);
- }
- } else {
- toolList.add(toolFxmlLoaderConfiguration);
- }
- }
- }
- toolList.addAll(toolMap.values());
- this.addMenu(toolList);
+ /**
+ * 加载/刷新插件列表
+ */
+ public void loadPlugins() {
+ this.pluginCategories.getChildren().clear();
+ this.pluginItemControllers.clear();
+ this.categoryControllers.clear();
+ this.menuItemMap.clear();
+ this.moreToolsMenu.getItems().clear();
+
+ PluginManager pluginManager = PluginManager.getInstance();
+ pluginManager.loadLocalPlugins();
+ pluginManager.getEnabledPluginList().forEach(this::loadPlugin);
}
- private void addMenu(List toolList) {
- for (ToolFxmlLoaderConfiguration toolConfig : toolList) {
- try {
- if (StringUtils.isEmpty(toolConfig.getResourceBundleName())) {
- if (StringUtils.isNotEmpty(bundle.getString(toolConfig.getTitle()))) {
- toolConfig.setTitle(bundle.getString(toolConfig.getTitle()));
- }
- } else {
- ResourceBundle resourceBundle = ResourceBundle.getBundle(toolConfig.getResourceBundleName(), Config.defaultLocale);
- if (StringUtils.isNotEmpty(resourceBundle.getString(toolConfig.getTitle()))) {
- toolConfig.setTitle(resourceBundle.getString(toolConfig.getTitle()));
- }
- }
- } catch (Exception e) {
- log.error("加载菜单失败", e);
- }
- if (toolConfig.getIsMenu()) {
- Menu menu = new Menu(toolConfig.getTitle());
- if (StringUtils.isNotEmpty(toolConfig.getIconPath())) {
- ImageView imageView = new ImageView(new Image(toolConfig.getIconPath()));
- imageView.setFitHeight(18);
- imageView.setFitWidth(18);
- menu.setGraphic(imageView);
- }
- menuMap.put(toolConfig.getMenuId(), menu);
+ /**
+ * 加载单个插件到界面,要求插件已经经过 {@link PluginParser#parse(File, PluginJarInfo)} 解析
+ *
+ * @param jarInfo 插件信息
+ */
+ private void loadPlugin(PluginJarInfo jarInfo) {
+ if (!jarInfo.getFile().exists()) {
+ log.info("跳过插件 {}: 文件不存在", jarInfo.getName());
+ return;
+ }
+ if (BooleanUtils.isFalse(jarInfo.getIsEnable())) {
+ log.info("跳过插件 {}: 插件未启用", jarInfo.getName());
+ return;
+ }
+ String menuParentTitle = jarInfo.getMenuParentTitle();
+ if (menuParentTitle == null) {
+ log.info("跳过插件 {}: menuParentTitle 为空", jarInfo.getName());
+ return;
+ }
+ String categoryName = jarInfo.getIsFavorite() ? FAVORITE_CATEGORY_NAME : XJavaFxToolApplication.RESOURCE_BUNDLE.getString(menuParentTitle);
+ PluginCategoryController category = categoryControllers.computeIfAbsent(
+ categoryName, __ -> {
+ PluginCategoryController _category = PluginCategoryController.newInstance(categoryName);
+ addCategory(_category);
+ return _category;
}
+ );
+
+ PluginItemController item = PluginItemController.newInstance(jarInfo);
+ item.setIndexController(this);
+ category.addItem(item);
+
+ if (!pluginItemControllers.contains(item)) {
+ pluginItemControllers.add(item);
}
- for (ToolFxmlLoaderConfiguration toolConfig : toolList) {
- if (toolConfig.getIsMenu()) {
- menuMap.get(toolConfig.getMenuParentId()).getItems().add(menuMap.get(toolConfig.getMenuId()));
- }
+ addMenu(jarInfo);
+ }
+
+ private void addCategory(PluginCategoryController category) {
+ if (category.lblCategoryName.getText().equals(FAVORITE_CATEGORY_NAME)) {
+ this.pluginCategories.getChildren().add(0, category.root);
+ } else {
+ this.pluginCategories.getChildren().add(category.root);
}
+ }
- for (ToolFxmlLoaderConfiguration toolConfig : toolList) {
- if (toolConfig.getIsMenu()) {
- continue;
+ private void addMenu(PluginJarInfo jarInfo) {
+ MenuItem menu = moreToolsMenu.getItems().stream().filter(menuItem1 -> jarInfo.getMenuParentId().equals(menuItem1.getId())).findAny().orElse(null);
+ if (menu == null) {
+ menu = new Menu(XJavaFxToolApplication.RESOURCE_BUNDLE.getString(jarInfo.getMenuParentTitle()));
+ menu.setId(jarInfo.getMenuParentId());
+ moreToolsMenu.getItems().add(menu);
}
- MenuItem menuItem = new MenuItem(toolConfig.getTitle());
- if (StringUtils.isNotEmpty(toolConfig.getIconPath())) {
- ImageView imageView = new ImageView(new Image(toolConfig.getIconPath()));
+ MenuItem menuItem = new MenuItem(jarInfo.getTitle());
+ if (StringUtils.isNotEmpty(jarInfo.getIconPath())) {
+ ImageView imageView = new ImageView(new Image(jarInfo.getIconPath()));
imageView.setFitHeight(18);
imageView.setFitWidth(18);
menuItem.setGraphic(imageView);
}
- if ("Node".equals(toolConfig.getControllerType())) {
- menuItem.setOnAction((ActionEvent event) -> {
- indexService.addContent(menuItem.getText(), toolConfig.getUrl(), toolConfig.getResourceBundleName(), toolConfig.getIconPath());
- });
- if (toolConfig.getIsDefaultShow()) {
- indexService.addContent(menuItem.getText(), toolConfig.getUrl(), toolConfig.getResourceBundleName(), toolConfig.getIconPath());
- }
- } else if ("WebView".equals(toolConfig.getControllerType())) {
- menuItem.setOnAction((ActionEvent event) -> {
- indexService.addWebView(menuItem.getText(), toolConfig.getUrl(), toolConfig.getIconPath());
- });
- if (toolConfig.getIsDefaultShow()) {
- indexService.addWebView(menuItem.getText(), toolConfig.getUrl(), toolConfig.getIconPath());
- }
- }
- menuMap.get(toolConfig.getMenuParentId()).getItems().add(menuItem);
+ menuItem.setOnAction((ActionEvent event) -> {
+ indexService.loadPlugin(jarInfo);
+ });
+ ((Menu)menu).getItems().add(menuItem);
menuItemMap.put(menuItem.getText(), menuItem);
- }
}
public void selectAction(String selectText) {
- if (contextMenu.isShowing()) {
- contextMenu.hide();
- }
- contextMenu = indexService.getSelectContextMenu(selectText);
- contextMenu.show(myTextField, null, 0, myTextField.getHeight());
+ boolean notSearching = StringUtils.isBlank(selectText);
+ pluginItemControllers.forEach(itemController -> {
+ itemController.setVisible(notSearching || itemController.matchKeyword(selectText));
+ });
}
@FXML
@@ -246,7 +199,7 @@ public class IndexController extends IndexView {
@FXML
private void closeAllTabAction() {
- tabPaneMain.getTabs().clear();
+ tabPaneMain.getTabs().removeIf(Tab::isClosable);
}
@FXML
@@ -268,18 +221,17 @@ public class IndexController extends IndexView {
@FXML
private void pluginManageAction() throws Exception {
- FXMLLoader fXMLLoader = PluginManageController.getFXMLLoader();
- Parent root = fXMLLoader.load();
- PluginManageController pluginManageController = fXMLLoader.getController();
- pluginManageController.setOnPluginDownloaded(jarFile -> {
- try {
- this.addToolMenu(jarFile);
- PluginManager.getInstance().loadLocalPlugins();
- } catch (Exception e) {
- log.error("加载工具出错:", e);
- }
- });
- JavaFxViewUtil.openNewWindow(bundle.getString("plugin_manage"), root);
+// FXMLLoader fXMLLoader = PluginManageController.getFXMLLoader();
+// Parent root = fXMLLoader.load();
+// JavaFxViewUtil.openNewWindow(bundle.getString("plugin_manage"), root);
+ new FxDialog()
+ .setBodyFxml(PluginManageController.FXML)
+ .setOwner(FxApp.primaryStage)
+ .setResizable(true)
+ .setTitle(XJavaFxToolApplication.RESOURCE_BUNDLE.getString("plugin_manage"))
+ .setPrefWidth(800)
+ .withStage(stage -> stage.setOnCloseRequest(event -> loadPlugins()))
+ .show();
}
@FXML
@@ -300,7 +252,7 @@ public class IndexController extends IndexView {
@FXML
private void openLogFileAction() {
- String filePath = "logs/logFile." + DateFormatUtils.format(new Date(), "yyyy-MM-dd") + ".log";
+ String filePath = "logs/logFile.log";
JavaFxSystemUtil.openDirectory(filePath);
}
diff --git a/src/main/java/com/xwintop/xJavaFxTool/controller/NotepadController.java b/src/main/java/com/xwintop/xJavaFxTool/controller/NotepadController.java
deleted file mode 100644
index e32b839e8395cd91d760b81108635e39862609a2..0000000000000000000000000000000000000000
--- a/src/main/java/com/xwintop/xJavaFxTool/controller/NotepadController.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.xwintop.xJavaFxTool.controller;
-
-import com.xwintop.xJavaFxTool.utils.NodeUtils;
-import com.xwintop.xJavaFxTool.view.NotepadView;
-import java.io.IOException;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Node;
-import javafx.scene.control.CheckMenuItem;
-import javafx.scene.control.ContextMenu;
-import javafx.scene.control.Tab;
-import javafx.scene.control.TextArea;
-import lombok.extern.slf4j.Slf4j;
-
-@Slf4j
-public class NotepadController extends NotepadView {
-
- private int counter = 0;
-
- public void initialize() {
- tabPane.getSelectionModel().selectedIndexProperty().addListener(((observable, oldValue, newValue) -> {
- int index = newValue.intValue();
- if (index + 1 == tabPane.getTabs().size()) {
- tabPane.getTabs().add(index, createTab());
- tabPane.getSelectionModel().select(index);
- }
- }));
-
- Tab firstTab = tabPane.getTabs().get(0);
- setupTab(firstTab, firstTab.getContent());
- }
-
- private Tab createTab() {
- counter += 1;
- Tab tab = new Tab("未命名" + counter);
-
- try {
- Node content = FXMLLoader.load(NotepadController.class
- .getResource("/com/xwintop/xJavaFxTool/fxmlView/notepad-tab.fxml")
- );
-
- setupTab(tab, content);
-
- tab.setContent(content);
- } catch (IOException e) {
- log.error("读取 FXML 失败", e);
- }
- return tab;
- }
-
- private void setupTab(Tab tab, Node content) {
-
- TextArea textArea = (TextArea) content.lookup(".text-area");
- if (textArea != null) {
- NodeUtils.setUserData(textArea, "id", counter);
- textArea.textProperty().addListener((_ob, _old, _new) -> {
- if (_new.trim().length() == 0) {
- tab.setText("未命名" + NodeUtils.getUserData(textArea, "id"));
- } else if (_new.contains("\n")) {
- tab.setText(_new.substring(0, _new.indexOf("\n")));
- } else {
- tab.setText(_new);
- }
- });
- }
-
- tab.setContextMenu(new ContextMenu(
- wrapTextMenuItem(textArea)
- ));
- }
-
- private CheckMenuItem wrapTextMenuItem(TextArea textArea) {
- CheckMenuItem menuItem = new CheckMenuItem("自动换行");
- if (textArea != null) {
- menuItem.setOnAction(event -> textArea.setWrapText(menuItem.isSelected()));
- }
- return menuItem;
- }
-}
diff --git a/src/main/java/com/xwintop/xJavaFxTool/controller/index/PluginManageController.java b/src/main/java/com/xwintop/xJavaFxTool/controller/index/PluginManageController.java
index 76be6cc7aeda5a9c5d889331290bba224c99b7ab..e8063f104578f4a9d68acb8fd6de4a9115c0d434 100644
--- a/src/main/java/com/xwintop/xJavaFxTool/controller/index/PluginManageController.java
+++ b/src/main/java/com/xwintop/xJavaFxTool/controller/index/PluginManageController.java
@@ -10,25 +10,16 @@ import com.xwintop.xJavaFxTool.plugin.PluginManager;
import com.xwintop.xJavaFxTool.plugin.PluginParser;
import com.xwintop.xJavaFxTool.services.index.PluginManageService;
import com.xwintop.xJavaFxTool.view.index.PluginManageView;
+import com.xwintop.xcore.javafx.dialog.FxAlerts;
import com.xwintop.xcore.util.javafx.FileChooserUtil;
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
import com.xwintop.xcore.util.javafx.TooltipUtil;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.function.Consumer;
+import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.fxml.FXMLLoader;
-import javafx.scene.control.Button;
-import javafx.scene.control.ContentDisplay;
-import javafx.scene.control.ContextMenu;
-import javafx.scene.control.MenuItem;
-import javafx.scene.control.TableCell;
-import javafx.scene.control.TableColumn;
+import javafx.scene.control.*;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Window;
import javafx.util.Callback;
@@ -36,6 +27,12 @@ import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+import java.util.ResourceBundle;
+
/**
* 插件管理
*
@@ -47,7 +44,6 @@ import lombok.extern.slf4j.Slf4j;
@Setter
@Slf4j
public class PluginManageController extends PluginManageView {
-
public static final String FXML = "/com/xwintop/xJavaFxTool/fxmlView/index/PluginManage.fxml";
private PluginManageService pluginManageService = new PluginManageService(this);
@@ -71,10 +67,6 @@ public class PluginManageController extends PluginManageView {
return this.pluginDataTableView.getScene().getWindow();
}
- public void setOnPluginDownloaded(Consumer onPluginDownloaded) {
- this.pluginManageService.setOnPluginDownloaded(onPluginDownloaded);
- }
-
private void initView() {
addLocalPluginButton.setVisible(Boolean.parseBoolean(System.getProperty("localPluginEnabled", "false")));
@@ -86,13 +78,11 @@ public class PluginManageController extends PluginManageView {
(mouseEvent, index) -> pluginManageService.setIsEnableTableColumn(index)
);
- // TODO 实现插件的启用禁用
-
downloadTableColumn.setCellFactory(
- new Callback, String>, TableCell