mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
synchronize courses after update for custom projects
This commit is contained in:
@@ -2,7 +2,6 @@ package com.jetbrains.python.edu;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.ide.RecentProjectsManager;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
@@ -24,8 +23,6 @@ public class StudyInitialConfigurator {
|
||||
@NonNls private static final String CONFIGURED_V1 = "StudyPyCharm.InitialConfiguration";
|
||||
@NonNls private static final String CONFIGURED_V11 = "StudyPyCharm.InitialConfiguration1.1";
|
||||
|
||||
public static boolean UPDATE_PROJECT = false;
|
||||
|
||||
/**
|
||||
* @noinspection UnusedParameters
|
||||
*/
|
||||
@@ -60,11 +57,6 @@ public class StudyInitialConfigurator {
|
||||
LOG.warn("Couldn't copy bundled courses " + e);
|
||||
}
|
||||
}
|
||||
final File projectDir = new File(ProjectUtil.getBaseDir(), "PythonIntroduction");
|
||||
if (projectDir.exists()) {
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
UPDATE_PROJECT = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.jetbrains.python.edu;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.ide.impl.ProjectUtil;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.notification.Notification;
|
||||
@@ -11,7 +10,6 @@ import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.AnActionListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
@@ -23,7 +21,9 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopupAdapter;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileAdapter;
|
||||
@@ -114,10 +114,8 @@ public class StudyTaskManager implements ProjectComponent, PersistentStateCompon
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
final File pythonIntroduction = new File(ProjectUtil.getBaseDir(), "PythonIntroduction");
|
||||
if (StudyInitialConfigurator.UPDATE_PROJECT && myProject.getBasePath().equals(pythonIntroduction.getAbsolutePath())) {
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
StudyInitialConfigurator.UPDATE_PROJECT = false;
|
||||
if (myCourse != null && !myCourse.isUpToDate()) {
|
||||
myCourse.setUpToDate(true);
|
||||
updateCourse();
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
|
||||
@@ -245,8 +243,17 @@ public class StudyTaskManager implements ProjectComponent, PersistentStateCompon
|
||||
}
|
||||
|
||||
private void updateCourse() {
|
||||
final File userCourseDir = new File(PathManager.getConfigPath(), StudyNames.COURSES);
|
||||
final File courseDir = new File(userCourseDir, StudyNames.INTRODUCTION_COURSE);
|
||||
if (myCourse == null) {
|
||||
return;
|
||||
}
|
||||
File resourceFile = new File(myCourse.getResourcePath());
|
||||
if (!resourceFile.exists()) {
|
||||
return;
|
||||
}
|
||||
final File courseDir = resourceFile.getParentFile();
|
||||
if (!courseDir.exists()) {
|
||||
return;
|
||||
}
|
||||
final File[] files = courseDir.listFiles();
|
||||
if (files == null) return;
|
||||
for (File lesson : files) {
|
||||
|
||||
@@ -24,6 +24,7 @@ public class Course {
|
||||
public String author;
|
||||
public static final String COURSE_DIR = "course";
|
||||
public static final String HINTS_DIR = "hints";
|
||||
private boolean myUpToDate = false;
|
||||
|
||||
|
||||
public List<Lesson> getLessons() {
|
||||
@@ -103,4 +104,12 @@ public class Course {
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public boolean isUpToDate() {
|
||||
return myUpToDate;
|
||||
}
|
||||
|
||||
public void setUpToDate(boolean upToDate) {
|
||||
myUpToDate = upToDate;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user