| | |
| | | |
| | | import baseStation.BaseStation; |
| | | |
| | | import zhuye.MapRenderer; |
| | | import zhuye.Shouye; |
| | | |
| | | import javax.swing.*; |
| | | import javax.swing.filechooser.FileNameExtensionFilter; |
| | | |
| | |
| | | private JLabel baseStationSimLabel; |
| | | private JLabel firmwareVersionLabel; |
| | | private JLabel appVersionLabel; |
| | | private JLabel idleTrailDurationLabel; |
| | | |
| | | private JButton mowerIdEditBtn; |
| | | private JButton handheldEditBtn; |
| | | private JButton checkUpdateBtn; |
| | | private JButton systemDebugButton; |
| | | private JButton feedbackButton; |
| | | private JButton idleTrailEditBtn; |
| | | |
| | | // 数据模型 |
| | | private Setsys setData; |
| | |
| | | setData.getFirmwareVersion() != null ? setData.getFirmwareVersion() : "未设置", false); |
| | | firmwareVersionLabel = (JLabel) firmwarePanel.getClientProperty("valueLabel"); |
| | | |
| | | JPanel idleTrailPanel = createSettingItemPanel("轨迹拖尾时长", |
| | | formatIdleTrailDurationValue(), true); |
| | | idleTrailDurationLabel = (JLabel) idleTrailPanel.getClientProperty("valueLabel"); |
| | | idleTrailEditBtn = (JButton) idleTrailPanel.getClientProperty("editButton"); |
| | | |
| | | JPanel feedbackPanel = createFeedbackPanel(); |
| | | |
| | | // APP版本 |
| | |
| | | addRowWithSpacing(panel, simCardPanel); |
| | | addRowWithSpacing(panel, baseStationSimPanel); |
| | | addRowWithSpacing(panel, firmwarePanel); |
| | | addRowWithSpacing(panel, idleTrailPanel); |
| | | addRowWithSpacing(panel, feedbackPanel); |
| | | addRowWithSpacing(panel, appVersionPanel); |
| | | panel.add(createDebugPanel()); |
| | |
| | | return panel; |
| | | } |
| | | |
| | | private String formatIdleTrailDurationValue() { |
| | | int seconds = setData != null ? setData.getIdleTrailDurationSeconds() : Setsys.DEFAULT_IDLE_TRAIL_DURATION_SECONDS; |
| | | if (seconds <= 0) { |
| | | seconds = Setsys.DEFAULT_IDLE_TRAIL_DURATION_SECONDS; |
| | | } |
| | | return seconds + "秒"; |
| | | } |
| | | |
| | | private void addRowWithSpacing(JPanel container, JPanel row) { |
| | | container.add(row); |
| | | container.add(Box.createRigidArea(new Dimension(0, ROW_SPACING))); |
| | |
| | | firmwareVersionLabel.setText(setData.getFirmwareVersion() != null ? |
| | | setData.getFirmwareVersion() : "未设置"); |
| | | } |
| | | |
| | | if (idleTrailDurationLabel != null) { |
| | | idleTrailDurationLabel.setText(formatIdleTrailDurationValue()); |
| | | } |
| | | |
| | | // 更新APP版本显示 |
| | | if (appVersionLabel != null) { |
| | |
| | | if (systemDebugButton != null) { |
| | | systemDebugButton.addActionListener(e -> openSystemDebugDialog()); |
| | | } |
| | | |
| | | if (idleTrailEditBtn != null) { |
| | | idleTrailEditBtn.addActionListener(e -> editIdleTrailDuration()); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void editIdleTrailDuration() { |
| | | int currentSeconds = setData != null ? setData.getIdleTrailDurationSeconds() : Setsys.DEFAULT_IDLE_TRAIL_DURATION_SECONDS; |
| | | if (currentSeconds <= 0) { |
| | | currentSeconds = Setsys.DEFAULT_IDLE_TRAIL_DURATION_SECONDS; |
| | | } |
| | | |
| | | String input = JOptionPane.showInputDialog(this, |
| | | "请输入轨迹拖尾时长(单位:秒)", |
| | | currentSeconds); |
| | | |
| | | if (input == null) { |
| | | return; |
| | | } |
| | | |
| | | String trimmed = input.trim(); |
| | | if (trimmed.isEmpty()) { |
| | | JOptionPane.showMessageDialog(this, "轨迹拖尾时长不能为空", "提示", JOptionPane.WARNING_MESSAGE); |
| | | return; |
| | | } |
| | | |
| | | int parsedSeconds; |
| | | try { |
| | | parsedSeconds = Integer.parseInt(trimmed); |
| | | } catch (NumberFormatException ex) { |
| | | JOptionPane.showMessageDialog(this, "请输入有效的整数秒数", "提示", JOptionPane.WARNING_MESSAGE); |
| | | return; |
| | | } |
| | | |
| | | if (parsedSeconds < 5 || parsedSeconds > 600) { |
| | | JOptionPane.showMessageDialog(this, "请输入5到600之间的秒数", "提示", JOptionPane.WARNING_MESSAGE); |
| | | return; |
| | | } |
| | | |
| | | if (setData.updateProperty("idleTrailDurationSeconds", String.valueOf(parsedSeconds))) { |
| | | int appliedSeconds = setData.getIdleTrailDurationSeconds(); |
| | | if (idleTrailDurationLabel != null) { |
| | | idleTrailDurationLabel.setText(appliedSeconds + "秒"); |
| | | } |
| | | MapRenderer renderer = null; |
| | | Shouye shouye = Shouye.getInstance(); |
| | | if (shouye != null) { |
| | | renderer = shouye.getMapRenderer(); |
| | | } |
| | | if (renderer != null) { |
| | | renderer.setIdleTrailDurationSeconds(appliedSeconds); |
| | | } |
| | | JOptionPane.showMessageDialog(this, "轨迹拖尾时长已更新为 " + appliedSeconds + " 秒", "成功", JOptionPane.INFORMATION_MESSAGE); |
| | | } else { |
| | | JOptionPane.showMessageDialog(this, "轨迹拖尾时长更新失败", "错误", JOptionPane.ERROR_MESSAGE); |
| | | } |
| | | } |
| | | |
| | | private void showFeedbackDialog() { |
| | | JDialog dialog = new JDialog(this, "问题反馈咨询", true); |
| | | dialog.setLayout(new BorderLayout(0, 12)); |