Ejemplo n.º 1
0
  public void setData(String[] data) {
    final int baseName = 12;
    final int basePrice = baseName + Constants.NO_OF_EXTRAS_IN_UI;
    final int basePriceValue = basePrice + Constants.NO_OF_EXTRAS_IN_UI;
    tbKeyId.setText(data[0]);
    String imageKey = data[1];
    if (imageKey != null) {
      imgItem.setUrl(GWT.getHostPageBaseURL() + "serveBlob?id=" + data[1]);
      imgItem.setVisible(true);
    }
    tbName.setText(data[2]);
    taDescription.setText(data[3]);
    editingExistingData = true;
    if (data[4] != null) {
      rbSinglePrice.setValue(true);
      rbSinglePrice.setFormValue("single");
      dbSinglePrice.setValue(Double.parseDouble(data[basePriceValue]));
    } else {
      rbMultiplePrice.setValue(true);
      rbMultiplePrice.setFormValue("multiple");
      if (data[5] != null) {
        cbSmall.setValue(true);
        dbSmallPrice.setValue(Double.parseDouble(data[basePriceValue + 1]));
      }
      if (data[6] != null) {
        cbMedium.setValue(true);
        dbMediumPrice.setValue(Double.parseDouble(data[basePriceValue + 2]));
      }
      if (data[7] != null) {
        cbLarge.setValue(true);
        dbLargePrice.setValue(Double.parseDouble(data[basePriceValue + 3]));
      }
      if (data[8] != null) {
        cbTapa.setValue(true);
        dbTapaPrice.setValue(Double.parseDouble(data[basePriceValue + 4]));
      }
      if (data[9] != null) {
        cbHalf.setValue(true);
        dbHalfPrice.setValue(Double.parseDouble(data[basePriceValue + 5]));
      }
      if (data[10] != null) {
        cbFull.setValue(true);
        dbFullPrice.setValue(Double.parseDouble(data[basePriceValue + 6]));
      }
    }
    if (data[11] != null) {
      tbExtrasName.setText(data[11]);
    }

    for (int i = 0; i < Constants.NO_OF_EXTRAS_IN_UI; i++) {
      String name = data[baseName + i];
      if (name != null) {
        tbExtras[i].setText(name);
        tbExtrasPrices[i].setText(data[basePrice + i]);
      }
    }
  }
Ejemplo n.º 2
0
 private void fixPriceFormat(DoubleBox dbPrice) {
   dbPrice.setText(dbPrice.getText().replaceAll(",", "."));
 }
Ejemplo n.º 3
0
  private boolean validate() {
    boolean result = true;
    String description = taDescription.getText();
    String name = tbName.getText();
    String imageFile = fuImageFile.getFilename();
    if (rbSinglePrice.getValue()) {
      fixPriceFormat(dbSinglePrice);
      if (dbSinglePrice.getValue() == null) {
        Window.alert("El precio introducido no es válido");
        result = false;
      }
    } else {
      boolean oneChecked = false;
      if (cbSmall.getValue()) {
        oneChecked = true;
        fixPriceFormat(dbSmallPrice);
        if (dbSmallPrice.getValue() == null) {
          Window.alert("El precio introducido para 'Pequeña' no es válido");
          result = false;
        }
      }
      if (result && cbMedium.getValue()) {
        oneChecked = true;
        fixPriceFormat(dbMediumPrice);
        if (dbMediumPrice.getValue() == null) {
          Window.alert("El precio introducido para 'Mediana' no es válido");
          result = false;
        }
      }
      if (result && cbLarge.getValue()) {
        oneChecked = true;
        fixPriceFormat(dbLargePrice);
        if (dbLargePrice.getValue() == null) {
          Window.alert("El precio introducido para 'Grande' no es válido");
          result = false;
        }
      }
      if (result && cbTapa.getValue()) {
        oneChecked = true;
        fixPriceFormat(dbTapaPrice);
        if (dbTapaPrice.getValue() == null) {
          Window.alert("El precio introducido para 'Tapa' no es válido");
          result = false;
        }
      }
      if (result && cbHalf.getValue()) {
        oneChecked = true;
        fixPriceFormat(dbHalfPrice);
        if (dbHalfPrice.getValue() == null) {
          Window.alert("El precio introducido para '1/2 Ración' no es válido");
          result = false;
        }
      }
      if (result && cbFull.getValue()) {
        oneChecked = true;
        fixPriceFormat(dbFullPrice);
        if (dbFullPrice.getValue() == null) {
          Window.alert("El precio introducido para 'Ración' no es válido");
          result = false;
        }
      }
    }

    if (result) {
      if (name == null || name.length() == 0) {
        Window.alert("Por favor, introduzca el nombre");
        result = false;
      }
    }
    return result;
  }