private AttributeRights getRightsFromWidgets(
      CheckBox read, CheckBox write, AttributeRights right) {

    right.setRights(read.getValue(), write.getValue());

    return right;
  }
  /**
   * 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;
  }
 @UiHandler("loadButton")
 public void onLoadClicked(SelectEvent event) {
   archiveHandler.onLoad(
       deviceCombo.getValue(),
       getCombineDate(fromDate, fromTime),
       getCombineDate(toDate, toTime),
       !disableFilter.getValue(),
       snapToRoads.getValue(),
       new ArchiveStyle(style));
 }
  @UiHandler("gpxButton")
  public void onGPXClicked(SelectionEvent<Item> event) {
    if (deviceCombo.getValue() == null) {
      new AlertMessageBox(i18n.error(), i18n.errFillFields()).show();
    } else {
      DateTimeFormat jsonTimeFormat =
          ApplicationContext.getInstance().getFormatterUtil().getRequestTimeFormat();

      Window.open(
          "/traccar/export/gpx"
              + "?deviceId="
              + (deviceCombo.getValue() == null ? null : deviceCombo.getValue().getId())
              + "&from="
              + jsonTimeFormat.format(getCombineDate(fromDate, fromTime)).replaceFirst("\\+", "%2B")
              + "&to="
              + jsonTimeFormat.format(getCombineDate(toDate, toTime)).replaceFirst("\\+", "%2B")
              + "&filter="
              + !disableFilter.getValue()
              + "&snapToRoads="
              + snapToRoads.getValue(),
          "_blank",
          null);
    }
  }
  /**
   * Converting HashSet<Molecule> for one PropertyType into text taking into account checked boxes.
   *
   * @param checkbox If not checked then this type of molecules does not need to be considered.
   * @param molecules List of molecules that has to be turned into a string.
   * @param string PropertyType as string (to be attached in front of every line)
   * @return String resultString
   */
  private String buildGroupString(CheckBox checkbox, HashSet<Molecule> molecules, String string) {
    String resultString = "";
    if (checkbox != null && checkbox.getValue()) {
      for (Molecule m : molecules) {
        if (m.isToHighlight()) {
          if (this.typeTB.getValue()) {
            resultString += string + "\t";
          }

          if (this.identifierTB.getValue()) {
            resultString += m.getIdentifier() + "\t";
          }

          if (this.nameTB.getValue()) {
            resultString += m.getDisplayName() + "\t";
          }

          resultString += "\n";
        }
      }
    }
    return resultString;
  }
  public void testResetEvent() {
    System.out.println("testResetEvent");
    FormPanel form = new FormPanel();
    RootPanel.get().add(form);
    TextBox textBox = new TextBox();
    textBox.setText("Hello World");
    form.setWidget(textBox);

    /*
     *  the following checkbox is not added to the form on purpose
     *  in order to reset it via callback
     */
    final CheckBox checkBox = new CheckBox();
    checkBox.setValue(true);

    /*
     * first test shall not affect the checkbox
     */

    // check preconditions
    assertEquals("Hello World", textBox.getText());
    assertTrue(checkBox.getValue());
    System.out.println("reset: normal");
    form.reset();
    // check postconditions
    assertEquals("", textBox.getText());
    assertTrue(checkBox.getValue());

    /*
     * second test shall affect the checkbox,
     * to this end a ResetHandler is added to to FormPanel which is called on a ResetEvent
     */
    HandlerRegistration handlerRegistration =
        form.addResetHandler(
            new ResetHandler() {

              @Override
              public void onReset(ResetEvent event) {
                checkBox.setValue(false);
              }
            });

    // init preconditions
    textBox.setText("Hello World");
    // check preconditions
    assertEquals("Hello World", textBox.getText());
    assertTrue(checkBox.getValue());
    System.out.println("reset: normal");
    form.reset();
    nativeFormReset(form.getElement());
    // check postconditions
    assertEquals("", textBox.getText());
    assertFalse(checkBox.getValue());

    /*
     * third test shall not affect the checkbox,
     * to this end the ResetHandler is removed from the FormPanel
     */
    handlerRegistration.removeHandler();
    // init preconditions
    textBox.setText("Hello World");
    checkBox.setValue(true);
    // check preconditions
    assertEquals("Hello World", textBox.getText());
    assertTrue(checkBox.getValue());
    System.out.println("reset: normal");
    form.reset();
    // check postconditions
    assertEquals("", textBox.getText());
    assertTrue(checkBox.getValue());

    RootPanel.get().remove(form);
  }
 public Boolean getIsResponseExpected() {
   return expectsAnswerContainer.getValue();
 }