Skip to content

Commit

Permalink
Added checking for the course plugin version when creating a new project
Browse files Browse the repository at this point in the history
Related to #147
  • Loading branch information
Taikelenn committed Mar 14, 2021
1 parent 2f7eb67 commit bc5951e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import fi.aalto.cs.apluscourses.model.ComponentInstaller;
import fi.aalto.cs.apluscourses.model.ComponentInstallerImpl;
import fi.aalto.cs.apluscourses.model.Course;
import fi.aalto.cs.apluscourses.model.CoursePluginVersion;
import fi.aalto.cs.apluscourses.model.MalformedCourseConfigurationException;
import fi.aalto.cs.apluscourses.presentation.CourseItemViewModel;
import fi.aalto.cs.apluscourses.presentation.CourseProjectViewModel;
Expand All @@ -42,6 +43,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.JOptionPane;

public class CourseProjectAction extends AnAction {

private static final Logger logger = LoggerFactory.getLogger(CourseProjectAction.class);
Expand Down Expand Up @@ -158,6 +161,15 @@ public void actionPerformed(@NotNull AnActionEvent e) {
return;
}

CoursePluginVersion minVersion = course.getRequiredPluginVersion();
CoursePluginVersion.Status versionCheckResult = minVersion.checkVersion();
if (versionCheckResult == CoursePluginVersion.Status.UPDATE_REQUIRED) {
JOptionPane.showMessageDialog(null, "version error", "test", JOptionPane.ERROR_MESSAGE);
return;
} else if (versionCheckResult == CoursePluginVersion.Status.UPDATE_OPTIONAL) {
JOptionPane.showMessageDialog(null, "version warning", "test", JOptionPane.WARNING_MESSAGE);
}

CourseProjectViewModel courseProjectViewModel
= new CourseProjectViewModel(course, settingsImporter.currentlyImportedIdeSettings());
if (!dialogs.showMainDialog(project, courseProjectViewModel)) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/fi/aalto/cs/apluscourses/model/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ public Map<String, URL> getResourceUrls() {
return Collections.unmodifiableMap(resourceUrls);
}

@NotNull
public CoursePluginVersion getRequiredPluginVersion() {
return minimumPluginVersion;
}

/**
* Returns a list of components that should be installed automatically for this course.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum Status {

// the major and minor version of the current plugin build
private static final int MAJOR_VERSION = 1;
private static final int MINOR_VERSION = 1;
private static final int MINOR_VERSION = 0;
public static final CoursePluginVersion CURRENT_VERSION =
new CoursePluginVersion(MAJOR_VERSION, MINOR_VERSION, "");

Expand Down

0 comments on commit bc5951e

Please sign in to comment.