19 package org.sleuthkit.autopsy.discovery.ui;
21 import java.awt.Color;
22 import java.awt.Component;
23 import java.awt.Point;
24 import java.awt.event.MouseEvent;
25 import java.text.SimpleDateFormat;
26 import java.util.Date;
27 import java.util.Locale;
28 import javax.swing.ImageIcon;
29 import javax.swing.JComponent;
30 import javax.swing.JList;
31 import javax.swing.ListCellRenderer;
32 import org.openide.util.NbBundle;
37 class DomainSummaryPanel
extends javax.swing.JPanel implements ListCellRenderer<DomainWrapper> {
39 private static final long serialVersionUID = 1L;
40 private static final Color SELECTION_COLOR =
new Color(0, 120, 215);
41 private static final SimpleDateFormat dateFormat =
new SimpleDateFormat(
"MMM dd yyyy", Locale.getDefault());
46 DomainSummaryPanel() {
48 domainNameLabel.setFont(domainNameLabel.getFont().deriveFont(domainNameLabel.getFont().getStyle(), domainNameLabel.getFont().getSize() + 6));
56 @SuppressWarnings(
"unchecked")
58 private
void initComponents() {
60 domainNameLabel =
new javax.swing.JLabel();
61 sampleImageLabel =
new javax.swing.JLabel();
62 numberOfImagesLabel =
new javax.swing.JLabel();
63 activityLabel =
new javax.swing.JLabel();
64 pagesLabel =
new javax.swing.JLabel();
65 filesDownloadedLabel =
new javax.swing.JLabel();
66 totalVisitsLabel =
new javax.swing.JLabel();
68 setBorder(javax.swing.BorderFactory.createEtchedBorder());
70 sampleImageLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
71 sampleImageLabel.setIconTextGap(0);
72 sampleImageLabel.setMaximumSize(
new java.awt.Dimension(100, 100));
73 sampleImageLabel.setMinimumSize(
new java.awt.Dimension(100, 100));
74 sampleImageLabel.setPreferredSize(
new java.awt.Dimension(100, 100));
76 org.openide.awt.Mnemonics.setLocalizedText(activityLabel,
org.openide.util.NbBundle.getMessage(DomainSummaryPanel.class,
"DomainSummaryPanel.activityLabel.text"));
78 org.openide.awt.Mnemonics.setLocalizedText(pagesLabel,
org.openide.util.NbBundle.getMessage(DomainSummaryPanel.class,
"DomainSummaryPanel.pagesLabel.text"));
80 org.openide.awt.Mnemonics.setLocalizedText(filesDownloadedLabel,
org.openide.util.NbBundle.getMessage(DomainSummaryPanel.class,
"DomainSummaryPanel.filesDownloadedLabel.text"));
82 org.openide.awt.Mnemonics.setLocalizedText(totalVisitsLabel,
org.openide.util.NbBundle.getMessage(DomainSummaryPanel.class,
"DomainSummaryPanel.totalVisitsLabel.text"));
84 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
85 this.setLayout(layout);
86 layout.setHorizontalGroup(
87 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
88 .addGroup(layout.createSequentialGroup()
90 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
91 .addGroup(layout.createSequentialGroup()
92 .addComponent(domainNameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE)
94 .addComponent(activityLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
95 .addComponent(pagesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
96 .addComponent(filesDownloadedLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
97 .addComponent(totalVisitsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
98 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
99 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
100 .addComponent(numberOfImagesLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
101 .addComponent(sampleImageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
104 layout.setVerticalGroup(
105 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
106 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
108 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109 .addGroup(layout.createSequentialGroup()
110 .addComponent(numberOfImagesLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
111 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
112 .addComponent(sampleImageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
113 .addGroup(layout.createSequentialGroup()
114 .addComponent(domainNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
115 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
116 .addComponent(activityLabel)
118 .addComponent(totalVisitsLabel)
120 .addComponent(pagesLabel)
121 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
122 .addComponent(filesDownloadedLabel)
123 .addGap(0, 0, Short.MAX_VALUE)))
130 private javax.swing.JLabel activityLabel;
131 private javax.swing.JLabel domainNameLabel;
132 private javax.swing.JLabel filesDownloadedLabel;
133 private javax.swing.JLabel numberOfImagesLabel;
134 private javax.swing.JLabel pagesLabel;
135 private javax.swing.JLabel sampleImageLabel;
136 private javax.swing.JLabel totalVisitsLabel;
139 @NbBundle.Messages({
"# {0} - startDate",
141 "DomainSummaryPanel.activity.text=Activity: {0} to {1}",
142 "DomainSummaryPanel.pages.text=Pages in past 60 days: ",
143 "DomainSummaryPanel.totalPages.text=Total visits: ",
144 "DomainSummaryPanel.downloads.text=Files downloaded: ",
145 "DomainSummaryPanel.loadingImages.text=Loading thumbnail..."})
147 public Component getListCellRendererComponent(JList<? extends DomainWrapper> list, DomainWrapper value,
int index,
boolean isSelected,
boolean cellHasFocus) {
148 domainNameLabel.setText(value.getResultDomain().getDomain());
149 String startDate = dateFormat.format(
new Date(value.getResultDomain().getActivityStart() * 1000));
150 String endDate = dateFormat.format(
new Date(value.getResultDomain().getActivityEnd() * 1000));
151 activityLabel.setText(Bundle.DomainSummaryPanel_activity_text(startDate, endDate));
152 totalVisitsLabel.setText(Bundle.DomainSummaryPanel_totalPages_text() + value.getResultDomain().getTotalVisits());
153 pagesLabel.setText(Bundle.DomainSummaryPanel_pages_text() + value.getResultDomain().getVisitsInLast60());
154 filesDownloadedLabel.setText(Bundle.DomainSummaryPanel_downloads_text() + value.getResultDomain().getFilesDownloaded());
155 if (value.getThumbnail() == null) {
156 numberOfImagesLabel.setText(Bundle.DomainSummaryPanel_loadingImages_text());
157 sampleImageLabel.setIcon(null);
159 numberOfImagesLabel.setText(null);
160 sampleImageLabel.setIcon(
new ImageIcon(value.getThumbnail()));
162 setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
167 public String getToolTipText(MouseEvent event) {
170 Point point =
event.getPoint();
171 for (Component comp : getComponents()) {
172 if (DiscoveryUiUtils.isPointOnIcon(comp, point)) {
173 String toolTip = ((JComponent) comp).getToolTipText();
174 if (toolTip == null || toolTip.isEmpty()) {