From e69e41faff8ddb489d0de0e1fb71d1fb74c9698e Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Wed, 7 Dec 2016 14:58:52 +0300 Subject: [PATCH] fix EDU-743 Disable create button in new project dialog if no course selected Properly compare invalid courses. By accident fixed error label listener also --- .../jetbrains/edu/learning/stepic/CourseInfo.java | 14 +++++++++++--- .../edu/learning/stepic/EduStepicConnector.java | 2 +- .../edu/learning/ui/StudyNewProjectPanel.java | 4 ++++ .../learning/PyStudyDirectoryProjectGenerator.java | 9 ++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/CourseInfo.java b/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/CourseInfo.java index 94accb19510d..deff5ee2611f 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/CourseInfo.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/CourseInfo.java @@ -60,9 +60,17 @@ public class CourseInfo { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CourseInfo that = (CourseInfo)o; - if (that.getName() == null || that.getDescription() == null) return false; - return that.getName().equals(getName()) - && that.getDescription().equals(myDescription); + final String thatName = that.getName(); + final String thatDescription = that.getDescription(); + if (thatName == null && getName() == null && thatDescription == null && + getDescription() == null) { + return true; + } + if (thatName == null || thatDescription == null) { + return false; + } + return thatName.equals(getName()) + && thatDescription.equals(myDescription); } @Override diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/EduStepicConnector.java b/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/EduStepicConnector.java index c425afe46c8d..9b5939471d61 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/EduStepicConnector.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/stepic/EduStepicConnector.java @@ -70,7 +70,7 @@ public class EduStepicConnector { return result; } catch (IOException e) { - LOG.error("Cannot load course list " + e.getMessage()); + LOG.warn("Cannot load course list " + e.getMessage()); } return Collections.singletonList(CourseInfo.INVALID_COURSE); } diff --git a/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyNewProjectPanel.java b/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyNewProjectPanel.java index f6d3df530e20..5e08f41115cf 100644 --- a/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyNewProjectPanel.java +++ b/python/educational-core/student/src/com/jetbrains/edu/learning/ui/StudyNewProjectPanel.java @@ -216,6 +216,10 @@ public class StudyNewProjectPanel extends JPanel implements PanelWithAnchor { isComboboxInitialized = true; initCoursesCombobox(); } + CourseInfo selectedCourse = (CourseInfo)myCoursesComboBox.getSelectedItem(); + if (selectedCourse == null || selectedCourse.equals(CourseInfo.INVALID_COURSE)) { + setError(CONNECTION_ERROR); + } } }); } diff --git a/python/educational-python/student-python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java b/python/educational-python/student-python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java index 52a964e8e4bd..988fef5e51cd 100644 --- a/python/educational-python/student-python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java +++ b/python/educational-python/student-python/src/com/jetbrains/edu/learning/PyStudyDirectoryProjectGenerator.java @@ -81,21 +81,24 @@ public class PyStudyDirectoryProjectGenerator extends PythonProjectGenerator