File tree Expand file tree Collapse file tree 5 files changed +24
-13
lines changed
tmc-plugin/src/fi/helsinki/cs/tmc Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Original file line number Diff line number Diff line change 1414import java .io .UnsupportedEncodingException ;
1515import java .net .MalformedURLException ;
1616import java .net .URL ;
17+ import java .nio .file .Paths ;
1718import java .util .Collection ;
1819
1920/**
@@ -44,7 +45,7 @@ public InputStream openInputStream() {
4445 public UpdateCenterLayerGen () {
4546 synchronized (UpdateCenterLayerGen .class ) {
4647 if (!callbackRegistered ) {
47- CallbackURLStreamHandler .registerCallback (CALLBACK_NAME , callback );
48+ CallbackURLStreamHandler .registerCallback (Paths . get ( CALLBACK_NAME ) , callback );
4849 }
4950 callbackRegistered = true ;
5051 }
Original file line number Diff line number Diff line change 77import fi .helsinki .cs .tmc .tailoring .Tailoring ;
88import fi .helsinki .cs .tmc .core .configuration .TmcSettings ;
99import fi .helsinki .cs .tmc .core .domain .Course ;
10+
11+ import java .nio .file .Path ;
12+ import java .nio .file .Paths ;
1013import java .util .Locale ;
1114
1215/**
@@ -143,7 +146,7 @@ public void setSavingPassword(boolean shouldSave) {
143146 if (shouldSave ) {
144147 settings .put (PREF_PASSWORD , unsavedPassword );
145148 } else {
146- settings .remove (PREF_PASSWORD );
149+ settings .remove (PREF_PASSWORD );
147150 }
148151 }
149152
@@ -153,9 +156,9 @@ public boolean isSavingPassword() {
153156
154157 @ Override
155158 public String getTmcMainDirectory () {
156- String path = settings .get (PREF_PROJECT_ROOT_DIR , null );
159+ Path path = Paths . get ( settings .get (PREF_PROJECT_ROOT_DIR , null ) );
157160 if (path != null ) {
158- return path ;
161+ return path . toString () ;
159162 } else {
160163 // Can sometimes take a while. That's why we don't pass it as a default above.
161164 return ProjectMediator .getDefaultProjectRootDir ();
Original file line number Diff line number Diff line change 22
33import fi .helsinki .cs .tmc .core .domain .Exercise ;
44import fi .helsinki .cs .tmc .utilities .ExceptionUtils ;
5+
56import java .io .File ;
67import java .io .IOException ;
8+ import java .nio .file .Path ;
9+ import java .nio .file .Paths ;
710import java .util .ArrayList ;
811import java .util .Arrays ;
912import java .util .Collection ;
@@ -113,13 +116,13 @@ public File getCourseRootDir(String courseName) {
113116 * The exercise must have a course name set.
114117 */
115118 public File getProjectDirForExercise (Exercise ex ) {
116- String path =
119+ Path path = Paths . get (
117120 getProjectRootDir ()
118121 + File .separator
119122 + ex .getCourseName ()
120123 + File .separator
121- + ex .getName ().replaceAll ("-" , "/" );
122- File file = new File ( path );
124+ + ex .getName ().replaceAll ("-" , "/" )) ;
125+ File file = path . toFile ( );
123126 return FileUtil .normalizeFile (file );
124127 }
125128
Original file line number Diff line number Diff line change 22
33import fi .helsinki .cs .tmc .core .domain .Exercise ;
44
5+ import java .nio .file .Path ;
6+ import java .nio .file .Paths ;
7+
58import org .netbeans .api .java .classpath .GlobalPathRegistry ;
69import org .openide .filesystems .FileObject ;
710
@@ -24,20 +27,20 @@ private SourceFileLookup(
2427
2528 public FileObject findSourceFileFor (Exercise exercise , String className ) {
2629 String outerClassName = className .replaceAll ("\\ $.*$" , "" );
27- String path = outerClassName .replace ('.' , '/' ) + ".java" ;
30+ Path path = Paths . get ( outerClassName .replace ('.' , '/' ) + ".java" ) ;
2831
2932 TmcProjectInfo correctProject = projectMediator .tryGetProjectForExercise (exercise );
3033 for (FileObject sr : globalPathRegistry .getSourceRoots ()) {
3134 TmcProjectInfo p = projectMediator .tryGetProjectOwningFile (sr );
3235 if (p != null && p .equals (correctProject )) {
33- FileObject result = sr .getFileObject (path );
36+ FileObject result = sr .getFileObject (path . toString () );
3437 if (result != null ) {
3538 return result ;
3639 }
3740 }
3841 }
3942
4043 // Fall back to findResource picking a source root from any project.
41- return GlobalPathRegistry .getDefault ().findResource (path );
44+ return GlobalPathRegistry .getDefault ().findResource (path . toString () );
4245 }
4346}
Original file line number Diff line number Diff line change 99import java .net .URL ;
1010import java .net .URLConnection ;
1111import java .net .URLStreamHandler ;
12+ import java .nio .file .Path ;
1213import java .util .Map ;
1314
1415/**
@@ -23,11 +24,11 @@ public class CallbackURLStreamHandler extends URLStreamHandler {
2324
2425 private static final Map <String , URLCallback > callbacks = Maps .newHashMap ();
2526
26- public static void registerCallback (String path , URLCallback callback ) {
27+ public static void registerCallback (Path path , URLCallback callback ) {
2728 if (callback == null ) {
28- callbacks .remove (path );
29+ callbacks .remove (path . toString () );
2930 } else {
30- callbacks .put (path , callback );
31+ callbacks .put (path . toString () , callback );
3132 }
3233 }
3334
You can’t perform that action at this time.
0 commit comments