Lines 44-49
Link Here
|
44 |
import java.beans.PropertyChangeListener; |
44 |
import java.beans.PropertyChangeListener; |
45 |
import java.util.Collection; |
45 |
import java.util.Collection; |
46 |
import java.util.concurrent.Future; |
46 |
import java.util.concurrent.Future; |
|
|
47 |
import java.util.concurrent.FutureTask; |
47 |
import org.netbeans.api.annotations.common.CheckForNull; |
48 |
import org.netbeans.api.annotations.common.CheckForNull; |
48 |
import org.netbeans.api.annotations.common.NonNull; |
49 |
import org.netbeans.api.annotations.common.NonNull; |
49 |
import org.netbeans.api.annotations.common.NullAllowed; |
50 |
import org.netbeans.api.annotations.common.NullAllowed; |
Lines 212-222
Link Here
|
212 |
@NonNull final Severity severity, |
213 |
@NonNull final Severity severity, |
213 |
@NonNull final String displayName, |
214 |
@NonNull final String displayName, |
214 |
@NonNull final String description, |
215 |
@NonNull final String description, |
215 |
@NonNull final ProjectProblemResolver resolver) { |
216 |
@NullAllowed final ProjectProblemResolver resolver) { |
216 |
Parameters.notNull("severity", severity); //NOI18N |
217 |
Parameters.notNull("severity", severity); //NOI18N |
217 |
Parameters.notNull("displayName", displayName); //NOI18N |
218 |
Parameters.notNull("displayName", displayName); //NOI18N |
218 |
Parameters.notNull("description", description); //NOI18N |
219 |
Parameters.notNull("description", description); //NOI18N |
219 |
Parameters.notNull("resolver", resolver); //NOI18N |
|
|
220 |
this.severity = severity; |
220 |
this.severity = severity; |
221 |
this.displayName = displayName; |
221 |
this.displayName = displayName; |
222 |
this.description = description; |
222 |
this.description = description; |
Lines 253-258
Link Here
|
253 |
} |
253 |
} |
254 |
|
254 |
|
255 |
/** |
255 |
/** |
|
|
256 |
* Is the problem resolvable? |
257 |
* @return |
258 |
* @since 1.74 |
259 |
*/ |
260 |
public boolean isResolvable() { |
261 |
return resolver != null; |
262 |
} |
263 |
|
264 |
/** |
256 |
* Resolves the problem. |
265 |
* Resolves the problem. |
257 |
* Called by the Event Dispatch Thread. |
266 |
* Called by the Event Dispatch Thread. |
258 |
* When the resolution needs to be done by a background thread, eg. downloading |
267 |
* When the resolution needs to be done by a background thread, eg. downloading |
Lines 261-266
Link Here
|
261 |
* @return the {@link Future} holding the problem resolution status. |
270 |
* @return the {@link Future} holding the problem resolution status. |
262 |
*/ |
271 |
*/ |
263 |
public Future<Result> resolve() { |
272 |
public Future<Result> resolve() { |
|
|
273 |
if (resolver == null) { |
274 |
return new FutureTask<Result>(new Runnable() { |
275 |
@Override |
276 |
public void run() { |
277 |
//noop |
278 |
} |
279 |
}, Result.create(Status.UNRESOLVED)); |
280 |
} |
264 |
return resolver.resolve(); |
281 |
return resolver.resolve(); |
265 |
} |
282 |
} |
266 |
|
283 |
|
Lines 278-284
Link Here
|
278 |
final ProjectProblem otherProblem = (ProjectProblem) other; |
295 |
final ProjectProblem otherProblem = (ProjectProblem) other; |
279 |
return displayName.equals(otherProblem.displayName) && |
296 |
return displayName.equals(otherProblem.displayName) && |
280 |
description.equals(otherProblem.description) && |
297 |
description.equals(otherProblem.description) && |
281 |
resolver.equals(otherProblem.resolver); |
298 |
(resolver != null ? resolver.equals(otherProblem.resolver) : otherProblem.resolver == null); |
282 |
} |
299 |
} |
283 |
|
300 |
|
284 |
/** |
301 |
/** |
Lines 289-295
Link Here
|
289 |
int result = 17; |
306 |
int result = 17; |
290 |
result = 31 * result + displayName.hashCode(); |
307 |
result = 31 * result + displayName.hashCode(); |
291 |
result = 31 * result + description.hashCode(); |
308 |
result = 31 * result + description.hashCode(); |
292 |
result = 31 * result + resolver.hashCode(); |
309 |
result = 31 * result + (resolver != null ? resolver.hashCode() : 0); |
293 |
return result; |
310 |
return result; |
294 |
} |
311 |
} |
295 |
|
312 |
|
Lines 321-326
Link Here
|
321 |
} |
338 |
} |
322 |
|
339 |
|
323 |
/** |
340 |
/** |
|
|
341 |
* Creates a new unresolvable instance of the {@link ProjectProblem} with error {@link Severity}. |
342 |
* @param displayName the project problem display name. |
343 |
* @param description the project problem description. |
344 |
* @return a new instance of {@link ProjectProblem} |
345 |
* @since 1.74 |
346 |
*/ |
347 |
@NonNull |
348 |
public static ProjectProblem createError( |
349 |
@NonNull final String displayName, |
350 |
@NonNull final String description) { |
351 |
return new ProjectProblem(Severity.ERROR, displayName, description, null); |
352 |
} |
353 |
|
354 |
/** |
324 |
* Creates a new instance of the {@link ProjectProblem} with warning {@link Severity}. |
355 |
* Creates a new instance of the {@link ProjectProblem} with warning {@link Severity}. |
325 |
* @param displayName the project problem display name. |
356 |
* @param displayName the project problem display name. |
326 |
* @param description the project problem description. |
357 |
* @param description the project problem description. |
Lines 335-340
Link Here
|
335 |
return new ProjectProblem(Severity.WARNING, displayName,description,resolver); |
366 |
return new ProjectProblem(Severity.WARNING, displayName,description,resolver); |
336 |
} |
367 |
} |
337 |
|
368 |
|
|
|
369 |
/** |
370 |
* Creates a new unresolvable instance of the {@link ProjectProblem} with warning {@link Severity}. |
371 |
* @param displayName the project problem display name. |
372 |
* @param description the project problem description. |
373 |
* @return a new instance of {@link ProjectProblem} |
374 |
* @since 1.74 |
375 |
*/ |
376 |
@NonNull |
377 |
public static ProjectProblem createWarning( |
378 |
@NonNull final String displayName, |
379 |
@NonNull final String description) { |
380 |
return new ProjectProblem(Severity.WARNING, displayName, description, null); |
338 |
} |
381 |
} |
339 |
|
382 |
|
340 |
} |
383 |
} |
|
|
384 |
|
385 |
} |