/**
   * Update the protein table according to the protein inference selection.
   *
   * @param evt
   */
  private void okButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okButtonActionPerformed

    PSParameter psParameter = new PSParameter();

    try {
      psParameter =
          (PSParameter)
              identification.getProteinMatchParameter(inspectedMatch.getKey(), psParameter);
    } catch (Exception e) {
      peptideShakerGUI.catchException(e);
      this.dispose();
      return;
    }
    if (!inspectedMatch.getMainMatch().equals(previousMainMatch)
        || groupClassJComboBox.getSelectedIndex() != psParameter.getGroupClass()) {
      try {
        psParameter.setGroupClass(groupClassJComboBox.getSelectedIndex());
        identification.updateProteinMatchParameter(inspectedMatch.getKey(), psParameter);
        peptideShakerGUI.updateMainMatch(
            inspectedMatch.getMainMatch(), groupClassJComboBox.getSelectedIndex());
      } catch (Exception e) {
        peptideShakerGUI.catchException(e);
      }
      peptideShakerGUI.setDataSaved(false);
    }
    this.dispose();
  } // GEN-LAST:event_okButtonActionPerformed
    @Override
    public Object getValueAt(int row, int column) {

      PSParameter pSParameter = new PSParameter();
      try {
        pSParameter =
            (PSParameter)
                identification.getProteinMatchParameter(associatedMatches.get(row), pSParameter);
      } catch (Exception e) {
        peptideShakerGUI.catchException(e);
      }
      switch (column) {
        case 0:
          return (row + 1);
        case 1:
          return peptideShakerGUI
              .getIdentificationFeaturesGenerator()
              .addDatabaseLinks(
                  new ArrayList<String>(
                      Arrays.asList(ProteinMatch.getAccessions(associatedMatches.get(row)))));
        case 2:
          return pSParameter.getProteinScore();
        case 3:
          return pSParameter.getProteinConfidence();
        case 4:
          return pSParameter.isValidated();
        default:
          return "";
      }
    }
  /**
   * Creates new form ProteinInferenceDialog.
   *
   * @param peptideShakerGUI
   * @param inspectedMatch
   * @param identification
   */
  public ProteinInferenceDialog(
      PeptideShakerGUI peptideShakerGUI, String inspectedMatch, Identification identification) {
    super(peptideShakerGUI, true);
    this.identification = identification;
    this.peptideShakerGUI = peptideShakerGUI;

    try {
      this.inspectedMatch = identification.getProteinMatch(inspectedMatch);
      previousMainMatch = this.inspectedMatch.getMainMatch();
    } catch (Exception e) {
      peptideShakerGUI.catchException(e);
      this.dispose();
    }

    accessions = new ArrayList(Arrays.asList(ProteinMatch.getAccessions(inspectedMatch)));

    for (String proteinAccession : accessions) {
      if (identification.getProteinIdentification().contains(proteinAccession)) {
        uniqueMatches.add(proteinAccession);
      }
    }

    for (String proteinKey : identification.getProteinIdentification()) {
      if (ProteinMatch.getNProteins(proteinKey) > 1
          && !associatedMatches.contains(proteinKey)
          && !proteinKey.equals(inspectedMatch)) {
        for (String proteinAccession : accessions) {
          if (proteinKey.contains(proteinAccession)) {
            associatedMatches.add(proteinKey);
            break;
          }
        }
      }
    }

    initComponents();

    // make sure that the scroll panes are see-through
    proteinMatchJScrollPane.getViewport().setOpaque(false);
    uniqueHitsJScrollPane.getViewport().setOpaque(false);
    relatedHitsJScrollPane.getViewport().setOpaque(false);

    groupClassJComboBox.setRenderer(new AlignedListCellRenderer(SwingConstants.CENTER));

    PSParameter psParameter = new PSParameter();
    try {
      psParameter =
          (PSParameter) identification.getProteinMatchParameter(inspectedMatch, psParameter);
    } catch (Exception e) {
      peptideShakerGUI.catchException(e);
    }
    matchInfoLbl.setText(
        "[Score: "
            + Util.roundDouble(psParameter.getProteinScore(), 2)
            + ", Confidence: "
            + Util.roundDouble(psParameter.getProteinConfidence(), 2)
            + "]");

    // set up the table column properties
    setColumnProperies();

    // The index should be set in the design according to the PSParameter class static fields!
    groupClassJComboBox.setSelectedIndex(psParameter.getGroupClass());

    setLocationRelativeTo(peptideShakerGUI);
    setVisible(true);
  }