/**
   * Set form data to the editor
   *
   * @return false if there is any problem
   */
  public boolean setForm2Editor() {
    IpssLogger.getLogger().info("NBFaultLocDataPanel setForm2Editor() called");

    if (xmlFaultData.getFaultType() == AcscFaultTypeEnumType.BUS_FAULT) {

    } else {
      AcscBranchFaultXmlType braFault = (AcscBranchFaultXmlType) xmlFaultData;
      reclosureCheckBox.setSelected(
          braFault.isBranchReclosure() != null && braFault.isBranchReclosure());
      branchReclosureCheckboxActionPerformed(null);
      atReclosureTimeTextField.setText(
          Number2String.toStr(braFault.getReclosureTime().getValue(), "0.00"));

      if (this.distanceTextField.isEnabled()) {
        this.distanceTextField.setText(Number2String.toStr(braFault.getDistance(), "#0.##"));
      }
    }

    if (xmlFaultData.getFaultCategory() == AcscFaultCategoryEnumType.FAULT_3_PHASE)
      this.type3PRadioButton.setSelected(true);
    else if (xmlFaultData.getFaultCategory() == AcscFaultCategoryEnumType.LINE_TO_GROUND)
      this.typeLGRadioButton.setSelected(true);
    else if (xmlFaultData.getFaultCategory() == AcscFaultCategoryEnumType.LINE_TO_LINE)
      this.typeLLRadioButton.setSelected(true);
    else if (xmlFaultData.getFaultCategory() == AcscFaultCategoryEnumType.LINE_LINE_TO_GROUND)
      this.typeLLGRadioButton.setSelected(true);
    else this.typeAllRadioButton.setSelected(true);

    setLabelText();

    if (this.rLGTextField.isEnabled()) {
      double r = 0.0, i = 0.0;
      if (xmlFaultData.getZLG() != null) {
        r = xmlFaultData.getZLG().getRe();
        i = xmlFaultData.getZLG().getIm();
      }
      this.rLGTextField.setText(Number2String.toStr(r, "#0.0000"));
      this.xLGTextField.setText(Number2String.toStr(i, "#0.0000"));
    }

    if (this.rLLTextField.isEnabled()) {
      double r = 0.0, i = 0.0;
      if (xmlFaultData.getZLL() != null) {
        r = xmlFaultData.getZLL().getRe();
        i = xmlFaultData.getZLL().getIm();
      }
      this.rLLTextField.setText(Number2String.toStr(r, "#0.0000"));
      this.xLLTextField.setText(Number2String.toStr(i, "#0.0000"));
    }

    return true;
  }
  /**
   * Save editor screen data to the form
   *
   * @param errMsg error messages during the saving process.
   * @return false if there is any problem
   */
  public boolean saveEditor2Form(Vector<String> errMsg) throws Exception {
    IpssLogger.getLogger().info("NBFaultLocDataPanel saveEditor2Form() called");

    boolean ok = true;

    if (xmlFaultData.getFaultType() == AcscFaultTypeEnumType.BUS_FAULT) {
      String id = (String) this.faultBusComboBox.getSelectedItem();

      AcscBusFaultXmlType busFault = (AcscBusFaultXmlType) xmlFaultData;
      busFault.getRefBus().setBusId(id);
    } else {
      String id = (String) this.faultBranchComboBox.getSelectedItem();
      AcscBranchFaultXmlType braFault = (AcscBranchFaultXmlType) xmlFaultData;
      braFault.getRefBranch().setBranchId(id);
      // TODO  setBranch fromId, toId, cirId

      braFault.setBranchReclosure(reclosureCheckBox.isSelected());
      if (reclosureCheckBox.isSelected()) {
        if (!SwingInputVerifyUtil.largeThan(this.atReclosureTimeTextField, 0.0d)) {
          errMsg.add("Branch reclosure at Time <= 0.0");
          ok = false;
        }
        braFault
            .getReclosureTime()
            .setValue((SwingInputVerifyUtil.getDouble(this.atReclosureTimeTextField)));
        braFault.getReclosureTime().setUnit(TimePeriodUnitType.SEC);
      }

      if (this.distanceTextField.isEnabled()) {
        if (!SwingInputVerifyUtil.largeEqualThan(this.distanceTextField, 0.0d)) {
          errMsg.add("Branch fault distance < 0.0");
          ok = false;
        }
        braFault.setDistance(SwingInputVerifyUtil.getDouble(this.distanceTextField));
      }
    }

    if (this.type3PRadioButton.isSelected())
      xmlFaultData.setFaultCategory(AcscFaultCategoryEnumType.FAULT_3_PHASE);
    else if (this.typeLGRadioButton.isSelected())
      xmlFaultData.setFaultCategory(AcscFaultCategoryEnumType.LINE_TO_GROUND);
    else if (this.typeLLRadioButton.isSelected())
      xmlFaultData.setFaultCategory(AcscFaultCategoryEnumType.LINE_TO_LINE);
    else if (this.typeLLGRadioButton.isSelected())
      xmlFaultData.setFaultCategory(AcscFaultCategoryEnumType.LINE_LINE_TO_GROUND);

    if (this.rLGTextField.isEnabled()) {
      if (!SwingInputVerifyUtil.largeEqualThan(this.rLGTextField, 0.0d)) {
        errMsg.add("Fault L-G R < 0.0");
        ok = false;
      }
      xmlFaultData.getZLG().setRe(SwingInputVerifyUtil.getDouble(this.rLGTextField));
    }

    if (this.xLGTextField.isEnabled()) {
      if (!SwingInputVerifyUtil.largeEqualThan(this.xLGTextField, 0.0d)) {
        errMsg.add("Fault L-G X < 0.0");
        ok = false;
      }
      xmlFaultData.getZLG().setIm(SwingInputVerifyUtil.getDouble(this.xLGTextField));
    }

    if (this.rLLTextField.isEnabled()) {
      if (!SwingInputVerifyUtil.largeEqualThan(this.rLLTextField, 0.0d)) {
        errMsg.add("Fault L-L R < 0.0");
        ok = false;
      }
      xmlFaultData.getZLL().setRe(SwingInputVerifyUtil.getDouble(this.rLLTextField));
    }

    if (this.xLLTextField.isEnabled()) {
      if (!SwingInputVerifyUtil.largeEqualThan(this.xLLTextField, 0.0d)) {
        errMsg.add("Fault L-L X < 0.0");
        ok = false;
      }
      xmlFaultData.getZLL().setIm(SwingInputVerifyUtil.getDouble(this.xLLTextField));
    }

    return ok;
  }