|
13 | 13 | * See the License for the specific language governing permissions and |
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | | - |
17 | 16 | package com.jetbrains.python.impl.run; |
18 | 17 |
|
19 | | -import com.jetbrains.python.impl.PythonIcons; |
20 | 18 | import consulo.annotation.component.ExtensionImpl; |
| 19 | +import consulo.application.Application; |
21 | 20 | import consulo.execution.configuration.ConfigurationFactory; |
22 | 21 | import consulo.execution.configuration.ConfigurationType; |
23 | 22 | import consulo.execution.configuration.RunConfiguration; |
24 | 23 | import consulo.localize.LocalizeValue; |
25 | 24 | import consulo.module.extension.ModuleExtensionHelper; |
26 | 25 | import consulo.project.Project; |
| 26 | +import consulo.python.impl.icon.PythonImplIconGroup; |
27 | 27 | import consulo.python.impl.localize.PyLocalize; |
28 | 28 | import consulo.python.module.extension.PyModuleExtension; |
29 | 29 | import consulo.ui.image.Image; |
|
36 | 36 | */ |
37 | 37 | @ExtensionImpl |
38 | 38 | public class PythonConfigurationType implements ConfigurationType { |
39 | | - private final PythonConfigurationFactory myFactory = new PythonConfigurationFactory(this); |
| 39 | + private final PythonConfigurationFactory myFactory = new PythonConfigurationFactory(this); |
| 40 | + |
| 41 | + public static PythonConfigurationType getInstance() { |
| 42 | + return Application.get().getExtensionPoint(ConfigurationType.class) |
| 43 | + .findExtensionOrFail(PythonConfigurationType.class); |
| 44 | + } |
| 45 | + |
| 46 | + private static class PythonConfigurationFactory extends ConfigurationFactory { |
| 47 | + protected PythonConfigurationFactory(ConfigurationType configurationType) { |
| 48 | + super(configurationType); |
| 49 | + } |
| 50 | + |
| 51 | + @Nonnull |
| 52 | + @Override |
| 53 | + public String getId() { |
| 54 | + return "Python"; |
| 55 | + } |
40 | 56 |
|
41 | | - public static PythonConfigurationType getInstance() { |
42 | | - return EP_NAME.findExtensionOrFail(PythonConfigurationType.class); |
43 | | - } |
| 57 | + @Override |
| 58 | + public boolean isApplicable(@Nonnull Project project) { |
| 59 | + return ModuleExtensionHelper.getInstance(project).hasModuleExtension(PyModuleExtension.class); |
| 60 | + } |
44 | 61 |
|
45 | | - private static class PythonConfigurationFactory extends ConfigurationFactory { |
46 | | - protected PythonConfigurationFactory(ConfigurationType configurationType) { |
47 | | - super(configurationType); |
| 62 | + @Override |
| 63 | + public RunConfiguration createTemplateConfiguration(Project project) { |
| 64 | + return new PythonRunConfiguration(project, this); |
| 65 | + } |
48 | 66 | } |
49 | 67 |
|
50 | 68 | @Nonnull |
51 | 69 | @Override |
52 | | - public String getId() { |
53 | | - return "Python"; |
| 70 | + public LocalizeValue getDisplayName() { |
| 71 | + return PyLocalize.pythonConfigurationName(); |
54 | 72 | } |
55 | 73 |
|
| 74 | + @Nonnull |
56 | 75 | @Override |
57 | | - public boolean isApplicable(@Nonnull Project project) { |
58 | | - return ModuleExtensionHelper.getInstance(project).hasModuleExtension(PyModuleExtension.class); |
| 76 | + public LocalizeValue getConfigurationTypeDescription() { |
| 77 | + return PyLocalize.pythonConfigurationDescription(); |
59 | 78 | } |
60 | 79 |
|
61 | 80 | @Override |
62 | | - public RunConfiguration createTemplateConfiguration(Project project) { |
63 | | - return new PythonRunConfiguration(project, this); |
| 81 | + public Image getIcon() { |
| 82 | + return PythonImplIconGroup.pythonPython(); |
64 | 83 | } |
65 | | - } |
66 | | - |
67 | | - @Override |
68 | | - public LocalizeValue getDisplayName() { |
69 | | - return PyLocalize.pythonConfigurationName(); |
70 | | - } |
71 | | - |
72 | | - @Override |
73 | | - public LocalizeValue getConfigurationTypeDescription() { |
74 | | - return PyLocalize.pythonConfigurationDescription(); |
75 | | - } |
76 | 84 |
|
77 | | - @Override |
78 | | - public Image getIcon() { |
79 | | - return PythonIcons.Python.Python; |
80 | | - } |
81 | | - |
82 | | - @Override |
83 | | - public ConfigurationFactory[] getConfigurationFactories() { |
84 | | - return new ConfigurationFactory[]{myFactory}; |
85 | | - } |
| 85 | + @Override |
| 86 | + public ConfigurationFactory[] getConfigurationFactories() { |
| 87 | + return new ConfigurationFactory[]{myFactory}; |
| 88 | + } |
86 | 89 |
|
87 | | - public PythonConfigurationFactory getFactory() { |
88 | | - return myFactory; |
89 | | - } |
| 90 | + public PythonConfigurationFactory getFactory() { |
| 91 | + return myFactory; |
| 92 | + } |
90 | 93 |
|
91 | | - @Override |
92 | | - @Nonnull |
93 | | - @NonNls |
94 | | - public String getId() { |
95 | | - return "PythonConfigurationType"; |
96 | | - } |
| 94 | + @Nonnull |
| 95 | + @Override |
| 96 | + public String getId() { |
| 97 | + return "PythonConfigurationType"; |
| 98 | + } |
97 | 99 | } |
0 commit comments