Skip to content

Commit c53e3ce

Browse files
committed
Cleanuop whitespace, reorder and group imports.
1 parent 1ff8a2f commit c53e3ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+412
-367
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ public void bgTaskFailed(Throwable ex) {
100100
dialogs.displayError("Failed to download exercises.\n" + ServerErrorHelper.getServerExceptionMsg(ex));
101101
}
102102
};
103-
}
103+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.Map;
1919
import java.util.logging.Level;
2020
import java.util.logging.Logger;
21-
import javax.swing.SwingUtilities;
2221

2322
/**
2423
* Stores the list of available courses, the current course and its exercise

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import fi.helsinki.cs.tmc.core.domain.Review;
44
import fi.helsinki.cs.tmc.events.TmcEvent;
55
import fi.helsinki.cs.tmc.events.TmcEventBus;
6+
67
import java.util.ArrayList;
78
import java.util.HashSet;
89
import java.util.List;
9-
import java.util.Set;
1010
import java.util.logging.Logger;
1111

1212
/**
1313
* Stores and periodically updates reviews.
14-
*
14+
*
1515
* <p>
1616
* Currently this is an in-memory-only store, so it's always initially empty when the program starts.
1717
*/
@@ -23,23 +23,23 @@ public NewUnreadReviewEvent(Review review) {
2323
this.review = review;
2424
}
2525
}
26-
26+
2727
public static final Logger logger = Logger.getLogger(CourseDb.class.getName());
2828
private static ReviewDb instance;
29-
29+
3030
private TmcEventBus eventBus; //TODO: send out an event on new unread reviews
31-
31+
3232
public static ReviewDb getInstance() {
3333
if (instance == null) {
3434
instance = new ReviewDb();
3535
}
3636
return instance;
3737
}
38-
39-
38+
39+
4040
private ArrayList<Review> reviews;
4141
private HashSet<Integer> reviewIdsNotifiedAbout;
42-
42+
4343
private ReviewDb() {
4444
this(TmcEventBus.getDefault());
4545
this.reviews = new ArrayList<Review>();
@@ -49,10 +49,10 @@ private ReviewDb() {
4949
public ReviewDb(TmcEventBus eventBus) {
5050
this.eventBus = eventBus;
5151
}
52-
52+
5353
/**
5454
* Updates the review store and fires an event if there is a new unread review.
55-
*
55+
*
5656
* @return whether there were any new unread reviews (for which events were fired).
5757
*/
5858
public boolean setReviews(List<Review> newReviews) {
@@ -63,22 +63,22 @@ public boolean setReviews(List<Review> newReviews) {
6363
notifyAboutNewReview(review);
6464
}
6565
}
66-
66+
6767
this.reviews.clear();
6868
this.reviews.addAll(newReviews);
6969
return newUnreadReviewsSeen;
7070
}
71-
71+
7272
/**
7373
* Makes it so that all unread reviews cause a notification again.
7474
* Normally an unread review is not notified about twice.
7575
*/
7676
public void forgetReviewsNotifiedAbout() {
7777
reviewIdsNotifiedAbout.clear();
7878
}
79-
79+
8080
private void notifyAboutNewReview(Review review) {
8181
reviewIdsNotifiedAbout.add(review.getId());
8282
eventBus.post(new NewUnreadReviewEvent(review));
8383
}
84-
}
84+
}

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

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
package fi.helsinki.cs.tmc.model;
22

3-
import com.google.gson.Gson;
4-
import com.google.gson.GsonBuilder;
5-
import com.google.gson.JsonObject;
6-
import com.google.gson.JsonParser;
7-
import com.google.gson.reflect.TypeToken;
83
import fi.helsinki.cs.tmc.core.domain.Course;
94
import fi.helsinki.cs.tmc.core.domain.Exercise;
105
import fi.helsinki.cs.tmc.data.FeedbackAnswer;
@@ -20,6 +15,15 @@
2015
import fi.helsinki.cs.tmc.utilities.http.FailedHttpResponseException;
2116
import fi.helsinki.cs.tmc.utilities.http.HttpTasks;
2217
import fi.helsinki.cs.tmc.core.TmcCore;
18+
19+
import com.google.gson.Gson;
20+
import com.google.gson.GsonBuilder;
21+
import com.google.gson.JsonObject;
22+
import com.google.gson.JsonParser;
23+
import com.google.gson.reflect.TypeToken;
24+
25+
import org.openide.modules.Modules;
26+
2327
import java.io.ByteArrayOutputStream;
2428
import java.io.IOException;
2529
import java.io.OutputStreamWriter;
@@ -66,30 +70,30 @@ public ServerAccess(
6670
this.reviewListParser = reviewListParser;
6771
this.clientVersion = getClientVersion();
6872
}
69-
73+
7074
private static String getClientVersion() {
7175
return Modules.getDefault().ownerOf(ServerAccess.class).getSpecificationVersion().toString();
7276
}
73-
77+
7478
public void setSettings(NbTmcSettings settings) {
7579
this.settings = settings;
7680
}
77-
81+
7882
private String getCourseListUrl() {
7983
return addApiCallQueryParameters(settings.getServerAddress() + "/courses.json");
8084
}
81-
85+
8286
public String addApiCallQueryParameters(String url) {
8387
url = UriUtils.withQueryParam(url, "api_version", ""+API_VERSION);
8488
url = UriUtils.withQueryParam(url, "client", "netbeans_plugin");
8589
url = UriUtils.withQueryParam(url, "client_version", getClientVersion());
8690
return url;
8791
}
88-
92+
8993
private HttpTasks createHttpTasks() {
9094
return new HttpTasks().setCredentials(settings.getUsername(), settings.getPassword());
9195
}
92-
96+
9397
public boolean hasEnoughSettings() {
9498
return
9599
!settings.getUsername().isEmpty() &&
@@ -103,7 +107,7 @@ public boolean needsOnlyPassword() {
103107
settings.getPassword().isEmpty() &&
104108
!settings.getServerAddress().isEmpty();
105109
}
106-
110+
107111
@Deprecated
108112
public CancellableCallable<List<Course>> getDownloadingCourseListTask() {
109113
final CancellableCallable<String> download = createHttpTasks().getForText(getCourseListUrl());
@@ -146,7 +150,7 @@ public boolean cancel() {
146150
}
147151
};
148152
}
149-
153+
150154
public CancellableCallable<Void> getUnlockingTask(Course course) {
151155
Map<String, String> params = Collections.emptyMap();
152156
final CancellableCallable<String> download = createHttpTasks().postForText(getUnlockUrl(course), params);
@@ -167,16 +171,16 @@ public boolean cancel() {
167171
}
168172
};
169173
}
170-
174+
171175
private String getUnlockUrl(Course course) {
172176
return addApiCallQueryParameters(course.getUnlockUrl());
173177
}
174-
178+
175179
public CancellableCallable<byte[]> getDownloadingExerciseZipTask(Exercise exercise) {
176180
String zipUrl = exercise.getDownloadUrl();
177181
return createHttpTasks().getForBinary(zipUrl);
178182
}
179-
183+
180184
public CancellableCallable<byte[]> getDownloadingExerciseSolutionZipTask(Exercise exercise) {
181185
String zipUrl = exercise.getSolutionDownloadUrl();
182186
return createHttpTasks().getForBinary(zipUrl);
@@ -192,7 +196,7 @@ public CancellableCallable<SubmissionResponse> getSubmittingExerciseTask(final E
192196

193197
final CancellableCallable<String> upload =
194198
createHttpTasks().uploadFileForTextDownload(submitUrl, params, "submission[file]", sourceZip);
195-
199+
196200
return new CancellableCallable<SubmissionResponse>() {
197201
@Override
198202
public SubmissionResponse call() throws Exception {
@@ -202,7 +206,7 @@ public SubmissionResponse call() throws Exception {
202206
} catch (FailedHttpResponseException ex) {
203207
return checkForObsoleteClient(ex);
204208
}
205-
209+
206210
JsonObject respJson = new JsonParser().parse(response).getAsJsonObject();
207211
if (respJson.get("error") != null) {
208212
throw new RuntimeException("Server responded with error: " + respJson.get("error"));
@@ -234,11 +238,11 @@ public SubmissionResponse(URI submissionUrl, URI pasteUrl) {
234238
this.pasteUrl = pasteUrl;
235239
}
236240
}
237-
241+
238242
public CancellableCallable<String> getSubmissionFetchTask(String submissionUrl) {
239243
return createHttpTasks().getForText(submissionUrl);
240244
}
241-
245+
242246
public CancellableCallable<List<Review>> getDownloadingReviewListTask(Course course) {
243247
String url = addApiCallQueryParameters(course.getReviewsUrl());
244248
final CancellableCallable<String> download = createHttpTasks().getForText(url);
@@ -259,7 +263,7 @@ public boolean cancel() {
259263
}
260264
};
261265
}
262-
266+
263267
public CancellableCallable<Void> getMarkingReviewAsReadTask(Review review, boolean read) {
264268
String url = addApiCallQueryParameters(review.getUpdateUrl() + ".json");
265269
Map<String, String> params = new HashMap<String, String>();
@@ -269,7 +273,7 @@ public CancellableCallable<Void> getMarkingReviewAsReadTask(Review review, boole
269273
} else {
270274
params.put("mark_as_unread", "1");
271275
}
272-
276+
273277
final CancellableCallable<String> task = createHttpTasks().postForText(url, params);
274278
return new CancellableCallable<Void>() {
275279
@Override
@@ -284,20 +288,20 @@ public boolean cancel() {
284288
}
285289
};
286290
}
287-
291+
288292
public CancellableCallable<String> getFeedbackAnsweringJob(String answerUrl, List<FeedbackAnswer> answers) {
289293
final String submitUrl = addApiCallQueryParameters(answerUrl);
290-
294+
291295
Map<String, String> params = new HashMap<String, String>();
292296
for (int i = 0; i < answers.size(); ++i) {
293297
String keyPrefix = "answers[" + i + "]";
294298
FeedbackAnswer answer = answers.get(i);
295299
params.put(keyPrefix + "[question_id]", "" + answer.getQuestion().getId());
296300
params.put(keyPrefix + "[answer]", answer.getAnswer());
297301
}
298-
302+
299303
final CancellableCallable<String> upload = createHttpTasks().postForText(submitUrl, params);
300-
304+
301305
return new CancellableCallable<String>() {
302306
@Override
303307
public String call() throws Exception {
@@ -314,7 +318,7 @@ public boolean cancel() {
314318
}
315319
};
316320
}
317-
321+
318322
public CancellableCallable<Object> getSendEventLogJob(String spywareServerUrl, List<LoggableEvent> events) {
319323
String url = addApiCallQueryParameters(spywareServerUrl);
320324

@@ -361,7 +365,7 @@ public byte[] eventListToPostBody(List<LoggableEvent> events) throws IOException
361365

362366
return bufferBos.toByteArray();
363367
}
364-
368+
365369
private <T> T checkForObsoleteClient(FailedHttpResponseException ex) throws ObsoleteClientException, FailedHttpResponseException {
366370
if (ex.getStatusCode() == 404) {
367371
boolean obsolete;
@@ -377,4 +381,4 @@ private <T> T checkForObsoleteClient(FailedHttpResponseException ex) throws Obso
377381

378382
throw ex;
379383
}
380-
}
384+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fi.helsinki.cs.tmc.model;
22

33
import fi.helsinki.cs.tmc.core.domain.Exercise;
4+
45
import org.netbeans.api.java.classpath.GlobalPathRegistry;
56
import org.openide.filesystems.FileObject;
67

@@ -38,4 +39,4 @@ public FileObject findSourceFileFor(Exercise exercise, String className) {
3839
// Fall back to findResource picking a source root from any project.
3940
return GlobalPathRegistry.getDefault().findResource(path);
4041
}
41-
}
42+
}

0 commit comments

Comments
 (0)