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();
}
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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations