Skip to content

Commit e74e524

Browse files
committed
More fixes
1 parent 5d0a89d commit e74e524

25 files changed

+98
-53
lines changed

tmc-plugin/nbproject/genfiles.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ [email protected]
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
66
nbproject/build-impl.xml.data.CRC32=71dc5f8e
77
nbproject/build-impl.xml.script.CRC32=72a9c69e
8-
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.71.1
8+
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.72.1
Binary file not shown.

tmc-plugin/src/fi/helsinki/cs/tmc/actions/DownloadExercisesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void bgTaskReady(List<Exercise> result) {
7474
return;
7575
}
7676
TmcProjectInfo proj = projectMediator.tryGetProjectForExercise(result.get(0));
77-
77+
7878
if (proj == null) {
7979
throw new RuntimeException("Failed to open project for exercise " + exercise.getName());
8080
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package fi.helsinki.cs.tmc.actions;
2+
3+
import java.io.IOException;
4+
import java.nio.file.Files;
5+
import java.nio.file.Path;
6+
import java.nio.file.Paths;
7+
import java.nio.file.attribute.PosixFilePermission;
8+
import java.util.Set;
9+
10+
public class EnsureMavenBinaryIsExecutable {
11+
12+
private final static Path RELATIVE_MAVEN_LOCATION = Paths.get("java").resolve("maven").resolve("bin").resolve("mvn");
13+
14+
private final Path mavenPath;
15+
private final boolean isUnix;
16+
17+
public EnsureMavenBinaryIsExecutable() {
18+
Path pathCandidate = Paths.get(System.getProperty("user.dir")).resolve(RELATIVE_MAVEN_LOCATION);
19+
if (Files.exists(pathCandidate)) {
20+
this.mavenPath = pathCandidate;
21+
} else {
22+
this.mavenPath = Paths.get(System.getProperty("user.dir")).resolve("../").resolve(RELATIVE_MAVEN_LOCATION);
23+
}
24+
this.isUnix = !System.getProperty("os.name").startsWith("Windows");
25+
}
26+
27+
public void run() {
28+
if (!isUnix || !Files.exists(mavenPath)) {
29+
return;
30+
}
31+
try {
32+
Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(mavenPath);
33+
if (!permissions.contains(PosixFilePermission.OWNER_EXECUTE)) {
34+
permissions.add(PosixFilePermission.OWNER_EXECUTE);
35+
Files.setPosixFilePermissions(mavenPath, permissions);
36+
}
37+
} catch (IOException ex) { }
38+
}
39+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package fi.helsinki.cs.tmc.actions;
2+
3+
import org.openide.util.NbPreferences;
4+
5+
import java.util.prefs.Preferences;
6+
7+
public class FixUnoptimalSettings {
8+
9+
private final Preferences mavenPrefrences;
10+
11+
public FixUnoptimalSettings() {
12+
this.mavenPrefrences = NbPreferences.root()
13+
.node("org")
14+
.node("netbeans")
15+
.node("modules")
16+
.node("maven");
17+
}
18+
19+
public void run() {
20+
fixMavenDependencyDownloadPolicy();
21+
}
22+
23+
private void fixMavenDependencyDownloadPolicy() {
24+
final String binaryDownloadValue = mavenPrefrences.get("binaryDownload", "");
25+
if (!binaryDownloadValue.equals("EVERY_OPEN")) {
26+
mavenPrefrences.put("binaryDownload", "EVERY_OPEN");
27+
}
28+
}
29+
30+
void undo() {
31+
final String binaryDownloadValue = mavenPrefrences.get("binaryDownload", "");
32+
if (binaryDownloadValue.equals("EVERY_OPEN")) {
33+
mavenPrefrences.put("binaryDownload", "NEVER");
34+
}
35+
}
36+
}

tmc-plugin/src/fi/helsinki/cs/tmc/actions/PastebinAction.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,8 @@ protected CourseDb getCourseDb() {
7474

7575
@Override
7676
public boolean enable(Project... projects) {
77-
if (projects.length > 1) {
78-
return false; // One at a time please
79-
} else {
80-
return super.enable(projects);
81-
}
77+
// One at a time please
78+
return projects.length <= 1 && super.enable(projects);
8279
}
8380

8481
@Override

tmc-plugin/src/fi/helsinki/cs/tmc/actions/ReviewEventListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static void start() {
5858
this.eventBus = TmcEventBus.getDefault();
5959
}
6060

61-
public void receive(PushEventListener.ReviewAvailableEvent e) throws Throwable {
61+
public void receive(PushEventListener.ReviewAvailableEvent e) {
6262
SwingUtilities.invokeLater(new Runnable() {
6363
@Override
6464
public void run() {
@@ -67,7 +67,7 @@ public void run() {
6767
});
6868
}
6969

70-
public void receive(ReviewDb.NewUnreadReviewEvent e) throws Throwable {
70+
public void receive(ReviewDb.NewUnreadReviewEvent e) {
7171
final Review review = e.review;
7272
SwingUtilities.invokeLater(new Runnable() {
7373
@Override

tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,17 @@
1010
import fi.helsinki.cs.tmc.langs.domain.RunResult;
1111
import fi.helsinki.cs.tmc.model.CourseDb;
1212
import fi.helsinki.cs.tmc.model.ProjectMediator;
13-
import fi.helsinki.cs.tmc.model.SourceFileLookup;
1413
import fi.helsinki.cs.tmc.ui.TestResultDisplayer;
1514
import fi.helsinki.cs.tmc.utilities.BgTask;
1615
import fi.helsinki.cs.tmc.utilities.BgTaskListener;
1716

1817
import java.util.concurrent.Callable;
1918
import java.util.logging.Level;
2019
import java.util.logging.Logger;
21-
import java.util.prefs.BackingStoreException;
22-
import java.util.prefs.Preferences;
20+
2321
import org.netbeans.api.project.Project;
24-
import org.openide.filesystems.FileObject;
2522
import org.openide.nodes.Node;
26-
import org.openide.util.Exceptions;
2723
import org.openide.util.NbBundle.Messages;
28-
import org.openide.util.NbPreferences;
2924
import org.openide.windows.WindowManager;
3025

3126
@Messages("CTL_RunTestsLocallyExerciseAction=Run &tests locally")

tmc-plugin/src/fi/helsinki/cs/tmc/data/ResultCollector.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,8 @@ private boolean isSubmittable() {
112112
return isReturnable;
113113
}
114114

115-
if (!validationResults.getValidationErrors().isEmpty()) {
116-
return false;
117-
}
115+
return validationResults.getValidationErrors().isEmpty() && isReturnable;
118116

119-
return isReturnable;
120117
}
121118

122119
private List<String> tryToCleanLog(List<String> log) {

tmc-plugin/src/fi/helsinki/cs/tmc/model/CourseDb.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ public Course getCourseByName(String name) {
130130

131131
public boolean isUnlockable(Exercise ex) {
132132
Course course = getCourseByName(ex.getCourseName());
133-
if (course != null) {
134-
return course.getUnlockables().contains(ex.getName());
135-
} else {
136-
return false;
137-
}
133+
return course != null && course.getUnlockables().contains(ex.getName());
138134
}
139135

140136
/**

0 commit comments

Comments
 (0)