Skip to content

Commit 225b9c0

Browse files
committed
Error message when using OneDrive for NetbeansProjectFolder
1 parent 23f75f5 commit 225b9c0

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package fi.helsinki.cs.tmc.actions;
2+
3+
import fi.helsinki.cs.tmc.core.configuration.TmcSettings;
4+
import fi.helsinki.cs.tmc.core.holders.TmcSettingsHolder;
5+
import fi.helsinki.cs.tmc.ui.ConvenientDialogDisplayer;
6+
7+
public class CheckForOneDrive {
8+
9+
public static void run() {
10+
TmcSettings settings = TmcSettingsHolder.get();
11+
12+
if (!settings.getTmcProjectDirectory().toAbsolutePath().toString().toLowerCase().contains("onedrive")) {
13+
return;
14+
}
15+
16+
final ConvenientDialogDisplayer displayer = ConvenientDialogDisplayer.getDefault();
17+
18+
StringBuilder htmlBuilder = new StringBuilder();
19+
htmlBuilder.append("<html><body>");
20+
htmlBuilder.append("<h1>OneDrive does not work with Netbeans</h1>");
21+
htmlBuilder.append("<div>Many students have had a problem when they have their Netbeans project folder in OneDrive, which results in submissions failing on the server.<br>The problem can be solved by moving the project folder out of OneDrive as follows:</div>");
22+
htmlBuilder.append("<ol>");
23+
htmlBuilder.append("<li>In Netbeans, close all the exercises by right clicking them on the \"Projects\"-sidebar on the left and selecting \"Close project\".<br>You can select multiple exercises at once by pressing down the shift button on your keyboard and while pressing the button, selecting the first and the last exercise on the list.</li>");
24+
htmlBuilder.append("<li>Copy or move the \"NetbeansProjects\" folder to some path that does not contain the \"OneDrive\" folder.</li>");
25+
htmlBuilder.append("<li>Now you can change the Netbeans project folder to the path you selected on step 2 by selecting \"TMC\" -> \"Settings\".</li>");
26+
htmlBuilder.append("<li>Open the moved exercises by selecting \"File\" -> \"Open Project...\", and selecting the exercises from the new folder.</li>");
27+
htmlBuilder.append("</ol>");
28+
htmlBuilder.append("</body></html>");
29+
30+
String errorMsg = htmlBuilder.toString();
31+
32+
displayer.displayError(errorMsg);
33+
}
34+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public void run() {
4646

4747
CheckForOutdatedNetbeans.run();
4848

49+
CheckForOneDrive.run();
50+
4951
TmcCore.setInstance(new TmcCore());
5052

5153
CheckForNewExercisesOrUpdates.startTimer();

tmc-plugin/src/fi/helsinki/cs/tmc/ui/PreferencesPanel.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,17 @@ private void folderChooserBtnActionPerformed(java.awt.event.ActionEvent evt) {//
492492
return;
493493
}
494494
File projectDefaultFolder = folderChooser.getSelectedFile();
495+
496+
final String projectDefaultFolderPath = projectDefaultFolder.getAbsolutePath();
497+
498+
final String errorMsg = "OneDrive doesn't work with Netbeans.\nPlease use another folder for your projects.";
499+
500+
if (projectDefaultFolderPath.toLowerCase().contains("onedrive")) {
501+
dialogs.displayError(errorMsg);
502+
return;
503+
}
495504

496-
projectFolderTextField.setText(projectDefaultFolder.getAbsolutePath());
505+
projectFolderTextField.setText(projectDefaultFolderPath);
497506
}//GEN-LAST:event_folderChooserBtnActionPerformed
498507

499508
private void changeCourseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeCourseButtonActionPerformed

0 commit comments

Comments
 (0)