ensure that Apply button is not active on open run configuration dialog — problem is that we had 2 instance of UnknownConfigurationType

This commit is contained in:
Vladimir Krivosheev
2018-04-13 16:06:21 +02:00
parent 2b3eef982f
commit cd00fbfe9d
5 changed files with 23 additions and 35 deletions
@@ -504,7 +504,7 @@ public abstract class DebuggerTestCase extends ExecutionWithDebuggerToolsTestCas
@Override
public ConfigurationFactory getFactory() {
return UnknownConfigurationType.FACTORY;
return UnknownConfigurationType.getFactory();
}
@Override
@@ -19,22 +19,25 @@ public class UnknownConfigurationType extends ConfigurationTypeBase {
protected UnknownConfigurationType(@NotNull Icon icon) {
super(NAME, NAME, ExecutionBundle.message("run.configuration.unknown.description"), icon);
addFactory(FACTORY);
addFactory(new ConfigurationFactory(this) {
@NotNull
@Override
public RunConfiguration createTemplateConfiguration(@NotNull Project project) {
return new UnknownRunConfiguration(this, project);
}
@Contract(pure = true)
@Override
public boolean canConfigurationBeSingleton() {
return false;
}
});
}
public static final String NAME = "Unknown";
public static final ConfigurationFactory FACTORY = new ConfigurationFactory(new UnknownConfigurationType()) {
@NotNull
@Override
public RunConfiguration createTemplateConfiguration(@NotNull Project project) {
return new UnknownRunConfiguration(this, project);
}
@Contract(pure = true)
@Override
public boolean canConfigurationBeSingleton() {
return false;
}
};
@NotNull
public static ConfigurationFactory getFactory() {
return INSTANCE.getConfigurationFactories()[0];
}
}
@@ -111,7 +111,7 @@ internal class RunConfigurationSchemeManager(private val manager: RunManagerImpl
}
else if (scheme.isTemplate) {
val factory = scheme.factory
if (factory != UnknownConfigurationType.FACTORY) {
if (factory != UnknownConfigurationType.getFactory()) {
val templateSettings = manager.createTemplateSettings(factory)
if (JDOMUtil.areElementsEqual(result, templateSettings.writeScheme())) {
return null
@@ -79,7 +79,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
private var uniqueId: String? = null
override fun getFactory(): ConfigurationFactory = _configuration?.factory ?: UnknownConfigurationType.FACTORY
override fun getFactory(): ConfigurationFactory = _configuration?.factory ?: UnknownConfigurationType.getFactory()
override fun isTemplate() = isTemplate
@@ -100,7 +100,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
}
}
override fun getConfiguration() = _configuration ?: UnknownConfigurationType.FACTORY.createTemplateConfiguration(manager.project)
override fun getConfiguration() = _configuration ?: UnknownConfigurationType.getFactory().createTemplateConfiguration(manager.project)
override fun createFactory() = Factory<RunnerAndConfigurationSettings> {
val configuration = configuration
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.gradle.importing;
import com.intellij.codeInspection.ex.InspectionProfileImpl;
@@ -371,7 +357,7 @@ class TestRunConfigurationImporter implements RunConfigurationImporter {
@NotNull
@Override
public ConfigurationFactory getConfigurationFactory() {
return UnknownConfigurationType.FACTORY;
return UnknownConfigurationType.getFactory();
}
public Map<String, Map<String, Object>> getConfigs() {
@@ -379,7 +365,6 @@ class TestRunConfigurationImporter implements RunConfigurationImporter {
}
}
class TestFacetConfigurationImporter implements FacetConfigurationImporter<Facet> {
private final String myTypeName;