/** {@inheritDoc} */ @Override public void onDirtyChanged() { for (PreferencePagePresenter p : preferences) { if (p.isDirty()) { view.enableSaveButton(true); return; } } view.enableSaveButton(false); }
@Override public void onSaveClicked() { for (PreferencePagePresenter preference : preferences) { if (preference.isDirty()) { preference.storeChanges(); } } Promise<Void> promise = Promises.resolve(null); final List<PromiseError> promiseErrorList = new ArrayList<>(); for (final PreferencesManager preferencesManager : managers) { promise = promise.thenPromise( new Function<Void, Promise<Void>>() { @Override public Promise<Void> apply(Void arg) throws FunctionException { return preferencesManager .flushPreferences() .catchError( new Operation<PromiseError>() { @Override public void apply(PromiseError error) throws OperationException { notificationManagerProvider .get() .notify( locale.unableToSavePreference(), error.getMessage(), FAIL, true); promiseErrorList.add(error); } }); } }); } promise.then( new Operation<Void>() { @Override public void apply(Void aVoid) throws OperationException { if (promiseErrorList.isEmpty()) { view.enableSaveButton(false); } } }); }
/** {@inheritDoc} */ @Override public void onCloseClicked() { boolean haveUnsavedData = false; for (PreferencePagePresenter preference : preferences) { if (preference.isDirty()) { haveUnsavedData = true; } } if (haveUnsavedData) { dialogFactory .createConfirmDialog( "", locale.messagesPromptSaveChanges(), getConfirmCallback(), getCancelCallback()) .show(); } else { view.close(); } view.enableSaveButton(false); }