package dell_suanfa; // ¶¨Òå°üÃû import javax.swing.*; // µ¼ÈëSwing×é¼þ import javax.swing.border.EmptyBorder; // µ¼Èë¿Õ±ß¿ò import javax.swing.border.TitledBorder; // µ¼Èë´ø±êÌâ±ß¿ò import java.awt.*; // µ¼ÈëAWT×é¼þ import java.awt.event.ItemEvent; // µ¼ÈëÏîĿʼþ import java.awt.event.ItemListener; // µ¼ÈëÏîÄ¿¼àÌýÆ÷ import java.sql.SQLException; // µ¼ÈëSQLÒì³£ import java.text.SimpleDateFormat; // µ¼Èë¼òµ¥ÈÕÆÚ¸ñʽ import java.util.Date; // µ¼ÈëÈÕÆÚÀà import java.util.HashMap; // µ¼Èë¹þÏ£Ó³Éä import java.util.Map; // µ¼ÈëÓ³Éä½Ó¿Ú import java.util.ResourceBundle; // µ¼Èë×ÊÔ´Êø import dell_system.Dell_company; // µ¼È빫˾Àà import dell_system.GeneralAlgorithm; import databases.DBConnector; // µ¼ÈëÊý¾Ý¿âÁ¬½ÓÆ÷ public class GeneralAlgorithmPanel extends JPanel { // ͨÓÃËã·¨Ãæ°åÀà private static final long serialVersionUID = 1L; // ÐòÁл¯°æ±¾ID private ResourceBundle messages; // ¹ú¼Ê»¯ÏûÏ¢×ÊÔ´ private GeneralAlgorithm currentAlgorithm; // µ±Ç°Ëã·¨¶ÔÏó // UI×é¼þÉùÃ÷ private JComboBox companyComboBox; // ¹«Ë¾Ñ¡ÔñÏÂÀ­¿ò private JTextField satelliteSignalFilterField; // ÎÀÐÇÐźŹýÂË×Ö¶Î private JTextField positionFilterField; // λÖùýÂË×Ö¶Î private JTextField closeUwbConditionField; // ¹Ø±ÕUWBÌõ¼þ×Ö¶Î private JTextField staticFilterField; // ¾²Ì¬¹ýÂË×Ö¶Î private JTextField systemMaxSpeedField; // ϵͳ×î´óËÙ¶È×Ö¶Î private JTextField maxRepeatRangingField; // ×î´óÖØ¸´²â¾à×Ö¶Î private JTextField filterLevelField; // ¹ýÂ˼¶±ð×Ö¶Î private JRadioButton gnssToXyEnabled; // GNSSתXYÆôÓà private JRadioButton gnssToXyDisabled; // GNSSתXY½ûÓà private JRadioButton areaJudgeIndoorEnabled; // ÇøÓòÅжÏÊÒÄÚÆôÓà private JRadioButton areaJudgeIndoorDisabled; // ÇøÓòÅжÏÊÒÄÚ½ûÓà private JRadioButton distanceJudgeIndoorEnabled; // ¾àÀëÅжÏÊÒÄÚÆôÓà private JRadioButton distanceJudgeIndoorDisabled; // ¾àÀëÅжÏÊÒÄÚ½ûÓà private JRadioButton satelliteSignalJudgeIndoorEnabled; // ÎÀÐÇÐźÅÅжÏÊÒÄÚÆôÓà private JRadioButton satelliteSignalJudgeIndoorDisabled; // ÎÀÐÇÐźÅÅжÏÊÒÄÚ½ûÓà private JRadioButton blurPositionCalculationEnabled; // Ä£ºýλÖüÆËãÆôÓà private JRadioButton blurPositionCalculationDisabled; // Ä£ºýλÖüÆËã½ûÓà private JRadioButton timeSlotAllocationMix; // ʱ϶·ÖÅä»ìºÏģʽ private JRadioButton timeSlotAllocationGap; // ʱ϶·ÖÅä¼ä¸ôģʽ private JRadioButton filterAlgorithmLowPass; // µÍͨÂ˲¨Ëã·¨ private JRadioButton filterAlgorithmSliding; // »¬¶¯Â˲¨Ëã·¨ private JRadioButton judge0dByPositionEnabled; // λÖÃÅжÏ0DÆôÓà private JRadioButton judge0dByPositionDisabled; // λÖÃÅжÏ0D½ûÓà private JTextField timeField; // ʱ¼ä×Ö¶Î private JButton saveButton; // ±£´æ°´Å¥ private JButton cancelButton; // È¡Ïû°´Å¥ public GeneralAlgorithmPanel(ResourceBundle messages) { // ¹¹Ô캯Êý this.messages = messages; // ³õʼ»¯ÏûÏ¢×ÊÔ´ setLayout(new BorderLayout()); // ÉèÖñ߽粼¾Ö setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // ÉèÖÃÃæ°å±ß¾à(5ÏñËØ) // Ö÷Ãæ°å JPanel mainPanel = new JPanel(); // ´´½¨Ö÷Ãæ°å mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); // ÉèÖô¹Ö±ºÐ²¼¾Ö mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // ÉèÖÃÖ÷Ãæ°å±ß¾à // ¹«Ë¾Ñ¡ÔñÃæ°å JPanel companyPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2)); // ×ó¶ÔÆëÁ÷ʽ²¼¾Ö JLabel companyLabel = new JLabel(getMessage("BELONGING_COMPANY") + ":"); // ¹«Ë¾±êÇ© companyComboBox = new JComboBox<>(); // ³õʼ»¯ÏÂÀ­¿ò companyComboBox.setPreferredSize(new Dimension(300, 25)); // ÉèÖÃÏÂÀ­¿ò³ß´ç companyPanel.add(companyLabel); // Ìí¼Ó±êÇ© companyPanel.add(companyComboBox); // Ìí¼ÓÏÂÀ­¿ò mainPanel.add(companyPanel); // Ìí¼Óµ½Ö÷Ãæ°å // Îı¾¿òÃæ°å JPanel textFieldsPanel = new JPanel(); // ´´½¨Îı¾¿òÃæ°å textFieldsPanel.setLayout(new GridLayout(0, 2, 5, 5)); // Íø¸ñ²¼¾Ö(2ÁÐ) textFieldsPanel.setBorder(BorderFactory.createCompoundBorder( // ×éºÏ±ß¿ò new TitledBorder(getMessage("TEXT_FIELDS")), // ±êÌâ±ß¿ò new EmptyBorder(3, 5, 3, 5) // µ÷Õû±êÌâÓëÄÚÈݼä¾à(ÉÏÏÂ3ÏñËØ) )); // Ìí¼Ó¹Ì¶¨¿í¶È(200ÏñËØ)µÄÎı¾¿ò addTextField(textFieldsPanel, getMessage("SATELLITE_SIGNAL_FILTER"), satelliteSignalFilterField = createFixedTextField(200)); addTextField(textFieldsPanel, getMessage("POSITION_FILTER"), positionFilterField = createFixedTextField(200)); addTextField(textFieldsPanel, getMessage("CLOSE_UWB_CONDITION"), closeUwbConditionField = createFixedTextField(200)); addTextField(textFieldsPanel, getMessage("STATIC_FILTER"), staticFilterField = createFixedTextField(200)); addTextField(textFieldsPanel, getMessage("SYSTEM_MAX_SPEED"), systemMaxSpeedField = createFixedTextField(200)); addTextField(textFieldsPanel, getMessage("MAX_REPEAT_RANGING"), maxRepeatRangingField = createFixedTextField(200)); addTextField(textFieldsPanel, getMessage("FILTER_LEVEL"), filterLevelField = createFixedTextField(200)); mainPanel.add(textFieldsPanel); // Ìí¼Óµ½Ö÷Ãæ°å // µ¥Ñ¡°´Å¥Ãæ°å JPanel radioPanel = new JPanel(); // ´´½¨µ¥Ñ¡Ãæ°å radioPanel.setLayout(new GridLayout(0, 2, 5, 5)); // Íø¸ñ²¼¾Ö(2ÁÐ) radioPanel.setBorder(BorderFactory.createCompoundBorder( // ×éºÏ±ß¿ò new TitledBorder(getMessage("RADIO_BUTTONS")), // ±êÌâ±ß¿ò new EmptyBorder(3, 5, 3, 5) // µ÷Õû±êÌâÓëÄÚÈݼä¾à(ÉÏÏÂ3ÏñËØ) )); // Ìí¼Óµ¥Ñ¡°´Å¥×é addRadioGroup(radioPanel, getMessage("GNSS_TO_XY"), gnssToXyEnabled = createRedRadioButton(getMessage("ENABLED")), gnssToXyDisabled = createRedRadioButton(getMessage("DISABLED"))); addRadioGroup(radioPanel, getMessage("AREA_JUDGE_INDOOR"), areaJudgeIndoorEnabled = createRedRadioButton(getMessage("ENABLED")), areaJudgeIndoorDisabled = createRedRadioButton(getMessage("DISABLED"))); addRadioGroup(radioPanel, getMessage("DISTANCE_JUDGE_INDOOR"), distanceJudgeIndoorEnabled = createRedRadioButton(getMessage("ENABLED")), distanceJudgeIndoorDisabled = createRedRadioButton(getMessage("DISABLED"))); addRadioGroup(radioPanel, getMessage("SATELLITE_SIGNAL_JUDGE_INDOOR"), satelliteSignalJudgeIndoorEnabled = createRedRadioButton(getMessage("ENABLED")), satelliteSignalJudgeIndoorDisabled = createRedRadioButton(getMessage("DISABLED"))); addRadioGroup(radioPanel, getMessage("BLUR_POSITION_CALCULATION"), blurPositionCalculationEnabled = createRedRadioButton(getMessage("ENABLED")), blurPositionCalculationDisabled = createRedRadioButton(getMessage("DISABLED"))); addRadioGroup(radioPanel, getMessage("TIME_SLOT_ALLOCATION"), timeSlotAllocationMix = createRedRadioButton("MIX"), timeSlotAllocationGap = createRedRadioButton("GAP")); addRadioGroup(radioPanel, getMessage("FILTER_ALGORITHM"), filterAlgorithmLowPass = createRedRadioButton(getMessage("LOW_PASS_FILTER")), filterAlgorithmSliding = createRedRadioButton(getMessage("SLIDING_FILTER"))); addRadioGroup(radioPanel, getMessage("JUDGE_0D_BY_POSITION"), judge0dByPositionEnabled = createRedRadioButton(getMessage("ENABLED")), judge0dByPositionDisabled = createRedRadioButton(getMessage("DISABLED"))); mainPanel.add(radioPanel); // Ìí¼Óµ½Ö÷Ãæ°å // ʱ¼äÃæ°å JPanel timePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2)); // ×ó¶ÔÆëÁ÷ʽ²¼¾Ö timePanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); // ÉèÖñ߾à JLabel timeLabel = new JLabel(getMessage("TIME") + ":"); // ʱ¼ä±êÇ© timeField = createFixedTextField(200); // ´´½¨¹Ì¶¨¿í¶ÈÎı¾¿ò timeField.setEditable(false); // ÉèÖÃΪ²»¿É±à¼­ timePanel.add(timeLabel); // Ìí¼Ó±êÇ© timePanel.add(timeField); // Ìí¼ÓÎı¾¿ò mainPanel.add(timePanel); // Ìí¼Óµ½Ö÷Ãæ°å // °´Å¥Ãæ°å JPanel buttonPanel = new JPanel(); // ´´½¨°´Å¥Ãæ°å buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); // ÉèÖÃÉϱ߾à saveButton = new JButton(getMessage("SAVE")); // ±£´æ°´Å¥ cancelButton = new JButton(getMessage("CANCEL")); // È¡Ïû°´Å¥ buttonPanel.add(saveButton); // Ìí¼Ó±£´æ°´Å¥ buttonPanel.add(cancelButton); // Ìí¼ÓÈ¡Ïû°´Å¥ mainPanel.add(buttonPanel); // Ìí¼Óµ½Ö÷Ãæ°å // Ìí¼Ó¹ö¶¯Ãæ°å JScrollPane scrollPane = new JScrollPane(mainPanel); // ´´½¨¹ö¶¯Ãæ°å scrollPane.setBorder(null); // ÒÆ³ý±ß¿ò add(scrollPane, BorderLayout.CENTER); // Ìí¼Óµ½ÖÐÐÄÇøÓò // ¼ÓÔØ¹«Ë¾Êý¾Ý loadCompanyData(); // ³õʼ»¯¹«Ë¾ÏÂÀ­¿ò // ¼ÓÔØËã·¨Êý¾Ý loadAlgorithmData(); // ³õʼ»¯±íµ¥Êý¾Ý // Ìí¼Óʼþ¼àÌýÆ÷ addEventListeners(); // ÉèÖð´Å¥Ê¼þ } // ´´½¨¹Ì¶¨¿í¶ÈÎı¾¿ò private JTextField createFixedTextField(int width) { JTextField textField = new JTextField(); // ´´½¨Îı¾¿ò textField.setPreferredSize(new Dimension(width, 25)); // ÉèÖÃÊ×Ñ¡³ß´ç textField.setMaximumSize(new Dimension(width, 25)); // ÉèÖÃ×î´ó³ß´ç return textField; // ·µ»ØÎı¾¿ò } // ´´½¨ºìÉ«µ¥Ñ¡°´Å¥ private JRadioButton createRedRadioButton(String text) { JRadioButton radioButton = new JRadioButton(text); // ´´½¨µ¥Ñ¡°´Å¥ // Ìí¼Ó״̬±ä»¯¼àÌýÆ÷ radioButton.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { // Ñ¡ÖÐ״̬ radioButton.setForeground(Color.RED); // ÉèÖúìÉ«ÎÄ×Ö } else { // δѡÖÐ״̬ radioButton.setForeground(Color.BLACK); // ÉèÖúÚÉ«ÎÄ×Ö } } }); return radioButton; // ·µ»Øµ¥Ñ¡°´Å¥ } // Ìí¼Ó´ø±êÇ©µÄÎı¾¿òµ½Ãæ°å private void addTextField(JPanel panel, String label, JTextField textField) { panel.add(new JLabel(label + ":")); // Ìí¼Ó±êÇ© panel.add(textField); // Ìí¼ÓÎı¾¿ò } // Ìí¼Óµ¥Ñ¡°´Å¥×éµ½Ãæ°å private void addRadioGroup(JPanel panel, String label, JRadioButton option1, JRadioButton option2) { panel.add(new JLabel(label + ":")); // Ìí¼Ó±êÇ© JPanel radioGroupPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // ×ó¶ÔÆëÃæ°å ButtonGroup group = new ButtonGroup(); // ´´½¨°´Å¥×é group.add(option1); // Ìí¼ÓÑ¡Ïî1 group.add(option2); // Ìí¼ÓÑ¡Ïî2 radioGroupPanel.add(option1); // Ìí¼Óµ½Ãæ°å radioGroupPanel.add(option2); // Ìí¼Óµ½Ãæ°å panel.add(radioGroupPanel); // Ìí¼Óµ¥Ñ¡×éÃæ°å } // ¼ÓÔØ¹«Ë¾Êý¾Ý private void loadCompanyData() { String[] companyNames = Dell_company.getAllCompanyNames(); // »ñÈ¡ËùÓй«Ë¾Ãû for (String name : companyNames) { // ±éÀú¹«Ë¾Ãû companyComboBox.addItem(name); // Ìí¼Óµ½ÏÂÀ­¿ò } } // ¼ÓÔØËã·¨Êý¾Ý private void loadAlgorithmData() { try { // »ñÈ¡µÚÒ»¸öËã·¨ÅäÖà currentAlgorithm = Dell_GeneralAlgorithm.getAllGeneralAlgorithms().get(0); fillFormWithData(currentAlgorithm); // Ìî³ä±íµ¥Êý¾Ý } catch (SQLException | IndexOutOfBoundsException ex) { // ²¶»ñÒì³£ JOptionPane.showMessageDialog(this, getMessage("DATA_LOAD_ERROR") + ": " + ex.getMessage(), getMessage("ERROR"), JOptionPane.ERROR_MESSAGE); // ÏÔʾ´íÎóÏûÏ¢ } } // ÓÃËã·¨Êý¾ÝÌî³ä±íµ¥ private void fillFormWithData(GeneralAlgorithm algorithm) { companyComboBox.setSelectedItem(algorithm.getCompany()); // ÉèÖÃÑ¡Öй«Ë¾ satelliteSignalFilterField.setText(algorithm.getSatelliteSignalFilterValue()); // ÉèÖÃÎÀÐÇÐźŹýÂËÖµ positionFilterField.setText(algorithm.getPositionFilterValue()); // ÉèÖÃλÖùýÂËÖµ closeUwbConditionField.setText(algorithm.getCloseUwbCondition()); // ÉèÖùرÕUWBÌõ¼þ staticFilterField.setText(algorithm.getStaticFilterValue()); // ÉèÖþ²Ì¬¹ýÂËÖµ systemMaxSpeedField.setText(algorithm.getSystemMaxSpeed()); // ÉèÖÃϵͳ×î´óËÙ¶È maxRepeatRangingField.setText(algorithm.getMaxRepeatRanging()); // ÉèÖÃ×î´óÖØ¸´²â¾à filterLevelField.setText(algorithm.getFilterLevel()); // ÉèÖùýÂ˼¶±ð // ÉèÖõ¥Ñ¡°´Å¥×´Ì¬ setRadioState(gnssToXyEnabled, gnssToXyDisabled, algorithm.getGnssToXy()); setRadioState(areaJudgeIndoorEnabled, areaJudgeIndoorDisabled, algorithm.getAreaJudgeIndoor()); setRadioState(distanceJudgeIndoorEnabled, distanceJudgeIndoorDisabled, algorithm.getDistanceJudgeIndoor()); setRadioState(satelliteSignalJudgeIndoorEnabled, satelliteSignalJudgeIndoorDisabled, algorithm.getSatelliteSignalJudgeIndoor()); setRadioState(blurPositionCalculationEnabled, blurPositionCalculationDisabled, algorithm.getBlurPositionCalculation()); setRadioState(judge0dByPositionEnabled, judge0dByPositionDisabled, algorithm.getJudge0dByPosition()); // ÉèÖÃʱ϶·ÖÅäģʽ if ("1".equals(algorithm.getTimeSlotAllocation())) { // »ìºÏģʽ timeSlotAllocationMix.setSelected(true); } else { // ¼ä¸ôģʽ timeSlotAllocationGap.setSelected(true); } // ÉèÖùýÂËËã·¨ if ("1".equals(algorithm.getFilterAlgorithm())) { // µÍͨÂ˲¨ filterAlgorithmLowPass.setSelected(true); } else { // »¬¶¯Â˲¨ filterAlgorithmSliding.setSelected(true); } // ÉèÖÃÐÞ¸Äʱ¼ä timeField.setText(algorithm.getModifyTime()); } // ÉèÖõ¥Ñ¡°´Å¥×´Ì¬ºÍÑÕÉ« private void setRadioState(JRadioButton enabled, JRadioButton disabled, String value) { if ("1".equals(value)) { // ÆôÓÃ״̬ enabled.setSelected(true); // Ñ¡ÖÐÆôÓð´Å¥ enabled.setForeground(Color.RED); // ÉèÖúìÉ«ÎÄ×Ö } else { // ½ûÓÃ״̬ disabled.setSelected(true); // Ñ¡ÖнûÓð´Å¥ disabled.setForeground(Color.RED); // ÉèÖúìÉ«ÎÄ×Ö } } // Ìí¼Óʼþ¼àÌýÆ÷ private void addEventListeners() { saveButton.addActionListener(e -> saveAlgorithm()); // ±£´æ°´Å¥Ê¼þ cancelButton.addActionListener(e -> resetForm()); // È¡Ïû°´Å¥Ê¼þ } // ±£´æËã·¨ÅäÖà private void saveAlgorithm() { GeneralAlgorithm algorithm = new GeneralAlgorithm(); // ´´½¨Ëã·¨¶ÔÏó algorithm.setCompany((String) companyComboBox.getSelectedItem()); // ÉèÖù«Ë¾ algorithm.setSatelliteSignalFilterValue(satelliteSignalFilterField.getText()); // ÉèÖÃÎÀÐÇÐźŹýÂË algorithm.setPositionFilterValue(positionFilterField.getText()); // ÉèÖÃλÖùýÂË algorithm.setCloseUwbCondition(closeUwbConditionField.getText()); // ÉèÖùرÕUWBÌõ¼þ algorithm.setStaticFilterValue(staticFilterField.getText()); // ÉèÖþ²Ì¬¹ýÂË algorithm.setSystemMaxSpeed(systemMaxSpeedField.getText()); // ÉèÖÃϵͳ×î´óËÙ¶È algorithm.setMaxRepeatRanging(maxRepeatRangingField.getText()); // ÉèÖÃ×î´óÖØ¸´²â¾à algorithm.setFilterLevel(filterLevelField.getText()); // ÉèÖùýÂ˼¶±ð // ÉèÖõ¥Ñ¡°´Å¥Öµ algorithm.setGnssToXy(getRadioValue(gnssToXyEnabled)); algorithm.setAreaJudgeIndoor(getRadioValue(areaJudgeIndoorEnabled)); algorithm.setDistanceJudgeIndoor(getRadioValue(distanceJudgeIndoorEnabled)); algorithm.setSatelliteSignalJudgeIndoor(getRadioValue(satelliteSignalJudgeIndoorEnabled)); algorithm.setBlurPositionCalculation(getRadioValue(blurPositionCalculationEnabled)); algorithm.setJudge0dByPosition(getRadioValue(judge0dByPositionEnabled)); // ÉèÖÃʱ϶·ÖÅäģʽ algorithm.setTimeSlotAllocation(timeSlotAllocationMix.isSelected() ? "1" : "0"); // ÉèÖùýÂËËã·¨ algorithm.setFilterAlgorithm(filterAlgorithmLowPass.isSelected() ? "1" : "2"); // ÉèÖõ±Ç°Ê±¼ä SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // ÈÕÆÚ¸ñʽ algorithm.setModifyTime(sdf.format(new Date())); // ¸ñʽ»¯µ±Ç°Ê±¼ä // ±£´æµ½Êý¾Ý¿â if (saveAlgorithmToDatabase(algorithm)) { // ±£´æ³É¹¦ currentAlgorithm = algorithm; // ¸üе±Ç°Ëã·¨ JOptionPane.showMessageDialog(this, getMessage("SAVE_SUCCESS"), getMessage("SUCCESS"), JOptionPane.INFORMATION_MESSAGE); // ÏÔʾ³É¹¦ÏûÏ¢ } } // »ñÈ¡µ¥Ñ¡°´Å¥Öµ private String getRadioValue(JRadioButton enabled) { return enabled.isSelected() ? "1" : "0"; // Ñ¡Öзµ»Ø1£¬·ñÔò·µ»Ø0 } // ÖØÖÃ±íµ¥ private void resetForm() { if (currentAlgorithm != null) { // µ±Ç°Ëã·¨´æÔÚ fillFormWithData(currentAlgorithm); // ÖØÐÂÌî³ä±íµ¥ } } // ±£´æËã·¨µ½Êý¾Ý¿â private boolean saveAlgorithmToDatabase(GeneralAlgorithm algorithm) { try { // ´´½¨×Ö¶ÎÓ³Éä Map fieldValues = new HashMap<>(); fieldValues.put("company", algorithm.getCompany()); fieldValues.put("satellite_signal_filter_value", algorithm.getSatelliteSignalFilterValue()); fieldValues.put("position_filter_value", algorithm.getPositionFilterValue()); fieldValues.put("close_uwb_condition", algorithm.getCloseUwbCondition()); fieldValues.put("static_filter_value", algorithm.getStaticFilterValue()); fieldValues.put("system_max_speed", algorithm.getSystemMaxSpeed()); fieldValues.put("max_repeat_ranging", algorithm.getMaxRepeatRanging()); fieldValues.put("filter_level", algorithm.getFilterLevel()); fieldValues.put("gnss_to_xy", algorithm.getGnssToXy()); fieldValues.put("area_judge_indoor", algorithm.getAreaJudgeIndoor()); fieldValues.put("distance_judge_indoor", algorithm.getDistanceJudgeIndoor()); fieldValues.put("satellite_signal_judge_indoor", algorithm.getSatelliteSignalJudgeIndoor()); fieldValues.put("blur_position_calculation", algorithm.getBlurPositionCalculation()); fieldValues.put("time_slot_allocation", algorithm.getTimeSlotAllocation()); fieldValues.put("filter_algorithm", algorithm.getFilterAlgorithm()); fieldValues.put("judge_0d_by_position", algorithm.getJudge0dByPosition()); fieldValues.put("modify_time", algorithm.getModifyTime()); // ¸üÐÂÊý¾Ý¿â int result = DBConnector.updateData("general_algorithm", fieldValues, 1); if (result > 0) { // ¸üгɹ¦ return true; } else { // ¸üÐÂʧ°Ü JOptionPane.showMessageDialog(this, getMessage("SAVE_FAILED"), getMessage("ERROR"), JOptionPane.ERROR_MESSAGE); return false; } } catch (Exception ex) { // ²¶»ñÒì³£ JOptionPane.showMessageDialog(this, getMessage("SAVE_FAILED") + ": " + ex.getMessage(), getMessage("ERROR"), JOptionPane.ERROR_MESSAGE); return false; } } // »ñÈ¡±¾µØ»¯ÏûÏ¢ private String getMessage(String key) { try { return messages.getString(key); // ·µ»Ø¼ü¶ÔÓ¦µÄÖµ } catch (Exception e) { // Òì³£´¦Àí return "[" + key + "]"; // ·µ»Ø¼üÃû(·½À¨ºÅ°ü¹ü) } } }