3815 adjust comments regarding for clarity and accuracy regarding the EventBus in AutoIngestJobsNode

This commit is contained in:
William Schaefer 2018-05-16 16:20:51 -04:00
parent f78010a3d1
commit 8ac29a33cf
2 changed files with 16 additions and 10 deletions

View File

@ -41,7 +41,8 @@ import org.sleuthkit.autopsy.guiutils.StatusIconCellRenderer;
* Each job with the specified status will have a child node representing it. * Each job with the specified status will have a child node representing it.
*/ */
final class AutoIngestJobsNode extends AbstractNode { final class AutoIngestJobsNode extends AbstractNode {
//Event bus is non static so that each instance of this will only listen to events sent to that instance
private final EventBus refreshChildrenEventBus; private final EventBus refreshChildrenEventBus;
@Messages({ @Messages({
@ -151,10 +152,11 @@ final class AutoIngestJobsNode extends AbstractNode {
* and refresh the children created by this factory. * and refresh the children created by this factory.
* *
* *
* @param refreshEvent the String which was received * @param refreshEvent the AutoIngestRefreshEvent which was received
*/ */
@Subscribe @Subscribe
private void subscribeToRefresh(AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent refreshEvent) { private void subscribeToRefresh(AutoIngestNodeRefreshEvents.AutoIngestRefreshEvent refreshEvent) {
//Ignore netbeans suggesting this isn't being used, it is used behind the scenes by the EventBus
//RefreshChildrenEvents can change which children are present however //RefreshChildrenEvents can change which children are present however
//RefreshJobEvents and RefreshCaseEvents can still change the order we want to display them in //RefreshJobEvents and RefreshCaseEvents can still change the order we want to display them in
refresh(true); refresh(true);
@ -296,28 +298,30 @@ final class AutoIngestJobsNode extends AbstractNode {
} }
/** /**
* Receive events of type String from the EventBus which this class * Receive events of type RefreshJobEvent from the EventBus which
* is registered to, and refresh the node's properties if the event * this class is registered to and refresh the nodes properties if
* matches the REFRESH_EVENT. * it is the node for the job specified in the event.
* *
* @param refreshEvent the String which was received * @param refreshEvent the RefreshJobEvent which was received
*/ */
@Subscribe @Subscribe
private void subscribeToRefreshJob(AutoIngestNodeRefreshEvents.RefreshJobEvent refreshEvent) { private void subscribeToRefreshJob(AutoIngestNodeRefreshEvents.RefreshJobEvent refreshEvent) {
//Ignore netbeans suggesting this isn't being used, it is used behind the scenes by the EventBus
if (getAutoIngestJob().equals(refreshEvent.getJobToRefresh())) { if (getAutoIngestJob().equals(refreshEvent.getJobToRefresh())) {
setSheet(createSheet()); setSheet(createSheet());
} }
} }
/** /**
* Receive events of type String from the EventBus which this class * Receive events of type RefreshCaseEvent from the EventBus which
* is registered to, and refresh the node's properties if the event * this class is registered to and refresh the nodes which have jobs
* matches the REFRESH_EVENT. * which are members of case specified in the event.
* *
* @param refreshEvent the String which was received * @param refreshEvent the RefreshCaseEvent which was received
*/ */
@Subscribe @Subscribe
private void subscribeToRefreshCase(AutoIngestNodeRefreshEvents.RefreshCaseEvent refreshEvent) { private void subscribeToRefreshCase(AutoIngestNodeRefreshEvents.RefreshCaseEvent refreshEvent) {
//Ignore netbeans suggesting this isn't being used, it is used behind the scenes by the EventBus
if (getAutoIngestJob().getManifest().getCaseName().equals(refreshEvent.getCaseToRefresh())) { if (getAutoIngestJob().getManifest().getCaseName().equals(refreshEvent.getCaseToRefresh())) {
setSheet(createSheet()); setSheet(createSheet());
} }
@ -331,6 +335,7 @@ final class AutoIngestJobsNode extends AbstractNode {
* @param refreshEvent - the RefreshChildrenEvent which was received * @param refreshEvent - the RefreshChildrenEvent which was received
*/ */
private void subscribeToRefreshChildren(AutoIngestNodeRefreshEvents.RefreshChildrenEvent refreshEvent) { private void subscribeToRefreshChildren(AutoIngestNodeRefreshEvents.RefreshChildrenEvent refreshEvent) {
//Ignore netbeans suggesting this isn't being used, it is used behind the scenes by the EventBus
if (jobStatus == AutoIngestJobStatus.RUNNING_JOB) { if (jobStatus == AutoIngestJobStatus.RUNNING_JOB) {
setSheet(createSheet()); setSheet(createSheet());
} }

View File

@ -170,6 +170,7 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
if (explorerManager.getRootContext() instanceof AutoIngestJobsNode) { if (explorerManager.getRootContext() instanceof AutoIngestJobsNode) {
((AutoIngestJobsNode) explorerManager.getRootContext()).refresh(refreshEvent); ((AutoIngestJobsNode) explorerManager.getRootContext()).refresh(refreshEvent);
} else { } else {
//Make a new AutoIngestJobsNode with it's own EventBus and set it as the root context
explorerManager.setRootContext(new AutoIngestJobsNode(jobsSnapshot, status, new EventBus("AutoIngestJobsNodeEventBus"))); explorerManager.setRootContext(new AutoIngestJobsNode(jobsSnapshot, status, new EventBus("AutoIngestJobsNodeEventBus")));
} }
outline.setRowSelectionAllowed(true); outline.setRowSelectionAllowed(true);