Skip to content

Commit

Permalink
EDU-827 Do not open random file on creating new subtask
Browse files Browse the repository at this point in the history
  • Loading branch information
ktisha committed Jan 10, 2017
1 parent 1b91778 commit d6059b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public PopupStep onChosen(String selectedValue, boolean finalChoice) {
if (activeSubtaskIndex > mySubtaskIndex) {
myTask.setActiveSubtaskIndex(activeSubtaskIndex - 1);
}
StudySubtaskUtils.updateUI(myProject, myTask, taskDir);
StudySubtaskUtils.updateUI(myProject, myTask, taskDir, true);
for (VirtualFile file : FileEditorManager.getInstance(myProject).getOpenFiles()) {
EditorNotifications.getInstance(myProject).updateNotifications(file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void addSubtask(@NotNull Task task, @NotNull Project project) {
createTestsForNewSubtask(project, task);
int num = task.getLastSubtaskIndex() + 1;
createTaskDescriptionFile(project, taskDir, num);
StudySubtaskUtils.switchStep(project, task, num);
StudySubtaskUtils.switchStep(project, task, num, false);
task.setLastSubtaskIndex(num);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ public class StudySubtaskUtils {
private StudySubtaskUtils() {
}

public static void switchStep(@NotNull Project project, @NotNull Task task, int toSubtaskIndex) {
switchStep(project, task, toSubtaskIndex, true);
}

/***
* @param toSubtaskIndex from 0 to subtaskNum - 1
*/
public static void switchStep(@NotNull Project project, @NotNull Task task, int toSubtaskIndex) {
public static void switchStep(@NotNull Project project, @NotNull Task task, int toSubtaskIndex, boolean navigateToTask) {
if (toSubtaskIndex == task.getActiveSubtaskIndex()) {
return;
}
Expand Down Expand Up @@ -79,7 +83,7 @@ public static void switchStep(@NotNull Project project, @NotNull Task task, int
}
transformTestFile(project, toSubtaskIndex, taskDir);
task.setActiveSubtaskIndex(toSubtaskIndex);
updateUI(project, task, taskDir);
updateUI(project, task, taskDir, navigateToTask);

for (StudySubtaskChangeListener listener : Extensions.getExtensions(StudySubtaskChangeListener.EP_NAME)) {
listener.subtaskChanged(project, task, fromSubtaskIndex, toSubtaskIndex);
Expand Down Expand Up @@ -112,7 +116,7 @@ private static void transformTestFile(@NotNull Project project, int toSubtaskInd
}
}

public static void updateUI(@NotNull Project project, @NotNull Task task, VirtualFile taskDir) {
public static void updateUI(@NotNull Project project, @NotNull Task task, VirtualFile taskDir, boolean navigateToTask) {
StudyCheckUtils.drawAllPlaceholders(project, task);
ProjectView.getInstance(project).refresh();
StudyToolWindow toolWindow = StudyUtils.getStudyToolWindow(project);
Expand All @@ -124,7 +128,9 @@ public static void updateUI(@NotNull Project project, @NotNull Task task, Virtua
}
toolWindow.setTaskText(text, taskDir, project);
}
StudyNavigator.navigateToTask(project, task);
if (navigateToTask) {
StudyNavigator.navigateToTask(project, task);
}
}

private static void updatePlaceholderTexts(@NotNull Document document,
Expand Down

0 comments on commit d6059b2

Please sign in to comment.