Search in sources :

Example 46 with Configurable

use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.

the class ConfigurableOptionsTopHitProvider method getOptions.

@NotNull
@Override
public Collection<OptionDescription> getOptions(@Nullable Project project) {
    try {
        Configurable configurable = getConfigurable(project);
        Component component = configurable.createComponent();
        configurable.reset();
        myPrefix.clear();
        String name = getName(configurable);
        if (name != null) {
            myPrefix.push(name);
        }
        Collection<BooleanOptionDescription> options = new ArrayList<>();
        init(options, configurable, component);
        return Collections.unmodifiableCollection(options);
    } catch (Exception exception) {
        LOG.debug(exception);
    }
    return Collections.emptyList();
}
Also used : BooleanOptionDescription(com.intellij.ide.ui.search.BooleanOptionDescription) Configurable(com.intellij.openapi.options.Configurable) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull)

Example 47 with Configurable

use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.

the class ConfigurationsTest method testModulesSelector.

public void testModulesSelector() throws ConfigurationException {
    if (PlatformTestUtil.COVERAGE_ENABLED_BUILD)
        return;
    Module module1 = getModule1();
    Module module2 = getModule2();
    JUnitConfigurable editor = new JUnitConfigurable(myProject);
    try {
        JUnitConfiguration configuration = createConfiguration(findTestA(module2));
        // To get all the watchers installed.
        editor.getComponent();
        Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
        JComboBox comboBox = editor.getModulesComponent();
        configurable.reset();
        assertFalse(configurable.isModified());
        assertEquals(module2.getName(), ((Module) comboBox.getSelectedItem()).getName());
        //no module
        assertEquals(ModuleManager.getInstance(myProject).getModules().length + 1, comboBox.getModel().getSize());
        comboBox.setSelectedItem(module1);
        assertTrue(configurable.isModified());
        configurable.apply();
        assertFalse(configurable.isModified());
        assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules()));
    } finally {
        Disposer.dispose(editor);
    }
}
Also used : JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable) Configurable(com.intellij.openapi.options.Configurable) ApplicationConfigurable(com.intellij.execution.application.ApplicationConfigurable) Module(com.intellij.openapi.module.Module) JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable)

Example 48 with Configurable

use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.

the class ConfigurationsTest method testCreatingApplicationConfiguration.

public void testCreatingApplicationConfiguration() throws ConfigurationException {
    if (PlatformTestUtil.COVERAGE_ENABLED_BUILD)
        return;
    ApplicationConfiguration configuration = new ApplicationConfiguration(null, myProject, ApplicationConfigurationType.getInstance());
    ApplicationConfigurable editor = new ApplicationConfigurable(myProject);
    try {
        // To get all the watchers installed.
        editor.getComponent();
        Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
        configurable.reset();
        CommonJavaParametersPanel javaParameters = editor.getCommonProgramParameters();
        javaParameters.setProgramParameters("prg");
        javaParameters.setVMParameters("vm");
        javaParameters.setWorkingDirectory("dir");
        assertTrue(configurable.isModified());
        configurable.apply();
        assertEquals("prg", configuration.getProgramParameters());
        assertEquals("vm", configuration.getVMParameters());
        assertEquals("dir", configuration.getWorkingDirectory());
    } finally {
        Disposer.dispose(editor);
    }
}
Also used : JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable) Configurable(com.intellij.openapi.options.Configurable) ApplicationConfigurable(com.intellij.execution.application.ApplicationConfigurable) ApplicationConfiguration(com.intellij.execution.application.ApplicationConfiguration) CommonJavaParametersPanel(com.intellij.execution.ui.CommonJavaParametersPanel) ApplicationConfigurable(com.intellij.execution.application.ApplicationConfigurable)

Example 49 with Configurable

use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.

the class ConfigurationsTest method testEditJUnitConfiguration.

public void testEditJUnitConfiguration() throws ConfigurationException {
    if (PlatformTestUtil.COVERAGE_ENABLED_BUILD)
        return;
    PsiClass testA = findTestA(getModule2());
    JUnitConfiguration configuration = createConfiguration(testA);
    JUnitConfigurable editor = new JUnitConfigurable(myProject);
    try {
        Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
        configurable.reset();
        final EditorTextFieldWithBrowseButton component = ((LabeledComponent<EditorTextFieldWithBrowseButton>) editor.getTestLocation(JUnitConfigurationModel.CLASS)).getComponent();
        assertEquals(testA.getQualifiedName(), component.getText());
        PsiClass otherTest = findClass(getModule2(), "test2.Test2");
        component.setText(otherTest.getQualifiedName());
        configurable.apply();
        assertEquals(otherTest.getName(), configuration.getName());
        String specialName = "My name";
        configuration.setName(specialName);
        configuration.setNameChangedByUser(true);
        configurable.reset();
        component.setText(testA.getQualifiedName());
        configurable.apply();
        assertEquals(specialName, configuration.getName());
    } finally {
        Disposer.dispose(editor);
    }
}
Also used : EditorTextFieldWithBrowseButton(com.intellij.ui.EditorTextFieldWithBrowseButton) JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable) Configurable(com.intellij.openapi.options.Configurable) ApplicationConfigurable(com.intellij.execution.application.ApplicationConfigurable) JUnitConfigurable(com.intellij.execution.junit2.configuration.JUnitConfigurable) LabeledComponent(com.intellij.openapi.ui.LabeledComponent)

Example 50 with Configurable

use of com.intellij.openapi.options.Configurable in project intellij-community by JetBrains.

the class CodeStyleSchemesConfigurable method buildConfigurables.

@Override
protected Configurable[] buildConfigurables() {
    myPanels = new ArrayList<>();
    final List<CodeStyleSettingsProvider> providers = Arrays.asList(Extensions.getExtensions(CodeStyleSettingsProvider.EXTENSION_POINT_NAME));
    Collections.sort(providers, (p1, p2) -> {
        if (!p1.getPriority().equals(p2.getPriority())) {
            return p1.getPriority().compareTo(p2.getPriority());
        }
        String name1 = p1.getConfigurableDisplayName();
        if (name1 == null)
            name1 = "";
        String name2 = p2.getConfigurableDisplayName();
        if (name2 == null)
            name2 = "";
        return name1.compareToIgnoreCase(name2);
    });
    for (final CodeStyleSettingsProvider provider : providers) {
        if (provider.hasSettingsPage()) {
            CodeStyleConfigurableWrapper e = ConfigurableFactory.Companion.getInstance().createCodeStyleConfigurable(provider, ensureModel(), this);
            myPanels.add(e);
        }
    }
    int size = myPanels.size();
    Configurable[] result = new Configurable[size > 0 ? size - 1 : 0];
    for (int i = 0; i < result.length; i++) {
        result[i] = myPanels.get(i + 1);
    }
    return result;
}
Also used : CodeStyleSettingsProvider(com.intellij.psi.codeStyle.CodeStyleSettingsProvider) Configurable(com.intellij.openapi.options.Configurable) SearchableConfigurable(com.intellij.openapi.options.SearchableConfigurable)

Aggregations

Configurable (com.intellij.openapi.options.Configurable)62 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)31 BaseConfigurable (com.intellij.openapi.options.BaseConfigurable)8 ConfigurableGroup (com.intellij.openapi.options.ConfigurableGroup)7 NotNull (org.jetbrains.annotations.NotNull)7 Project (com.intellij.openapi.project.Project)5 ArrayList (java.util.ArrayList)5 ConfigurationException (com.intellij.openapi.options.ConfigurationException)4 ArtifactsStructureConfigurable (com.intellij.openapi.roots.ui.configuration.artifacts.ArtifactsStructureConfigurable)4 ApplicationConfigurable (com.intellij.execution.application.ApplicationConfigurable)3 JUnitConfigurable (com.intellij.execution.junit2.configuration.JUnitConfigurable)3 DataContext (com.intellij.openapi.actionSystem.DataContext)3 Module (com.intellij.openapi.module.Module)3 TabbedConfigurable (com.intellij.openapi.options.TabbedConfigurable)3 UnnamedConfigurable (com.intellij.openapi.options.UnnamedConfigurable)3 Settings (com.intellij.openapi.options.ex.Settings)3 ActionCallback (com.intellij.openapi.util.ActionCallback)3 Nullable (org.jetbrains.annotations.Nullable)3 ExtensionsArea (com.intellij.openapi.extensions.ExtensionsArea)2 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)2