Example usage for com.intellij.openapi.options SettingsEditor getSnapshot

List of usage examples for com.intellij.openapi.options SettingsEditor getSnapshot

Introduction

In this page you can find the example usage for com.intellij.openapi.options SettingsEditor getSnapshot.

Prototype

@NotNull
    public Settings getSnapshot() throws ConfigurationException 

Source Link

Usage

From source file:com.intellij.execution.impl.RunConfigurable.java

License:Apache License

private void installUpdateListeners(final SingleConfigurationConfigurable<RunConfiguration> info) {
    final boolean[] changed = new boolean[] { false };
    info.getEditor().addSettingsEditorListener(new SettingsEditorListener<RunnerAndConfigurationSettings>() {
        @Override/*  ww w.  j  a  v  a  2  s.  c  o m*/
        public void stateChanged(final SettingsEditor<RunnerAndConfigurationSettings> editor) {
            update();
            final RunConfiguration configuration = info.getConfiguration();
            if (configuration instanceof LocatableConfiguration) {
                final LocatableConfiguration runtimeConfiguration = (LocatableConfiguration) configuration;
                if (runtimeConfiguration.isGeneratedName() && !changed[0]) {
                    try {
                        final LocatableConfiguration snapshot = (LocatableConfiguration) editor.getSnapshot()
                                .getConfiguration();
                        final String generatedName = snapshot.suggestedName();
                        if (generatedName != null && generatedName.length() > 0) {
                            info.setNameText(generatedName);
                            changed[0] = false;
                        }
                    } catch (ConfigurationException ignore) {
                    }
                }
            }
            setupDialogBounds();
        }
    });

    info.addNameListener(new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
            changed[0] = true;
            update();
        }
    });

    info.addSharedListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            changed[0] = true;
            update();
        }
    });
}

From source file:com.intellij.execution.impl.SingleConfigurationConfigurable.java

License:Apache License

public RunnerAndConfigurationSettings getSnapshot() throws ConfigurationException {
    final SettingsEditor<RunnerAndConfigurationSettings> editor = getEditor();
    return editor == null ? null : editor.getSnapshot();
}