| | |
| | | package set; |
| | | |
| | | import baseStation.BaseStation; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.filechooser.FileNameExtensionFilter; |
| | | |
| | |
| | | private JLabel mowerIdLabel; |
| | | private JLabel handheldMarkerLabel; |
| | | private JLabel simCardNumberLabel; |
| | | private JLabel baseStationSimLabel; |
| | | private JLabel firmwareVersionLabel; |
| | | private JLabel appVersionLabel; |
| | | |
| | | private JButton mowerIdEditBtn; |
| | | private JButton handheldEditBtn; |
| | | private JButton checkUpdateBtn; |
| | | private JButton systemDebugButton; |
| | | private JButton feedbackButton; |
| | | |
| | | // 数据模型 |
| | | private Setsys setData; |
| | | private final BaseStation baseStation; |
| | | |
| | | public Sets(JFrame parent, Color themeColor) { |
| | | super(parent, "系统设置", true); |
| | | this.THEME_COLOR = themeColor; |
| | | this.setData = new Setsys(); |
| | | this.baseStation = new BaseStation(); |
| | | initializeUI(); |
| | | loadData(); |
| | | } |
| | |
| | | super(parent, "系统设置", true); |
| | | this.THEME_COLOR = themeColor; |
| | | this.setData = new Setsys(); |
| | | this.baseStation = new BaseStation(); |
| | | initializeUI(); |
| | | loadData(); |
| | | } |
| | |
| | | handheldEditBtn = (JButton) handheldPanel.getClientProperty("editButton"); |
| | | |
| | | // 物联卡号 |
| | | JPanel simCardPanel = createSettingItemPanel("物联卡号", |
| | | JPanel simCardPanel = createSettingItemPanel("割草机物联网卡号", |
| | | setData.getSimCardNumber() != null ? setData.getSimCardNumber() : "未设置", false); |
| | | simCardNumberLabel = (JLabel) simCardPanel.getClientProperty("valueLabel"); |
| | | |
| | | JPanel baseStationSimPanel = createSettingItemPanel("基准站物联网卡号", |
| | | resolveBaseStationSimCard(), false); |
| | | baseStationSimLabel = (JLabel) baseStationSimPanel.getClientProperty("valueLabel"); |
| | | |
| | | // 固件版本 |
| | | JPanel firmwarePanel = createSettingItemPanel("固件版本", |
| | | setData.getFirmwareVersion() != null ? setData.getFirmwareVersion() : "未设置", false); |
| | |
| | | addRowWithSpacing(panel, mowerIdPanel); |
| | | addRowWithSpacing(panel, handheldPanel); |
| | | addRowWithSpacing(panel, simCardPanel); |
| | | addRowWithSpacing(panel, baseStationSimPanel); |
| | | addRowWithSpacing(panel, firmwarePanel); |
| | | addRowWithSpacing(panel, feedbackPanel); |
| | | panel.add(appVersionPanel); |
| | | addRowWithSpacing(panel, appVersionPanel); |
| | | panel.add(createDebugPanel()); |
| | | |
| | | return panel; |
| | | } |
| | |
| | | checkUpdateBtn.setFont(new Font("微软雅黑", Font.PLAIN, 12)); |
| | | checkUpdateBtn.setBackground(THEME_COLOR); |
| | | checkUpdateBtn.setForeground(Color.WHITE); |
| | | checkUpdateBtn.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 12)); |
| | | checkUpdateBtn.setPreferredSize(new Dimension(90, 25)); |
| | | checkUpdateBtn.setMinimumSize(new Dimension(90, 25)); |
| | | checkUpdateBtn.setMaximumSize(new Dimension(90, 25)); |
| | | checkUpdateBtn.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); |
| | | checkUpdateBtn.setPreferredSize(new Dimension(100, 28)); |
| | | checkUpdateBtn.setMinimumSize(new Dimension(100, 28)); |
| | | checkUpdateBtn.setMaximumSize(new Dimension(100, 28)); |
| | | checkUpdateBtn.setFocusPainted(false); |
| | | |
| | | checkUpdateBtn.addMouseListener(new MouseAdapter() { |
| | |
| | | return panel; |
| | | } |
| | | |
| | | private JPanel createDebugPanel() { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setBackground(PANEL_BACKGROUND); |
| | | panel.setAlignmentX(Component.LEFT_ALIGNMENT); |
| | | panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, ROW_HEIGHT)); |
| | | panel.setPreferredSize(new Dimension(Integer.MAX_VALUE, ROW_HEIGHT)); |
| | | panel.setMinimumSize(new Dimension(0, ROW_HEIGHT)); |
| | | |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | | |
| | | JLabel titleLabel = new JLabel("系统调试"); |
| | | titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 14)); |
| | | titleLabel.setForeground(Color.BLACK); |
| | | titleLabel.setHorizontalAlignment(SwingConstants.RIGHT); |
| | | gbc.gridx = 0; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 0; |
| | | gbc.anchor = GridBagConstraints.EAST; |
| | | gbc.insets = new Insets(0, 0, 0, 12); |
| | | panel.add(titleLabel, gbc); |
| | | |
| | | systemDebugButton = new JButton("系统调试"); |
| | | systemDebugButton.setFont(new Font("微软雅黑", Font.PLAIN, 12)); |
| | | systemDebugButton.setBackground(new Color( |
| | | Math.max(THEME_COLOR.getRed() - 20, 0), |
| | | Math.max(THEME_COLOR.getGreen() - 20, 0), |
| | | Math.max(THEME_COLOR.getBlue() - 20, 0))); |
| | | systemDebugButton.setForeground(Color.WHITE); |
| | | systemDebugButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); |
| | | systemDebugButton.setPreferredSize(new Dimension(100, 28)); |
| | | systemDebugButton.setMinimumSize(new Dimension(100, 28)); |
| | | systemDebugButton.setMaximumSize(new Dimension(100, 28)); |
| | | systemDebugButton.setFocusPainted(false); |
| | | |
| | | systemDebugButton.addMouseListener(new MouseAdapter() { |
| | | public void mouseEntered(MouseEvent e) { |
| | | systemDebugButton.setBackground(THEME_COLOR); |
| | | } |
| | | public void mouseExited(MouseEvent e) { |
| | | systemDebugButton.setBackground(new Color( |
| | | Math.max(THEME_COLOR.getRed() - 20, 0), |
| | | Math.max(THEME_COLOR.getGreen() - 20, 0), |
| | | Math.max(THEME_COLOR.getBlue() - 20, 0))); |
| | | } |
| | | }); |
| | | |
| | | gbc = new GridBagConstraints(); |
| | | gbc.gridx = 1; |
| | | gbc.gridy = 0; |
| | | gbc.weightx = 1.0; |
| | | gbc.anchor = GridBagConstraints.EAST; |
| | | panel.add(systemDebugButton, gbc); |
| | | |
| | | return panel; |
| | | } |
| | | |
| | | private JPanel createFeedbackPanel() { |
| | | JPanel panel = new JPanel(new GridBagLayout()); |
| | | panel.setBackground(PANEL_BACKGROUND); |
| | |
| | | private void loadData() { |
| | | // 从Setsys类加载数据 |
| | | setData.initializeFromProperties(); |
| | | baseStation.load(); |
| | | updateDisplay(); |
| | | } |
| | | |
| | |
| | | setData.getSimCardNumber() : "未设置"); |
| | | } |
| | | |
| | | if (baseStationSimLabel != null) { |
| | | baseStationSimLabel.setText(resolveBaseStationSimCard()); |
| | | } |
| | | |
| | | // 更新固件版本显示 |
| | | if (firmwareVersionLabel != null) { |
| | | firmwareVersionLabel.setText(setData.getFirmwareVersion() != null ? |
| | |
| | | } |
| | | } |
| | | |
| | | private String resolveBaseStationSimCard() { |
| | | if (baseStation == null) { |
| | | return "未设置"; |
| | | } |
| | | String value = baseStation.getIotSimCardNumber(); |
| | | if (value == null) { |
| | | return "未设置"; |
| | | } |
| | | String trimmed = value.trim(); |
| | | if (trimmed.isEmpty() || "-1".equals(trimmed)) { |
| | | return "未设置"; |
| | | } |
| | | return trimmed; |
| | | } |
| | | |
| | | private void setupEventHandlers() { |
| | | // 割草机编号编辑按钮事件 |
| | | if (mowerIdEditBtn != null) { |
| | |
| | | feedbackButton.addActionListener(e -> showFeedbackDialog()); |
| | | } |
| | | |
| | | if (systemDebugButton != null) { |
| | | systemDebugButton.addActionListener(e -> openSystemDebugDialog()); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void editMowerId() { |
| | |
| | | timer.start(); |
| | | } |
| | | |
| | | private void openSystemDebugDialog() { |
| | | debug dialog = new debug(this, THEME_COLOR); |
| | | dialog.setLocationRelativeTo(this); |
| | | dialog.setVisible(true); |
| | | } |
| | | |
| | | @Override |
| | | public void setVisible(boolean visible) { |
| | | if (visible) { |