4792 kinda working field population

This commit is contained in:
William Schaefer 2019-04-04 14:51:35 -04:00
parent 48264cbba0
commit d5531d8ffc
4 changed files with 188 additions and 149 deletions

View File

@ -33,7 +33,6 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -237,47 +236,37 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
"DataContentViewerOtherCases.caseDetailsDialog.noCaseNameError=Error", "DataContentViewerOtherCases.caseDetailsDialog.noCaseNameError=Error",
"DataContentViewerOtherCases.noOpenCase.errMsg=No open case available."}) "DataContentViewerOtherCases.noOpenCase.errMsg=No open case available."})
private void showCaseDetails(int selectedRowViewIdx) { private void showCaseDetails(int selectedRowViewIdx) {
String caseDisplayName = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noCaseNameError(); String caseDisplayName = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noCaseNameError();
String details = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetails();
try { try {
if (-1 != selectedRowViewIdx) { if (-1 != selectedRowViewIdx) {
EamDb dbManager = EamDb.getInstance(); EamDb dbManager = EamDb.getInstance();
int selectedRowModelIdx = filesTable.convertRowIndexToModel(selectedRowViewIdx); int selectedRowModelIdx = filesTable.convertRowIndexToModel(selectedRowViewIdx);
OtherOccurrenceNodeInstanceData nodeData = (OtherOccurrenceNodeInstanceData) filesTableModel.getRow(selectedRowModelIdx); CorrelationCase eamCasePartial = null;
CorrelationCase eamCasePartial = nodeData.getCorrelationAttributeInstance().getCorrelationCase(); List<OtherOccurrenceNodeData> rowList = filesTableModel.getRow(selectedRowModelIdx);
if (eamCasePartial == null) { if (rowList.get(0) instanceof OtherOccurrenceNodeInstanceData) {
JOptionPane.showConfirmDialog(showCaseDetailsMenuItem, if (!rowList.isEmpty()) {
Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetailsReference(), eamCasePartial = ((OtherOccurrenceNodeInstanceData) rowList.get(0)).getCorrelationAttributeInstance().getCorrelationCase();
caseDisplayName,
DEFAULT_OPTION, PLAIN_MESSAGE);
return;
}
caseDisplayName = eamCasePartial.getDisplayName(); caseDisplayName = eamCasePartial.getDisplayName();
// query case details // query case details
CorrelationCase eamCase = dbManager.getCaseByUUID(eamCasePartial.getCaseUUID()); CorrelationCase eamCase = dbManager.getCaseByUUID(eamCasePartial.getCaseUUID());
if (eamCase == null) { if (eamCase != null) {
JOptionPane.showConfirmDialog(showCaseDetailsMenuItem, details = eamCase.getCaseDetailsOptionsPaneDialog();
Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetails(),
caseDisplayName,
DEFAULT_OPTION, PLAIN_MESSAGE);
return;
}
// display case details
JOptionPane.showConfirmDialog(showCaseDetailsMenuItem,
eamCase.getCaseDetailsOptionsPaneDialog(),
caseDisplayName,
DEFAULT_OPTION, PLAIN_MESSAGE);
} else { } else {
JOptionPane.showConfirmDialog(showCaseDetailsMenuItem, details = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetails();
Bundle.DataContentViewerOtherCases_caseDetailsDialog_notSelected(), }
caseDisplayName, } else {
DEFAULT_OPTION, PLAIN_MESSAGE); details = Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetailsReference();
}
} else {
details = Bundle.DataContentViewerOtherCases_caseDetailsDialog_notSelected();
}
} }
} catch (EamDbException ex) { } catch (EamDbException ex) {
LOGGER.log(Level.SEVERE, "Error loading case details", ex); LOGGER.log(Level.SEVERE, "Error loading case details", ex);
} finally {
JOptionPane.showConfirmDialog(showCaseDetailsMenuItem, JOptionPane.showConfirmDialog(showCaseDetailsMenuItem,
Bundle.DataContentViewerOtherCases_caseDetailsDialog_noDetails(), details,
caseDisplayName, caseDisplayName,
DEFAULT_OPTION, PLAIN_MESSAGE); DEFAULT_OPTION, PLAIN_MESSAGE);
} }
@ -301,6 +290,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
writeSelectedRowsToFileAsCSV(selectedFile); writeSelectedRowsToFileAsCSV(selectedFile);
} }
} }
} }
@ -308,9 +298,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
StringBuilder content; StringBuilder content;
int[] selectedRowViewIndices = filesTable.getSelectedRows(); int[] selectedRowViewIndices = filesTable.getSelectedRows();
int colCount = filesTableModel.getColumnCount(); int colCount = filesTableModel.getColumnCount();
try (BufferedWriter writer = Files.newBufferedWriter(destFile.toPath())) { try (BufferedWriter writer = Files.newBufferedWriter(destFile.toPath())) {
// write column names // write column names
content = new StringBuilder(""); content = new StringBuilder("");
for (int colIdx = 0; colIdx < colCount; colIdx++) { for (int colIdx = 0; colIdx < colCount; colIdx++) {
@ -319,7 +307,6 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
content.append(","); content.append(",");
} }
} }
content.append(System.getProperty("line.separator")); content.append(System.getProperty("line.separator"));
writer.write(content.toString()); writer.write(content.toString());
@ -387,6 +374,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
@Override @Override
public int isPreferred(Node node) { public int isPreferred(Node node) {
return 1; return 1;
} }
/** /**
@ -886,7 +874,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
private void updateOnFileSelection() { private void updateOnFileSelection() {
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible //calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible
if (filesTable.getSelectedRowCount() == 1) { if (filesTable.getSelectedRowCount() == 1) {
occurrencePanel = new OccurrencePanel(filesTableModel.getNodeDataList()); occurrencePanel = new OccurrencePanel(filesTableModel.getRow(filesTable.convertRowIndexToModel(filesTable.getSelectedRow())));
} else if (dataSourcesTable.getSelectedRowCount() == 1) { } else if (dataSourcesTable.getSelectedRowCount() == 1) {
} else if (casesTable.getSelectedRowCount() == 1) { } else if (casesTable.getSelectedRowCount() == 1) {
@ -1075,18 +1063,18 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void rightClickPopupMenuPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_rightClickPopupMenuPopupMenuWillBecomeVisible private void rightClickPopupMenuPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_rightClickPopupMenuPopupMenuWillBecomeVisible
boolean enableCentralRepoActions = false; // boolean enableCentralRepoActions = false;
//
if (EamDb.isEnabled() && filesTable.getSelectedRowCount() == 1) { // if (EamDb.isEnabled() && filesTable.getSelectedRowCount() == 1) {
int rowIndex = filesTable.getSelectedRow(); // int rowIndex = filesTable.getSelectedRow();
OtherOccurrenceNodeData selectedNode = (OtherOccurrenceNodeData) filesTableModel.getRow(rowIndex); // List<OtherOccurrenceNodeData> selectedNode = (OtherOccurrenceNodeData) filesTableModel.getRow(rowIndex);
if (selectedNode instanceof OtherOccurrenceNodeInstanceData) { // if (selectedNode instanceof OtherOccurrenceNodeInstanceData) {
OtherOccurrenceNodeInstanceData instanceData = (OtherOccurrenceNodeInstanceData) selectedNode; // OtherOccurrenceNodeInstanceData instanceData = (OtherOccurrenceNodeInstanceData) selectedNode;
enableCentralRepoActions = instanceData.isCentralRepoNode(); // enableCentralRepoActions = instanceData.isCentralRepoNode();
} // }
} // }
showCaseDetailsMenuItem.setVisible(enableCentralRepoActions); // showCaseDetailsMenuItem.setVisible(enableCentralRepoActions);
showCommonalityMenuItem.setVisible(enableCentralRepoActions); // showCommonalityMenuItem.setVisible(enableCentralRepoActions);
}//GEN-LAST:event_rightClickPopupMenuPopupMenuWillBecomeVisible }//GEN-LAST:event_rightClickPopupMenuPopupMenuWillBecomeVisible
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables

View File

@ -19,7 +19,9 @@
package org.sleuthkit.autopsy.centralrepository.contentviewer; package org.sleuthkit.autopsy.centralrepository.contentviewer;
import java.awt.Font; import java.awt.Font;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
final class OccurrencePanel extends javax.swing.JPanel { final class OccurrencePanel extends javax.swing.JPanel {
@ -33,20 +35,29 @@ final class OccurrencePanel extends javax.swing.JPanel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int gridY = 0; private int gridY = 0;
List<OtherOccurrenceNodeData> nodeData; private final List<OtherOccurrenceNodeData> nodeData;
private final Set<String> caseNames = new HashSet<>();
private final Set<String> dataSourceNames = new HashSet<>();
private final Set<String> filePaths = new HashSet<>();
/** /**
* Creates new form OccurrencePanel2 * Creates new form OccurrencePanel2
*/ */
OccurrencePanel(List<OtherOccurrenceNodeData> nodeDataList) { OccurrencePanel(List<OtherOccurrenceNodeData> nodeDataList) {
nodeData = nodeDataList; nodeData = nodeDataList;
// if (nodeData != null && !nodeData.isEmpty()) {
initComponents(); initComponents();
if (!nodeData.isEmpty()) {
addInstanceDetails(); addInstanceDetails();
if (!filePaths.isEmpty()) {
addFileDetails(); addFileDetails();
}
if (!dataSourceNames.isEmpty()) {
addDataSourceDetails(); addDataSourceDetails();
}
if (!caseNames.isEmpty()) {
addCaseDetails(); addCaseDetails();
// } }
}
//add filler to keep everything else at the top //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))); 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)));
} }
@ -65,33 +76,45 @@ final class OccurrencePanel extends javax.swing.JPanel {
addItemToBag(gridY, 0, TOP_INSET, 0, commonPropertiesLabel); addItemToBag(gridY, 0, TOP_INSET, 0, commonPropertiesLabel);
gridY++; gridY++;
//for each other occurrence //for each other occurrence
for (int i = 1; i < 3; i++) { for (OtherOccurrenceNodeData occurrence : nodeData) {
if (occurrence instanceof OtherOccurrenceNodeInstanceData) {
String type = ((OtherOccurrenceNodeInstanceData) occurrence).getType();
if (!type.isEmpty()) {
javax.swing.JLabel typeLabel = new javax.swing.JLabel(); javax.swing.JLabel typeLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(typeLabel, Bundle.OccurrencePanel_commonPropertyTypeLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(typeLabel, Bundle.OccurrencePanel_commonPropertyTypeLabel_text());
addItemToBag(gridY, 0, VERTICAL_GAP, 0, typeLabel); addItemToBag(gridY, 0, VERTICAL_GAP, 0, typeLabel);
javax.swing.JLabel typeFieldValue = new javax.swing.JLabel(); javax.swing.JLabel typeFieldValue = new javax.swing.JLabel();
typeFieldValue.setText("FAKETYPE" + i); typeFieldValue.setText(type);
addItemToBag(gridY, 1, VERTICAL_GAP, 0, typeFieldValue); addItemToBag(gridY, 1, VERTICAL_GAP, 0, typeFieldValue);
gridY++; gridY++;
}
String value = ((OtherOccurrenceNodeInstanceData) occurrence).getValue();
if (!value.isEmpty()) {
javax.swing.JLabel valueLabel = new javax.swing.JLabel(); javax.swing.JLabel valueLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(valueLabel, Bundle.OccurrencePanel_commonPropertyValueLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(valueLabel, Bundle.OccurrencePanel_commonPropertyValueLabel_text());
addItemToBag(gridY, 0, 0, 0, valueLabel); addItemToBag(gridY, 0, 0, 0, valueLabel);
javax.swing.JLabel valueFieldValue = new javax.swing.JLabel(); javax.swing.JLabel valueFieldValue = new javax.swing.JLabel();
valueFieldValue.setText("FAKEVALUE" + i); valueFieldValue.setText(value);
addItemToBag(gridY, 1, 0, 0, valueFieldValue); addItemToBag(gridY, 1, 0, 0, valueFieldValue);
gridY++; gridY++;
}
String known = ((OtherOccurrenceNodeInstanceData) occurrence).getKnown().toString();
if (!known.isEmpty()) {
javax.swing.JLabel knownStatusLabel = new javax.swing.JLabel(); javax.swing.JLabel knownStatusLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(knownStatusLabel, Bundle.OccurrencePanel_commonPropertyKnownStatusLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(knownStatusLabel, Bundle.OccurrencePanel_commonPropertyKnownStatusLabel_text());
addItemToBag(gridY, 0, 0, 0, knownStatusLabel); addItemToBag(gridY, 0, 0, 0, knownStatusLabel);
javax.swing.JLabel knownStatusValue = new javax.swing.JLabel(); javax.swing.JLabel knownStatusValue = new javax.swing.JLabel();
knownStatusValue.setText("FAKESTATUS" + i); knownStatusValue.setText(known);
addItemToBag(gridY, 1, 0, 0, knownStatusValue); addItemToBag(gridY, 1, 0, 0, knownStatusValue);
gridY++; gridY++;
}
String comment = ((OtherOccurrenceNodeInstanceData) occurrence).getComment();
if (!comment.isEmpty()) {
javax.swing.JLabel commentLabel = new javax.swing.JLabel(); javax.swing.JLabel commentLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(commentLabel, Bundle.OccurrencePanel_commonPropertyCommentLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(commentLabel, Bundle.OccurrencePanel_commonPropertyCommentLabel_text());
addItemToBag(gridY, 0, 0, VERTICAL_GAP, commentLabel); addItemToBag(gridY, 0, 0, VERTICAL_GAP, commentLabel);
javax.swing.JTextArea commentValue = new javax.swing.JTextArea(); javax.swing.JTextArea commentValue = new javax.swing.JTextArea();
commentValue.setText("FAKECOMMENT" + i); commentValue.setText(comment);
commentValue.setEditable(false); commentValue.setEditable(false);
commentValue.setColumns(20); commentValue.setColumns(20);
commentValue.setLineWrap(true); commentValue.setLineWrap(true);
@ -103,6 +126,11 @@ final class OccurrencePanel extends javax.swing.JPanel {
addItemToBag(gridY, 1, 0, VERTICAL_GAP, commentValue); addItemToBag(gridY, 1, 0, VERTICAL_GAP, commentValue);
gridY++; gridY++;
} }
caseNames.add(((OtherOccurrenceNodeInstanceData) occurrence).getCaseName());
dataSourceNames.add(((OtherOccurrenceNodeInstanceData) occurrence).getDataSourceName());
filePaths.add(((OtherOccurrenceNodeInstanceData) occurrence).getFilePath());
}
}
//end for each //end for each
} }
@ -111,16 +139,18 @@ final class OccurrencePanel extends javax.swing.JPanel {
"OccurrencePanel.filePathLabel.text=File Path:" "OccurrencePanel.filePathLabel.text=File Path:"
}) })
private void addFileDetails() { private void addFileDetails() {
javax.swing.JLabel fileDetailsLabel = new javax.swing.JLabel(); javax.swing.JLabel fileDetailsLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(fileDetailsLabel, Bundle.OccurrencePanel_fileDetails_text()); org.openide.awt.Mnemonics.setLocalizedText(fileDetailsLabel, Bundle.OccurrencePanel_fileDetails_text());
fileDetailsLabel.setFont(fileDetailsLabel.getFont().deriveFont(Font.BOLD, fileDetailsLabel.getFont().getSize())); fileDetailsLabel.setFont(fileDetailsLabel.getFont().deriveFont(Font.BOLD, fileDetailsLabel.getFont().getSize()));
addItemToBag(gridY, 0, TOP_INSET, 0, fileDetailsLabel); addItemToBag(gridY, 0, TOP_INSET, 0, fileDetailsLabel);
gridY++; gridY++;
String filePath = filePaths.size() > 1 ? "too many files" : filePaths.iterator().next();
javax.swing.JLabel filePathLabel = new javax.swing.JLabel(); javax.swing.JLabel filePathLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(filePathLabel, Bundle.OccurrencePanel_filePathLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(filePathLabel, Bundle.OccurrencePanel_filePathLabel_text());
addItemToBag(gridY, 0, VERTICAL_GAP, VERTICAL_GAP, filePathLabel); addItemToBag(gridY, 0, VERTICAL_GAP, VERTICAL_GAP, filePathLabel);
javax.swing.JTextArea filePathValue = new javax.swing.JTextArea(); javax.swing.JTextArea filePathValue = new javax.swing.JTextArea();
filePathValue.setText("fakedataSourceName"); filePathValue.setText(filePath);
filePathValue.setEditable(false); filePathValue.setEditable(false);
filePathValue.setColumns(20); filePathValue.setColumns(20);
filePathValue.setLineWrap(true); filePathValue.setLineWrap(true);
@ -143,11 +173,12 @@ final class OccurrencePanel extends javax.swing.JPanel {
dataSourceDetailsLabel.setFont(dataSourceDetailsLabel.getFont().deriveFont(Font.BOLD, dataSourceDetailsLabel.getFont().getSize())); dataSourceDetailsLabel.setFont(dataSourceDetailsLabel.getFont().deriveFont(Font.BOLD, dataSourceDetailsLabel.getFont().getSize()));
addItemToBag(gridY, 0, TOP_INSET, 0, dataSourceDetailsLabel); addItemToBag(gridY, 0, TOP_INSET, 0, dataSourceDetailsLabel);
gridY++; gridY++;
String dataSourceName = dataSourceNames.size() > 1 ? "too many data sources" : dataSourceNames.iterator().next();
javax.swing.JLabel dataSourceNameLabel = new javax.swing.JLabel(); javax.swing.JLabel dataSourceNameLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(dataSourceNameLabel, Bundle.OccurrencePanel_dataSourceNameLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(dataSourceNameLabel, Bundle.OccurrencePanel_dataSourceNameLabel_text());
addItemToBag(gridY, 0, VERTICAL_GAP, VERTICAL_GAP, dataSourceNameLabel); addItemToBag(gridY, 0, VERTICAL_GAP, VERTICAL_GAP, dataSourceNameLabel);
javax.swing.JLabel dataSourceNameValue = new javax.swing.JLabel(); javax.swing.JLabel dataSourceNameValue = new javax.swing.JLabel();
dataSourceNameValue.setText("fakedataSourceName"); dataSourceNameValue.setText(dataSourceName);
addItemToBag(gridY, 1, VERTICAL_GAP, VERTICAL_GAP, dataSourceNameValue); addItemToBag(gridY, 1, VERTICAL_GAP, VERTICAL_GAP, dataSourceNameValue);
gridY++; gridY++;
} }
@ -163,11 +194,12 @@ final class OccurrencePanel extends javax.swing.JPanel {
caseDetailsLabel.setFont(caseDetailsLabel.getFont().deriveFont(Font.BOLD, caseDetailsLabel.getFont().getSize())); caseDetailsLabel.setFont(caseDetailsLabel.getFont().deriveFont(Font.BOLD, caseDetailsLabel.getFont().getSize()));
addItemToBag(gridY, 0, TOP_INSET, 0, caseDetailsLabel); addItemToBag(gridY, 0, TOP_INSET, 0, caseDetailsLabel);
gridY++; gridY++;
String caseName = caseNames.size() > 1 ? "too many cases" : caseNames.iterator().next();
javax.swing.JLabel caseNameLabel = new javax.swing.JLabel(); javax.swing.JLabel caseNameLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(caseNameLabel, Bundle.OccurrencePanel_caseNameLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(caseNameLabel, Bundle.OccurrencePanel_caseNameLabel_text());
addItemToBag(gridY, 0, VERTICAL_GAP, 0, caseNameLabel); addItemToBag(gridY, 0, VERTICAL_GAP, 0, caseNameLabel);
javax.swing.JLabel caseNameValue = new javax.swing.JLabel(); javax.swing.JLabel caseNameValue = new javax.swing.JLabel();
caseNameValue.setText("fakecaseName"); caseNameValue.setText(caseName);
addItemToBag(gridY, 1, VERTICAL_GAP, 0, caseNameValue); addItemToBag(gridY, 1, VERTICAL_GAP, 0, caseNameValue);
gridY++; gridY++;
javax.swing.JLabel caseCreatedLabel = new javax.swing.JLabel(); javax.swing.JLabel caseCreatedLabel = new javax.swing.JLabel();

View File

@ -24,7 +24,6 @@ import javax.swing.JComponent;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import org.sleuthkit.datamodel.TskData;
/** /**
* Renderer for cells in the files section of the other occurrences data content viewer * Renderer for cells in the files section of the other occurrences data content viewer
@ -49,17 +48,17 @@ public class OtherOccurrencesFilesTableCellRenderer implements TableCellRenderer
foreground = Color.WHITE; foreground = Color.WHITE;
background = new Color(51,153,255); background = new Color(51,153,255);
} else { } else {
TskData.FileKnown knownStatus = ((OtherOccurrencesFilesTableModel)table.getModel()).getKnownStatusForRow(table.convertRowIndexToModel(row)); // TskData.FileKnown knownStatus = ((OtherOccurrencesFilesTableModel)table.getModel()).getKnownStatusForRow(table.convertRowIndexToModel(row));
if (knownStatus.equals(TskData.FileKnown.BAD)) { // if (knownStatus.equals(TskData.FileKnown.BAD)) {
foreground = Color.WHITE; // foreground = Color.WHITE;
background = Color.RED; // background = Color.RED;
} else if (knownStatus.equals(TskData.FileKnown.UNKNOWN)) { // } else if (knownStatus.equals(TskData.FileKnown.UNKNOWN)) {
// foreground = Color.BLACK;
// background = Color.WHITE;
// } else {
foreground = Color.BLACK; foreground = Color.BLACK;
background = Color.WHITE; background = Color.WHITE;
} else { // }
foreground = Color.BLACK;
background = Color.WHITE;
}
} }
renderer.setForeground(foreground); renderer.setForeground(foreground);
renderer.setBackground(background); renderer.setBackground(background);

View File

@ -20,11 +20,12 @@ package org.sleuthkit.autopsy.centralrepository.contentviewer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.sleuthkit.datamodel.TskData;
/** /**
* Model for cells in the files section of the other occurrences data content * Model for cells in the files section of the other occurrences data content
@ -56,7 +57,9 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
} }
}; };
private final List<OtherOccurrenceNodeData> nodeDataList = new ArrayList<>(); // private final List<OtherOccurrenceNodeData> nodeDataList = new ArrayList<>();
private final List<String> nodeKeys = new ArrayList<>();
private final Map<String, List<OtherOccurrenceNodeData>> nodeMap = new HashMap<>();
OtherOccurrencesFilesTableModel() { OtherOccurrencesFilesTableModel() {
@ -83,7 +86,7 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
@Override @Override
public int getRowCount() { public int getRowCount() {
return nodeDataList.size(); return nodeKeys.size();
} }
@Override @Override
@ -93,46 +96,51 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
@Override @Override
public Object getValueAt(int rowIdx, int colIdx) { public Object getValueAt(int rowIdx, int colIdx) {
if (0 == nodeDataList.size()) { if (0 == nodeKeys.size()) {
return Bundle.OtherOccurrencesFilesTableModel_noData(); return Bundle.OtherOccurrencesFilesTableModel_noData();
}System.out.println("Getting file path");
String nodeKey = nodeKeys.get(rowIdx);
System.out.println("KEY: " + nodeKey);
List<OtherOccurrenceNodeData> dataList = nodeMap.get(nodeKey);
OtherOccurrenceNodeInstanceData data = (OtherOccurrenceNodeInstanceData)dataList.get(0);
String filePath = data.getFilePath();
System.out.println("PATH: " + filePath);
String fileName = FilenameUtils.getName(filePath);
System.out.println("NAME: " + fileName);
return fileName;
// return nodeMap.get(FilenameUtils.getName(((OtherOccurrenceNodeInstanceData)nodeMap.get(nodeKeys.get(rowIdx)).get(0)).getFilePath()));
} }
OtherOccurrenceNodeData nodeData = nodeDataList.get(rowIdx); // public TskData.FileKnown getKnownStatusForRow(int rowIdx) {
TableColumns columnId = TableColumns.values()[colIdx]; // if (rowIdx >= nodeDataList.size()) {
return mapNodeInstanceData((OtherOccurrenceNodeInstanceData) nodeData, columnId); // return TskData.FileKnown.UNKNOWN;
} // } else {
// return ((OtherOccurrenceNodeInstanceData) nodeDataList.get(rowIdx)).getKnown();
// }
// }
// /**
// * Map a column ID to the value in that cell for node instance data.
// *
// * @param nodeData The node instance data.
// * @param columnId The ID of the cell column.
// *
// * @return The value in the cell.
// */
// private Object mapNodeInstanceData(OtherOccurrenceNodeInstanceData nodeData, TableColumns columnId) {
// String value = Bundle.OtherOccurrencesFilesTableModel_noData();
//
// switch (columnId) {
// case FILE_NAME:
// value = FilenameUtils.getName(nodeData.getFilePath());
// break;
// default: //Use default "No data" value.
// break;
// }
// return value;
// }
public TskData.FileKnown getKnownStatusForRow(int rowIdx) { List<OtherOccurrenceNodeData> getRow(int rowIdx) {
if (rowIdx >= nodeDataList.size()) { return nodeMap.get(nodeKeys.get(rowIdx));
return TskData.FileKnown.UNKNOWN;
} else {
return ((OtherOccurrenceNodeInstanceData) nodeDataList.get(rowIdx)).getKnown();
}
}
/**
* Map a column ID to the value in that cell for node instance data.
*
* @param nodeData The node instance data.
* @param columnId The ID of the cell column.
*
* @return The value in the cell.
*/
private Object mapNodeInstanceData(OtherOccurrenceNodeInstanceData nodeData, TableColumns columnId) {
String value = Bundle.OtherOccurrencesFilesTableModel_noData();
switch (columnId) {
case FILE_NAME:
value = FilenameUtils.getName(nodeData.getFilePath());
break;
default: //Use default "No data" value.
break;
}
return value;
}
Object getRow(int rowIdx) {
return nodeDataList.get(rowIdx);
} }
@Override @Override
@ -146,19 +154,31 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
* @param newNodeData data to add to the table * @param newNodeData data to add to the table
*/ */
void addNodeData(OtherOccurrenceNodeData newNodeData) { void addNodeData(OtherOccurrenceNodeData newNodeData) {
nodeDataList.add(newNodeData); String newNodeKey = createNodeKey((OtherOccurrenceNodeInstanceData) newNodeData);//FilenameUtils.getName(((OtherOccurrenceNodeInstanceData)newNodeData).getFilePath());
List<OtherOccurrenceNodeData> nodeList = nodeMap.get(newNodeKey);
if (nodeList == null) {
nodeKeys.add(newNodeKey);
nodeList = new ArrayList<>();
}
nodeList.add(newNodeData);
nodeMap.put(newNodeKey, nodeList);
fireTableDataChanged(); fireTableDataChanged();
} }
List<OtherOccurrenceNodeData> getNodeDataList() { List<OtherOccurrenceNodeData> getNodeDataList(String nodeKey) {
return Collections.unmodifiableList(nodeDataList); return Collections.unmodifiableList(nodeMap.get(nodeKey));
}
private String createNodeKey(OtherOccurrenceNodeInstanceData nodeData) {
return nodeData.getCaseName() + nodeData.getDataSourceName() + nodeData.getDeviceID() + nodeData.getFilePath();
} }
/** /**
* Clear the node data table. * Clear the node data table.
*/ */
void clearTable() { void clearTable() {
nodeDataList.clear(); nodeKeys.clear();
nodeMap.clear();
fireTableDataChanged(); fireTableDataChanged();
} }