Remote Interpreters: add path mappings to python appcode/146.5
authorSvetlana.Zemlyanskaya <Svetlana.Zemlyanskaya@jetbrains.com>
Fri, 5 Feb 2016 09:22:24 +0000 (10:22 +0100)
committerSvetlana.Zemlyanskaya <Svetlana.Zemlyanskaya@jetbrains.com>
Tue, 16 Feb 2016 16:42:10 +0000 (17:42 +0100)
(cherry picked from commit b0e41df)

python/python-community-configure/src/com/jetbrains/python/configuration/PyActiveSdkConfigurable.java
python/src/META-INF/python-core-common.xml
python/src/com/jetbrains/python/PyBundle.properties
python/src/com/jetbrains/python/sdk/PyCustomSdkUiProvider.java [new file with mode: 0644]

index f8124626d5204ac2228663e666e0a26074aff859..df01a1c3130d6a8eac0eb089c960a2313419d912 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.jetbrains.python.configuration;
 
+import com.intellij.openapi.Disposable;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.options.ConfigurationException;
@@ -31,6 +32,7 @@ import com.intellij.openapi.ui.ComboBox;
 import com.intellij.openapi.ui.FixedSizeButton;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Disposer;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.ui.CollectionComboBoxModel;
@@ -71,6 +73,8 @@ public class PyActiveSdkConfigurable implements UnnamedConfigurable {
   private static final String SHOW_ALL = PyBundle.message("active.sdk.dialog.show.all.item");
   private Set<Sdk> myInitialSdkSet;
 
+  private Disposable myDisposable = null;
+
   public PyActiveSdkConfigurable(@NotNull Project project) {
     myModule = null;
     myProject = project;
@@ -149,14 +153,21 @@ public class PyActiveSdkConfigurable implements UnnamedConfigurable {
     c.weightx = 0.0;
     myMainPanel.add(myDetailsButton, c);
 
+    final PyCustomSdkUiProvider customUiProvider = PyCustomSdkUiProvider.getInstance();
+    if (customUiProvider != null) {
+      myDisposable = Disposer.newDisposable();
+      customUiProvider.customizeActiveSdkPanel(myProject, mySdkCombo, myMainPanel, c, myDisposable);
+    }
+
     c.insets = new Insets(2,2,0,2);
     c.gridx = 0;
-    c.gridy = 1;
+    c.gridy++;
     c.gridwidth = 3;
+    c.weightx = 0.0;
     myMainPanel.add(emptyLabel, c);
 
     c.gridx = 0;
-    c.gridy = 2;
+    c.gridy++;
     c.weighty = 1.;
     c.gridwidth = 3;
     c.gridheight = GridBagConstraints.RELATIVE;
@@ -165,7 +176,7 @@ public class PyActiveSdkConfigurable implements UnnamedConfigurable {
 
     c.gridheight = GridBagConstraints.REMAINDER;
     c.gridx = 0;
-    c.gridy = 3;
+    c.gridy++;
     c.gridwidth = 3;
     c.weighty = 0.;
     c.fill = GridBagConstraints.HORIZONTAL;
@@ -374,6 +385,9 @@ public class PyActiveSdkConfigurable implements UnnamedConfigurable {
   public void disposeUIResources() {
     myProjectSdksModel.removeListener(mySdkModelListener);
     myInterpreterList.disposeModel();
+    if (myDisposable != null) {
+      Disposer.dispose(myDisposable);
+    }
   }
 
   private class MySdkModelListener implements SdkModel.Listener {
index d4ce10ae8af35852023b1c8491aca2323a7880c1..30bb68914ed7d18f526f8c27cb94816b19f36e4e 100644 (file)
     <extensionPoint qualifiedName="Pythonid.consoleOptionsProvider" interface="com.jetbrains.python.console.PyConsoleOptionsProvider"/>
     <extensionPoint qualifiedName="Pythonid.testLocator" interface="com.jetbrains.python.testing.PythonTestLocator"/>
     <extensionPoint qualifiedName="Pythonid.pyRootTypeProvider" interface="com.jetbrains.python.module.PyRootTypeProvider"/>
+    <extensionPoint qualifiedName="Pythonid.pyCustomSdkUiProvider" interface="com.jetbrains.python.sdk.PyCustomSdkUiProvider"/>
   </extensionPoints>
 
   <extensions defaultExtensionNs="Pythonid">
index da279f743a53045b760869b935293a67d7e27fee..51fd13b7e041fb25aba16c349b2e93b3c5ea5cba 100644 (file)
@@ -890,6 +890,8 @@ sdk.gen.stubs.for.binary.modules=Generate stubs for binary module {0}
 # Active SDK configurable and related dialogs
 active.sdk.dialog.show.all.item=Show All
 active.sdk.dialog.project.interpreter=Project Interpreter:
+active.sdk.dialog.project.interpreter.path.mappings=Path mappings:
+active.sdk.dialog.project.interpreter.path.mappings.default.project.error=Open or create project to configure mappings
 
 sdk.details.step.add.local=Add Local
 sdk.details.step.add.remote=Add Remote
diff --git a/python/src/com/jetbrains/python/sdk/PyCustomSdkUiProvider.java b/python/src/com/jetbrains/python/sdk/PyCustomSdkUiProvider.java
new file mode 100644 (file)
index 0000000..350b6d1
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+package com.jetbrains.python.sdk;
+
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.extensions.ExtensionPointName;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.ComboBox;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+
+public abstract class PyCustomSdkUiProvider {
+  public final static ExtensionPointName<PyCustomSdkUiProvider> EP_NAME =
+    ExtensionPointName.create("Pythonid.pyCustomSdkUiProvider");
+
+  @Nullable
+  public static PyCustomSdkUiProvider getInstance() {
+    if (EP_NAME.getExtensions().length > 0) {
+      return EP_NAME.getExtensions()[0];
+    }
+    else {
+      return null;
+    }
+  }
+
+  public abstract void customizeActiveSdkPanel(@NotNull Project project, @NotNull ComboBox mySdkCombo, @NotNull JPanel myMainPanel,
+                                               @NotNull GridBagConstraints c, @NotNull Disposable disposable);
+}