Remote interpreter library paths handling rework.

This commit is contained in:
Dmitry Trofimov
2014-06-25 14:51:27 +02:00
parent 35357d307a
commit 9196c19776
14 changed files with 235 additions and 42 deletions
@@ -300,7 +300,7 @@ public class PythonPathEditor extends SdkPathEditor {
}
private static class PythonPathListCellRenderer extends ListCellRendererWrapper<VirtualFile> {
private class PythonPathListCellRenderer extends ListCellRendererWrapper<VirtualFile> {
private final PathListModel model;
public PythonPathListCellRenderer(final ListCellRenderer listCellRenderer, PathListModel model) {
@@ -314,7 +314,11 @@ public class PythonPathEditor extends SdkPathEditor {
if (suffix.length() > 0) {
suffix = " " + suffix;
}
setText(value != null ? value.getPresentableUrl() + suffix : "");
setText(value != null ? getPresentablePath(value) + suffix : "");
}
}
protected String getPresentablePath(VirtualFile value) {
return value.getPresentableUrl();
}
}
@@ -45,6 +45,7 @@ import com.intellij.ui.components.JBList;
import com.intellij.util.NullableConsumer;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.FactoryMap;
import com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase;
import com.jetbrains.python.remote.PythonRemoteInterpreterManager;
import com.jetbrains.python.sdk.*;
import com.jetbrains.python.sdk.flavors.PythonSdkFlavor;
@@ -286,8 +287,9 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
myModifiedModificators.add(modificator);
}
final Sdk oldSdk = myProjectSdksModel.findSdk(sdk);
if (oldSdk == null)
if (oldSdk == null) {
myProjectSdksModel.addSdk(sdk);
}
refreshSdkList();
mySdkList.setSelectedValue(sdk, true);
mySdkListChanged = true;
@@ -452,15 +454,10 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
return LocalFileSystem.getInstance().refreshAndFindFileByPath(sdkName);
}
});
sdk = SdkConfigurationUtil.setupSdk(ProjectJdkTable.getInstance().getAllJdks(), sdkHome, PythonSdkType.getInstance(), true, null, null);
sdk =
SdkConfigurationUtil.setupSdk(ProjectJdkTable.getInstance().getAllJdks(), sdkHome, PythonSdkType.getInstance(), true, null, null);
}
final PythonPathEditor pathEditor =
new PythonPathEditor("Classes", OrderRootType.CLASSES, FileChooserDescriptorFactory.createAllButJarContentsDescriptor()) {
@Override
protected void onReloadButtonClicked() {
reloadSdk();
}
};
final PythonPathEditor pathEditor = createPathEditor(sdk);
final SdkModificator sdkModificator = myModificators.get(sdk);
PythonPathDialog dialog = new PythonPathDialog(myProject, pathEditor);
@@ -476,4 +473,40 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
updateOkButton();
}
}
private PythonPathEditor createPathEditor(final Sdk sdk) {
if (PySdkUtil.isRemote(sdk)) {
return new PythonPathEditor("Classes", OrderRootType.CLASSES, FileChooserDescriptorFactory.createAllButJarContentsDescriptor()) {
private final PyRemoteSdkAdditionalDataBase myRemoteSdkData = (PyRemoteSdkAdditionalDataBase) sdk.getSdkAdditionalData();
@Override
protected void onReloadButtonClicked() {
reloadSdk();
}
@Override
protected String getPresentablePath(VirtualFile value) {
String path = value.getPath();
return myRemoteSdkData.getPathMappings().convertToRemote(path);
}
@Override
protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) {
toolbarDecorator.setAddActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return false; //TODO: implement adding remote path
}
});
}
};
}
else {
return new PythonPathEditor("Classes", OrderRootType.CLASSES, FileChooserDescriptorFactory.createAllButJarContentsDescriptor()) {
@Override
protected void onReloadButtonClicked() {
reloadSdk();
}
};
}
}
}