Skip to content

feat(core): 支持JDK Tool ActionGroup #2130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2025
Merged

feat(core): 支持JDK Tool ActionGroup #2130

merged 3 commits into from
May 4, 2025

Conversation

unknowIfGuestInDream
Copy link
Owner

@unknowIfGuestInDream unknowIfGuestInDream commented May 4, 2025

Close #2078

Fixes #

Proposed Changes

  1. ...
  2. ...
  3. ...

Readiness Checklist

Author/Contributor

  • If documentation is needed for this change, has that been included in this pull request

Reviewing Maintainer

  • Label as either enhancement, bug, documentation or dependencies
  • Verify design and implementation

Summary by Sourcery

Add JDK Tool support to the application's menubar, introducing a new action group for JDK-related tools

New Features:

  • Added JDK Tool group to menubar with JMC, JConsole, and JVisualVM tools

Enhancements:

  • Implemented dynamic detection of JDK tools based on Java home directory
  • Added internationalized labels for JDK tools

Chores:

  • Updated menubar configurations in multiple modules to include JDK Tool group

Summary by CodeRabbit

  • 新功能
    • 工具菜单新增“JDK 工具”分组,支持直接启动 JMC、JConsole、JVisualVM 和 JShell 等 JDK 工具。
  • 多语言
    • “JDK 工具”菜单项现已支持中文、英文和日文显示。

Close #2078

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>
Copy link

Thank you for following naming conventions! 😻

Copy link

vercel bot commented May 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
javafx-tool ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 4, 2025 2:02pm

Copy link

quine-bot bot commented May 4, 2025

👋 Figuring out if a PR is useful is hard, hopefully this will help.

  • @unknowIfGuestInDream has been on GitHub since 2019 and in that time has had 1239 public PRs merged
  • Don't you recognize them? They've been here before 🎉
  • Here's a good example of their work: javafxTool (Javafx scaffolding, built on JDK17 + JavaFX21 + controlsfx 11.x.x + Maven)
  • From looking at their profile, they seem to be good with Java and HTML.

Their most recently public accepted PR is: #2129

Copy link

sourcery-ai bot commented May 4, 2025

Reviewer's Guide

This pull request introduces a new "JDK Tool" action group to the menubar by creating a dedicated FxJDKToolActionGroup class to handle finding and launching jmc, jconsole, and jvisualvm executables. It integrates this group into the "Tool" menu for both qe and smc modules and adds necessary internationalization keys.

Sequence diagram for JDK Tool menu creation

sequenceDiagram
    participant Provider as MenubarConfigProvider
    participant JDKToolGroup as FxJDKToolActionGroup
    participant ActionGroupFactory as FxActionGroup

    Provider->>+JDKToolGroup: new FxJDKToolActionGroup()
    Note right of JDKToolGroup: Finds tool paths, creates Actions (jmc, jconsole, etc.)
    JDKToolGroup-->>-Provider: instance
    Provider->>+JDKToolGroup: create()
    JDKToolGroup->>+ActionGroupFactory: jdkTool(jmcAction, jconsoleAction, ...)
    ActionGroupFactory-->>-JDKToolGroup: jdkToolGroup (ActionGroup)
    JDKToolGroup-->>-Provider: jdkToolGroup
    Provider->>+ActionGroupFactory: tool(jdkToolGroup, ..., otherTools)
    ActionGroupFactory-->>-Provider: mainToolGroup (ActionGroup)
    Note left of Provider: Adds mainToolGroup to menubar actions
Loading

Class diagram for JDK Tool ActionGroup feature

classDiagram
    class FxActionGroup {
        +static ActionGroup jdkTool(Action... actions)
    }

    class FxJDKToolActionGroup {
        -Action jmc
        -Action jconsole
        -Action jvisualvm
        -String javaHome
        -String javaHomeEnv
        -String jmcRelativePath
        -String jconsoleRelativePath
        -String jvisualvmRelativePath
        +FxJDKToolActionGroup()
        -void runProgram(String filePath)
        +ActionGroup create()
    }
    note for FxJDKToolActionGroup "Handles finding and launching JDK tools (jmc, jconsole, jvisualvm). \nChecks java.home and JAVA_HOME."

    class QeMenubarConfigrationProvider {
        -ActionGroup jdkToolGroup
        -Collection~Action~ actions
        +QeMenubarConfigrationProvider()
    }
    note for QeMenubarConfigrationProvider "Integrates FxJDKToolActionGroup into the Tool menu."

    class SmcMenubarConfigrationProvider {
        -ActionGroup jdkToolGroup
        -Collection~Action~ actions
        +SmcMenubarConfigrationProvider()
    }
    note for SmcMenubarConfigrationProvider "Integrates FxJDKToolActionGroup into the Tool menu."

    class ActionGroup
    class Action
    class OSUtil
    class LayoutHelper
    class ProcessBuilder
    class ExceptionDialog
    class StaticLog

    QeMenubarConfigrationProvider --> FxJDKToolActionGroup : uses
    SmcMenubarConfigrationProvider --> FxJDKToolActionGroup : uses
    FxJDKToolActionGroup --> FxActionGroup : uses
    FxJDKToolActionGroup --> Action : creates
    FxJDKToolActionGroup --> OSUtil : uses
    FxJDKToolActionGroup --> LayoutHelper : uses
    FxJDKToolActionGroup --> ProcessBuilder : uses
    FxJDKToolActionGroup --> ExceptionDialog : uses
    FxJDKToolActionGroup --> StaticLog : uses
    FxJDKToolActionGroup ..> ActionGroup : creates via create()
Loading

File-Level Changes

Change Details Files
Added a factory method for creating a JDK tools action group.
  • Introduced the static jdkTool method to create an ActionGroup with a specific title and icon for JDK tools.
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java
Implemented the logic for finding and launching JDK tools.
  • Created FxJDKToolActionGroup class.
  • Added logic to locate jmc, jconsole, jvisualvm executables in java.home or JAVA_HOME.
  • Defined actions to launch these tools using ProcessBuilder.
  • Included icon loading and disabling actions if tools are not found.
  • Added error handling for process execution.
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java
Integrated the JDK Tool ActionGroup into application menubars.
  • Instantiated FxJDKToolActionGroup in menubar configuration providers.
  • Added the created jdkToolGroup to the 'Tool' menu section.
qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java
smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java
Added internationalization support for the new menu item.
  • Added the core.menubar.setting.jdkTool key with translations for English, Japanese, and Chinese.
core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties
core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties
core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties

Assessment against linked issues

Issue Objective Addressed Explanation
#2078 Add a menu item for jconsole.
#2078 Add a menu item for jshell. The PR does not include a menu item for jshell.
#2078 Add a menu item for jvisualvm.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

coderabbitai bot commented May 4, 2025

"""

Walkthrough

本次变更为应用的菜单栏新增了“JDK工具”功能组。通过引入新的 FxJDKToolActionGroup 类,集合了 JDK 相关的工具(如 jmc、jconsole、jvisualvm),并将该工具组集成到 QE 和 SMC 两个模块的菜单栏配置中。为多语言支持,分别在英文、日文、中文的资源文件中添加了“JDK工具”的本地化条目。同时,FxActionGroup 新增了用于构建 JDK 工具组的静态方法。

Changes

文件/文件组 变更摘要
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java 新增静态方法 jdkTool,用于创建带有本地化标签和图标的 JDK 工具 ActionGroup。
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java 新增类 FxJDKToolActionGroup,用于封装 jmc、jconsole、jvisualvm 等 JDK 工具的 ActionGroup,自动适配操作系统并查找可执行文件,支持异常弹窗。
core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties
core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties
core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties
各自新增 core.menubar.setting.jdkTool 的本地化条目。
qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java
smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java
新增 jdkToolGroup 字段,并将其作为工具菜单的首项,集成到现有菜单栏配置。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MenuBar
    participant FxJDKToolActionGroup
    participant OS
    participant JDK Tool

    User->>MenuBar: 点击“JDK工具”菜单
    MenuBar->>FxJDKToolActionGroup: 展示工具项(jmc, jconsole, jvisualvm)
    User->>MenuBar: 选择某个 JDK 工具
    MenuBar->>FxJDKToolActionGroup: 调用对应 Action
    FxJDKToolActionGroup->>OS: 检查工具路径并尝试启动进程
    OS-->>JDK Tool: 启动工具进程
    JDK Tool-->>User: 展示工具界面
Loading

Assessment against linked issues

Objective Addressed Explanation
菜单栏新增“JDK工具”功能组,包含 jconsole、jvisualvm(#2078
菜单栏“JDK工具”多语言支持(#2078
集成 jshell 工具(#2078 未包含 jshell,仅有 jmc、jconsole、jvisualvm。

Suggested labels

size/M

Poem

小兔挥爪添新功,
菜单栏里 JDK 工,
三国鼎立工具现,
一键启动不再慌。
多语切换皆周全,
代码跳跃似飞翔!
🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba77031 and 366e05b.

📒 Files selected for processing (1)
  • core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (17, macos-latest, false)
  • GitHub Check: build (21, macos-latest, false)
  • GitHub Check: build (21, windows-latest, false)
  • GitHub Check: build (17, windows-latest, false)
  • GitHub Check: build (21, ubuntu-latest, false)
  • GitHub Check: build (17, ubuntu-latest, false)
  • GitHub Check: qodana
  • GitHub Check: StepSecurity Harden-Runner
  • GitHub Check: Summary
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@mergify mergify bot added the enhancement New feature or request label May 4, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @unknowIfGuestInDream - I've reviewed your changes - here's some feedback:

  • Consider refactoring the repeated logic for finding JDK tool paths within FxJDKToolActionGroup into a reusable helper method.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (2)

45-54: 建议改进字段访问修饰符

Action字段(jmc、jconsole、jvisualvm)当前使用的是默认(包级别)访问修饰符,但这些字段只在类内部使用。

建议将这些字段声明为私有:

-    Action jmc;
-    Action jconsole;
-    Action jvisualvm;
+    private final Action jmc;
+    private final Action jconsole;
+    private final Action jvisualvm;

55-123: 构造函数复杂度较高,建议重构

当前构造函数包含初始化三个工具操作的重复逻辑,导致方法较长且复杂。静态代码分析工具已标记此方法为"复杂方法"。

建议将初始化每个工具的逻辑提取到单独的方法中,简化构造函数:

    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")));
+        jmc = createToolAction("jmc", jmcRelativePath, "/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")));
+        jconsole = createToolAction("jConsole", jconsoleRelativePath, "/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")));
+        jvisualvm = createToolAction("jvisualvm", jvisualvmRelativePath, "/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 Action createToolAction(String name, String relativePath, String iconPath) {
+        Action action = new Action(name, e -> {
+            File file = new File(javaHome, relativePath);
+            if (file.exists()) {
+                runProgram(file.getAbsolutePath());
+            } else {
+                file = new File(javaHomeEnv, relativePath);
+                if (!file.exists()) {
+                    StaticLog.warn("Not found " + name + ".");
+                    return;
+                }
+                runProgram(file.getAbsolutePath());
+            }
+        });
+        action.setGraphic(LayoutHelper.iconView(FxJDKToolActionGroup.class.getResource(iconPath)));
+        return action;
+    }

另外,验证工具可用性的重复代码也可以提取到单独的辅助方法中:

private boolean isToolAvailable(String relativePath) {
    File file1 = new File(javaHome, relativePath);
    File file2 = new File(javaHomeEnv, relativePath);
    return file1.exists() || file2.exists();
}
🧰 Tools
🪛 GitHub Check: CodeFactor

[notice] 55-124: core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java#L55-L124
Complex Method

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae0f037 and e982e05.

⛔ Files ignored due to path filters (4)
  • core/src/main/resources/com/tlcsdm/core/static/icon/jmc.png is excluded by !**/*.png
  • core/src/main/resources/com/tlcsdm/core/static/icon/jmc@2x.png is excluded by !**/*.png
  • core/src/main/resources/com/tlcsdm/core/static/icon/jvisualvm.png is excluded by !**/*.png
  • core/src/main/resources/com/tlcsdm/core/static/icon/jvisualvm@2x.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java (1 hunks)
  • core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (1 hunks)
  • core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties (1 hunks)
  • core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties (1 hunks)
  • core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties (1 hunks)
  • qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java (3 hunks)
  • smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java (2)
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (1)
  • FxJDKToolActionGroup (45-137)
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java (1)
  • FxActionGroup (43-119)
🪛 GitHub Check: CodeFactor
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java

[notice] 55-124: core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java#L55-L124
Complex Method

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (21, windows-latest, false)
  • GitHub Check: build (21, ubuntu-latest, false)
  • GitHub Check: build (21, macos-latest, false)
  • GitHub Check: build (17, macos-latest, false)
  • GitHub Check: build (17, windows-latest, false)
  • GitHub Check: build (17, ubuntu-latest, false)
  • GitHub Check: qodana
  • GitHub Check: StepSecurity Harden-Runner
  • GitHub Check: Summary
🔇 Additional comments (12)
core/src/main/resources/com/tlcsdm/core/i18n/messages_zh.properties (1)

68-68: 很好的本地化实现!

该变更正确地为新的"JDK 工具"菜单项添加了中文本地化支持,格式与现有条目保持一致。

core/src/main/resources/com/tlcsdm/core/i18n/messages_en.properties (1)

68-68: 英文本地化实现完美!

该变更为"JDK Tool"菜单项添加了英文本地化支持,且格式规范,与整体风格保持一致。

core/src/main/resources/com/tlcsdm/core/i18n/messages_ja.properties (1)

68-68: 日文本地化实现完整!

该变更为"JDKツール"菜单项添加了日文本地化支持,遵循了正确的格式规范,与其他本地化条目风格一致。

core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxActionGroup.java (1)

89-95: 新方法实现规范!

jdkTool方法实现符合类中已有的编码模式,正确地使用了I18n获取本地化文本和适当的图标资源。JavaDoc注释风格与现有代码保持一致,整体集成良好。

smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java (3)

34-34: 已正确导入JDK工具组相关类

导入FxJDKToolActionGroup类以支持新增的JDK工具功能组,导入声明位置合理。


182-183: 成功初始化JDK工具组

通过FxJDKToolActionGroup().create()创建的JDK工具组实例被正确声明为私有的final字段,遵循了类中其他ActionGroup的声明风格。


196-196: JDK工具组已正确集成到工具菜单

JDK工具组作为第一个元素添加到工具菜单中,并通过ACTION_SEPARATOR与其他工具选项分隔,保持了良好的菜单结构。

qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java (3)

36-36: 已正确导入JDK工具组相关类

导入FxJDKToolActionGroup类以支持新增的JDK工具功能组,导入声明位置合理。


185-186: 成功初始化JDK工具组

通过FxJDKToolActionGroup().create()创建的JDK工具组实例被正确声明为私有的final字段,遵循了类中其他ActionGroup的声明风格。


197-197: JDK工具组已正确集成到工具菜单

JDK工具组作为第一个元素添加到工具菜单中,并通过ACTION_SEPARATOR与其他工具选项分隔,保持了良好的菜单结构。与SmcMenubarConfigrationProvider中的实现保持一致,确保了应用不同模块间的UI一致性。

core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (2)

1-44: JDK工具组类的版权和基本声明符合项目标准

类声明、包结构、导入和JavaDoc注释都符合项目规范。


134-136: 创建方法实现正确

create方法通过FxActionGroup.jdkTool静态方法正确创建了包含所有JDK工具的ActionGroup,实现简洁明了。

Copy link
Contributor

github-actions bot commented May 4, 2025

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Close #2078

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (1)

152-159: 🛠️ Refactor suggestion

增强进程启动的跨平台支持和错误处理

当前的 runProgram 方法仅支持 Windows 系统(使用 "cmd", "/c", "start" 命令),但构造函数中已进行了操作系统判断以设置不同系统的可执行文件扩展名。

建议改进 runProgram 方法,使其支持不同操作系统并增强错误处理:

private void runProgram(String filePath) {
-   ProcessBuilder builder = new ProcessBuilder("cmd", "/c", "start", filePath);
+   ProcessBuilder builder;
+   if (OSUtil.getOS().equals(OSUtil.OS.WINDOWS)) {
+       builder = new ProcessBuilder("cmd", "/c", "start", filePath);
+   } else {
+       builder = new ProcessBuilder(filePath);
+   }
+   // 设置工作目录,确保程序在正确的上下文中运行
+   builder.directory(new File(System.getProperty("user.dir")));
    try {
        builder.start();
    } catch (IOException ex) {
-       new ExceptionDialog(ex).show();
+       StaticLog.error("启动程序失败: " + filePath, ex);
+       new ExceptionDialog(ex, "启动JDK工具失败", "无法启动工具: " + new File(filePath).getName()).show();
    }
}
🧹 Nitpick comments (2)
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (2)

45-55: 建议将 Action 字段修改为私有访问控制

当前 Action 字段(jmc, jconsole, jvisualvm, jshell)是包访问权限的。为遵循封装原则,建议将这些字段设置为私有(private)以防止外部直接访问和修改。

- Action jmc;
- Action jconsole;
- Action jvisualvm;
- Action jshell;
+ private Action jmc;
+ private Action jconsole;
+ private Action jvisualvm;
+ private Action jshell;

1-164: 建议添加单元测试确保可靠性

新增的 FxJDKToolActionGroup 类缺少单元测试。为保证功能的可靠性,建议添加测试用例,覆盖以下场景:

  1. 检测不同操作系统下工具路径的正确生成
  2. 检测工具可用性判断的正确性
  3. 模拟工具启动过程并验证结果

您需要我为这个类提供单元测试示例吗?

🧰 Tools
🪛 GitHub Check: CodeFactor

[notice] 57-151: core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java#L57-L151
Complex Method

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e982e05 and ba77031.

⛔ Files ignored due to path filters (2)
  • core/src/main/resources/com/tlcsdm/core/static/icon/jshell.png is excluded by !**/*.png
  • core/src/main/resources/com/tlcsdm/core/static/icon/jshell@2x.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java (1 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeFactor
core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java

[notice] 57-151: core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxJDKToolActionGroup.java#L57-L151
Complex Method

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: build (21, ubuntu-latest, false)
  • GitHub Check: build (17, macos-latest, false)
  • GitHub Check: build (21, macos-latest, false)
  • GitHub Check: build (21, windows-latest, false)
  • GitHub Check: build (17, windows-latest, false)
  • GitHub Check: build (17, ubuntu-latest, false)
  • GitHub Check: qodana
  • GitHub Check: Summary

Close #2078

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>
Copy link

sonarqubecloud bot commented May 4, 2025

@unknowIfGuestInDream unknowIfGuestInDream merged commit de11091 into master May 4, 2025
33 checks passed
@unknowIfGuestInDream unknowIfGuestInDream deleted the jdk branch May 4, 2025 14:22
@quine-bot quine-bot bot mentioned this pull request May 5, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] 菜单-> JDK工具
1 participant