19 package org.sleuthkit.autopsy.discovery.ui;
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.JPanel;
24 import javax.swing.event.ListSelectionListener;
25 import javax.swing.table.AbstractTableModel;
26 import javax.swing.table.TableCellRenderer;
27 import org.openide.util.NbBundle;
36 class MiniTimelineDateListPanel
extends JPanel {
38 private static final long serialVersionUID = 1L;
39 private final DateCountTableModel tableModel =
new DateCountTableModel();
44 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
45 MiniTimelineDateListPanel() {
48 TableCellRenderer renderer =
new SimpleTableCellRenderer();
49 for (
int i = 0; i < tableModel.getColumnCount(); ++i) {
50 jTable1.getColumnModel().getColumn(i).setCellRenderer(renderer);
52 jTable1.getRowSorter().toggleSortOrder(0);
53 jTable1.getRowSorter().toggleSortOrder(0);
62 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
63 void addSelectionListener(ListSelectionListener listener) {
64 jTable1.getSelectionModel().addListSelectionListener(listener);
72 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
73 void removeListSelectionListener(ListSelectionListener listener) {
74 jTable1.getSelectionModel().removeListSelectionListener(listener);
82 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
84 return tableModel.getRowCount() <= 0;
91 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
94 jTable1.setRowSelectionInterval(0, 0);
96 jTable1.clearSelection();
107 List<BlackboardArtifact> getArtifactsForSelectedDate() {
108 int selectedIndex = jTable1.getSelectionModel().getLeadSelectionIndex();
109 if (selectedIndex < jTable1.getSelectionModel().getMinSelectionIndex()
110 || jTable1.getSelectionModel().getMaxSelectionIndex() < 0
111 || selectedIndex > jTable1.getSelectionModel().getMaxSelectionIndex()) {
112 return new ArrayList<>();
114 return tableModel.getDateCountByRow(jTable1.convertRowIndexToModel(selectedIndex)).getArtifactList();
123 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
124 void addArtifacts(List<MiniTimelineResult> dateArtifactList) {
125 tableModel.setContents(dateArtifactList);
128 tableModel.fireTableDataChanged();
134 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
136 tableModel.setContents(
new ArrayList<>());
137 tableModel.fireTableDataChanged();
143 private void initComponents() {
145 javax.swing.JScrollPane jScrollPane1 =
new javax.swing.JScrollPane();
146 jTable1 =
new javax.swing.JTable();
149 setPreferredSize(
new java.awt.Dimension(200, 10));
150 jScrollPane1.setPreferredSize(
new java.awt.Dimension(200, 10));
151 jScrollPane1.setBorder(null);
152 jScrollPane1.setMinimumSize(
new java.awt.Dimension(0, 0));
154 jTable1.setAutoCreateRowSorter(
true);
155 jTable1.setModel(tableModel);
156 jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
157 jScrollPane1.setViewportView(jTable1);
159 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
160 this.setLayout(layout);
161 layout.setHorizontalGroup(
162 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
163 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
165 layout.setVerticalGroup(
166 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
167 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
177 private static final long serialVersionUID = 1L;
188 jTable1.clearSelection();
189 this.dateCountList.clear();
190 this.dateCountList.addAll(dateCountList);
196 return dateCountList.size();
214 return dateCountList.get(rowIndex);
218 @NbBundle.Messages({
"MiniTimelineDateListPanel.value.noValue=No value available."})
221 switch (columnIndex) {
223 return dateCountList.get(rowIndex).getDate();
225 return dateCountList.get(rowIndex).getCount();
227 return Bundle.MiniTimelineDateListPanel_value_noValue();
233 "MiniTimelineDateListPanel.dateColumn.name=Date",
234 "MiniTimelineDateListPanel.countColumn.name=Count"})
239 return Bundle.MiniTimelineDateListPanel_dateColumn_name();
241 return Bundle.MiniTimelineDateListPanel_countColumn_name();
249 private javax.swing.JTable jTable1;
String getColumnName(int column)
final List< MiniTimelineResult > dateCountList
Object getValueAt(int rowIndex, int columnIndex)