Ejemplo n.º 1
0
  @Override
  public void deleteButtonClick(EditionToolbar.ClickNavigationEvent event) {
    final Calendar editingCalendar = (Calendar) event.getRegister();

    ConfirmDialog.show(
        getWindow(),
        "Borrar Calendario",
        "¿Estás seguro?",
        "Si",
        "No",
        new ConfirmDialog.Listener() {

          public void onClose(ConfirmDialog dialog) {
            if (dialog.isConfirmed()) {
              try {
                calendarService.delete(editingCalendar);

                bsCalendar.removeItem(editingCalendar);
              } catch (IllegalArgumentException e) {
                throw new RuntimeException("¡No se pudo borrar el calendario!", e);
              } catch (Exception e) {
                throw new RuntimeException("¡No se pudo borrar el calendario!", e);
              }
            }
          }
        });
  }
Ejemplo n.º 2
0
  @Override
  public void editButtonClick(EditionToolbar.ClickNavigationEvent event) {
    Calendar editingCalendar = (Calendar) event.getRegister();

    try {
      @SuppressWarnings("unused")
      WindowDialog<Calendar> windowDialog =
          new WindowDialog<Calendar>(
              getApplication().getMainWindow(),
              "Editor Calendario",
              "Guardar",
              DialogResult.SAVE,
              "Cancelar",
              DialogResult.CANCEL,
              new CalendarViewForm(),
              editingCalendar,
              new WindowDialog.CloseWindowDialogListener<Calendar>() {
                public void windowDialogClose(
                    WindowDialog<Calendar>.CloseWindowDialogEvent<Calendar> event) {
                  if (event.getDialogResult() != WindowDialog.DialogResult.SAVE) return;

                  try {

                    Calendar savingCalendar = event.getDomainEntity();

                    Calendar savedCalendar = calendarService.save(savingCalendar);

                    refreshDataGridView(savedCalendar);
                  } catch (Exception e) {
                    throw new RuntimeException("¡No se pudo modificar el calendario!", e);
                  }
                }
              });
    } catch (IllegalArgumentException e) {
      throw new RuntimeException("¡No se pudo abrir el formulario Editor Calendario!", e);
    } catch (Exception e) {
      throw new RuntimeException("¡No se pudo abrir el formulario Editor Calendario!", e);
    }
  }