张世豪
6 天以前 8ce07ce9a4034fdc959d280dd38ecb3e05cbe6e1
src/zhangaiwu/AddDikuai.java
@@ -27,10 +27,12 @@
import dikuai.Dikuaiguanli;
import bianjie.bianjieguihua2;
import lujing.Lunjingguihua;
import set.Setsys;
import ui.UIConfig;
import zhuye.MowerLocationData;
import zhuye.Shouye;
import zhuye.Coordinate;
import zhuye.buttonset;
/**
 * 新增地块对话框 - 多步骤表单设计
@@ -290,10 +292,6 @@
        formGroup.add(areaNameField);
        formGroup.add(Box.createRigidArea(new Dimension(0, 8)));
        formGroup.add(hintLabel);
    formGroup.add(Box.createRigidArea(new Dimension(0, 20)));
    JPanel obstacleSection = createObstacleSummarySection();
    formGroup.add(obstacleSection);
        
        stepPanel.add(formGroup);
        stepPanel.add(Box.createVerticalGlue());
@@ -741,8 +739,9 @@
                if (!optionPanel.isEnabled()) {
                    return;
                }
                selectDrawingOption(optionPanel, type);
                startEndDrawingBtn.setEnabled(true); // 选择后启用按钮
                if (selectDrawingOption(optionPanel, type, true)) {
                    startEndDrawingBtn.setEnabled(true); // 选择后启用按钮
                }
            }
            
            @Override
@@ -764,7 +763,15 @@
        return optionPanel;
    }
    
    private void selectDrawingOption(JPanel optionPanel, String type) {
    private boolean selectDrawingOption(JPanel optionPanel, String type, boolean userTriggered) {
        if (optionPanel == null) {
            return false;
        }
        if (userTriggered && "handheld".equalsIgnoreCase(type) && !hasConfiguredHandheldMarker()) {
            JOptionPane.showMessageDialog(this, "请先添加便携打点器编号", "提示", JOptionPane.WARNING_MESSAGE);
            return false;
        }
        // 重置之前选中的选项
        if (selectedOptionPanel != null) {
            selectedOptionPanel.setBorder(BorderFactory.createLineBorder(BORDER_COLOR, 2));
@@ -774,7 +781,7 @@
                ((JLabel) oldTitle).setForeground(TEXT_COLOR);
            }
        }
        // 设置新的选中状态
        optionPanel.setBorder(BorderFactory.createLineBorder(PRIMARY_COLOR, 3));
        optionPanel.setBackground(PRIMARY_LIGHT);
@@ -783,9 +790,15 @@
            ((JLabel) titleObj).setForeground(PRIMARY_COLOR);
        }
        selectedOptionPanel = optionPanel;
        // 保存选择
        dikuaiData.put("drawingMethod", type);
        return true;
    }
    private boolean hasConfiguredHandheldMarker() {
        String handheldId = Setsys.getPropertyValue("handheldMarkerId");
        return handheldId != null && !handheldId.trim().isEmpty();
    }
    
    private void toggleDrawing() {
@@ -1260,18 +1273,14 @@
    }
    
    private JButton createPrimaryButton(String text, int fontSize) {
        JButton button = new JButton(text);
        JButton button = buttonset.createStyledButton(text, PRIMARY_COLOR);
        button.setFont(new Font("微软雅黑", Font.BOLD, fontSize));
        button.setBackground(PRIMARY_COLOR);
        button.setForeground(WHITE);
        button.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(PRIMARY_DARK, 2),
            BorderFactory.createEmptyBorder(12, 25, 12, 25)
        ));
        button.setFocusPainted(false);
        button.setCursor(new Cursor(Cursor.HAND_CURSOR));
        // 按钮悬停效果
        button.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseEntered(MouseEvent e) {
@@ -1279,7 +1288,7 @@
                    button.setBackground(PRIMARY_DARK);
                }
            }
            @Override
            public void mouseExited(MouseEvent e) {
                if (button.isEnabled()) {
@@ -1287,7 +1296,7 @@
                }
            }
        });
        return button;
    }
@@ -1335,15 +1344,13 @@
        buttonPanel.setBackground(WHITE);
        buttonPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
        prevButton = new JButton("上一步");
        prevButton = buttonset.createStyledButton("上一步", MEDIUM_GRAY);
        prevButton.setFont(new Font("微软雅黑", Font.BOLD, 16));
        prevButton.setBackground(MEDIUM_GRAY);
        prevButton.setForeground(TEXT_COLOR);
        prevButton.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(BORDER_COLOR, 2),
            BorderFactory.createEmptyBorder(10, 25, 10, 25)
        ));
        prevButton.setFocusPainted(false);
        prevButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
        nextButton = createPrimaryButton("下一步", 16);
@@ -1647,10 +1654,6 @@
    private void showStep(int step) {
        currentStep = step;
        cardLayout.show(stepsPanel, "step" + step);
        if (step == 1) {
            updateObstacleSummary();
        }
        // 更新按钮状态
        updateButtonState(step);
@@ -1951,7 +1954,7 @@
        if (method != null) {
            JPanel panel = drawingOptionPanels.get(method);
            if (panel != null) {
                selectDrawingOption(panel, method);
                selectDrawingOption(panel, method, false);
            }
        }