mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 11:50:54 +07:00
add language specific advanced settings (EDU-926)
This commit is contained in:
committed by
liana.bakradze
parent
92d11923e5
commit
021496d378
@@ -17,11 +17,14 @@ package com.jetbrains.edu.learning.newproject;
|
||||
|
||||
import com.intellij.facet.ui.ValidationResult;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.platform.DirectoryProjectGenerator;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public interface EduCourseProjectGenerator {
|
||||
@NotNull
|
||||
DirectoryProjectGenerator getDirectoryProjectGenerator();
|
||||
@@ -36,4 +39,9 @@ public interface EduCourseProjectGenerator {
|
||||
boolean beforeProjectGenerated();
|
||||
|
||||
void afterProjectGenerated(@NotNull Project project);
|
||||
|
||||
@Nullable
|
||||
default LabeledComponent<JComponent> getLanguageSettingsComponent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="c19f6" binding="myAdvancedSettings" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<grid id="c19f6" binding="myAdvancedSettings" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints border-constraint="Center"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class EduCoursesPanel extends JPanel {
|
||||
private static final JBColor LIST_COLOR = new JBColor(Gray.xFF, Gray.x39);
|
||||
private JPanel myMainPanel;
|
||||
private JEditorPane myDescriptionTextArea;
|
||||
private JPanel myCourseListPanel;
|
||||
@@ -65,7 +66,6 @@ public class EduCoursesPanel extends JPanel {
|
||||
}
|
||||
});
|
||||
myLocationField = createLocationComponent();
|
||||
UIUtil.setBackgroundRecursively(myLocationField, UIUtil.getTextFieldBackground());
|
||||
myCoursesList.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
@@ -73,20 +73,34 @@ public class EduCoursesPanel extends JPanel {
|
||||
myDescriptionTextArea.setText(selectedCourse.getDescription());
|
||||
myAdvancedSettingsPlaceholder.setVisible(true);
|
||||
myLocationField.getComponent().setText(nameToLocation(selectedCourse.getName()));
|
||||
EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(selectedCourse.getLanguageById());
|
||||
if (configurator == null) {
|
||||
return;
|
||||
}
|
||||
EduCourseProjectGenerator generator = configurator.getEduCourseProjectGenerator();
|
||||
if (generator == null) {
|
||||
return;
|
||||
}
|
||||
LabeledComponent<JComponent> component = generator.getLanguageSettingsComponent();
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
myAdvancedSettings.removeAll();
|
||||
myAdvancedSettings.add(myLocationField, BorderLayout.NORTH);
|
||||
myAdvancedSettings.add(component, BorderLayout.SOUTH);
|
||||
UIUtil.mergeComponentsWithAnchor(myLocationField, component);
|
||||
}
|
||||
});
|
||||
JScrollPane installedScrollPane = ScrollPaneFactory.createScrollPane(myCoursesList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
myCourseListPanel.add(installedScrollPane, BorderLayout.CENTER);
|
||||
myDescriptionScrollPane.setBackground(UIUtil.getTextFieldBackground());
|
||||
Border border = JBUI.Borders.customLine(OnePixelDivider.BACKGROUND, 1, 0, 1, 1);
|
||||
myInfoPanel.setBorder(border);
|
||||
HideableDecorator decorator = new HideableDecorator(myAdvancedSettingsPlaceholder, "Advanced Settings", false);
|
||||
decorator.setContentComponent(myAdvancedSettings);
|
||||
myAdvancedSettings.setBorder(IdeBorderFactory.createEmptyBorder(0, IdeBorderFactory.TITLED_BORDER_INDENT, 5, 0));
|
||||
UIUtil.setBackgroundRecursively(myAdvancedSettingsPlaceholder, UIUtil.getTextFieldBackground());
|
||||
myAdvancedSettings.setLayout(new BorderLayout());
|
||||
myAdvancedSettings.add(myLocationField, BorderLayout.CENTER);
|
||||
UIUtil.setBackgroundRecursively(myCoursesList, LIST_COLOR);
|
||||
UIUtil.setBackgroundRecursively(myDescriptionScrollPane, UIUtil.getPanelBackground());
|
||||
myAdvancedSettingsPlaceholder.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,5 +14,6 @@
|
||||
<orderEntry type="module" module-name="educational-python" />
|
||||
<orderEntry type="module" module-name="python-community-configure" />
|
||||
<orderEntry type="module" module-name="educational-core" />
|
||||
<orderEntry type="library" name="Guava" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -21,11 +21,14 @@ import com.intellij.openapi.projectRoots.SdkAdditionalData;
|
||||
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
|
||||
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel;
|
||||
import com.intellij.openapi.ui.LabeledComponent;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.platform.DirectoryProjectGenerator;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.BooleanFunction;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.jetbrains.edu.learning.core.EduNames;
|
||||
import com.jetbrains.edu.learning.courseFormat.Course;
|
||||
import com.jetbrains.edu.learning.courseFormat.RemoteCourse;
|
||||
@@ -36,8 +39,10 @@ import com.jetbrains.edu.learning.stepic.EduStepicConnector;
|
||||
import com.jetbrains.edu.learning.stepic.StepicUser;
|
||||
import com.jetbrains.edu.learning.ui.StudyNewProjectPanel;
|
||||
import com.jetbrains.python.configuration.PyConfigurableInterpreterList;
|
||||
import com.jetbrains.python.configuration.VirtualEnvProjectFilter;
|
||||
import com.jetbrains.python.newProject.PyNewProjectSettings;
|
||||
import com.jetbrains.python.newProject.PythonProjectGenerator;
|
||||
import com.jetbrains.python.newProject.steps.PythonSdkChooserCombo;
|
||||
import com.jetbrains.python.packaging.PyPackageManager;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.remote.PyProjectSynchronizer;
|
||||
@@ -169,6 +174,21 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator<PyN
|
||||
SdkConfigurationUtil.setDirectoryProjectSdk(project, sdk);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LabeledComponent<JComponent> getLanguageSettingsComponent() {
|
||||
final Project project = ProjectManager.getInstance().getDefaultProject();
|
||||
final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks();
|
||||
VirtualEnvProjectFilter.removeAllAssociated(sdks);
|
||||
|
||||
PythonSdkChooserCombo combo = new PythonSdkChooserCombo(project, sdks, sdk -> true);
|
||||
if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
|
||||
combo.putClientProperty("JButton.buttonType", null);
|
||||
}
|
||||
combo.setButtonIcon(PythonIcons.Python.InterpreterGear);
|
||||
return LabeledComponent.create(combo, "Interpreter", BorderLayout.WEST);
|
||||
}
|
||||
|
||||
public void setValidationResult(ValidationResult validationResult) {
|
||||
myValidationResult = validationResult;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user