use of org.eclipse.che.ide.api.preferences.PreferencePagePresenter in project che by eclipse.
the class PreferencesPresenter method getConfirmCallback.
private ConfirmCallback getConfirmCallback() {
return new ConfirmCallback() {
@Override
public void accepted() {
for (PreferencePagePresenter preference : preferences) {
if (preference.isDirty()) {
preference.storeChanges();
}
}
view.enableSaveButton(false);
view.close();
}
};
}
use of org.eclipse.che.ide.api.preferences.PreferencePagePresenter in project che by eclipse.
the class PreferencesPresenter method showPreferences.
/** Shows preferences. */
public void showPreferences() {
if (preferencesMap != null) {
view.show();
return;
}
preferencesMap = new HashMap<>();
for (PreferencePagePresenter preference : preferences) {
Set<PreferencePagePresenter> prefsList = preferencesMap.get(preference.getCategory());
if (prefsList == null) {
prefsList = new HashSet<PreferencePagePresenter>();
preferencesMap.put(preference.getCategory(), prefsList);
}
prefsList.add(preference);
}
view.setPreferences(preferencesMap);
view.show();
view.enableSaveButton(false);
view.selectPreference(preferencesMap.entrySet().iterator().next().getValue().iterator().next());
}
use of org.eclipse.che.ide.api.preferences.PreferencePagePresenter 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.PreferencePagePresenter 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);
}
}
});
}
use of org.eclipse.che.ide.api.preferences.PreferencePagePresenter in project che by eclipse.
the class JavaGinModule method configure.
/** {@inheritDoc} */
@Override
protected void configure() {
GinMapBinder<String, ProposalAction> proposalActionMapBinder = GinMapBinder.newMapBinder(binder(), String.class, ProposalAction.class);
proposalActionMapBinder.addBinding(JAVA_ORGANIZE_IMPORT_ID).to(OrganizeImportsAction.class);
bind(NewJavaSourceFileView.class).to(NewJavaSourceFileViewImpl.class).in(Singleton.class);
bind(QuickDocumentation.class).to(QuickDocPresenter.class).in(Singleton.class);
bind(JavaNavigationService.class).to(JavaNavigationServiceImpl.class);
bind(JavaClasspathServiceClient.class).to(JavaClasspathServiceClientImpl.class);
bind(JavaSearchService.class).to(JavaSearchServiceWS.class);
GinMultibinder.newSetBinder(binder(), NodeInterceptor.class).addBinding().to(TestFolderDecorator.class);
GinMultibinder.newSetBinder(binder(), NodeInterceptor.class).addBinding().to(JavaPackageConnector.class);
GinMultibinder.newSetBinder(binder(), NodeIconProvider.class).addBinding().to(SourceFolderDecorator.class);
GinMultibinder.newSetBinder(binder(), NodeInterceptor.class).addBinding().to(LibraryNodeProvider.class);
GinMultibinder.newSetBinder(binder(), ResourceInterceptor.class).addBinding().to(SourceFolderInterceptor.class);
GinMultibinder.newSetBinder(binder(), ResourceInterceptor.class).addBinding().to(ClassInterceptor.class);
GinMultibinder.newSetBinder(binder(), CommandType.class).addBinding().to(JavaCommandType.class);
GinMapBinder<String, FqnProvider> fqnProviders = GinMapBinder.newMapBinder(binder(), String.class, FqnProvider.class);
fqnProviders.addBinding("maven").to(JavaFqnProvider.class);
install(new GinFactoryModuleBuilder().build(JavaNodeFactory.class));
install(new GinFactoryModuleBuilder().implement(PropertyWidget.class, PropertyWidgetImpl.class).build(PropertyWidgetFactory.class));
install(new GinFactoryModuleBuilder().build(NodeFactory.class));
install(new GinFactoryModuleBuilder().build(org.eclipse.che.ide.ext.java.client.navigation.factory.NodeFactory.class));
GinMultibinder<PreferencePagePresenter> settingsBinder = GinMultibinder.newSetBinder(binder(), PreferencePagePresenter.class);
settingsBinder.addBinding().to(JavaCompilerPreferencePresenter.class);
bind(PreferencesManager.class).annotatedWith(JavaCompilerPreferenceManager.class).to(ErrorsWarningsPreferenceManager.class);
GinMultibinder.newSetBinder(binder(), PreferencesManager.class).addBinding().to(ErrorsWarningsPreferenceManager.class);
GinMultibinder.newSetBinder(binder(), Macro.class).addBinding().to(ClasspathMacro.class);
GinMultibinder.newSetBinder(binder(), Macro.class).addBinding().to(OutputDirMacro.class);
GinMultibinder.newSetBinder(binder(), Macro.class).addBinding().to(MainClassMacro.class);
GinMultibinder.newSetBinder(binder(), Macro.class).addBinding().to(SourcepathMacro.class);
GinMultibinder.newSetBinder(binder(), Macro.class).addBinding().to(CurrentClassFQN_Macro.class);
GinMultibinder.newSetBinder(binder(), ClasspathPagePresenter.class).addBinding().to(LibEntryPresenter.class);
GinMultibinder.newSetBinder(binder(), ClasspathPagePresenter.class).addBinding().to(SourceEntryPresenter.class);
GinMultibinder.newSetBinder(binder(), RenamingSupport.class).addBinding().to(JavaSourceRenameValidator.class);
}
Aggregations