예제 #1
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;
  }