Tweak ingest finished dialog.

Add javadoc.
This commit is contained in:
adam-m 2012-03-20 17:03:37 -04:00
parent 61aa26653b
commit b44236fe24
3 changed files with 20 additions and 15 deletions

View File

@ -960,14 +960,10 @@ public class IngestManager {
public String toHtmlString() { public String toHtmlString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("<html>"); sb.append("<html>");
if (startTime != null) {
sb.append("Start time: ").append(dateFormatter.format(startTime)).append("<br />"); sb.append("Ingest time: ").append(getTotalTimeString()).append("<br />");
}
if (endTime != null) {
sb.append("End time: ").append(dateFormatter.format(endTime)).append("<br />");
}
sb.append("Total ingest time: ").append(getTotalTimeString()).append("<br />");
sb.append("Total errors: ").append(errorsTotal).append("<br />"); sb.append("Total errors: ").append(errorsTotal).append("<br />");
/*
if (errorsTotal > 0) { if (errorsTotal > 0) {
sb.append("Errors per service:"); sb.append("Errors per service:");
for (IngestServiceAbstract service : errors.keySet()) { for (IngestServiceAbstract service : errors.keySet()) {
@ -975,6 +971,8 @@ public class IngestManager {
sb.append("\t").append(service.getName()).append(": ").append(errorsService).append("<br />"); sb.append("\t").append(service.getName()).append(": ").append(errorsService).append("<br />");
} }
} }
* */
sb.append("</html>"); sb.append("</html>");
return sb.toString(); return sb.toString();
} }

View File

@ -229,8 +229,8 @@ public final class IngestMessageTopComponent extends TopComponent implements Ing
@Override @Override
public void displayReport(String ingestReport) { public void displayReport(String ingestReport) {
Object[] options = {"Generate Report", Object[] options = {"OK",
"Cancel"}; "Generate Report"};
final int choice = JOptionPane.showOptionDialog(null, final int choice = JOptionPane.showOptionDialog(null,
ingestReport, ingestReport,
"Ingest Report", "Ingest Report",
@ -244,7 +244,7 @@ public final class IngestMessageTopComponent extends TopComponent implements Ing
Action reportAction = null; Action reportAction = null;
//find action by name from action lookup, without introducing cyclic dependency //find action by name from action lookup, without introducing cyclic dependency
if (choice == JOptionPane.YES_OPTION) { if (choice == JOptionPane.NO_OPTION) {
List<? extends Action> actions = Utilities.actionsForPath("Toolbars/File"); List<? extends Action> actions = Utilities.actionsForPath("Toolbars/File");
for (Action a : actions) { for (Action a : actions) {
//separators are null actions //separators are null actions

View File

@ -64,18 +64,25 @@ public interface IngestServiceAbstract {
/** /**
* A service can manage and use additional threads to perform some work in the background. * A service can manage and use additional threads to perform some work in the background.
* This method provides insight to the manager if the service has truly completed its work or not. * This method provides insight to the manager if the service has truly completed its work or not.
*
*
* @return true if any background threads/workers managed by this service are still running * @return true if any background threads/workers managed by this service are still running
* false if all work has been done, or if background threads are not used by this service * false if all work has been done, or if background threads are not managed by this service
*/ */
public boolean hasBackgroundJobsRunning(); public boolean hasBackgroundJobsRunning();
/** /**
* Register listener to notify when all background jobs have completed and the service * Register listener to notify when all background jobs managed by this service have completed and the service
* has truly finished. The service should first check if it has threads running, and then register the listener, all in atomic operation. * has truly finished. The service should first check if it has threads running, and then register the listener, all in a single atomic, synchronized operation, and return the result of the registration.
* The event fired off should be BCKGRND_JOBS_COMPLETED_EVT, with the instance of IngestServiceAbstract in the newValue parameter. * Do not register the listener if the background threads are not running and will not run during this service invocation.
* If the service does use background threads it is required to implement this method properly and ensure the event is fired when the service-managed threads complete (are finished or cancelled)
* The event fired off should be IngestServiceAbstract.BCKGRND_JOBS_COMPLETED_EVT, with the instance of IngestServiceAbstract in the newValue parameter.
* The listeners should be reset at service init() - listeners are expected to register again as needed during the new service run.
* Typical use case is for ingest manager to try to register the listener for every service when the queue has been consumed,
* for a precise indication when all work is truly done.
* *
* @param l listener * @param l listener
* @return true if listener registered, false otherwise (i.e. no background jobs were running) * @return true if listener registered, false otherwise (i.e. no background jobs were running, or the service does not manage additional threads)
*/ */
public boolean backgroundJobsCompleteListener(PropertyChangeListener l); public boolean backgroundJobsCompleteListener(PropertyChangeListener l);