4792 display details when just case or data source selected

This commit is contained in:
William Schaefer 2019-04-05 13:12:06 -04:00
parent 793366a142
commit 84b69f86c9
5 changed files with 80 additions and 19 deletions

View File

@ -57,6 +57,7 @@ import javax.swing.table.TableRowSorter;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDateTime;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.ServiceProvider;
import org.sleuthkit.autopsy.casemodule.Case;
@ -117,7 +118,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
this.casesTableModel = new OtherOccurrencesCasesTableModel();
this.dataSourcesTableModel = new OtherOccurrencesDataSourcesTableModel();
this.correlationAttributes = new ArrayList<>();
occurrencePanel = new OccurrencePanel(new ArrayList<>());
occurrencePanel = new OccurrencePanel();
initComponents();
customizeComponents();
@ -337,7 +338,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
earliestCaseDate.setText(Bundle.DataContentViewerOtherCases_earliestCaseNotAvailable());
foundInLabel.setText("");
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible
occurrencePanel = new OccurrencePanel(new ArrayList<>());
occurrencePanel = new OccurrencePanel();
occurrencePanel.getPreferredSize();
detailsPanelScrollPane.setViewportView(occurrencePanel);
}
@ -809,7 +810,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
try {
if (nodeData.isCentralRepoNode()) {
if (casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(selectedRow)) != null
&& ((CorrelationCase) casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(selectedRow))).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID())) {
&& casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(selectedRow)).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID())) {
dataSourcesTableModel.addNodeData(nodeData);
}
} else {
@ -845,7 +846,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
try {
if (nodeData.isCentralRepoNode()) {
if (casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(selectedCaseRow)) != null
&& ((CorrelationCase) casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(selectedCaseRow))).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID())
&& casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(selectedCaseRow)).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID())
&& dataSourcesTableModel.getDeviceIdForRow(dataSourcesTable.convertRowIndexToModel(selectedDataSourceRow)).equals(nodeData.getDeviceID())) {
filesTableModel.addNodeData(nodeData);
}
@ -872,18 +873,52 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
occurrencePanel = new OccurrencePanel(filesTableModel.getRow(filesTable.convertRowIndexToModel(filesTable.getSelectedRow())));
} else if (dataSourcesTable.getSelectedRowCount() == 1) {
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible
occurrencePanel = new OccurrencePanel(new ArrayList<>());
String caseName = dataSourcesTableModel.getCaseNameForRow(dataSourcesTable.convertRowIndexToModel(dataSourcesTable.getSelectedRow()));
String dataSourceName = dataSourcesTableModel.getValueAt(dataSourcesTable.convertRowIndexToModel(dataSourcesTable.getSelectedRow()), 0).toString();
String caseCreatedDate = "";
for (int row : casesTable.getSelectedRows()) {
if (casesTableModel.getValueAt(casesTable.convertRowIndexToModel(row), 0).toString().equals(caseName)) {
caseCreatedDate = getCaseCreatedDate(row);
break;
}
}
occurrencePanel = new OccurrencePanel(caseName, caseCreatedDate, dataSourceName);
} else if (casesTable.getSelectedRowCount() == 1) {
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible
occurrencePanel = new OccurrencePanel(new ArrayList<>());
String createdDate = "";
String caseName = "";
if (casesTable.getRowCount() > 0) {
caseName = casesTableModel.getValueAt(casesTable.convertRowIndexToModel(casesTable.getSelectedRow()), 0).toString();
}
if (caseName.isEmpty()) {
occurrencePanel = new OccurrencePanel();
} else {
createdDate = getCaseCreatedDate(casesTable.getSelectedRow());
occurrencePanel = new OccurrencePanel(caseName, createdDate);
}
} else {
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible
occurrencePanel = new OccurrencePanel(new ArrayList<>());
occurrencePanel = new OccurrencePanel();
}
occurrencePanel.getPreferredSize();
detailsPanelScrollPane.setViewportView(occurrencePanel);
}
private String getCaseCreatedDate(int caseTableRowIdx) {
try {
if (EamDb.isEnabled()) {
CorrelationCase partialCase;
partialCase = casesTableModel.getCorrelationCase(casesTable.convertRowIndexToModel(caseTableRowIdx));
return EamDb.getInstance().getCaseByUUID(partialCase.getCaseUUID()).getCreationDate();
} else {
return Case.getCurrentCase().getCreatedDate();
}
} catch (EamDbException ex) {
}
return "";
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always

View File

@ -5,9 +5,6 @@
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[50, 30]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="null"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>

View File

@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.centralrepository.contentviewer;
import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.HashSet;
@ -48,24 +49,44 @@ final class OccurrencePanel extends javax.swing.JPanel {
private final Set<String> dataSourceNames = new HashSet<>();
private final Set<String> filePaths = new HashSet<>();
OccurrencePanel() {
nodeDataList = new ArrayList<>();
}
OccurrencePanel(String caseName, String caseCreatedDate) {
this();
caseNamesAndDates.put(caseName, caseCreatedDate);
customizeComponents();
}
OccurrencePanel(String caseName, String caseCreatedDate, String dataSourceName) {
this(caseName, caseCreatedDate);
dataSourceNames.add(dataSourceName);
customizeComponents();
}
/**
* Creates new form OccurrencePanel2
*/
OccurrencePanel(List<OtherOccurrenceNodeData> nodeDataList) {
this.nodeDataList = nodeDataList;
initComponents();
customizeComponents();
}
private void customizeComponents() {
if (!this.nodeDataList.isEmpty()) {
addInstanceDetails();
if (!filePaths.isEmpty()) {
addFileDetails();
}
}
if (!dataSourceNames.isEmpty()) {
addDataSourceDetails();
}
if (!caseNamesAndDates.keySet().isEmpty()) {
addCaseDetails();
}
}
//add filler to keep everything else at the top
addItemToBag(gridY, 0, 0, 0, new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767)));
}

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationCase;
/**
* Model for cells in the cases section of the other occurrences data content
@ -40,7 +41,6 @@ public class OtherOccurrencesCasesTableModel extends AbstractTableModel {
return 1;
}
@Override
public int getRowCount() {
return correlationCaseList.size();
@ -66,8 +66,12 @@ public class OtherOccurrencesCasesTableModel extends AbstractTableModel {
return value;
}
Object getCorrelationCase(int rowIdx) {
CorrelationCase getCorrelationCase(int rowIdx) {
if (rowIdx < correlationCaseList.size()) {
return correlationCaseList.get(rowIdx).getCorrelationCase();
} else {
return null;
}
}
@Override

View File

@ -63,6 +63,10 @@ final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel {
return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDeviceId();
}
public String getCaseNameForRow(int rowIdx){
return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getCaseName();
}
@Override
public Class<String> getColumnClass(int colIdx) {
return String.class;