use of org.eclipse.che.ide.api.preferences.PreferencesManager in project che by eclipse.
the class PreferencesPresenter method onRefreshClicked.
@Override
public void onRefreshClicked() {
Promise<Map<String, String>> promise = Promises.resolve(null);
for (final PreferencesManager preferencesManager : managers) {
promise = promise.thenPromise(new Function<Map<String, String>, Promise<Map<String, String>>>() {
@Override
public Promise<Map<String, String>> apply(Map<String, String> arg) throws FunctionException {
return preferencesManager.loadPreferences().catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
notificationManagerProvider.get().notify(locale.unableToLoadPreference(), error.getMessage(), FAIL, FLOAT_MODE);
}
});
}
});
}
/**
* Revert changes on every preference page
*/
promise.then(new Operation<Map<String, String>>() {
@Override
public void apply(Map<String, String> arg) throws OperationException {
for (PreferencePagePresenter p : PreferencesPresenter.this.preferences) {
p.revertChanges();
}
}
});
}
use of org.eclipse.che.ide.api.preferences.PreferencesManager in project che by eclipse.
the class PreferencesPresenter method onSaveClicked.
@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, FLOAT_MODE);
promiseErrorList.add(error);
}
});
}
});
}
promise.then(new Operation<Void>() {
@Override
public void apply(Void aVoid) throws OperationException {
if (promiseErrorList.isEmpty()) {
view.enableSaveButton(false);
}
}
});
}
Aggregations