Minor Fix according to review IDEA-CR-11509: remove explicit getters/setters from...
authorValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Mon, 20 Jun 2016 12:48:02 +0000 (15:48 +0300)
committerValentina Kiryushkina <valentina.kiryushkina@jetbrains.com>
Mon, 20 Jun 2016 12:48:02 +0000 (15:48 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/StudyTaskManager.java
python/educational-core/student/src/com/jetbrains/edu/learning/checker/StudyCheckTask.java
python/educational-core/student/src/com/jetbrains/edu/learning/stepic/EduStepicConnector.java
python/educational-core/student/src/com/jetbrains/edu/learning/stepic/StepicStudyOptions.java

index ff870e726fac9a6889f39a54bce01804919eef05..8b53f1ea785535c5c4722906b0940a6e8b3222ad 100644 (file)
@@ -187,37 +187,7 @@ public class StudyTaskManager implements PersistentStateComponent<Element>, Dumb
   public void setTurnEditingMode(boolean turnEditingMode) {
     myTurnEditingMode = turnEditingMode;
   }
-
-  @Transient
-  public String getLogin() {
-    if (myUser != null) {
-      return myUser.getEmail();
-    }
-    return "";
-  }
-
-  @Transient
-  public void setLogin(String login) {
-    if (myUser != null) {
-      myUser.setEmail(login);
-    }
-  }
-
-  @Transient
-  public String getPassword() {
-    if (myUser != null) {
-      return myUser.getPassword();
-    }
-    return "";
-  }
-
-  @Transient
-  public void setPassword(String password) {
-    if (myUser != null) {
-      myUser.setPassword(password);
-    }
-  }
-
+  
   public StepicUser getUser() {
     return myUser;
   }
index 570951877ed58e65dfd3436feec08beacf38bcab..62374bff04674b6841c45f5e30248f9a55022359 100644 (file)
@@ -210,8 +210,8 @@ public class StudyCheckTask extends com.intellij.openapi.progress.Task.Backgroun
 
   protected void postAttemptToStepic(@NotNull StudyTestsOutputParser.TestsOutput testsOutput) {
     final StudyTaskManager studySettings = StudyTaskManager.getInstance(myProject);
-    final String login = studySettings.getLogin();
-    final String password = StringUtil.isEmptyOrSpaces(login) ? "" : studySettings.getPassword();
+    final String login = studySettings.getUser().getEmail();
+    final String password = StringUtil.isEmptyOrSpaces(login) ? "" : studySettings.getUser().getPassword();
     EduStepicConnector.postAttempt(myTask, testsOutput.isSuccess(), login, password);
   }
 }
index 30429ed8e0610db7da09c5b9a72279f3c62bbe3e..081081923c8f871ec59c019b08f4d2865b00e368 100644 (file)
@@ -513,12 +513,13 @@ public class EduStepicConnector {
   }
 
   private static boolean login(@NotNull final Project project) {
-    final String login = StudyTaskManager.getInstance(project).getLogin();
+    final StepicUser user = StudyTaskManager.getInstance(project).getUser();
+    final String login =  user.getEmail();
     if (StringUtil.isEmptyOrSpaces(login)) {
       return showLoginDialog();
     }
     else {
-      if (login(login, StudyTaskManager.getInstance(project).getPassword()) == null) {
+      if (login(login, user.getPassword()) == null) {
         return showLoginDialog();
       }
     }
index 097c4a64ef9c4aca23f9976388209a5cae5b1199..ae823206ddf41a9cbb7797b51b8f6354fa59c6c1 100644 (file)
@@ -107,8 +107,8 @@ public class StepicStudyOptions implements StudyOptionsProvider {
   public void reset() {
     Project project = StudyUtils.getStudyProject();
     if (project != null) {
-      final StudyTaskManager studySettings = StudyTaskManager.getInstance(project);
-      setLogin(studySettings.getLogin());
+      final StepicUser user = StudyTaskManager.getInstance(project).getUser();
+      setLogin(user.getEmail());
       setPassword(DEFAULT_PASSWORD_TEXT);
 
       resetCredentialsModification();
@@ -128,9 +128,9 @@ public class StepicStudyOptions implements StudyOptionsProvider {
     if (myCredentialsModified) {
       final Project project = StudyUtils.getStudyProject();
       if (project != null) {
-        final StudyTaskManager studyTaskManager = StudyTaskManager.getInstance(project);
-        studyTaskManager.setLogin(getLogin());
-        studyTaskManager.setPassword(getPassword());
+        final StepicUser user = StudyTaskManager.getInstance(project).getUser();
+        user.setEmail(getLogin());
+        user.setPassword(getPassword());
         if (!StringUtil.isEmptyOrSpaces(getLogin()) && !StringUtil.isEmptyOrSpaces(getPassword())) {
           EduStepicConnector.login(getLogin(), getPassword());
         }