19 package org.sleuthkit.autopsy.ingest;
21 import java.awt.BorderLayout;
22 import java.awt.Color;
23 import java.awt.EventQueue;
25 import java.awt.Graphics;
26 import java.beans.PropertyChangeEvent;
27 import java.beans.PropertyChangeListener;
28 import javax.swing.JButton;
30 import org.openide.util.NbBundle;
31 import org.openide.windows.Mode;
32 import org.openide.windows.WindowManager;
39 class IngestMessagesToolbar
extends javax.swing.JPanel {
41 private IngestMessagesButton ingestMessagesButton =
new IngestMessagesButton();
42 private static volatile IngestMessagesToolbar instance;
47 private IngestMessagesToolbar() {
49 customizeComponents();
55 public static IngestMessagesToolbar getDefault() {
56 if (instance == null) {
57 synchronized (IngestMessagesToolbar.class) {
58 if (instance == null) {
59 instance =
new IngestMessagesToolbar();
71 @SuppressWarnings(
"unchecked")
73 private
void initComponents() {
75 setToolTipText(
org.openide.util.NbBundle.getMessage(IngestMessagesToolbar.class,
"IngestMessagesToolbar.toolTipText"));
76 setMaximumSize(
new java.awt.Dimension(32767, 25));
77 setPreferredSize(
new java.awt.Dimension(80, 25));
78 setLayout(
new java.awt.BorderLayout());
83 private void customizeButton() {
84 ingestMessagesButton =
new IngestMessagesButton();
86 setMaximumSize(
new java.awt.Dimension(32767, 25));
87 setPreferredSize(
new java.awt.Dimension(80, 25));
89 ingestMessagesButton.setFocusPainted(
false);
90 ingestMessagesButton.setContentAreaFilled(
false);
91 ingestMessagesButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/eye-bw-25.png")));
92 ingestMessagesButton.setRolloverEnabled(
true);
93 ingestMessagesButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/ingest/eye-bw-25-rollover.png")));
94 ingestMessagesButton.setToolTipText(
95 NbBundle.getMessage(
this.getClass(),
"IngestMessagesToolbar.customizeButton.toolTipText"));
96 ingestMessagesButton.setBorder(null);
97 ingestMessagesButton.setBorderPainted(
false);
98 ingestMessagesButton.setEnabled(
false);
99 ingestMessagesButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
100 ingestMessagesButton.setMargin(
new java.awt.Insets(0, 0, 0, 0));
101 ingestMessagesButton.setMaximumSize(
new java.awt.Dimension(38, 24));
102 ingestMessagesButton.setMinimumSize(
new java.awt.Dimension(38, 24));
103 ingestMessagesButton.setPreferredSize(
new java.awt.Dimension(38, 24));
104 ingestMessagesButton.addActionListener(
new java.awt.event.ActionListener() {
106 public void actionPerformed(java.awt.event.ActionEvent evt) {
107 EventQueue.invokeLater(
new Runnable() {
110 showIngestMessages();
116 this.add(ingestMessagesButton, BorderLayout.CENTER);
119 private void customizeComponents() {
123 this.setBorder(null);
125 IngestMessagePanel.addPropertyChangeSupportListener(
new PropertyChangeListener() {
126 private int numNewMessages = 0;
129 public void propertyChange(PropertyChangeEvent evt) {
131 String propName = evt.getPropertyName();
132 int newNumNewMessages = numNewMessages;
133 if (propName.equals(IngestMessagePanel.MESSAGES_BOX_CLEARED)
134 || propName.equals(IngestMessagePanel.TOTAL_NUM_NEW_MESSAGES_CHANGED)) {
135 newNumNewMessages = (Integer) evt.getNewValue();
138 if (newNumNewMessages != numNewMessages) {
139 ingestMessagesButton.setMessages(newNumNewMessages);
140 numNewMessages = newNumNewMessages;
141 ingestMessagesButton.repaint();
146 Case.addPropertyChangeListener(
new PropertyChangeListener() {
148 public void propertyChange(PropertyChangeEvent evt) {
149 if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
150 setEnabled(evt.getNewValue() != null);
159 void showIngestMessages() {
160 IngestMessageTopComponent tc = IngestMessageTopComponent.findInstance();
162 Mode mode = WindowManager.getDefault().findMode(
"floatingLeftBottom");
172 public void setEnabled(
boolean enabled) {
173 super.setEnabled(enabled);
174 ingestMessagesButton.setEnabled(enabled);
190 Font messagesFont = g.getFont().deriveFont(Font.PLAIN, fontSize);
191 String messageStr = Integer.toString(messages);
192 final int len = messageStr.length();
193 g.setFont(messagesFont);
195 int dx = len * 5 + 5;
196 int x = getSize().width - dx;
200 g.setColor(Color.GRAY);
202 g.fillRoundRect(x, 1, dx, fontSize, 2, 2);
203 g.setColor(Color.WHITE);
204 g.drawString(messageStr, x + 2, fontSize);
207 void setMessages(
int messages) {