mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
3815 make registration and subscription occur in non static inner classes
This commit is contained in:
parent
4480f4c910
commit
26cfb15f6b
@ -79,8 +79,8 @@ final class AutoIngestJobsNode extends AbstractNode {
|
|||||||
|
|
||||||
private final AutoIngestJobStatus autoIngestJobStatus;
|
private final AutoIngestJobStatus autoIngestJobStatus;
|
||||||
private final AutoIngestMonitor autoIngestMonitor;
|
private final AutoIngestMonitor autoIngestMonitor;
|
||||||
|
private final RefreshChildrenSubscriber refreshChildrenSubscriber = new RefreshChildrenSubscriber();
|
||||||
private final EventBus refreshEventBus;
|
private final EventBus refreshEventBus;
|
||||||
private boolean registered = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create children nodes for the AutoIngestJobsNode which will each
|
* Create children nodes for the AutoIngestJobsNode which will each
|
||||||
@ -93,6 +93,7 @@ final class AutoIngestJobsNode extends AbstractNode {
|
|||||||
autoIngestMonitor = monitor;
|
autoIngestMonitor = monitor;
|
||||||
autoIngestJobStatus = status;
|
autoIngestJobStatus = status;
|
||||||
refreshEventBus = eventBus;
|
refreshEventBus = eventBus;
|
||||||
|
refreshChildrenSubscriber.register(refreshEventBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -116,30 +117,32 @@ final class AutoIngestJobsNode extends AbstractNode {
|
|||||||
if (jobs != null && jobs.size() > 0) {
|
if (jobs != null && jobs.size() > 0) {
|
||||||
list.addAll(jobs);
|
list.addAll(jobs);
|
||||||
}
|
}
|
||||||
if (!registered) {
|
|
||||||
refreshEventBus.register(this); //register for refreshes
|
|
||||||
registered = true;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Node createNodeForKey(AutoIngestJob key) {
|
protected Node createNodeForKey(AutoIngestJob key) {
|
||||||
JobNode jobNode = new JobNode(key, autoIngestJobStatus);
|
return new JobNode(key, autoIngestJobStatus, refreshEventBus);
|
||||||
refreshEventBus.register(jobNode);
|
|
||||||
return jobNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private class RefreshChildrenSubscriber {
|
||||||
* Receive events of type String from the EventBus which this class is
|
|
||||||
* registered to, and refresh the children created by this factory if
|
private RefreshChildrenSubscriber() {
|
||||||
* the event matches the REFRESH_EVENT.
|
}
|
||||||
*
|
|
||||||
* @param refreshEvent the String which was received
|
private void register(EventBus eventBus) {
|
||||||
*/
|
eventBus.register(this);
|
||||||
@Subscribe
|
}
|
||||||
private void subscribeToRefresh(String refreshEvent) {
|
|
||||||
if (refreshEvent.equals(REFRESH_EVENT)) {
|
/**
|
||||||
|
* Receive events of type String from the EventBus which this class
|
||||||
|
* is registered to, and refresh the children created by this
|
||||||
|
* factory if the event matches the REFRESH_EVENT.
|
||||||
|
*
|
||||||
|
* @param refreshEvent the String which was received
|
||||||
|
*/
|
||||||
|
@Subscribe
|
||||||
|
private void subscribeToRefresh(String refreshEvent) {
|
||||||
refresh(true);
|
refresh(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,6 +156,7 @@ final class AutoIngestJobsNode extends AbstractNode {
|
|||||||
|
|
||||||
private final AutoIngestJob autoIngestJob;
|
private final AutoIngestJob autoIngestJob;
|
||||||
private final AutoIngestJobStatus jobStatus;
|
private final AutoIngestJobStatus jobStatus;
|
||||||
|
private final RefreshNodeSubscriber refreshNodeSubscriber = new RefreshNodeSubscriber();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new JobNode to represent an AutoIngestJob and its status.
|
* Construct a new JobNode to represent an AutoIngestJob and its status.
|
||||||
@ -161,12 +165,13 @@ final class AutoIngestJobsNode extends AbstractNode {
|
|||||||
* @param status - the current status of the AutoIngestJob being
|
* @param status - the current status of the AutoIngestJob being
|
||||||
* represented
|
* represented
|
||||||
*/
|
*/
|
||||||
JobNode(AutoIngestJob job, AutoIngestJobStatus status) {
|
JobNode(AutoIngestJob job, AutoIngestJobStatus status, EventBus eventBus) {
|
||||||
super(Children.LEAF);
|
super(Children.LEAF);
|
||||||
jobStatus = status;
|
jobStatus = status;
|
||||||
autoIngestJob = job;
|
autoIngestJob = job;
|
||||||
setName(autoIngestJob.toString()); //alows job to be uniquely found by name since it will involve a hash of the AutoIngestJob
|
setName(autoIngestJob.toString()); //alows job to be uniquely found by name since it will involve a hash of the AutoIngestJob
|
||||||
setDisplayName(autoIngestJob.getManifest().getCaseName()); //displays user friendly case name as name
|
setDisplayName(autoIngestJob.getManifest().getCaseName()); //displays user friendly case name as name
|
||||||
|
refreshNodeSubscriber.register(eventBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -222,20 +227,6 @@ final class AutoIngestJobsNode extends AbstractNode {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Receive events of type String from the EventBus which this class is
|
|
||||||
* registered to, and refresh the node's properties if the event matches
|
|
||||||
* the REFRESH_EVENT.
|
|
||||||
*
|
|
||||||
* @param refreshEvent the String which was received
|
|
||||||
*/
|
|
||||||
@Subscribe
|
|
||||||
private void subscribeToRefresh(String refreshEvent) {
|
|
||||||
if (refreshEvent.equals(REFRESH_EVENT)) {
|
|
||||||
this.setSheet(createSheet());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Action[] getActions(boolean context) {
|
public Action[] getActions(boolean context) {
|
||||||
List<Action> actions = new ArrayList<>();
|
List<Action> actions = new ArrayList<>();
|
||||||
@ -266,6 +257,28 @@ final class AutoIngestJobsNode extends AbstractNode {
|
|||||||
}
|
}
|
||||||
return actions.toArray(new Action[actions.size()]);
|
return actions.toArray(new Action[actions.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RefreshNodeSubscriber {
|
||||||
|
|
||||||
|
private RefreshNodeSubscriber() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void register(EventBus eventBus) {
|
||||||
|
eventBus.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receive events of type String from the EventBus which this class
|
||||||
|
* is registered to, and refresh the node's properties if the event
|
||||||
|
* matches the REFRESH_EVENT.
|
||||||
|
*
|
||||||
|
* @param refreshEvent the String which was received
|
||||||
|
*/
|
||||||
|
@Subscribe
|
||||||
|
private void subscribeToRefresh(String refreshEvent) {
|
||||||
|
setSheet(createSheet());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user