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

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

Introduction

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

Prototype

public final JComponent getComponent() 

Source Link

Usage

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

License:Apache License

private JComponent createCompositePerRunnerSettings(final Executor executor, final ProgramRunner runner) {
    final SettingsEditor<ConfigurationPerRunnerSettings> configEditor = myConfiguration
            .getRunnerSettingsEditor(runner);
    SettingsEditor<RunnerSettings> runnerEditor;

    try {/*from  w w w  .  j  a  v a2s  .c  om*/
        runnerEditor = runner.getSettingsEditor(executor, myConfiguration);
    } catch (AbstractMethodError error) {
        // this is stub code for plugin compatibility!
        runnerEditor = null;
    }

    if (configEditor == null && runnerEditor == null)
        return null;
    SettingsEditor<RunnerAndConfigurationSettings> wrappedConfigEditor = null;
    SettingsEditor<RunnerAndConfigurationSettings> wrappedRunEditor = null;
    if (configEditor != null) {
        wrappedConfigEditor = new SettingsEditorWrapper<RunnerAndConfigurationSettings, ConfigurationPerRunnerSettings>(
                configEditor, new Convertor<RunnerAndConfigurationSettings, ConfigurationPerRunnerSettings>() {
                    @Override
                    public ConfigurationPerRunnerSettings convert(
                            RunnerAndConfigurationSettings configurationSettings) {
                        return configurationSettings.getConfigurationSettings(runner);
                    }
                });
        myRunnerEditors.add(wrappedConfigEditor);
        Disposer.register(this, wrappedConfigEditor);
    }

    if (runnerEditor != null) {
        wrappedRunEditor = new SettingsEditorWrapper<RunnerAndConfigurationSettings, RunnerSettings>(
                runnerEditor, new Convertor<RunnerAndConfigurationSettings, RunnerSettings>() {
                    @Override
                    public RunnerSettings convert(RunnerAndConfigurationSettings configurationSettings) {
                        return configurationSettings.getRunnerSettings(runner);
                    }
                });
        myRunnerEditors.add(wrappedRunEditor);
        Disposer.register(this, wrappedRunEditor);
    }

    if (wrappedRunEditor != null && wrappedConfigEditor != null) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(wrappedConfigEditor.getComponent(), BorderLayout.CENTER);
        JComponent wrappedRunEditorComponent = wrappedRunEditor.getComponent();
        wrappedRunEditorComponent.setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 0, 0));
        panel.add(wrappedRunEditorComponent, BorderLayout.SOUTH);
        return panel;
    }

    if (wrappedRunEditor != null)
        return wrappedRunEditor.getComponent();
    return wrappedConfigEditor.getComponent();
}