Esempio n. 1
0
  @UiHandler("btnOk")
  void saveChanges(ClickEvent e) {
    if (separator.isVisible()) {
      editMode(false);
    }

    if (removedRecs.size() > 0) {

      final InputItem rec = removedRecs.entrySet().iterator().next().getValue();

      MethodCallback<Void> cb =
          new MethodCallback<Void>() {
            @Override
            public void onFailure(Method method, Throwable exception) {
              askRetry(rec, "Error removing record " + rec.getName() + ". Retry ?");
            }

            @Override
            public void onSuccess(Method method, Void response) {
              removedRecs.remove(rec.getId());
              saveChanges(null);
            }
          };

      md.info(MDS, "Removing record " + rec.getName());
      clientApi.iitemsApi().delete(rec.getId(), cb);

    } else if (changedRecs.size() > 0) {

      final InputItem rec = changedRecs.entrySet().iterator().next().getValue();

      MethodCallback<Void> cb =
          new MethodCallback<Void>() {
            @Override
            public void onFailure(Method method, Throwable exception) {
              askRetry(rec, "Error updating user " + rec.getName() + ". Retry ?");
            }

            @Override
            public void onSuccess(Method method, Void response) {
              changedRecs.remove(rec.getId());
              saveChanges(null);
            }
          };

      if (rec.getId() == 0) {
        md.info(MDS, "Creating user " + rec);
        clientApi.iitemsApi().create(rec, cb);
      } else {
        md.info(MDS, "Updating user " + rec);
        clientApi.iitemsApi().update(rec.getId(), rec, cb);
      }

    } else {
      refreshRecords(e);
      md.clear(MDS);
    }
  }
Esempio n. 2
0
 public static void sendSimpleMessage(String message) {
   // Pop up a text-based message
   if (display != null) {
     if (!awaitingInput) {
       display.showSimpleMessage(message);
     }
   }
 }
Esempio n. 3
0
 public static void sendInterruptingMessage(String message) {
   // Pop up a message which awaits action key input before vanishing
   if (display != null) {
     if (!awaitingInput) {
       display.showInterruptingMessage(message);
       awaitingInput = true;
     }
   }
 }
Esempio n. 4
0
 @UiHandler("btnCancel")
 void cancelChanges(ClickEvent e) {
   recordStore.getList().clear();
   changedRecs.clear();
   removedRecs.clear();
   editMode(false);
   refreshRecords(e);
   md.clear(MDS);
 }
Esempio n. 5
0
 public static void askYesNo(String question, MessageSender theReturnObject) {
   // Ask a yes/no question
   if (display != null) {
     if (!awaitingInput) {
       display.askYesNo(question);
       awaitingInput = true;
       returnObject = theReturnObject;
     }
   }
 }
Esempio n. 6
0
 private void markChange(InputItem rec) {
   if (!changedRecs.containsKey(rec.getId())) {
     changedRecs.put(rec.getId(), rec);
     if (!separator.isVisible()) {
       md.info(
           MDS, "Some data has been changed. Click 'Save' or 'Cancel' when editing is finished.");
       editMode(true);
     }
     dataGrid.redraw();
   }
 }