/** {@inheritDoc} */
  @Override
  public UnsavedChangesDialog.Result checkUnsavedChanges() {
    UnsavedChangesDialog.Result result;
    UnsavedChangesDialog unsavedChangesDlg =
        new UnsavedChangesDialog(Utilities.getParentDialog(this), getInfo());
    unsavedChangesDlg.setMessage(
        INFO_CTRL_PANEL_UNSAVED_CHANGES_SUMMARY.get(),
        INFO_CTRL_PANEL_UNSAVED_OBJECTCLASS_CHANGES_DETAILS.get(objectClass.getNameOrOID()));
    Utilities.centerGoldenMean(unsavedChangesDlg, Utilities.getParentDialog(this));
    unsavedChangesDlg.setVisible(true);
    result = unsavedChangesDlg.getResult();
    if (result == UnsavedChangesDialog.Result.SAVE) {
      ArrayList<LocalizableMessage> errors = new ArrayList<>();
      saveChanges(true, errors);
      if (!errors.isEmpty()) {
        result = UnsavedChangesDialog.Result.CANCEL;
      }
    }

    return result;
  }
Exemple #2
0
  /**
   * Tells whether the user chose to save the changes in the panel, to not save them or simply
   * cancelled the selection in the tree.
   *
   * @return the value telling whether the user chose to save the changes in the panel, to not save
   *     them or simply cancelled the selection change in the tree.
   */
  public UnsavedChangesDialog.Result checkUnsavedChanges() {
    UnsavedChangesDialog.Result result;
    UnsavedChangesDialog unsavedChangesDlg =
        new UnsavedChangesDialog(Utilities.getParentDialog(this), getInfo());
    unsavedChangesDlg.setMessage(
        INFO_CTRL_PANEL_UNSAVED_CHANGES_SUMMARY.get(),
        INFO_CTRL_PANEL_UNSAVED_INDEX_CHANGES_DETAILS.get(index.getName()));
    Utilities.centerGoldenMean(unsavedChangesDlg, Utilities.getParentDialog(this));
    unsavedChangesDlg.setVisible(true);
    result = unsavedChangesDlg.getResult();
    if (result == UnsavedChangesDialog.Result.SAVE) {
      saveIndex(false);
      if (newModifyTask == null
          || // The user data is not valid
          newModifyTask.getState() != Task.State.FINISHED_SUCCESSFULLY) {
        result = UnsavedChangesDialog.Result.CANCEL;
      }
    }

    return result;
  }