Example #1
0
  public ConfigPanel(Step2Module step2Module) throws Exception {

    this.step2Module = step2Module;
    this.GC = step2Module.getGC();
    this.setName(step2Module.getName());
    this.setLayout(new BorderLayout(5, 5));
    addComponents();

    addListeners();
  }
Example #2
0
  private void addListeners() {
    for (int i = 0; i < algorithmChooseRadioButtons.size(); i++) {
      JRadioButton button = algorithmChooseRadioButtons.get(i);
      button.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              if (e.getStateChange() == ItemEvent.SELECTED) {
                step2Module.setHcsAlgm(map.get(e.getSource()));
                JPanel p = step2Module.getHcsAlgm().getAlgorithmConfigPanel();
                algmConfigPanel.removeAll();
                algmConfigPanel.add(p);
              }
            }
          });
      if (i == 0) {
        button.doClick();
        algmConfigPanel.removeAll();
        step2Module.setHcsAlgm(map.get(button));
        algmConfigPanel.add(step2Module.getHcsAlgm().getAlgorithmConfigPanel());
      }
    }
    apply.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < algorithmChooseRadioButtons.size(); i++) {
              JRadioButton button = algorithmChooseRadioButtons.get(i);
              if (button.isSelected()) {
                JPanel algmConfigPanel = algms.get(i).getAlgorithmConfigPanel();
                if (algmConfigPanel instanceof PickAlgorithmConfigPanel) {
                  PickAlgorithmConfigPanel pacPanel = (PickAlgorithmConfigPanel) algmConfigPanel;
                  PickAlgorithm palgm = pacPanel.getAlgorithm();

                  palgm.setAlgorithm_selected(true);

                  palgm.setCondition_number_value(pacPanel.getCondition_number_value());

                  // palgm.setGuaranteed_loan_balance_floor_selected(
                  // pacPanel.isGuaranteed_loan_balance_floor_selected());
                  palgm.setGuaranteed_loan_balance_floor_unit(
                      pacPanel.getGuaranteed_loan_balance_floor_unit());
                  palgm.setGuaranteed_loan_balance_floor_value(
                      pacPanel.getGuaranteed_loan_balance_floor_value());
                  palgm.setOut_Guaranteed_loan_balance_floor_unit(
                      pacPanel.getGuaranteed_loan_balance_floor_unit());
                  palgm.setOut_Guaranteed_loan_balance_floor_value(
                      pacPanel.getGuaranteed_loan_balance_floor_value());

                  palgm.setGuarantor_floor_selected(pacPanel.isGuarantorFloorSelected());
                  palgm.setOut_guarantor_floor_selected(pacPanel.isOutGuarantorFloorSelected());
                  palgm.setGuarantor_floor_value(pacPanel.getGuarantorFloor());
                  palgm.setOut_Guarantor_floor_value(pacPanel.getOutGuarantorFloor());

                  palgm.setLoan_balance_floor_selected(pacPanel.isLoanBalanceFloorSelected());
                  palgm.setLoan_balance_floor_unit(pacPanel.getLoanBalanceFloorUnit());
                  palgm.setLoan_balance_floor_value(pacPanel.getLoanBalanceFloor());

                  palgm.setMutually_guaranteed_floor_selected(
                      pacPanel.isMutuallyGuarantorFloorSelected());
                  palgm.setMutually_guaranteed_floor_value(pacPanel.getMutuallyGuarantorFloor());

                  palgm.setOne_hand_vertex_all(pacPanel.isOne_hand_vertex_all_selected());
                  palgm.setOne_hand_vertex_in_only(pacPanel.isOne_hand_vertex_in_only_selected());
                  palgm.setOne_hand_vertex_none(pacPanel.isOne_hand_vertex_none_selected());

                  palgm.setTwo_hand_vertex_all(pacPanel.isTwo_hand_vertex_all_selected());
                  palgm.setTwo_hand_vertex_in_only(pacPanel.isTwo_hand_vertex_in_only_selected());
                  palgm.setTwo_hand_vertex_none(pacPanel.isTwo_hand_vertex_none_selected());

                  palgm.setThree_hand_vertex_all(pacPanel.isThree_hand_vertex_all_selected());
                  palgm.setThree_hand_vertex_in_only(
                      pacPanel.isThree_hand_vertex_in_only_selected());
                  palgm.setThree_hand_vertex_none(pacPanel.isThree_hand_vertex_none_selected());

                  palgm.setPick_corecorp_loop(pacPanel.isPickCorecorpLoopSelected());
                  palgm.setPick_mutually_guaranteed_corp(
                      pacPanel.isPickMutuallyGuaranteedCorpSelected());
                  palgm.setUnpick_corecorp_son(pacPanel.isUnpickCorecorpSonSelected());

                  GCClassify gcClassify = gcClassifyConfigPanel.getGcClassify();
                  gcClassify.setLoan_balance_floor(gcClassifyConfigPanel.getLoan_balance_floor());
                  gcClassify.setLoan_balance_ceiling(
                      gcClassifyConfigPanel.getLoan_balance_ceiling());

                  try {
                    palgm.updateConfigCache();
                    gcClassify.updateConfigCache();
                    rdaConfigPanel.updateConfigCache();
                    boolean sucess = Config.saveDoc();

                    if (sucess) {
                      JOptionPane.showMessageDialog(
                          ConfigPanel.this, successMessage, "提示", JOptionPane.INFORMATION_MESSAGE);
                      InfoPane.getInstance().info(successMessage);
                    }
                  } catch (Exception e1) {
                    JOptionPane.showMessageDialog(
                        ConfigPanel.this,
                        "应用配置成功,但保存配置时出错,不影响下一步继续进行。",
                        "警告",
                        JOptionPane.WARNING_MESSAGE);
                  } finally {
                    Module.gotoStep(3);
                  }
                }
              }
            }
          }
        });
  }