+ *
The presence of the {@link ProjectProblemsProvider} in the project lookup
+ * automatically enable the broken project metadata badge on the project.
+ * If the project wants to provide the "Resolve Broken Project" action it needs
+ * to add a reference to the "org.netbeans.modules.project.ui.problems.BrokenProjectActionFactory"
+ * action with required position, for example using the ActionRefrecne annotation:
+ *
+ * @ActionReferences({
+ @ActionReference(
+ id=@ActionID(id="org.netbeans.modules.project.ui.problems.BrokenProjectActionFactory",category="Project"),
+ position = 2600,
+ path = "Projects/org-netbeans-modules-myproject/Actions")
+})
+ *
+ *
+ *
+ *
+ * @author Tomas Zezula
+ * @since 1.60
+ */
+public interface ProjectProblemsProvider {
+
+ /**
+ * Name of the problems property.
+ */
+ String PROP_PROBLEMS = "problems"; //NOI18N
+
+
+ /**
+ * Adds a {@link PropertyChangeListener} listening on change of project
+ * metadata problems.
+ * @param listener the listener to be added.
+ */
+ void addPropertyChangeListener(@NonNull PropertyChangeListener listener);
+
+ /**
+ * Removes a {@link PropertyChangeListener} listening on change of project
+ * metadata problems.
+ * @param listener the listener to be removed.
+ */
+ void removePropertyChangeListener (@NonNull PropertyChangeListener listener);
+
+ /**
+ * Returns project metadata problems found by this {@link ProjectProblemsProvider}.
+ * @return the problems
+ */
+ @NonNull
+ Collection extends ProjectProblem> getProblems();
+
+
+ /**
+ * The {@link ProjectProblem} resolution status.
+ */
+ enum Status {
+ RESOLVED,
+ RESOLVED_WITH_WARNING,
+ UNRESOLVED
+ }
+
+
+ /**
+ * The {@link ProjectProblem} severity.
+ */
+ enum Severity {
+ ERROR,
+ WARNING
+ }
+
+ /**
+ * Result of the project metadata problem resolution.
+ */
+ public final class Result {
+ private final Status status;
+ private final String message;
+
+ private Result(
+ @NonNull final Status status,
+ @NullAllowed final String message) {
+ this.status = status;
+ this.message = message;
+ }
+
+ /**
+ * Returns true if the problem was resolved.
+ * @return true if the problem was successfully resolved.
+ */
+ public boolean isResolved() {
+ return status != Status.UNRESOLVED;
+ }
+
+ /**
+ * Returns status of the resolution.
+ * @return the {@link ProjectProblemsProvider.Status}
+ */
+ @NonNull
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * Returns possible error or warning message.
+ * @return the message which should be presented to the user.
+ */
+ @CheckForNull
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Creates a new instance of the {@link Result}.
+ * @param status the status of the project problem resolution.
+ * @return the new {@link Result} instance.
+ */
+ public static Result create(
+ @NonNull final Status status) {
+ Parameters.notNull("status", status); //NOI18N
+ return new Result(status, null);
+ }
+
+ /**
+ * Creates a new instance of the {@link Result}.
+ * @param status the status of the project problem resolution.
+ * @param message the message which should be presented to the user.
+ * @return the new {@link Result} instance.
+ */
+ public static Result create(
+ @NonNull final Status status,
+ @NonNull final String message) {
+ Parameters.notNull("status", status); //NOI18N
+ Parameters.notNull("message", message); //NOI18N
+ return new Result(status, message);
+ }
+
+ }
+
+
+ /**
+ * Project metadata problem.
+ * Represents a problem in the project metadata which should be presented
+ * to the user and resolved.
+ */
+ public final class ProjectProblem {
+
+ private final Severity severity;
+ private final String displayName;
+ private final String description;
+ private final ProjectProblemResolver resolver;
+
+ private ProjectProblem(
+ @NonNull final Severity severity,
+ @NonNull final String displayName,
+ @NonNull final String description,
+ @NonNull final ProjectProblemResolver resolver) {
+ Parameters.notNull("severity", severity); //NOI18N
+ Parameters.notNull("displayName", displayName); //NOI18N
+ Parameters.notNull("description", description); //NOI18N
+ Parameters.notNull("resolver", resolver); //NOI18N
+ this.severity = severity;
+ this.displayName = displayName;
+ this.description = description;
+ this.resolver = resolver;
+ }
+
+ /**
+ * Returns a {@link ProjectProblem} severity.
+ * @return the {@link Severity}
+ */
+ @NonNull
+ public Severity getSeverity() {
+ return severity;
+ }
+
+ /**
+ * Returns a display name of the problem.
+ * The display name is presented to the user in the UI.
+ * @return the display name.
+ */
+ @NonNull
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * Returns the description of the problem.
+ * The description is shown in the project problems details.
+ * @return project problem description.
+ */
+ @NonNull
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Resolves the problem.
+ * Called by the Event Dispatch Thread.
+ * When the resolution needs to be done by a background thread, eg. downloading
+ * an archive from repository, the implementation directly returns
+ * a {@link Future} which is completed by the background thread.
+ * @return the {@link Future} holding the problem resolution status.
+ */
+ public Future