private void deleteNote(String path) {
    service.deleteNote(
        path,
        new AsyncCallback() {

          public void onFailure(Throwable throwable) {
            Window.alert("Failed to delete note: " + throwable.getMessage());
          }

          public void onSuccess(Object o) {
            getNotes();
          }
        });
  }
  private void getNotes() {

    notesPanel.clear();

    service.getNotes(
        new AsyncCallback() {
          public void onFailure(Throwable throwable) {
            notesPanel.add(new HTML("No notes stored so far."));
            Window.alert("Could not retrieve notes: " + throwable.getMessage());
          }

          public void onSuccess(Object o) {
            ArrayList notesList = (ArrayList) o;
            for (int i = 0; i < notesList.size(); i++) {
              final Note note = (Note) notesList.get(i);

              final HorizontalPanel noteEntry = new HorizontalPanel();
              noteEntry.setStyleName("noteEntry");

              final HTML noteTitle = new HTML(note.getTitle());
              noteTitle.setStyleName("noteTitle");

              final HTML noteText = new HTML(note.getText());
              noteText.setStyleName("noteText");

              final Button delButton = new Button("Delete");
              delButton.setStyleName("noteControls");
              delButton.addClickListener(
                  new ClickListener() {

                    public void onClick(Widget widget) {
                      deleteNote(note.getPath());
                    }
                  });

              noteEntry.add(noteTitle);
              noteEntry.add(noteText);
              noteEntry.add(delButton);

              notesPanel.add(noteEntry);
            }

            if (notesList.size() == 0) {
              notesPanel.add(new HTML("No notes stored so far."));
            }
          }
        });
  }
  private void createNote(String title, String text) {

    final Note note = new Note();
    note.setTitle(title);
    note.setText(text);

    service.createNote(
        note,
        new AsyncCallback() {

          public void onFailure(Throwable throwable) {
            Window.alert("Failed to created note: " + throwable.getMessage());
          }

          public void onSuccess(Object o) {
            getNotes();
          }
        });
  }