From e982e0562f5440f0d977f9dd8e606a31a9b5bc80 Mon Sep 17 00:00:00 2001 From: unknowIfGuestInDream Date: Sun, 4 May 2025 21:31:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(core):=20=E6=94=AF=E6=8C=81JDK=20Tool?= =?UTF-8?q?=20ActionGroup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #2078 Signed-off-by: unknowIfGuestInDream --- .../core/javafx/controlsfx/FxActionGroup.java | 8 + .../controlsfx/FxJDKToolActionGroup.java | 137 ++++++++++++++++++ .../tlcsdm/core/i18n/messages_en.properties | 1 + .../tlcsdm/core/i18n/messages_ja.properties | 1 + .../tlcsdm/core/i18n/messages_zh.properties | 1 + .../com/tlcsdm/core/static/icon/jmc.png | Bin 0 -> 1065 bytes .../com/tlcsdm/core/static/icon/jmc@2x.png | Bin 0 -> 3291 bytes .../com/tlcsdm/core/static/icon/jvisualvm.png | Bin 0 -> 526 bytes .../tlcsdm/core/static/icon/jvisualvm@2x.png | Bin 0 -> 1513 bytes .../QeMenubarConfigrationProvider.java | 5 +- .../SmcMenubarConfigrationProvider.java | 5 +- 11 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java create mode 100644 core/src/main/resources/com/tlcsdm/core/static/icon/jmc.png create mode 100644 core/src/main/resources/com/tlcsdm/core/static/icon/jmc@2x.png create mode 100644 core/src/main/resources/com/tlcsdm/core/static/icon/jvisualvm.png create mode 100644 core/src/main/resources/com/tlcsdm/core/static/icon/jvisualvm@2x.png diff --git a/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java index f9ba25279..c7866bc98 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java @@ -86,6 +86,14 @@ public static ActionGroup view(Action... actions) { return create(I18nUtils.get("core.menubar.view"), "/com/tlcsdm/core/static/menubar/view.png", actions); } + /** + * menubar jdkTool + */ + public static ActionGroup jdkTool(Action... actions) { + return create(I18nUtils.get("core.menubar.setting.jdkTool"), "/com/tlcsdm/core/static/icon/java.png", + actions); + } + /** * menubar language */ diff --git a/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java new file mode 100644 index 000000000..735939eb4 --- /dev/null +++ b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2023 unknowIfGuestInDream. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of unknowIfGuestInDream, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL UNKNOWIFGUESTINDREAM BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.tlcsdm.core.javafx.controlsfx; + +import cn.hutool.log.StaticLog; +import com.tlcsdm.core.javafx.dialog.ExceptionDialog; +import com.tlcsdm.core.javafx.helper.LayoutHelper; +import com.tlcsdm.core.javafx.util.OSUtil; +import org.controlsfx.control.action.Action; +import org.controlsfx.control.action.ActionGroup; + +import java.io.File; +import java.io.IOException; + +/** + * JDK Tool ActionGroup. + * + * @author unknowIfGuestInDream + */ +public class FxJDKToolActionGroup { + Action jmc; + Action jconsole; + Action jvisualvm; + private static final String javaHome = System.getProperty("java.home"); + private static final String javaHomeEnv = System.getenv("JAVA_HOME"); + private final String jmcRelativePath; + private final String jconsoleRelativePath; + private final String jvisualvmRelativePath; + + public FxJDKToolActionGroup() { + boolean isWin = OSUtil.getOS().equals(OSUtil.OS.WINDOWS); + jmcRelativePath = "bin" + File.separator + (isWin ? "jmc.exe" : "jmc"); + jconsoleRelativePath = "bin" + File.separator + (isWin ? "jconsole.exe" : "jconsole"); + jvisualvmRelativePath = "bin" + File.separator + (isWin ? "jvisualvm.exe" : "jvisualvm"); + + jmc = new Action("jmc", e -> { + File file = new File(javaHome, jmcRelativePath); + if (file.exists()) { + runProgram(file.getAbsolutePath()); + } else { + file = new File(javaHomeEnv, jmcRelativePath); + if (!file.exists()) { + StaticLog.warn("Not found jmc."); + return; + } + runProgram(file.getAbsolutePath()); + } + }); + jmc.setGraphic( + LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jmc.png"))); + jconsole = new Action("jConsole", e -> { + File file = new File(javaHome, jconsoleRelativePath); + if (file.exists()) { + runProgram(file.getAbsolutePath()); + } else { + file = new File(javaHomeEnv, jconsoleRelativePath); + if (!file.exists()) { + StaticLog.warn("Not found jconsole."); + return; + } + runProgram(file.getAbsolutePath()); + } + }); + jconsole.setGraphic( + LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/java.png"))); + jvisualvm = new Action("jvisualvm", e -> { + File file = new File(javaHome, jvisualvmRelativePath); + if (file.exists()) { + runProgram(file.getAbsolutePath()); + } else { + file = new File(javaHomeEnv, jvisualvmRelativePath); + if (!file.exists()) { + StaticLog.warn("Not found jvisualvm."); + return; + } + runProgram(file.getAbsolutePath()); + } + }); + jvisualvm.setGraphic( + LayoutHelper.iconView( + FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jvisualvm.png"))); + + File file1 = new File(javaHome, jmcRelativePath); + File file2 = new File(javaHomeEnv, jmcRelativePath); + if (!file1.exists() && !file2.exists()) { + jmc.setDisabled(true); + } + file1 = new File(javaHome, jconsoleRelativePath); + file2 = new File(javaHomeEnv, jconsoleRelativePath); + if (!file1.exists() && !file2.exists()) { + jconsole.setDisabled(true); + } + file1 = new File(javaHome, jvisualvmRelativePath); + file2 = new File(javaHomeEnv, jvisualvmRelativePath); + if (!file1.exists() && !file2.exists()) { + jvisualvm.setDisabled(true); + } + } + + private void runProgram(String filePath) { + ProcessBuilder processBuilder = new ProcessBuilder(filePath); + try { + processBuilder.start(); + } catch (IOException ex) { + new ExceptionDialog(ex).show(); + } + } + + public ActionGroup create() { + return FxActionGroup.jdkTool(jmc, jconsole, jvisualvm); + } +} diff --git a/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties b/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties index a49cd7393..0de2881c4 100644 --- a/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties +++ b/core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties @@ -65,6 +65,7 @@ core.menubar.file.restart=Restart core.menubar.file.exit=Exit core.menubar.setting=Setting core.menubar.setting.language=Language +core.menubar.setting.jdkTool=JDK Tool core.menubar.setting.systemSetting=System Setting core.menubar.setting.systemProperties=System Properties core.menubar.setting.colorPicker=Color Extractor diff --git a/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties b/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties index b55f8b46b..63f2a1ccd 100644 --- a/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties +++ b/core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties @@ -65,6 +65,7 @@ core.menubar.file.restart=\u518D\u8D77\u52D5 core.menubar.file.exit=\u7D42\u4E86\u3059\u308B core.menubar.setting=\u8A2D\u5B9A core.menubar.setting.language=\u8A00\u8A9E +core.menubar.setting.jdkTool=JDK\u30C4\u30FC\u30EB core.menubar.setting.systemSetting=\u30B7\u30B9\u30C6\u30E0\u8A2D\u5B9A core.menubar.setting.systemProperties=\u30B7\u30B9\u30C6\u30E0\u30D7\u30ED\u30D1\u30C6\u30A3 core.menubar.setting.colorPicker=\u30AB\u30E9\u30FC\u30A8\u30AF\u30B9\u30C8\u30E9\u30AF\u30BF diff --git a/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties b/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties index 45cddb2eb..de55eec2b 100644 --- a/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties +++ b/core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties @@ -65,6 +65,7 @@ core.menubar.file.restart=\u91CD\u542F core.menubar.file.exit=\u9000\u51FA core.menubar.setting=\u8BBE\u7F6E core.menubar.setting.language=\u8BED\u8A00 +core.menubar.setting.jdkTool=JDK \u5DE5\u5177 core.menubar.setting.systemSetting=\u7CFB\u7EDF\u8BBE\u7F6E core.menubar.setting.systemProperties=\u7CFB\u7EDF\u5C5E\u6027 core.menubar.setting.colorPicker=\u989C\u8272\u63D0\u53D6\u5668 diff --git a/core/src/main/resources/com/tlcsdm/core/static/icon/jmc.png b/core/src/main/resources/com/tlcsdm/core/static/icon/jmc.png new file mode 100644 index 0000000000000000000000000000000000000000..9dadad1696e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($aUr|$EeUjRW jk2rZQbM~b}l^^~G%g~Ptk;|8i00000NkvXXu0mjf@;U0R literal 0 HcmV?d00001 diff --git a/core/src/main/resources/com/tlcsdm/core/static/icon/jmc@2x.png b/core/src/main/resources/com/tlcsdm/core/static/icon/jmc@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..92445b495bdf005c1a35e869d1770c8fea6fc1ff GIT binary patch literal 3291 zcmV<13?%c3P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qQF!XYv000b1NklzBXhFO^0l4km=s^9n*LJM~d8=hW?W9@Ud@M8}vzI${s%7$u6{ zuVwf?EfIMdf_7;L$S%Wodl{~or7S+Fr@9VmUZ}dZ9z#_vWqKnw@0IZWmI9i)y?0lM z+H0XG?u+&}3i%hoo1U@Zdm{@j7)dy7An;f@E(i4t+^fSjUx$sTf1X@L14O3#@Wsb? zXTcr(g>9cWG(6O~ad8HM}8u^W*1gEovj5cl+=<>0$9aaP5W0#flQUZWP(s zP_R0S`hU>>FL=@Q8x)@TicMLE=oGS|L{a>95}RGZBB?xB;_jTSrA4NOW*Hiq%eA@b zDl&cc=7z_N9-Gd!!8T}o-$vusi!#UVln&^ME-?nRs`6#&{~tUjZ$CNvkI*xGg{m|T z%q8`RmXxn57$`BCsx|@N_(Y&`Z!*$svj(SWhxjbOm$J}-XomDh<6%wNpq`Z4TB41M zLNyp(f!Ea3yb}90Q{|_>A}4Pjd-okAaeN9L{THc9)8ITN9o7*hO=pqyy!tkBZM$2` z>jLhy_zJ6rCGvQf6WRy|w1ETAc=bW!Y(=R=uZ;~yE!V$L?Z^Y4d>sdKug&2gM2w^D7r}j=;8;Xi*`mEW+&12dmg=04>VB$ zsAZ)u;iY%)a>~bzQlEj8e0T1D!S}K=Yc~mr$v8W^(#9tlWzuEY7h6@O+t>rF`mz*1 zIfj6(SIA9Ep=4?p9W&R(`{&-xo4I2C2h6O_cW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*j`BEeDr>nJmFdkfE*AJy zF|tYw?07@qV^GiAQL((GRBj`1+3~TCvTQ_S#f(X_LUPI#~$Zodz| zjfd-D6rYI0CwZl+c=ikAVQ>rT)|yc(Do<`g#pI?k_peix-inGTVq{r!slFxkCj#Mz zS*V3JVzP}?FO4>GfEch91ER45A#Nassh(VzD=FMbhd-CVAG6@siSSc2T=ho%)}Gt{ zioi84T~&Jcrd3>8Z!P0zM#Y3i4XS#-2{r56P?2UPPs!J*{-_!ChorKvN5lC<)RVUI zz%qy7y~KbtUyL-~3)M_^;7W8aZhbZaevu=%nFu!oe9a#&I||&2+S3-C&mBw0z$Jev zibwkH8L3|Ukz$5^lE4=>rY^$_!;~f%XEu=(no_%~8|rZn)Gy?Z6oygvnG^be4q`yY zE?V~e2-yXq>L^QYC0SE2xi@N&7$^#dAN^1-4?_K}FY4D8)D^zT!^7Q4nUN}w(@Wj6}_e58QS&Px#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUzj7da6R5(wCl1ncGQ5c4gpI~EW;Scl=u*V-@EfE_eO>AmG*tjf2 z5fRb|LZcOzsI(QDYKe$Tl~g3+l7=vPnRa?++8J8BGpELAn)J<+$@$)SzMNT1)%J1Z zIhLxesV0?D)TTCr-&(%1g5tFnUT)Y}Hjv3iFkH|gd&a4`E^F&xW7$9^YX_H~`8-gf z*WzG<9QLrWERe~n??O>N7`c#JzCBWeB%U(&ghpEK!L`yqB~J zJV3^RFOlSp2s3TCs-$EiWYRV66iX605D)F8r8Yw*_`N%=Ym*y+ia>+>1J&?S;pOM) Q#sB~S07*qoM6N<$f{~%#2><{9 literal 0 HcmV?d00001 diff --git a/core/src/main/resources/com/tlcsdm/core/static/icon/jvisualvm@2x.png b/core/src/main/resources/com/tlcsdm/core/static/icon/jvisualvm@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..8ec7221e3f760a7d126c21ff5d383b6db4a66411 GIT binary patch literal 1513 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rationProvider.java b/qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java index 8dd1d62bf..a2646b5e6 100644 --- a/qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java +++ b/qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java @@ -33,6 +33,7 @@ import com.tlcsdm.core.javafx.control.DependencyTableView; import com.tlcsdm.core.javafx.controlsfx.FxAction; import com.tlcsdm.core.javafx.controlsfx.FxActionGroup; +import com.tlcsdm.core.javafx.controlsfx.FxJDKToolActionGroup; import com.tlcsdm.core.javafx.controlsfx.FxLanguageActionGroup; import com.tlcsdm.core.javafx.dialog.FxAlerts; import com.tlcsdm.core.javafx.dialog.FxButtonType; @@ -181,6 +182,8 @@ public class QeMenubarConfigrationProvider implements MenubarConfigration { private final Action release = FxAction.release(actionEvent -> CoreUtil.openWeb(QeConstant.PROJECT_RELEASE_URL)); + private final ActionGroup jdkToolGroup = new FxJDKToolActionGroup().create(); + private final ActionGroup languageGroup = new FxLanguageActionGroup((s) -> { if (FxAlerts.confirmOkCancel(I18nUtils.get("qe.menubar.setting.language.dialog.title"), I18nUtils.get("qe.menubar.setting.language.dialog.message"))) { @@ -191,7 +194,7 @@ public class QeMenubarConfigrationProvider implements MenubarConfigration { private final Collection actions = List.of( FxActionGroup.file(export, induct, ACTION_SEPARATOR, restart, exit), FxActionGroup.setting(systemSetting, languageGroup), - FxActionGroup.tool(logConsole, pathWatch, colorPicker, screenshot), + FxActionGroup.tool(jdkToolGroup, ACTION_SEPARATOR, logConsole, pathWatch, colorPicker, screenshot), FxActionGroup.help(openSysConfig, openLogDir, openUserData, openPropertiesDialog, ACTION_SEPARATOR, contactSupport, submitFeedback, ACTION_SEPARATOR, api, css, fxml, ACTION_SEPARATOR, helpContent, release, about)); diff --git a/smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java b/smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java index 0f50bc9bd..0da7e3067 100644 --- a/smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java +++ b/smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java @@ -31,6 +31,7 @@ import com.tlcsdm.core.javafx.control.DependencyTableView; import com.tlcsdm.core.javafx.controlsfx.FxAction; import com.tlcsdm.core.javafx.controlsfx.FxActionGroup; +import com.tlcsdm.core.javafx.controlsfx.FxJDKToolActionGroup; import com.tlcsdm.core.javafx.controlsfx.FxLanguageActionGroup; import com.tlcsdm.core.javafx.dialog.FxAlerts; import com.tlcsdm.core.javafx.dialog.FxButtonType; @@ -178,6 +179,8 @@ public class SmcMenubarConfigrationProvider implements MenubarConfigration { private final Action release = FxAction.release(actionEvent -> CoreUtil.openWeb(SmcConstant.PROJECT_RELEASE_URL)); + private final ActionGroup jdkToolGroup = new FxJDKToolActionGroup().create(); + private final ActionGroup languageGroup = new FxLanguageActionGroup((s) -> { if (FxAlerts.confirmOkCancel(I18nUtils.get("smc.menubar.setting.language.dialog.title"), I18nUtils.get("smc.menubar.setting.language.dialog.message"))) { @@ -190,7 +193,7 @@ public class SmcMenubarConfigrationProvider implements MenubarConfigration { private final Collection actions = List.of( FxActionGroup.file(export, induct, ACTION_SEPARATOR, restart, exit), FxActionGroup.setting(preferences, languageGroup), FxActionGroup.view(fullscreen), - FxActionGroup.tool(logConsole, pathWatch, colorPicker, screenshot), + FxActionGroup.tool(jdkToolGroup, ACTION_SEPARATOR, logConsole, pathWatch, colorPicker, screenshot), FxActionGroup.help(openSysConfig, openLogDir, openUserData, openPropertiesDialog, ACTION_SEPARATOR, contactSupport, submitFeedback, ACTION_SEPARATOR, api, css, fxml, ACTION_SEPARATOR, helpContent, release, about)); From ba77031d0c3df40dde629ceba54ddeabfc64ea12 Mon Sep 17 00:00:00 2001 From: unknowIfGuestInDream Date: Sun, 4 May 2025 21:56:24 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(core):=20=E6=94=AF=E6=8C=81JDK=20Tool?= =?UTF-8?q?=20ActionGroup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #2078 Signed-off-by: unknowIfGuestInDream --- .../controlsfx/FxJDKToolActionGroup.java | 33 ++++++++++++++++-- .../com/tlcsdm/core/static/icon/jshell.png | Bin 0 -> 199 bytes .../com/tlcsdm/core/static/icon/jshell@2x.png | Bin 0 -> 280 bytes 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 core/src/main/resources/com/tlcsdm/core/static/icon/jshell.png create mode 100644 core/src/main/resources/com/tlcsdm/core/static/icon/jshell@2x.png diff --git a/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java index 735939eb4..e9a6e3a9b 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java @@ -46,17 +46,20 @@ public class FxJDKToolActionGroup { Action jmc; Action jconsole; Action jvisualvm; + Action jshell; private static final String javaHome = System.getProperty("java.home"); private static final String javaHomeEnv = System.getenv("JAVA_HOME"); private final String jmcRelativePath; private final String jconsoleRelativePath; private final String jvisualvmRelativePath; + private final String jshellRelativePath; public FxJDKToolActionGroup() { boolean isWin = OSUtil.getOS().equals(OSUtil.OS.WINDOWS); jmcRelativePath = "bin" + File.separator + (isWin ? "jmc.exe" : "jmc"); jconsoleRelativePath = "bin" + File.separator + (isWin ? "jconsole.exe" : "jconsole"); jvisualvmRelativePath = "bin" + File.separator + (isWin ? "jvisualvm.exe" : "jvisualvm"); + jshellRelativePath = "bin" + File.separator + (isWin ? "jshell.exe" : "jshell"); jmc = new Action("jmc", e -> { File file = new File(javaHome, jmcRelativePath); @@ -73,6 +76,7 @@ public FxJDKToolActionGroup() { }); jmc.setGraphic( LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jmc.png"))); + jconsole = new Action("jConsole", e -> { File file = new File(javaHome, jconsoleRelativePath); if (file.exists()) { @@ -88,6 +92,7 @@ public FxJDKToolActionGroup() { }); jconsole.setGraphic( LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/java.png"))); + jvisualvm = new Action("jvisualvm", e -> { File file = new File(javaHome, jvisualvmRelativePath); if (file.exists()) { @@ -105,6 +110,23 @@ public FxJDKToolActionGroup() { LayoutHelper.iconView( FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jvisualvm.png"))); + jshell = new Action("jshell", e -> { + File file = new File(javaHome, jshellRelativePath); + if (file.exists()) { + runProgram(file.getAbsolutePath()); + } else { + file = new File(javaHomeEnv, jshellRelativePath); + if (!file.exists()) { + StaticLog.warn("Not found jshell."); + return; + } + runProgram(file.getAbsolutePath()); + } + }); + jshell.setGraphic( + LayoutHelper.iconView( + FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jshell.png"))); + File file1 = new File(javaHome, jmcRelativePath); File file2 = new File(javaHomeEnv, jmcRelativePath); if (!file1.exists() && !file2.exists()) { @@ -120,18 +142,23 @@ public FxJDKToolActionGroup() { if (!file1.exists() && !file2.exists()) { jvisualvm.setDisabled(true); } + file1 = new File(javaHome, jshellRelativePath); + file2 = new File(javaHomeEnv, jshellRelativePath); + if (!file1.exists() && !file2.exists()) { + jshell.setDisabled(true); + } } private void runProgram(String filePath) { - ProcessBuilder processBuilder = new ProcessBuilder(filePath); + ProcessBuilder builder = new ProcessBuilder("cmd", "/c", "start", filePath); try { - processBuilder.start(); + builder.start(); } catch (IOException ex) { new ExceptionDialog(ex).show(); } } public ActionGroup create() { - return FxActionGroup.jdkTool(jmc, jconsole, jvisualvm); + return FxActionGroup.jdkTool(jmc, jconsole, jvisualvm, jshell); } } diff --git a/core/src/main/resources/com/tlcsdm/core/static/icon/jshell.png b/core/src/main/resources/com/tlcsdm/core/static/icon/jshell.png new file mode 100644 index 0000000000000000000000000000000000000000..c9a1b7ee8c9b586081ab87179d38bf0aa2a9d7d0 GIT binary patch literal 199 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|8a-VcLoEE) zPQJ@~K!KxW=gC#l4_t0_7BugY?5$m8@7a7UyjY%HX2IEZUt7hN0>O#VEK|8IxPDa5 zW?1!#(WQH_+=QZY%a^WQ$Qo+uxXgHiLt2B9(!80<4PQ(j$R!B*Z+CDxzI#)LNn&yu w`+~Ien8(xa-u%DcF{&WoTYu)lEajbyxx3w7PO7!`1UiPn)78&qol`;+0E_)fJ^%m! literal 0 HcmV?d00001 diff --git a/core/src/main/resources/com/tlcsdm/core/static/icon/jshell@2x.png b/core/src/main/resources/com/tlcsdm/core/static/icon/jshell@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..51208856612aeec6b6b470c5a7074157233a0033 GIT binary patch literal 280 zcmV+z0q6dSP)Px#(n&-?R9Hvtm)#A*Fbsrqo3$Gx69E%B8<5S6j9OHorZI?Xcu1bD-sgW8q4Ps$ z{V)I!W1Ik7LI~5@=}^@fDW!W4@x|F<0D89PTfP4Vc;*PO6wzKa0w$hwE~d;((_sok zeXWhVAsym1)lGJZ8HFRN1&`{IrZ$S6i89k e+xRmY5qJOrwuH@t>$hG20000 Date: Sun, 4 May 2025 22:02:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat(core):=20=E6=94=AF=E6=8C=81JDK=20Tool?= =?UTF-8?q?=20ActionGroup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #2078 Signed-off-by: unknowIfGuestInDream --- .../controlsfx/FxJDKToolActionGroup.java | 105 +++++------------- 1 file changed, 28 insertions(+), 77 deletions(-) diff --git a/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java index e9a6e3a9b..01bd48ade 100644 --- a/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java +++ b/core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java @@ -61,92 +61,43 @@ public FxJDKToolActionGroup() { jvisualvmRelativePath = "bin" + File.separator + (isWin ? "jvisualvm.exe" : "jvisualvm"); jshellRelativePath = "bin" + File.separator + (isWin ? "jshell.exe" : "jshell"); - jmc = new Action("jmc", e -> { - File file = new File(javaHome, jmcRelativePath); - if (file.exists()) { - runProgram(file.getAbsolutePath()); - } else { - file = new File(javaHomeEnv, jmcRelativePath); - if (!file.exists()) { - StaticLog.warn("Not found jmc."); - return; - } - runProgram(file.getAbsolutePath()); - } - }); - jmc.setGraphic( - LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jmc.png"))); + jmc = createToolAction("jmc", jmcRelativePath, "/com/tlcsdm/core/static/icon/jmc.png"); + jconsole = createToolAction("jConsole", jconsoleRelativePath, "/com/tlcsdm/core/static/icon/java.png"); + jvisualvm = createToolAction("jvisualvm", jvisualvmRelativePath, "/com/tlcsdm/core/static/icon/jvisualvm.png"); + jshell = createToolAction("jshell", jshellRelativePath, "/com/tlcsdm/core/static/icon/jshell.png"); + } - jconsole = new Action("jConsole", e -> { - File file = new File(javaHome, jconsoleRelativePath); - if (file.exists()) { - runProgram(file.getAbsolutePath()); - } else { - file = new File(javaHomeEnv, jconsoleRelativePath); - if (!file.exists()) { - StaticLog.warn("Not found jconsole."); - return; - } + private Action createToolAction(String name, String relativePath, String iconPath) { + Action action = new Action(name, e -> { + File file = findToolExecutable(name, relativePath); + if (file != null) { runProgram(file.getAbsolutePath()); } }); - jconsole.setGraphic( - LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/java.png"))); + action.setGraphic(LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource(iconPath))); - jvisualvm = new Action("jvisualvm", e -> { - File file = new File(javaHome, jvisualvmRelativePath); - if (file.exists()) { - runProgram(file.getAbsolutePath()); - } else { - file = new File(javaHomeEnv, jvisualvmRelativePath); - if (!file.exists()) { - StaticLog.warn("Not found jvisualvm."); - return; - } - runProgram(file.getAbsolutePath()); - } - }); - jvisualvm.setGraphic( - LayoutHelper.iconView( - FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jvisualvm.png"))); + // 检查工具是否存在 + boolean toolExists = findToolExecutable(name, relativePath) != null; + if (!toolExists) { + action.setDisabled(true); + } - jshell = new Action("jshell", e -> { - File file = new File(javaHome, jshellRelativePath); - if (file.exists()) { - runProgram(file.getAbsolutePath()); - } else { - file = new File(javaHomeEnv, jshellRelativePath); - if (!file.exists()) { - StaticLog.warn("Not found jshell."); - return; - } - runProgram(file.getAbsolutePath()); - } - }); - jshell.setGraphic( - LayoutHelper.iconView( - FxJDKToolActionGroup.class.getResource("/com/tlcsdm/core/static/icon/jshell.png"))); + return action; + } - File file1 = new File(javaHome, jmcRelativePath); - File file2 = new File(javaHomeEnv, jmcRelativePath); - if (!file1.exists() && !file2.exists()) { - jmc.setDisabled(true); - } - file1 = new File(javaHome, jconsoleRelativePath); - file2 = new File(javaHomeEnv, jconsoleRelativePath); - if (!file1.exists() && !file2.exists()) { - jconsole.setDisabled(true); - } - file1 = new File(javaHome, jvisualvmRelativePath); - file2 = new File(javaHomeEnv, jvisualvmRelativePath); - if (!file1.exists() && !file2.exists()) { - jvisualvm.setDisabled(true); + private File findToolExecutable(String toolName, String relativePath) { + File file = new File(javaHome, relativePath); + if (file.exists()) { + return file; } - file1 = new File(javaHome, jshellRelativePath); - file2 = new File(javaHomeEnv, jshellRelativePath); - if (!file1.exists() && !file2.exists()) { - jshell.setDisabled(true); + + file = new File(javaHomeEnv, relativePath); + if (file.exists()) { + return file; } + + StaticLog.warn("Not found " + toolName + "."); + return null; } private void runProgram(String filePath) {