/**
   * Converting ResultObject into text for preview according to checkboxes.
   *
   * @return String for preview
   */
  private String resultToText() {
    String resultString = "";

    // Adding column names:
    if (typeTB.getValue()) {
      resultString += "MoleculeType\t";
    }

    if (identifierTB.getValue()) {
      resultString += "Identifier\t";
    }

    if (nameTB.getValue()) {
      resultString += "MoleculeName\t";
    }

    // Adding line break in case there are column names
    if (resultString.length() > 0) {
      resultString += "\n";
    }

    resultString +=
        buildGroupString(chemTB, result.getChemicals(), PropertyType.CHEMICAL_COMPOUNDS.getTitle());
    resultString +=
        buildGroupString(protTB, result.getProteins(), PropertyType.PROTEINS.getTitle());
    resultString +=
        buildGroupString(sequTB, result.getSequences(), PropertyType.SEQUENCES.getTitle());
    resultString += buildGroupString(otheTB, result.getOthers(), PropertyType.OTHERS.getTitle());

    return resultString;
  }
  public MoleculesDownloadPanel(Result result, MoleculesTab.Presenter presenter) {
    super(Style.Unit.PX);
    this.result = result;
    this.presenter = presenter;
    this.setWidth("99%");
    this.textArea = new TextArea();

    // Initialising and setting all the currently available checkboxes.
    chemTB = new CheckBox(PropertyType.CHEMICAL_COMPOUNDS.getTitle());
    chemTB.setTitle("Show or hide " + PropertyType.CHEMICAL_COMPOUNDS.getTitle());
    chemTB.setValue(true);

    protTB = new CheckBox(PropertyType.PROTEINS.getTitle());
    protTB.setTitle("Show or hide " + PropertyType.PROTEINS.getTitle());
    protTB.setValue(true);

    sequTB = new CheckBox(PropertyType.SEQUENCES.getTitle());
    sequTB.setTitle("Show or hide " + PropertyType.SEQUENCES.getTitle());
    sequTB.setValue(true);

    otheTB = new CheckBox(PropertyType.OTHERS.getTitle());
    otheTB.setTitle("Show or hide " + PropertyType.OTHERS.getTitle());
    otheTB.setValue(true);

    typeTB = new CheckBox("Type");
    typeTB.setTitle("Show or hide type column");
    typeTB.setValue(true);

    identifierTB = new CheckBox("Identifier");
    identifierTB.setTitle("Show or hide identifier column");
    identifierTB.setValue(true);

    nameTB = new CheckBox("Name");
    nameTB.setTitle("Show or hide name column");
    nameTB.setValue(true);
  }