Search in sources :

Example 1 with PreferencePagePresenter

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();
        }
    };
}
Also used : ConfirmCallback(org.eclipse.che.ide.api.dialogs.ConfirmCallback) PreferencePagePresenter(org.eclipse.che.ide.api.preferences.PreferencePagePresenter)

Example 2 with PreferencePagePresenter

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());
}
Also used : PreferencePagePresenter(org.eclipse.che.ide.api.preferences.PreferencePagePresenter)

Example 3 with PreferencePagePresenter

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();
            }
        }
    });
}
Also used : Function(org.eclipse.che.api.promises.client.Function) PromiseError(org.eclipse.che.api.promises.client.PromiseError) PreferencePagePresenter(org.eclipse.che.ide.api.preferences.PreferencePagePresenter) HashMap(java.util.HashMap) Map(java.util.Map) PreferencesManager(org.eclipse.che.ide.api.preferences.PreferencesManager) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 4 with PreferencePagePresenter

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);
            }
        }
    });
}
Also used : Function(org.eclipse.che.api.promises.client.Function) PreferencePagePresenter(org.eclipse.che.ide.api.preferences.PreferencePagePresenter) PromiseError(org.eclipse.che.api.promises.client.PromiseError) ArrayList(java.util.ArrayList) PreferencesManager(org.eclipse.che.ide.api.preferences.PreferencesManager) OperationException(org.eclipse.che.api.promises.client.OperationException)

Example 5 with PreferencePagePresenter

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);
}
Also used : JavaNodeFactory(org.eclipse.che.ide.ext.java.client.tree.JavaNodeFactory) PreferencePagePresenter(org.eclipse.che.ide.api.preferences.PreferencePagePresenter) JavaClasspathServiceClient(org.eclipse.che.ide.ext.java.client.dependenciesupdater.JavaClasspathServiceClient) GinFactoryModuleBuilder(com.google.gwt.inject.client.assistedinject.GinFactoryModuleBuilder) PropertyWidgetFactory(org.eclipse.che.ide.ext.java.client.inject.factories.PropertyWidgetFactory) JavaSearchService(org.eclipse.che.ide.ext.java.client.search.JavaSearchService) FqnProvider(org.eclipse.che.ide.api.reference.FqnProvider) JavaFqnProvider(org.eclipse.che.ide.ext.java.client.reference.JavaFqnProvider) ProposalAction(org.eclipse.che.ide.ext.java.client.action.ProposalAction) QuickDocPresenter(org.eclipse.che.ide.ext.java.client.documentation.QuickDocPresenter) NewJavaSourceFileViewImpl(org.eclipse.che.ide.ext.java.client.newsourcefile.NewJavaSourceFileViewImpl) JavaNavigationService(org.eclipse.che.ide.ext.java.client.navigation.service.JavaNavigationService) JavaNodeFactory(org.eclipse.che.ide.ext.java.client.tree.JavaNodeFactory) NodeFactory(org.eclipse.che.ide.ext.java.client.search.node.NodeFactory) JavaCompilerPreferenceManager(org.eclipse.che.ide.ext.java.client.settings.compiler.JavaCompilerPreferenceManager)

Aggregations

PreferencePagePresenter (org.eclipse.che.ide.api.preferences.PreferencePagePresenter)5 Function (org.eclipse.che.api.promises.client.Function)2 OperationException (org.eclipse.che.api.promises.client.OperationException)2 PromiseError (org.eclipse.che.api.promises.client.PromiseError)2 PreferencesManager (org.eclipse.che.ide.api.preferences.PreferencesManager)2 GinFactoryModuleBuilder (com.google.gwt.inject.client.assistedinject.GinFactoryModuleBuilder)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConfirmCallback (org.eclipse.che.ide.api.dialogs.ConfirmCallback)1 FqnProvider (org.eclipse.che.ide.api.reference.FqnProvider)1 ProposalAction (org.eclipse.che.ide.ext.java.client.action.ProposalAction)1 JavaClasspathServiceClient (org.eclipse.che.ide.ext.java.client.dependenciesupdater.JavaClasspathServiceClient)1 QuickDocPresenter (org.eclipse.che.ide.ext.java.client.documentation.QuickDocPresenter)1 PropertyWidgetFactory (org.eclipse.che.ide.ext.java.client.inject.factories.PropertyWidgetFactory)1 JavaNavigationService (org.eclipse.che.ide.ext.java.client.navigation.service.JavaNavigationService)1 NewJavaSourceFileViewImpl (org.eclipse.che.ide.ext.java.client.newsourcefile.NewJavaSourceFileViewImpl)1 JavaFqnProvider (org.eclipse.che.ide.ext.java.client.reference.JavaFqnProvider)1 JavaSearchService (org.eclipse.che.ide.ext.java.client.search.JavaSearchService)1 NodeFactory (org.eclipse.che.ide.ext.java.client.search.node.NodeFactory)1