3610 add comments to clarifiy new methods and classes for outlineView aid2.0

This commit is contained in:
William Schaefer 2018-04-09 17:04:51 -04:00
parent 8d7cc2550f
commit 14d271bb28
3 changed files with 86 additions and 31 deletions

View File

@ -90,7 +90,7 @@ final class AutoIngestDashboard extends JPanel implements Observer {
statusByService.put(ServicesMonitor.Service.REMOTE_KEYWORD_SEARCH.toString(), NbBundle.getMessage(AutoIngestDashboard.class, "AutoIngestDashboard.tbServicesStatusMessage.Message.Down"));
statusByService.put(ServicesMonitor.Service.MESSAGING.toString(), NbBundle.getMessage(AutoIngestDashboard.class, "AutoIngestDashboard.tbServicesStatusMessage.Message.Down"));
setServicesStatusMessage();
pendingJobsPanel = new AutoIngestJobsPanel(AutoIngestNode.AutoIngestJobType.PENDING_JOB);
pendingJobsPanel = new AutoIngestJobsPanel(AutoIngestJobsNode.AutoIngestJobType.PENDING_JOB);
pendingJobsPanel.setSize(pendingScrollPane.getSize());
pendingScrollPane.add(pendingJobsPanel);
pendingScrollPane.setViewportView(pendingJobsPanel);
@ -112,7 +112,7 @@ final class AutoIngestDashboard extends JPanel implements Observer {
this.deprioritizeCaseButton.setEnabled(enableDeprioritizeButtons);
});
pendingJobsPanel.setToolTipText(Bundle.AutoIngestDashboard_pendingTable.toolTipText());
runningJobsPanel = new AutoIngestJobsPanel(AutoIngestNode.AutoIngestJobType.RUNNING_JOB);
runningJobsPanel = new AutoIngestJobsPanel(AutoIngestJobsNode.AutoIngestJobType.RUNNING_JOB);
runningJobsPanel.setSize(runningScrollPane.getSize());
runningScrollPane.add(runningJobsPanel);
runningScrollPane.setViewportView(runningJobsPanel);
@ -124,7 +124,7 @@ final class AutoIngestDashboard extends JPanel implements Observer {
this.deprioritizeCaseButton.setEnabled(enabled);
});
runningJobsPanel.setToolTipText(Bundle.AutoIngestDashboard_runningTable.toolTipText());
completedJobsPanel = new AutoIngestJobsPanel(AutoIngestNode.AutoIngestJobType.COMPLETED_JOB);
completedJobsPanel = new AutoIngestJobsPanel(AutoIngestJobsNode.AutoIngestJobType.COMPLETED_JOB);
completedJobsPanel.setSize(completedScrollPane.getSize());
completedScrollPane.add(completedJobsPanel);
completedScrollPane.setViewportView(completedJobsPanel);

View File

@ -33,7 +33,11 @@ import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMonitor.JobsSnaps
import org.sleuthkit.autopsy.guiutils.DurationCellRenderer;
import org.sleuthkit.autopsy.guiutils.StatusIconCellRenderer;
final class AutoIngestNode extends AbstractNode {
/**
* A node which represents all AutoIngestJobs of a given AutoIngestJobStatus.
* Each job with the specified status will have a child node representing it.
*/
final class AutoIngestJobsNode extends AbstractNode {
@Messages({
"AutoIngestNode.caseName.text=Case Name",
@ -47,24 +51,37 @@ final class AutoIngestNode extends AbstractNode {
"AutoIngestNode.status.text=Status"
})
AutoIngestNode(JobsSnapshot snapshot, AutoIngestJobType type) {
super(Children.create(new AutoIngestNodeChildren(snapshot, type), false));
/**
* Construct a new AutoIngestJobsNode.
*/
AutoIngestJobsNode(JobsSnapshot snapshot, AutoIngestJobStatus status) {
super(Children.create(new AutoIngestNodeChildren(snapshot, status), false));
}
/**
* A ChildFactory for generating JobNodes.
*/
static class AutoIngestNodeChildren extends ChildFactory<AutoIngestJob> {
private final AutoIngestJobType autoIngestJobType;
private final AutoIngestJobStatus autoIngestJobStatus;
private final JobsSnapshot jobsSnapshot;
AutoIngestNodeChildren(JobsSnapshot snapshot, AutoIngestJobType type) {
/**
* Create children nodes for the AutoIngestJobsNode which will each
* represent a single AutoIngestJob
*
* @param snapshot the snapshot which contains the AutoIngestJobs
* @param status the status of the jobs being displayed
*/
AutoIngestNodeChildren(JobsSnapshot snapshot, AutoIngestJobStatus status) {
jobsSnapshot = snapshot;
autoIngestJobType = type;
autoIngestJobStatus = status;
}
@Override
protected boolean createKeys(List<AutoIngestJob> list) {
List<AutoIngestJob> jobs;
switch (autoIngestJobType) {
switch (autoIngestJobStatus) {
case PENDING_JOB:
jobs = jobsSnapshot.getPendingJobs();
break;
@ -85,28 +102,40 @@ final class AutoIngestNode extends AbstractNode {
@Override
protected Node createNodeForKey(AutoIngestJob key) {
return new JobNode(key, autoIngestJobType);
return new JobNode(key, autoIngestJobStatus);
}
}
/**
* A node which represents a single multi user case.
* A node which represents a single auto ingest job.
*/
static final class JobNode extends AbstractNode {
private final AutoIngestJob autoIngestJob;
private final AutoIngestJobType jobType;
private final AutoIngestJobStatus jobStatus;
JobNode(AutoIngestJob job, AutoIngestJobType type) {
/**
* Construct a new JobNode to represent an AutoIngestJob and its status.
*
* @param job - the AutoIngestJob being represented by this node
* @param status - the current status of the AutoIngestJob being
* represented
*/
JobNode(AutoIngestJob job, AutoIngestJobStatus status) {
super(Children.LEAF);
jobType = type;
jobStatus = status;
autoIngestJob = job;
super.setName(autoIngestJob.getManifest().getCaseName());
setName(autoIngestJob.getManifest().getCaseName());
setDisplayName(autoIngestJob.getManifest().getCaseName());
}
/**
* Get the AutoIngestJob which this node represents.
*
* @return autoIngestJob
*/
AutoIngestJob getAutoIngestJob() {
return autoIngestJob;
}
@ -123,7 +152,7 @@ final class AutoIngestNode extends AbstractNode {
autoIngestJob.getManifest().getCaseName()));
ss.put(new NodeProperty<>(Bundle.AutoIngestNode_dataSource_text(), Bundle.AutoIngestNode_dataSource_text(), Bundle.AutoIngestNode_dataSource_text(),
autoIngestJob.getManifest().getDataSourcePath().getFileName().toString()));
switch (jobType) {
switch (jobStatus) {
case PENDING_JOB:
ss.put(new NodeProperty<>(Bundle.AutoIngestNode_jobCreated_text(), Bundle.AutoIngestNode_jobCreated_text(), Bundle.AutoIngestNode_jobCreated_text(),
autoIngestJob.getManifest().getDateFileCreated()));
@ -153,7 +182,11 @@ final class AutoIngestNode extends AbstractNode {
}
}
enum AutoIngestJobType {
/**
* An enumeration used to indicate the current status of an auto ingest job
* node.
*/
enum AutoIngestJobStatus {
PENDING_JOB, //NON-NLS
RUNNING_JOB, //NON-NLS
COMPLETED_JOB //NON-NLS

View File

@ -27,12 +27,11 @@ import org.netbeans.swing.outline.Outline;
import org.openide.explorer.ExplorerManager;
import org.openide.nodes.Node;
import org.sleuthkit.autopsy.datamodel.EmptyNode;
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestNode.AutoIngestJobType;
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestNode.JobNode;
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestJobsNode.AutoIngestJobStatus;
import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestJobsNode.JobNode;
/**
*
* @author wschaefer
* A panel which displays an outline view with all jobs for a specified status.
*/
final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerManager.Provider {
@ -40,22 +39,28 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
private final org.openide.explorer.view.OutlineView outlineView;
private final Outline outline;
private ExplorerManager explorerManager;
private final AutoIngestJobType type;
private final AutoIngestJobStatus status;
/**
* Creates new form PendingJobsPanel
* Creates a new AutoIngestJobsPanel of the specified jobStatus
*
* @param jobStatus the status of the jbos to be displayed on this panel
*/
AutoIngestJobsPanel(AutoIngestJobType jobType) {
AutoIngestJobsPanel(AutoIngestJobStatus jobStatus) {
initComponents();
type = jobType;
status = jobStatus;
outlineView = new org.openide.explorer.view.OutlineView();
outline = outlineView.getOutline();
customize();
}
/**
* Set up the AutoIngestJobsPanel's so that its outlineView is displaying
* the correct columns for the specified AutoIngestJobStatus
*/
void customize() {
switch (type) {
switch (status) {
case PENDING_JOB:
outlineView.setPropertyColumns(Bundle.AutoIngestNode_dataSource_text(), Bundle.AutoIngestNode_dataSource_text(),
Bundle.AutoIngestNode_jobCreated_text(), Bundle.AutoIngestNode_jobCreated_text(),
@ -102,6 +107,12 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
outline.setPreferredScrollableViewportSize(new Dimension(400, 100));
}
/**
* Add a list selection listener to the selection model of the outline being
* used in this panel.
*
* @param listener the ListSelectionListener to add
*/
void addListSelectionListener(ListSelectionListener listener) {
outline.getSelectionModel().addListSelectionListener(listener);
}
@ -111,20 +122,26 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
return explorerManager;
}
/**
* Update the contents of this AutoIngestJobsPanel while retaining currently
* selected node.
*
* @param jobsSnapshot - the JobsSnapshot which will provide the new
* contents
*/
void refresh(AutoIngestMonitor.JobsSnapshot jobsSnapshot) {
synchronized (this) {
outline.setRowSelectionAllowed(false);
Node[] selectedNodes = explorerManager.getSelectedNodes();
AutoIngestNode autoIngestNode = new AutoIngestNode(jobsSnapshot, type);
AutoIngestJobsNode autoIngestNode = new AutoIngestJobsNode(jobsSnapshot, status);
explorerManager.setRootContext(autoIngestNode);
outline.setRowSelectionAllowed(true);
if (selectedNodes.length > 0) {
try {
explorerManager.setSelectedNodes(new Node[]{autoIngestNode.getChildren().findChild(selectedNodes[0].getName())});
} catch (PropertyVetoException ignore) {
explorerManager.setSelectedNodes(new Node[]{autoIngestNode.getChildren().findChild(selectedNodes[0].getName())});
} catch (PropertyVetoException ignore) {
//Unable to select previously selected node
}
}
}
}
@ -141,8 +158,13 @@ final class AutoIngestJobsPanel extends javax.swing.JPanel implements ExplorerMa
setLayout(new java.awt.BorderLayout());
}// </editor-fold>//GEN-END:initComponents
/**
* Get the AutoIngestJob for the currently selected node of this panel.
*
* @return AutoIngestJob which is currently selected in this panel
*/
AutoIngestJob getSelectedAutoIngestJob() {
Node[] selectedRows = getSelectedNodes();
Node[] selectedRows = explorerManager.getSelectedNodes();
if (selectedRows.length == 1) {
return ((JobNode) selectedRows[0]).getAutoIngestJob();
}