| | |
| | | import javax.swing.*; |
| | | import javax.swing.border.EmptyBorder; |
| | | |
| | | import chuankou.SystemDebugDialog; |
| | | import chushihua.Chushihua; |
| | | import chushihua.lunxun; |
| | | |
| | |
| | | private final MenuItemListener menuItemListener; |
| | | |
| | | public ConfigSet(JFrame parent) { |
| | | super(parent, "设置", true); |
| | | super(parent, "", true); |
| | | configManager = Chushihua.getInstance(); |
| | | menuItemListener = new MenuItemListener(); |
| | | // 记录进入设置页面前的轮询状态 |
| | | // 记录进入设置页面前的轮询状态 |
| | | recordPollingStateBeforeEntering(); |
| | | initializeUI(); |
| | | // 进入设置页面时暂停轮询 |
| | | // 进入设置页面时暂停轮询 |
| | | pausePollingWhenEntering(); |
| | | } |
| | | |
| | |
| | | if (lunxun.isPolling() && !lunxun.isPaused()) { |
| | | boolean paused = lunxun.setPollingPaused(true); |
| | | if (paused) { |
| | | System.out.println("进入设置页面,轮询已暂停"); |
| | | //System.out.println("进入设置页面,轮询已暂停"); |
| | | } else { |
| | | System.err.println("进入设置页面,暂停轮询失败"); |
| | | } |
| | |
| | | if (lunxun.checkSerialConnection()) { |
| | | boolean resumed = lunxun.setPollingPaused(false); |
| | | if (resumed) { |
| | | System.out.println("退出设置页面,轮询已恢复"); |
| | | //System.out.println("退出设置页面,轮询已恢复"); |
| | | } else { |
| | | System.err.println("退出设置页面,恢复轮询失败"); |
| | | } |
| | |
| | | } |
| | | } |
| | | } else { |
| | | System.out.println("退出设置页面,保持原有轮询状态 - 运行: " + wasPollingRunning + ", 暂停: " + wasPollingPaused); |
| | | //System.out.println("退出设置页面,保持原有轮询状态 - 运行: " + wasPollingRunning + ", 暂停: " + wasPollingPaused); |
| | | } |
| | | } |
| | | |
| | |
| | | mainPanel.add(createHeaderPanel(), BorderLayout.NORTH); |
| | | mainPanel.add(createMenuGridPanel(), BorderLayout.CENTER); |
| | | |
| | | // 添加版权信息在底部 |
| | | mainPanel.add(createCopyrightPanel(), BorderLayout.SOUTH); |
| | | |
| | | getContentPane().add(mainPanel); |
| | | } |
| | | |
| | | // 创建版权信息面板 |
| | | private JPanel createCopyrightPanel() { |
| | | JPanel copyrightPanel = new JPanel(); |
| | | copyrightPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); |
| | | copyrightPanel.setOpaque(true); |
| | | copyrightPanel.setBackground(DARK_COLOR); |
| | | copyrightPanel.setBorder(new EmptyBorder(10, 0, 5, 0)); |
| | | |
| | | JLabel copyrightLabel = new JLabel("北京华星北斗智控技术有限公司 版权所有 2025"); |
| | | copyrightLabel.setFont(new Font("Microsoft YaHei", Font.PLAIN, 12)); |
| | | copyrightLabel.setForeground(new Color(160, 160, 160)); |
| | | |
| | | copyrightPanel.add(copyrightLabel); |
| | | return copyrightPanel; |
| | | } |
| | | |
| | | private JPanel createHeaderPanel() { |
| | |
| | | closeButton.setOpaque(true); // 确保不透明 |
| | | closeButton.setFocusPainted(false); |
| | | closeButton.setBorder(BorderFactory.createEmptyBorder(10, 18, 10, 18)); |
| | | closeButton.setIcon(getCachedIcon("✕", 16)); |
| | | closeButton.addActionListener(e -> dispose()); |
| | | closeButton.addActionListener(e -> { |
| | | // 强制开启轮询查询功能 |
| | | forceStartPolling(); |
| | | dispose(); |
| | | }); |
| | | |
| | | // 添加悬停效果 |
| | | closeButton.addMouseListener(new java.awt.event.MouseAdapter() { |
| | |
| | | kacaoguanli.showSlotManagementDialog((JFrame) getParent()); |
| | | break; |
| | | case "历史记录": |
| | | showMessageDialog("历史记录功能开发中..."); |
| | | lishijilu.showHistoryDialog((JFrame) getParent()); |
| | | break; |
| | | case "参数设置": |
| | | canshushezhi.showSettingsDialog((JFrame) getParent()); |
| | |
| | | mimaguanli.showPasswordManagementDialog((JFrame) getParent(), configManager); |
| | | break; |
| | | case "版本管理": |
| | | showMessageDialog("版本管理功能开发中..."); |
| | | banbenguanli.showVersionManagementDialog((JFrame) getParent()); |
| | | break; |
| | | case "语言设置": |
| | | showMessageDialog("语言设置功能开发中..."); |
| | | showMessageDialog("语言设置不可选择"); |
| | | break; |
| | | } |
| | | } |
| | |
| | | return icon; |
| | | } |
| | | |
| | | private void showSystemDebugDialog() { |
| | | SystemDebugDialog.showSystemDebugDialog((JFrame) getParent()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void dispose() { |
| | | // 退出设置页面时恢复轮询控制 |
| | | SystemDebugDialog.setPollingControlEnabled(true); |
| | | |
| | | // 退出设置页面时恢复轮询 |
| | | resumePollingWhenExiting(); |
| | | |
| | |
| | | configDialog.setVisible(true); |
| | | }); |
| | | } |
| | | /** |
| | | * 强制开启轮询查询功能(无论当前状态如何) |
| | | */ |
| | | private void forceStartPolling() { |
| | | try { |
| | | // 如果轮询未运行,则启动轮询 |
| | | if (!lunxun.isPolling()) { |
| | | boolean started = lunxun.startPolling(); |
| | | if (started) { |
| | | //System.out.println("强制开启:轮询查询已启动"); |
| | | } else { |
| | | System.err.println("强制开启:启动轮询查询失败"); |
| | | } |
| | | } |
| | | // 如果轮询已运行但处于暂停状态,则恢复轮询 |
| | | else if (lunxun.isPaused()) { |
| | | boolean resumed = lunxun.resumePolling(); |
| | | if (resumed) { |
| | | //System.out.println("强制开启:轮询查询已恢复"); |
| | | } else { |
| | | System.err.println("强制开启:恢复轮询查询失败"); |
| | | } |
| | | } |
| | | // 如果轮询已运行且未暂停,则无需操作 |
| | | else { |
| | | //System.out.println("强制开启:轮询查询已在运行中"); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | System.err.println("强制开启轮询查询时发生异常: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | // 在 showSystemDebugDialog 方法中添加 |
| | | private void showSystemDebugDialog() { |
| | | // 在打开调试对话框时禁用轮询控制 |
| | | SystemDebugDialog.setPollingControlEnabled(false); |
| | | SystemDebugDialog.showSystemDebugDialog((JFrame) getParent()); |
| | | } |
| | | } |