19 package org.sleuthkit.autopsy.discovery.ui;
21 import java.awt.Dimension;
22 import java.util.ArrayList;
23 import java.util.List;
24 import javax.swing.JPanel;
25 import javax.swing.event.ListSelectionListener;
26 import javax.swing.table.AbstractTableModel;
27 import javax.swing.table.TableCellRenderer;
28 import org.openide.util.NbBundle;
37 final class MiniTimelineDateListPanel
extends JPanel {
39 private static final long serialVersionUID = 1L;
40 private final DateCountTableModel tableModel =
new DateCountTableModel();
45 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
46 MiniTimelineDateListPanel() {
49 TableCellRenderer renderer =
new SimpleTableCellRenderer();
50 for (
int i = 0; i < tableModel.getColumnCount(); ++i) {
51 jTable1.getColumnModel().getColumn(i).setCellRenderer(renderer);
53 setMinimumSize(
new Dimension(125, 20));
54 jTable1.getRowSorter().toggleSortOrder(0);
55 jTable1.getRowSorter().toggleSortOrder(0);
64 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
65 void addSelectionListener(ListSelectionListener listener) {
66 jTable1.getSelectionModel().addListSelectionListener(listener);
72 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
82 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
83 void removeListSelectionListener(ListSelectionListener listener) {
84 jTable1.getSelectionModel().removeListSelectionListener(listener);
92 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
94 return tableModel.getRowCount() <= 0;
101 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
104 jTable1.setRowSelectionInterval(0, 0);
106 jTable1.clearSelection();
117 List<BlackboardArtifact> getArtifactsForSelectedDate() {
118 int selectedIndex = jTable1.getSelectionModel().getLeadSelectionIndex();
119 if (selectedIndex < jTable1.getSelectionModel().getMinSelectionIndex()
120 || jTable1.getSelectionModel().getMaxSelectionIndex() < 0
121 || selectedIndex > jTable1.getSelectionModel().getMaxSelectionIndex()) {
122 return new ArrayList<>();
124 return tableModel.getDateCountByRow(jTable1.convertRowIndexToModel(selectedIndex)).getArtifactList();
133 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
134 void addArtifacts(List<MiniTimelineResult> dateArtifactList) {
135 tableModel.setContents(dateArtifactList);
138 tableModel.fireTableDataChanged();
144 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
146 tableModel.setContents(
new ArrayList<>());
147 tableModel.fireTableDataChanged();
153 private void initComponents() {
155 javax.swing.JScrollPane jScrollPane1 =
new javax.swing.JScrollPane();
156 jTable1 =
new javax.swing.JTable();
159 setPreferredSize(
new java.awt.Dimension(200, 10));
160 jScrollPane1.setPreferredSize(
new java.awt.Dimension(200, 10));
161 jScrollPane1.setBorder(null);
162 jScrollPane1.setMinimumSize(
new java.awt.Dimension(0, 0));
164 jTable1.setAutoCreateRowSorter(
true);
165 jTable1.setModel(tableModel);
166 jTable1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
167 jScrollPane1.setViewportView(jTable1);
169 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
170 this.setLayout(layout);
171 layout.setHorizontalGroup(
172 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
173 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
175 layout.setVerticalGroup(
176 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
177 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
187 private static final long serialVersionUID = 1L;
198 jTable1.clearSelection();
199 this.dateCountList.clear();
200 this.dateCountList.addAll(dateCountList);
206 return dateCountList.size();
224 return dateCountList.get(rowIndex);
228 @NbBundle.Messages({
"MiniTimelineDateListPanel.value.noValue=No value available."})
231 switch (columnIndex) {
233 return dateCountList.get(rowIndex).getDate();
235 return dateCountList.get(rowIndex).getCount();
237 return Bundle.MiniTimelineDateListPanel_value_noValue();
243 "MiniTimelineDateListPanel.dateColumn.name=Date",
244 "MiniTimelineDateListPanel.countColumn.name=Count"})
249 return Bundle.MiniTimelineDateListPanel_dateColumn_name();
251 return Bundle.MiniTimelineDateListPanel_countColumn_name();
259 private javax.swing.JTable jTable1;
String getColumnName(int column)
final List< MiniTimelineResult > dateCountList
Object getValueAt(int rowIndex, int columnIndex)