mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-98563 make all RC types singletons by default
This commit is contained in:
+15
-2
@@ -104,11 +104,24 @@ public abstract class ConfigurationFactory {
|
||||
public void configureBeforeRunTaskDefaults(Key<? extends BeforeRunTask> providerID, BeforeRunTask task) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link RunConfigurationSingletonPolicy}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isConfigurationSingletonByDefault() {
|
||||
return false;
|
||||
return getSingletonPolicy() != RunConfigurationSingletonPolicy.MULTIPLE_INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link RunConfigurationSingletonPolicy}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean canConfigurationBeSingleton() {
|
||||
return true; // Configuration may be marked as singleton by default
|
||||
return getSingletonPolicy() != RunConfigurationSingletonPolicy.SINGLE_INSTANCE_ONLY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public RunConfigurationSingletonPolicy getSingletonPolicy() {
|
||||
return RunConfigurationSingletonPolicy.SINGLE_INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,19 @@ import javax.swing.Icon
|
||||
|
||||
private val EMPTY_FACTORIES = arrayOf<ConfigurationFactory>()
|
||||
|
||||
enum class RunConfigurationSingletonPolicy {
|
||||
SINGLE_INSTANCE,
|
||||
MULTIPLE_INSTANCE,
|
||||
SINGLE_INSTANCE_ONLY,
|
||||
MULTIPLE_INSTANCE_ONLY;
|
||||
|
||||
val isPolicyConfigurable: Boolean
|
||||
get() = this != SINGLE_INSTANCE_ONLY && this != MULTIPLE_INSTANCE_ONLY
|
||||
|
||||
val isSingleton: Boolean
|
||||
get() = this == SINGLE_INSTANCE || this == SINGLE_INSTANCE_ONLY
|
||||
}
|
||||
|
||||
abstract class ConfigurationTypeBase protected constructor(private val id: String, private val displayName: String, description: String? = null, private val icon: NotNullLazyValue<Icon>?) : ConfigurationType {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
|
||||
+4
-4
@@ -5,7 +5,6 @@ import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.LazyUtil;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class UnknownConfigurationType extends ConfigurationTypeBase {
|
||||
@@ -22,10 +21,11 @@ public final class UnknownConfigurationType extends ConfigurationTypeBase {
|
||||
return new UnknownRunConfiguration(this, project);
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
@NotNull
|
||||
@Override
|
||||
public boolean canConfigurationBeSingleton() {
|
||||
return false;
|
||||
public RunConfigurationSingletonPolicy getSingletonPolicy() {
|
||||
// in any case you cannot run UnknownConfigurationType
|
||||
return RunConfigurationSingletonPolicy.SINGLE_INSTANCE_ONLY;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+4
-11
@@ -1,10 +1,7 @@
|
||||
// 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 com.intellij.execution.compound;
|
||||
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationTypeBase;
|
||||
import com.intellij.execution.configurations.ConfigurationTypeUtil;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
@@ -32,14 +29,10 @@ public final class CompoundRunConfigurationType extends ConfigurationTypeBase {
|
||||
return "Compound Run Configuration";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public boolean isConfigurationSingletonByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConfigurationBeSingleton() {
|
||||
return false;
|
||||
public RunConfigurationSingletonPolicy getSingletonPolicy() {
|
||||
return RunConfigurationSingletonPolicy.SINGLE_INSTANCE_ONLY;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
val configuration = factory.createTemplateConfiguration(project, this)
|
||||
val template = RunnerAndConfigurationSettingsImpl(this, configuration,
|
||||
isTemplate = true,
|
||||
isSingleton = factory.isConfigurationSingletonByDefault)
|
||||
isSingleton = factory.singletonPolicy.isSingleton)
|
||||
if (configuration is UnknownRunConfiguration) {
|
||||
configuration.isDoNotStore = true
|
||||
}
|
||||
|
||||
+4
-4
@@ -53,7 +53,7 @@ enum class RunConfigurationLevel {
|
||||
class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(val manager: RunManagerImpl,
|
||||
private var _configuration: RunConfiguration? = null,
|
||||
private var isTemplate: Boolean = false,
|
||||
private var isSingleton: Boolean = false,
|
||||
private var isSingleton: Boolean = true,
|
||||
var level: RunConfigurationLevel = RunConfigurationLevel.WORKSPACE) : Cloneable, RunnerAndConfigurationSettings, Comparable<Any>, SerializableScheme {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@@ -181,12 +181,12 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(val manager:
|
||||
|
||||
wasSingletonSpecifiedExplicitly = false
|
||||
if (isTemplate) {
|
||||
isSingleton = factory.isConfigurationSingletonByDefault
|
||||
isSingleton = factory.singletonPolicy.isSingleton
|
||||
}
|
||||
else {
|
||||
val singletonStr = element.getAttributeValue(SINGLETON)
|
||||
if (singletonStr.isNullOrEmpty()) {
|
||||
isSingleton = factory.isConfigurationSingletonByDefault
|
||||
isSingleton = factory.singletonPolicy.isSingleton
|
||||
}
|
||||
else {
|
||||
wasSingletonSpecifiedExplicitly = true
|
||||
@@ -258,7 +258,7 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(val manager:
|
||||
if (!isActivateToolWindowBeforeRun) {
|
||||
element.setAttribute(ACTIVATE_TOOLWINDOW_BEFORE_RUN, "false")
|
||||
}
|
||||
if (wasSingletonSpecifiedExplicitly || isSingleton != factory.isConfigurationSingletonByDefault) {
|
||||
if (wasSingletonSpecifiedExplicitly || isSingleton != factory.singletonPolicy.isSingleton) {
|
||||
element.setAttribute(SINGLETON, isSingleton.toString())
|
||||
}
|
||||
if (isTemporary) {
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@
|
||||
<text resource-bundle="messages/ExecutionBundle" key="run.configuration.store.place.option"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d7b04" class="com.intellij.ui.components.JBCheckBox" binding="myCbSingleton">
|
||||
<component id="d7b04" class="com.intellij.ui.components.JBCheckBox" binding="myIsAllowMultipleInstances">
|
||||
<constraints>
|
||||
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
|
||||
+8
-12
@@ -48,7 +48,7 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
private final String myHelpTopic;
|
||||
private final boolean myBrokenConfiguration;
|
||||
private boolean myStoreProjectConfiguration;
|
||||
private boolean mySingleton;
|
||||
private boolean mySingleton = true;
|
||||
private String myFolderName;
|
||||
private boolean myChangingNameFromCode;
|
||||
|
||||
@@ -156,10 +156,6 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
return myStoreProjectConfiguration;
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
return mySingleton;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ValidationResult getValidationResult() {
|
||||
if (!myValidationResultValid) {
|
||||
@@ -286,7 +282,7 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
@NotNull
|
||||
public RunnerAndConfigurationSettings createSnapshot(boolean cloneBeforeRunTasks) throws ConfigurationException {
|
||||
RunnerAndConfigurationSettings snapshot = getEditor().getSnapshot();
|
||||
snapshot.setSingleton(isSingleton());
|
||||
snapshot.setSingleton(mySingleton);
|
||||
if (cloneBeforeRunTasks) {
|
||||
RunManagerImplKt.cloneBeforeRunTasks(snapshot.getConfiguration());
|
||||
}
|
||||
@@ -319,7 +315,7 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
private JButton myFixButton;
|
||||
private JSeparator mySeparator;
|
||||
private JCheckBox myCbStoreProjectConfiguration;
|
||||
private JBCheckBox myCbSingleton;
|
||||
private JBCheckBox myIsAllowMultipleInstances;
|
||||
private JPanel myValidationPanel;
|
||||
|
||||
private Runnable myQuickFix = null;
|
||||
@@ -355,11 +351,11 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setModified(true);
|
||||
myStoreProjectConfiguration = myCbStoreProjectConfiguration.isSelected();
|
||||
mySingleton = myCbSingleton.isSelected();
|
||||
mySingleton = !myIsAllowMultipleInstances.isSelected();
|
||||
}
|
||||
};
|
||||
myCbStoreProjectConfiguration.addActionListener(actionListener);
|
||||
myCbSingleton.addActionListener(actionListener);
|
||||
myIsAllowMultipleInstances.addActionListener(actionListener);
|
||||
}
|
||||
|
||||
private void doReset(RunnerAndConfigurationSettings settings) {
|
||||
@@ -370,9 +366,9 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
myCbStoreProjectConfiguration.setVisible(!settings.isTemplate());
|
||||
|
||||
mySingleton = settings.isSingleton();
|
||||
myCbSingleton.setEnabled(!isUnknownRunConfiguration);
|
||||
myCbSingleton.setSelected(mySingleton);
|
||||
myCbSingleton.setVisible(settings.getFactory().canConfigurationBeSingleton());
|
||||
myIsAllowMultipleInstances.setEnabled(!isUnknownRunConfiguration);
|
||||
myIsAllowMultipleInstances.setSelected(!mySingleton);
|
||||
myIsAllowMultipleInstances.setVisible(settings.getFactory().getSingletonPolicy().isPolicyConfigurable());
|
||||
}
|
||||
|
||||
public final JComponent getWholePanel() {
|
||||
|
||||
+3
-18
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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 com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.execution.ExecutionManager;
|
||||
@@ -60,7 +46,6 @@ public class ExecutionManagerTest extends LightPlatformTestCase {
|
||||
RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(
|
||||
RunManagerImpl.getInstanceImpl(project), rc, false
|
||||
);
|
||||
settings.setSingleton(true);
|
||||
|
||||
ExecutionEnvironment env1 = createEnv(project, settings);
|
||||
executionManager.restartRunProfile(env1);
|
||||
@@ -77,7 +62,7 @@ public class ExecutionManagerTest extends LightPlatformTestCase {
|
||||
// It will be terminated on the second request: executionManager.restartRunProfile(env3)
|
||||
|
||||
ProcessHandler processHandler2 = getProcessHandler(executionManager);
|
||||
assertTrue(processHandler1 == processHandler2);
|
||||
assertSame(processHandler1, processHandler2);
|
||||
assertTrue(processHandler1.isProcessTerminating());
|
||||
|
||||
ExecutionEnvironment env3 = createEnv(project, settings);
|
||||
@@ -85,7 +70,7 @@ public class ExecutionManagerTest extends LightPlatformTestCase {
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
|
||||
FakeProcessHandler processHandler3 = getProcessHandler(executionManager);
|
||||
assertTrue(processHandler1 != processHandler3);
|
||||
assertNotSame(processHandler1, processHandler3);
|
||||
|
||||
assertTrue(!processHandler3.isProcessTerminating() && !processHandler3.isProcessTerminated());
|
||||
processHandler3.killProcess();
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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 com.intellij.platform;
|
||||
|
||||
import com.intellij.facet.ui.ValidationResult;
|
||||
@@ -22,7 +8,6 @@ import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -60,7 +45,6 @@ public interface DirectoryProjectGenerator<T> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nls
|
||||
String getName();
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -311,7 +311,7 @@ show.swing.inspector=&Enable capturing form snapshots
|
||||
show.swing.inspector.disabled=&Enable capturing form snapshots (requires JRE 5.0 or higher)
|
||||
before.run.property.make=Make
|
||||
run.configuration.store.place.option=&Share
|
||||
run.configuration.singleton=Single &instance only
|
||||
run.configuration.singleton=Allow multiple &instances
|
||||
run.configuration.default.type.description=configuration
|
||||
|
||||
#GeneralCommandLine
|
||||
|
||||
-1
@@ -191,7 +191,6 @@ public class GradleIntellijPluginFrameworkSupportProvider extends GradleFramewor
|
||||
settings.setTaskNames(Collections.singletonList(":runIde"));
|
||||
settings.setExternalProjectPath(contentRootPath);
|
||||
}
|
||||
configuration.setSingleton(true);
|
||||
runManager.addConfiguration(configuration);
|
||||
runManager.setSelectedConfiguration(configuration);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// 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.idea.devkit.run;
|
||||
|
||||
import com.intellij.diagnostic.VMOptions;
|
||||
@@ -47,11 +45,6 @@ public class PluginConfigurationType implements ConfigurationType {
|
||||
return ModuleUtil.hasModulesOfType(project, PluginModuleType.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationSingletonByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunConfiguration createConfiguration(String name, RunConfiguration template) {
|
||||
PluginRunConfiguration pluginRunConfiguration = (PluginRunConfiguration)template;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// 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.ipnb.configuration;
|
||||
|
||||
import com.intellij.execution.RunManager;
|
||||
@@ -408,8 +409,6 @@ public final class IpnbConnectionManager implements ProjectComponent, Disposable
|
||||
final IpnbRunConfiguration configuration = (IpnbRunConfiguration)configurationSettings.getConfiguration();
|
||||
configuration.setHost(IpnbConfigurationEditor.DEFAULT_HOST);
|
||||
configuration.setPort(IpnbConfigurationEditor.DEFAULT_PORT);
|
||||
configurationSettings.setSingleton(true);
|
||||
|
||||
ExecutionUtil.runConfiguration(configurationSettings, DefaultRunExecutor.getRunExecutorInstance());
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -50,11 +50,6 @@ public class IpnbRunConfigurationType implements ConfigurationType {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConfigurationSingletonByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public RunConfiguration createTemplateConfiguration(@NotNull Project project) {
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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 com.jetbrains.python.run;
|
||||
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
@@ -33,10 +19,9 @@ public abstract class PyRunConfigurationFactory {
|
||||
*
|
||||
* @param module the module in the context of which the script is run.
|
||||
* @param scriptName the path to the script file.
|
||||
* @param singleton if true, the "Check no other instances are running" option will be set for the run configuration.
|
||||
* @return the settings of the created run configuration.
|
||||
*/
|
||||
public abstract PythonRunConfigurationParams createPythonScriptRunConfiguration(Module module, String scriptName, boolean singleton);
|
||||
public abstract PythonRunConfigurationParams createPythonScriptRunConfiguration(Module module, String scriptName);
|
||||
|
||||
public abstract RunnerAndConfigurationSettings createRunConfiguration(Module module, ConfigurationFactory factory);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class PyRunConfigurationFactoryImpl extends PyRunConfigurationFactory {
|
||||
@Override
|
||||
public PythonRunConfigurationParams createPythonScriptRunConfiguration(Module module, String scriptName, boolean singleton) {
|
||||
public PythonRunConfigurationParams createPythonScriptRunConfiguration(Module module, String scriptName) {
|
||||
RunnerAndConfigurationSettings settings = createRunConfiguration(module, PythonConfigurationType.getInstance().getFactory());
|
||||
settings.setSingleton(singleton);
|
||||
PythonRunConfigurationParams configuration = (PythonRunConfigurationParams)settings.getConfiguration();
|
||||
configuration.setScriptName(scriptName);
|
||||
return configuration;
|
||||
|
||||
Reference in New Issue
Block a user