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 14
14
import java .io .UnsupportedEncodingException ;
15
15
import java .net .MalformedURLException ;
16
16
import java .net .URL ;
17
+ import java .nio .file .Paths ;
17
18
import java .util .Collection ;
18
19
19
20
/**
@@ -44,7 +45,7 @@ public InputStream openInputStream() {
44
45
public UpdateCenterLayerGen () {
45
46
synchronized (UpdateCenterLayerGen .class ) {
46
47
if (!callbackRegistered ) {
47
- CallbackURLStreamHandler .registerCallback (CALLBACK_NAME , callback );
48
+ CallbackURLStreamHandler .registerCallback (Paths . get ( CALLBACK_NAME ) , callback );
48
49
}
49
50
callbackRegistered = true ;
50
51
}
Original file line number Diff line number Diff line change 7
7
import fi .helsinki .cs .tmc .tailoring .Tailoring ;
8
8
import fi .helsinki .cs .tmc .core .configuration .TmcSettings ;
9
9
import fi .helsinki .cs .tmc .core .domain .Course ;
10
+
11
+ import java .nio .file .Path ;
12
+ import java .nio .file .Paths ;
10
13
import java .util .Locale ;
11
14
12
15
/**
@@ -143,7 +146,7 @@ public void setSavingPassword(boolean shouldSave) {
143
146
if (shouldSave ) {
144
147
settings .put (PREF_PASSWORD , unsavedPassword );
145
148
} else {
146
- settings .remove (PREF_PASSWORD );
149
+ settings .remove (PREF_PASSWORD );
147
150
}
148
151
}
149
152
@@ -153,9 +156,9 @@ public boolean isSavingPassword() {
153
156
154
157
@ Override
155
158
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 ) );
157
160
if (path != null ) {
158
- return path ;
161
+ return path . toString () ;
159
162
} else {
160
163
// Can sometimes take a while. That's why we don't pass it as a default above.
161
164
return ProjectMediator .getDefaultProjectRootDir ();
Original file line number Diff line number Diff line change 2
2
3
3
import fi .helsinki .cs .tmc .core .domain .Exercise ;
4
4
import fi .helsinki .cs .tmc .utilities .ExceptionUtils ;
5
+
5
6
import java .io .File ;
6
7
import java .io .IOException ;
8
+ import java .nio .file .Path ;
9
+ import java .nio .file .Paths ;
7
10
import java .util .ArrayList ;
8
11
import java .util .Arrays ;
9
12
import java .util .Collection ;
@@ -113,13 +116,13 @@ public File getCourseRootDir(String courseName) {
113
116
* The exercise must have a course name set.
114
117
*/
115
118
public File getProjectDirForExercise (Exercise ex ) {
116
- String path =
119
+ Path path = Paths . get (
117
120
getProjectRootDir ()
118
121
+ File .separator
119
122
+ ex .getCourseName ()
120
123
+ File .separator
121
- + ex .getName ().replaceAll ("-" , "/" );
122
- File file = new File ( path );
124
+ + ex .getName ().replaceAll ("-" , "/" )) ;
125
+ File file = path . toFile ( );
123
126
return FileUtil .normalizeFile (file );
124
127
}
125
128
Original file line number Diff line number Diff line change 2
2
3
3
import fi .helsinki .cs .tmc .core .domain .Exercise ;
4
4
5
+ import java .nio .file .Path ;
6
+ import java .nio .file .Paths ;
7
+
5
8
import org .netbeans .api .java .classpath .GlobalPathRegistry ;
6
9
import org .openide .filesystems .FileObject ;
7
10
@@ -24,20 +27,20 @@ private SourceFileLookup(
24
27
25
28
public FileObject findSourceFileFor (Exercise exercise , String className ) {
26
29
String outerClassName = className .replaceAll ("\\ $.*$" , "" );
27
- String path = outerClassName .replace ('.' , '/' ) + ".java" ;
30
+ Path path = Paths . get ( outerClassName .replace ('.' , '/' ) + ".java" ) ;
28
31
29
32
TmcProjectInfo correctProject = projectMediator .tryGetProjectForExercise (exercise );
30
33
for (FileObject sr : globalPathRegistry .getSourceRoots ()) {
31
34
TmcProjectInfo p = projectMediator .tryGetProjectOwningFile (sr );
32
35
if (p != null && p .equals (correctProject )) {
33
- FileObject result = sr .getFileObject (path );
36
+ FileObject result = sr .getFileObject (path . toString () );
34
37
if (result != null ) {
35
38
return result ;
36
39
}
37
40
}
38
41
}
39
42
40
43
// Fall back to findResource picking a source root from any project.
41
- return GlobalPathRegistry .getDefault ().findResource (path );
44
+ return GlobalPathRegistry .getDefault ().findResource (path . toString () );
42
45
}
43
46
}
Original file line number Diff line number Diff line change 9
9
import java .net .URL ;
10
10
import java .net .URLConnection ;
11
11
import java .net .URLStreamHandler ;
12
+ import java .nio .file .Path ;
12
13
import java .util .Map ;
13
14
14
15
/**
@@ -23,11 +24,11 @@ public class CallbackURLStreamHandler extends URLStreamHandler {
23
24
24
25
private static final Map <String , URLCallback > callbacks = Maps .newHashMap ();
25
26
26
- public static void registerCallback (String path , URLCallback callback ) {
27
+ public static void registerCallback (Path path , URLCallback callback ) {
27
28
if (callback == null ) {
28
- callbacks .remove (path );
29
+ callbacks .remove (path . toString () );
29
30
} else {
30
- callbacks .put (path , callback );
31
+ callbacks .put (path . toString () , callback );
31
32
}
32
33
}
33
34
You can’t perform that action at this time.
0 commit comments