public void onAddedStar(Star s) {
   mState = State.Default;
   setLeftButton(true, "add", DrifMaps.Words.Add());
   setRightButton(false, "save", DrifMaps.Words.Save());
   setStarButton(true, "star", DrifMaps.Words.Star());
   mMapController.addStar(s);
   mMapController.onChangeCursor(null);
 }
 /**
  * Event called on start editing
  *
  * @param mi
  */
 public void onStartEditing(MapItem mi) {
   // map handler call this method => witch handler to edit state made before this call
   mState = State.Editing;
   showMapItemEdit(mi);
   mDisplay.setContextButtonsVisible(true);
   setRightButton(true, "cancel", DrifMaps.Words.Cancel());
   setLeftButton(true, "save", DrifMaps.Words.Save());
   mMapController.startEditing(mi);
 }
  /** Changes states of objects during @value {@link State#Adding} */
  public void onStartAddingItem() {
    mState = State.Adding;

    mDisplay.getMenuContent().setOpen(true);
    mDisplay.setContextButtonsVisible(true);
    mDisplay.setMapItem(new MapItem());
    setLeftButton(true, "save", DrifMaps.Words.Save());
    setRightButton(true, "cancel", DrifMaps.Words.Cancel());
    setStarButton(false);
    mMapController.startAdding();
  }
 public void onAddingStar(String type) {
   mStarType = type;
   mState = State.AddingStar;
   mMapController.onChangeCursor(Cursor.CROSSHAIR.toString());
   mDisplay.getMenuContent().setOpen(false);
   setStarButton(true, "cancel", DrifMaps.Words.Cancel());
   setLeftButton(false);
   setRightButton(false);
 }
  protected void showMapItemEdit(MapItem mi) {
    mDisplay.setMapItem(mi);
    mDisplay.getMenuContent().setOpen(true);
    mDisplay.getContextItemsContainer().clear();
    if (mi.getPros() != null) {
      for (String s : mi.getPros()) onAddPro(s, false);
    }

    if (mi.getCons() != null) {
      for (String s : mi.getCons()) onAddCon(s, false);
    }

    if (mi.getDetails() != null) {
      for (Detail d : mi.getDetails()) onAddDetail(d, false);
    }

    setLeftButton(true, "edit", DrifMaps.Words.Edit());
    setRightButton(true, "cancel", DrifMaps.Words.Hide());
  }
  private void handleRemoveDetail(final DetailItem<Detail> di) {
    if (mState == State.Default) return;
    QuestionDialog.show(
        DrifMaps.Words.ReallyQstn(),
        new QuestionDialog.OnQuestionDialogButtonClick() {
          @Override
          public void onYesClick() {
            onRemoveDetail(di);
          }

          @Override
          public void onNoClick() {}

          @Override
          public void onCancelClick() {}
        });
  }
  private void handleRemoveCon(final ContextItem<String> ci) {
    if (mState == State.Default) return;
    QuestionDialog.show(
        DrifMaps.Words.ReallyQstn(),
        new QuestionDialog.OnQuestionDialogButtonClick() {
          @Override
          public void onYesClick() {
            onRemoveCon(ci);
          }

          @Override
          public void onNoClick() {}

          @Override
          public void onCancelClick() {}
        });
  }
  /**
   * Called only if data model is valid
   *
   * @throws ValidationException
   */
  public void onSavingItem() throws ValidationException {
    if (!mDisplay.validate()) throw new ValidationException("Map Item validation");

    MapItem item = mDisplay.getDataModel().getValue();
    setLeftButton(false, "save", DrifMaps.Words.Saving());
    int operation = (item.getId() == 0) ? DataService.ADD : DataService.UPDATE;

    mDataService.processMapItem(
        item,
        operation,
        new AsyncCallback<MapItem>() {
          @Override
          public void onSuccess(MapItem result) {
            onSavedItem(result);
          }

          @Override
          public void onFailure(Throwable caught) {
            setLeftButton(true, "save", DrifMaps.Words.Save());
            NotificationDialog.show(caught);
          }
        });
  }
 private void resetButtons() {
   setLeftButton(true, "add", DrifMaps.Words.Add());
   setRightButton(false, "cancel", DrifMaps.Words.Cancel());
   setStarButton(true, "star", DrifMaps.Words.Star());
 }