19 package org.sleuthkit.autopsy.coreutils;
21 import java.awt.event.ActionEvent;
22 import java.awt.event.ActionListener;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.List;
26 import java.util.logging.Level;
27 import javax.swing.Icon;
28 import javax.swing.ImageIcon;
29 import org.openide.DialogDisplayer;
30 import org.openide.NotifyDescriptor;
31 import org.openide.awt.Notification;
32 import org.openide.awt.NotificationDisplayer;
33 import org.openide.util.ImageUtilities;
52 INFO(NotifyDescriptor.INFORMATION_MESSAGE,
"info-icon-16.png"),
53 ERROR(NotifyDescriptor.ERROR_MESSAGE,
"error-icon-16.png"),
54 WARNING(NotifyDescriptor.WARNING_MESSAGE,
"warning-icon-16.png");
58 private MessageType(
int notifyDescriptorType, String resourceName) {
59 this.notifyDescriptorType = notifyDescriptorType;
60 if (resourceName == null) {
61 icon =
new ImageIcon();
63 icon = loadIcon(resourceName);
67 private static Icon
loadIcon(String resourceName) {
68 Icon icon = ImageUtilities.loadImageIcon(
"org/sleuthkit/autopsy/images/" + resourceName,
false);
71 logger.log(Level.SEVERE,
"Failed to load icon resource: " + resourceName +
". Using blank image.");
72 icon =
new ImageIcon();
78 return notifyDescriptorType;
98 return DialogDisplayer.getDefault();
117 public static void info(String message) {
126 public static void error(String message) {
135 public static void warn(String message) {
146 private static final List<Notification>
notifications = Collections.synchronizedList(
new ArrayList<Notification>());
156 for (Notification n : notifications) {
159 notifications.clear();
165 public static void show(String title, String message,
MessageType type, ActionListener actionListener) {
166 Notification newNotification =
167 NotificationDisplayer.getDefault().notify(title, type.
getIcon(), message, actionListener);
168 notifications.add(newNotification);
181 ActionListener actionListener =
new ActionListener() {
183 public void actionPerformed(ActionEvent e) {
188 show(title, message, type, actionListener);
197 public static void info(String title, String message) {
207 public static void error(String title, String message) {
217 public static void warn(String title, String message) {
static DialogDisplayer getDialogDisplayer()
static void warn(String message)
MessageType(int notifyDescriptorType, String resourceName)
static void info(String title, String message)
static Icon loadIcon(String resourceName)
static void show(String message, MessageType messageType)
int getNotifyDescriptorType()
static final List< Notification > notifications
static void error(String title, String message)
static void show(String title, String message, MessageType type, ActionListener actionListener)
static void show(String title, final String message, final MessageType type)
static void info(String message)
static void warn(String title, String message)
static Logger getLogger(String name)
static void error(String message)