public void makeEditable(ClickHandler saveClickHandler, Labels labels) {
    annotationPanel.setVisible(false);

    CommentField commentField = new CommentField(annotation.getText(), labels, true);
    commentField.addSaveClickHandler(saveClickHandler);
    container.insert(commentField, container.getWidgetIndex(annotationPanel));
  }
  public AnnotationWidget(Annotation a, Labels labels) {
    this.annotation = a;

    // Construct annotation panel
    annotationPanel = new FlowPanel();
    annotationPanel.setStyleName("yuma-annotation-content");

    // Username will be undefined in server-less mode!
    InlineHTML username = null;
    if (annotation.getUserRealName() != null) {
      username = new InlineHTML(annotation.getUserRealName());
    } else if (annotation.getUsername() != null) {
      username = new InlineHTML(annotation.getUsername());
    }

    if (username != null) {
      username.setStyleName("yuma-annotation-username");
      annotationPanel.add(username);
    }

    // Timestamps will be -1 in server-less mode!
    InlineHTML timestamp = new InlineHTML();
    long modified = annotation.getModified();
    if (modified > 0) {
      timestamp.setHTML(DateTimeFormat.getFormat(DATE_FORMAT).format(new Date(modified)));
      timestamp.setStyleName("yuma-annotation-modified");
    }

    annotationPanel.add(new InlineHTML(annotation.getText() + "<br/>"));
    annotationPanel.add(timestamp);

    annotationPanel.addDomHandler(
        new MouseOverHandler() {
          public void onMouseOver(MouseOverEvent event) {
            btnEdit.removeStyleName(CSS_HIDDEN);
            btnDelete.removeStyleName(CSS_HIDDEN);
          }
        },
        MouseOverEvent.getType());

    // Construct button panel
    buttonPanel = new FlowPanel();
    buttonPanel.setStyleName("yuma-annotation-buttons");

    btnDelete = new PushButton();
    btnDelete.setStyleName("yuma-button");
    btnDelete.addStyleName("yuma-button-delete");
    btnDelete.addStyleName(CSS_HIDDEN);
    btnDelete.getElement().getStyle().setFloat(Float.RIGHT);
    btnDelete.getElement().getStyle().setCursor(Cursor.POINTER);

    btnEdit = new PushButton();
    btnEdit.setStyleName("yuma-button");
    btnEdit.addStyleName("yuma-button-edit");
    btnEdit.addStyleName(CSS_HIDDEN);
    btnEdit.getElement().getStyle().setFloat(Float.RIGHT);
    btnEdit.getElement().getStyle().setCursor(Cursor.POINTER);

    if (labels == null) {
      btnDelete.setTitle("Delete this Comment");
      btnEdit.setTitle("Edit this Comment");
    } else {
      btnDelete.setTitle(labels.deleteTooltip());
      btnEdit.setTitle(labels.editTooltip());
    }
    buttonPanel.add(btnDelete);
    buttonPanel.add(btnEdit);

    // Wrap everything into the container panel
    container = new FlowPanel();
    container.setStyleName("yuma-annotation");
    container.add(annotationPanel);
    container.add(buttonPanel);

    container.addDomHandler(
        new MouseOutHandler() {
          public void onMouseOut(MouseOutEvent event) {
            btnEdit.addStyleName(CSS_HIDDEN);
            btnDelete.addStyleName(CSS_HIDDEN);
          }
        },
        MouseOutEvent.getType());

    initWidget(container);
  }