From 8d662de2fd262b3a485f16e197cb4d0ca2a61cdf Mon Sep 17 00:00:00 2001
From: zsh_root <979909237@qq.com>
Date: 星期三, 10 十二月 2025 17:03:47 +0800
Subject: [PATCH] 发布版V1.0

---
 src/home/ExtensionPanel.java |   78 +++++++++++++++++++-------------------
 1 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/src/home/ExtensionPanel.java b/src/home/ExtensionPanel.java
index c4ad45d..4ac5f71 100644
--- a/src/home/ExtensionPanel.java
+++ b/src/home/ExtensionPanel.java
@@ -17,19 +17,19 @@
     private File commandFile;
     
     public ExtensionPanel(MainFrame parent) {
-        super(parent, getString(parent, "extension"), false); // 设置为非模态对话框
+        super(parent, getString(parent, "extension"), false); // 璁剧疆涓洪潪妯℃�佸璇濇
         this.mainFrame = parent;
         initializeUI();
         loadCommands();
     }
     
     private void initializeUI() {
-        setSize(800, 500); // 修改默认打开窗口为800*500
+        setSize(800, 500); // 淇敼榛樿鎵撳紑绐楀彛涓�800*500
         setLocationRelativeTo(mainFrame);
         setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
         setLayout(new BorderLayout());
         
-        // 创建命令面板
+        // 鍒涘缓鍛戒护闈㈡澘
         commandPanel = new JPanel();
         commandPanel.setLayout(new BoxLayout(commandPanel, BoxLayout.Y_AXIS));
         
@@ -41,10 +41,10 @@
             TitledBorder.TOP
         ));
         
-        // 创建按钮面板
+        // 鍒涘缓鎸夐挳闈㈡澘
         JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
         
-        // 使用ButtonUtils创建样式按钮
+        // 浣跨敤ButtonUtils鍒涘缓鏍峰紡鎸夐挳
         saveButton = ButtonUtils.createBlueButton(getString(mainFrame, "save.common.commands"), 25);
         saveButton.setPreferredSize(new Dimension(120, 25));
         
@@ -60,7 +60,7 @@
         add(scrollPane, BorderLayout.CENTER);
         add(buttonPanel, BorderLayout.SOUTH);
         
-        // 初始化指令文件
+        // 鍒濆鍖栨寚浠ゆ枃浠�
         String rootPath = System.getProperty("user.dir");
         File systemFileDir = new File(rootPath + File.separator + "systemfile");
         if (!systemFileDir.exists()) {
@@ -70,14 +70,14 @@
     }
     
     private void loadCommands() {
-        commandPanel.removeAll(); // 清空面板
+        commandPanel.removeAll(); // 娓呯┖闈㈡澘
         
         if (commandFile.exists()) {
             try (BufferedReader reader = new BufferedReader(new FileReader(commandFile))) {
                 String line;
                 while ((line = reader.readLine()) != null) {
                     if (!line.trim().isEmpty()) {
-                        // 每行格式:是否HEX:指令内容
+                        // 姣忚鏍煎紡锛氭槸鍚EX:鎸囦护鍐呭
                         String[] parts = line.split(":", 2);
                         boolean isHex = false;
                         String command = "";
@@ -100,7 +100,7 @@
             }
         }
         
-        // 添加一个空行用于新增命令
+        // 娣诲姞涓�涓┖琛岀敤浜庢柊澧炲懡浠�
         addCommandRow(false, "");
         
         commandPanel.revalidate();
@@ -110,18 +110,18 @@
     private void addCommandRow(boolean isHex, String command) {
         JPanel rowPanel = new JPanel();
         rowPanel.setLayout(new BoxLayout(rowPanel, BoxLayout.X_AXIS));
-        rowPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // 设置行间距
+        rowPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // 璁剧疆琛岄棿璺�
         
-        // HEX复选框
+        // HEX澶嶉�夋
         JCheckBox hexCheckBox = new JCheckBox(getString(mainFrame, "hex.send"));
         hexCheckBox.setSelected(isHex);
         hexCheckBox.setAlignmentY(Component.CENTER_ALIGNMENT);
         
-        // 命令文本框
+        // 鍛戒护鏂囨湰妗�
         JTextField commandField = new JTextField(command);
-        commandField.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30)); // 限制高度,宽度自适应
+        commandField.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30)); // 闄愬埗楂樺害锛屽搴﹁嚜閫傚簲
         
-        // 发送按钮
+        // 鍙戦�佹寜閽�
         JButton sendButton = createSendButton();
         sendButton.addActionListener(new ActionListener() {
             @Override
@@ -130,11 +130,11 @@
             }
         });
         
-        // 添加组件到行面板
+        // 娣诲姞缁勪欢鍒拌闈㈡澘
         rowPanel.add(hexCheckBox);
-        rowPanel.add(Box.createHorizontalStrut(5)); // HEX复选框与文本框间隔5像素
+        rowPanel.add(Box.createHorizontalStrut(5)); // HEX澶嶉�夋涓庢枃鏈闂撮殧5鍍忕礌
         rowPanel.add(commandField);
-        rowPanel.add(Box.createHorizontalStrut(10)); // 文本框与按钮间隔10像素
+        rowPanel.add(Box.createHorizontalStrut(10)); // 鏂囨湰妗嗕笌鎸夐挳闂撮殧10鍍忕礌
         rowPanel.add(sendButton);
         
         commandPanel.add(rowPanel);
@@ -143,38 +143,38 @@
     private JButton createSendButton() {
         JButton button = new JButton(getString(mainFrame, "send"));
         
-        // 设置按钮大小为60×20(宽×高)
+        // 璁剧疆鎸夐挳澶у皬涓�60脳20锛堝脳楂橈級
         button.setPreferredSize(new Dimension(80, 20));
         button.setMinimumSize(new Dimension(80, 20));
         button.setMaximumSize(new Dimension(80, 20));
         
-        // 设置按钮样式
+        // 璁剧疆鎸夐挳鏍峰紡
         button.setBackground(new Color(0, 120, 215));
         button.setForeground(Color.WHITE);
         button.setFocusPainted(false);
         button.setBorderPainted(false);
         button.setFont(button.getFont().deriveFont(Font.BOLD, 12f));
         
-        // 添加鼠标交互效果
+        // 娣诲姞榧犳爣浜や簰鏁堟灉
         button.addMouseListener(new java.awt.event.MouseAdapter() {
             public void mouseEntered(java.awt.event.MouseEvent evt) {
-                button.setBackground(new Color(0, 150, 255)); // 悬停时变亮
+                button.setBackground(new Color(0, 150, 255)); // 鎮仠鏃跺彉浜�
                 button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
             }
             
             public void mouseExited(java.awt.event.MouseEvent evt) {
-                button.setBackground(new Color(0, 120, 215)); // 恢复正常颜色
+                button.setBackground(new Color(0, 120, 215)); // 鎭㈠姝e父棰滆壊
                 button.setCursor(Cursor.getDefaultCursor());
             }
             
             public void mousePressed(java.awt.event.MouseEvent evt) {
-                // 点击效果 - 颜色变深并有轻微缩小效果
+                // 鐐瑰嚮鏁堟灉 - 棰滆壊鍙樻繁骞舵湁杞诲井缂╁皬鏁堟灉
                 button.setBackground(new Color(0, 80, 160));
                 button.setBounds(button.getX() + 1, button.getY() + 1, 58, 18);
             }
             
             public void mouseReleased(java.awt.event.MouseEvent evt) {
-                // 恢复原状
+                // 鎭㈠鍘熺姸
                 button.setBackground(new Color(0, 150, 255));
                 button.setBounds(button.getX() - 1, button.getY() - 1, 60, 20);
             }
@@ -229,16 +229,16 @@
             return;
         }
         
-        // 获取当前时间
+        // 鑾峰彇褰撳墠鏃堕棿
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String currentTime = dateFormat.format(new Date());
         
-        // 构建日志信息
+        // 鏋勫缓鏃ュ織淇℃伅
         StringBuilder logMessage = new StringBuilder();
         logMessage.append("[").append(currentTime).append("] ");
         logMessage.append(getString(mainFrame, "send")).append(": ");
         
-        // 根据HEX发送选项格式化内容
+        // 鏍规嵁HEX鍙戦�侀�夐」鏍煎紡鍖栧唴瀹�
         if (isHex) {
             logMessage.append("HEX ");
             logMessage.append(command);
@@ -250,28 +250,28 @@
         logMessage.append(" [").append(getString(mainFrame, "extension.command")).append("]");
         logMessage.append("\n");
         
-        // 将发送信息添加到数据日志面板
+        // 灏嗗彂閫佷俊鎭坊鍔犲埌鏁版嵁鏃ュ織闈㈡澘
         addLogToDataLogPanel(logMessage.toString());
         
-        // 调用主框架的发送方法
+        // 璋冪敤涓绘鏋剁殑鍙戦�佹柟娉�
         if (mainFrame != null) {
             mainFrame.sendDataFromExtension(command, isHex);
         }
     }
     
     /**
-     * 将日志信息添加到数据日志面板
-     * @param logMessage 日志信息
+     * 灏嗘棩蹇椾俊鎭坊鍔犲埌鏁版嵁鏃ュ織闈㈡澘
+     * @param logMessage 鏃ュ織淇℃伅
      */
     private void addLogToDataLogPanel(String logMessage) {
         try {
-            // 通过主框架获取DataLogPanel实例
+            // 閫氳繃涓绘鏋惰幏鍙朌ataLogPanel瀹炰緥
             if (mainFrame != null) {
-                // 直接调用MainFrame的日志添加方法,避免使用反射
+                // 鐩存帴璋冪敤MainFrame鐨勬棩蹇楁坊鍔犳柟娉曪紝閬垮厤浣跨敤鍙嶅皠
                 mainFrame.addToDataLog(logMessage);
             }
         } catch (Exception ex) {
-            // 备用方案:尝试使用反射
+            // 澶囩敤鏂规锛氬皾璇曚娇鐢ㄥ弽灏�
             try {
                 DataLogPanel dataLogPanel = mainFrame.getDataLogPanel();
                 if (dataLogPanel != null) {
@@ -281,16 +281,16 @@
                     
                     if (logArea != null) {
                         logArea.append(logMessage);
-                        // 自动滚动到最后
+                        // 鑷姩婊氬姩鍒版渶鍚�
                         logArea.setCaretPosition(logArea.getDocument().getLength());
                     }
                 }
             } catch (Exception e) {
-                System.err.println("无法访问数据日志区域: " + e.getMessage());
-                // 显示错误信息
+                System.err.println("鏃犳硶璁块棶鏁版嵁鏃ュ織鍖哄煙: " + e.getMessage());
+                // 鏄剧ず閿欒淇℃伅
                 JOptionPane.showMessageDialog(this,
-                    "无法在数据日志中显示内容: " + e.getMessage(),
-                    "错误",
+                    getString(mainFrame, "cannot.display.in.data.log") + ": " + e.getMessage(),
+                    getString(mainFrame, "error"),
                     JOptionPane.ERROR_MESSAGE);
             }
         }

--
Gitblit v1.10.0