mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
hide Python run configurations if they are irrelevant (IDEA-116046)
This commit is contained in:
@@ -15,8 +15,12 @@
|
||||
*/
|
||||
package com.jetbrains.rest.run;
|
||||
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.execution.configurations.ConfigurationTypeUtil;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.jetbrains.python.run.PythonConfigurationFactoryBase;
|
||||
import com.jetbrains.rest.RestBundle;
|
||||
import com.jetbrains.rest.RestFileType;
|
||||
import com.jetbrains.rest.run.docutils.DocutilsRunConfiguration;
|
||||
@@ -59,7 +63,7 @@ public class RestRunConfigurationType implements ConfigurationType {
|
||||
return new ConfigurationFactory[] {DOCUTILS_FACTORY, SPHINX_FACTORY};
|
||||
}
|
||||
|
||||
private static abstract class RestConfigurationFactory extends ConfigurationFactory {
|
||||
private static abstract class RestConfigurationFactory extends PythonConfigurationFactoryBase {
|
||||
private final String myName;
|
||||
|
||||
public RestConfigurationFactory(@NotNull final ConfigurationType type, @NotNull String name) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.
|
||||
*/
|
||||
package com.jetbrains.python.run;
|
||||
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.jetbrains.python.sdk.PythonSdkType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class PythonConfigurationFactoryBase extends ConfigurationFactory {
|
||||
protected PythonConfigurationFactoryBase(@NotNull ConfigurationType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(@NotNull Project project) {
|
||||
return PlatformUtils.isPyCharm() || PythonSdkType.hasValidSdk();
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class PythonConfigurationType implements ConfigurationType {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class PythonConfigurationFactory extends ConfigurationFactory {
|
||||
private static class PythonConfigurationFactory extends PythonConfigurationFactoryBase {
|
||||
protected PythonConfigurationFactory(ConfigurationType configurationType) {
|
||||
super(configurationType);
|
||||
}
|
||||
|
||||
@@ -190,6 +190,15 @@ public class PythonSdkType extends SdkType {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static boolean hasValidSdk() {
|
||||
for (Sdk sdk : ProjectJdkTable.getInstance().getAllJdks()) {
|
||||
if (sdk.getSdkType() instanceof PythonSdkType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValidSdkHome(@Nullable final String path) {
|
||||
return PythonSdkFlavor.getFlavor(path) != null;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,13 @@
|
||||
*/
|
||||
package com.jetbrains.python.testing;
|
||||
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.configurations.ConfigurationFactory;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.execution.configurations.ConfigurationTypeUtil;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.run.PythonConfigurationFactoryBase;
|
||||
import com.jetbrains.python.testing.attest.PythonAtTestRunConfiguration;
|
||||
import com.jetbrains.python.testing.doctest.PythonDocTestRunConfiguration;
|
||||
import com.jetbrains.python.testing.nosetest.PythonNoseTestRunConfiguration;
|
||||
@@ -44,7 +48,7 @@ public class PythonTestConfigurationType implements ConfigurationType {
|
||||
return ConfigurationTypeUtil.findConfigurationType(PythonTestConfigurationType.class);
|
||||
}
|
||||
|
||||
private static class PythonUnitTestConfigurationFactory extends ConfigurationFactory {
|
||||
private static class PythonUnitTestConfigurationFactory extends PythonConfigurationFactoryBase {
|
||||
protected PythonUnitTestConfigurationFactory(ConfigurationType configurationType) {
|
||||
super(configurationType);
|
||||
}
|
||||
@@ -60,7 +64,7 @@ public class PythonTestConfigurationType implements ConfigurationType {
|
||||
}
|
||||
}
|
||||
|
||||
private static class PythonDocTestConfigurationFactory extends ConfigurationFactory {
|
||||
private static class PythonDocTestConfigurationFactory extends PythonConfigurationFactoryBase {
|
||||
protected PythonDocTestConfigurationFactory(ConfigurationType configurationType) {
|
||||
super(configurationType);
|
||||
}
|
||||
@@ -76,7 +80,7 @@ public class PythonTestConfigurationType implements ConfigurationType {
|
||||
}
|
||||
}
|
||||
|
||||
private static class PythonPyTestConfigurationFactory extends ConfigurationFactory {
|
||||
private static class PythonPyTestConfigurationFactory extends PythonConfigurationFactoryBase {
|
||||
protected PythonPyTestConfigurationFactory(ConfigurationType configurationType) {
|
||||
super(configurationType);
|
||||
}
|
||||
@@ -92,7 +96,7 @@ public class PythonTestConfigurationType implements ConfigurationType {
|
||||
}
|
||||
}
|
||||
|
||||
private static class PythonNoseTestConfigurationFactory extends ConfigurationFactory {
|
||||
private static class PythonNoseTestConfigurationFactory extends PythonConfigurationFactoryBase {
|
||||
protected PythonNoseTestConfigurationFactory(ConfigurationType configurationType) {
|
||||
super(configurationType);
|
||||
}
|
||||
@@ -108,7 +112,7 @@ public class PythonTestConfigurationType implements ConfigurationType {
|
||||
}
|
||||
}
|
||||
|
||||
private static class PythonAtTestConfigurationFactory extends ConfigurationFactory {
|
||||
private static class PythonAtTestConfigurationFactory extends PythonConfigurationFactoryBase {
|
||||
protected PythonAtTestConfigurationFactory(ConfigurationType configurationType) {
|
||||
super(configurationType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user