fixed PY-12964 add path to the interpreter doesn't work

This commit is contained in:
Ekaterina Tuzova
2014-05-15 13:33:42 +04:00
parent 90a5b72763
commit 38ba59f7b3
2 changed files with 63 additions and 16 deletions
@@ -0,0 +1,46 @@
/*
* 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.configuration;
import com.intellij.openapi.project.Project;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.SideBorder;
import com.jetbrains.python.ui.IdeaDialog;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.awt.*;
public class PythonPathDialog extends IdeaDialog {
private PythonPathEditor myEditor;
public PythonPathDialog(@NotNull final Project project, @NotNull final PythonPathEditor editor) {
super(project);
myEditor = editor;
init();
setTitle("Interpreter Paths");
}
@Override
protected JComponent createCenterPanel() {
JComponent mainPanel = myEditor.createComponent();
mainPanel.setPreferredSize(new Dimension(600, 400));
mainPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.ALL));
return mainPanel;
}
}
@@ -33,7 +33,6 @@ import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderRootType;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
import com.intellij.openapi.ui.DialogBuilder;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
@@ -444,19 +443,6 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
@Override
public void actionPerformed(AnActionEvent e) {
DialogBuilder dialog = new DialogBuilder(myProject);
final PythonPathEditor editor =
new PythonPathEditor("Classes", OrderRootType.CLASSES, FileChooserDescriptorFactory.createAllButJarContentsDescriptor()) {
@Override
protected void onReloadButtonClicked() {
reloadSdk();
}
};
final JComponent component = editor.createComponent();
component.setPreferredSize(new Dimension(600, 400));
component.setBorder(IdeBorderFactory.createBorder(SideBorder.ALL));
dialog.setCenterPanel(component);
Sdk sdk = getSelectedSdk();
if (sdk instanceof PyDetectedSdk) {
final String sdkName = sdk.getName();
@@ -468,10 +454,25 @@ public class PythonSdkDetailsDialog extends DialogWrapper {
});
sdk = SdkConfigurationUtil.setupSdk(ProjectJdkTable.getInstance().getAllJdks(), sdkHome, PythonSdkType.getInstance(), true, null, null);
}
editor.reload(sdk != null ? sdk.getSdkModificator(): null);
final PythonPathEditor pathEditor =
new PythonPathEditor("Classes", OrderRootType.CLASSES, FileChooserDescriptorFactory.createAllButJarContentsDescriptor()) {
@Override
protected void onReloadButtonClicked() {
reloadSdk();
}
};
final SdkModificator sdkModificator = myModificators.get(sdk);
dialog.setTitle("Interpreter Paths");
PythonPathDialog dialog = new PythonPathDialog(myProject, pathEditor);
pathEditor.reload(sdk != null ? sdkModificator : null);
dialog.show();
if (dialog.isOK()) {
if (pathEditor.isModified()) {
pathEditor.apply(sdkModificator);
myModifiedModificators.add(sdkModificator);
}
}
updateOkButton();
}
}