package com.ebixio.util;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
/**
* Modified by Gabriel Burca.
*
* @author qbeukes.blogspot.com, used by metalklesk
*/
public class MessageUtil {
private MessageUtil() {}
/**
* @return The dialog displayer used to show message boxes
*/
public static DialogDisplayer getDialogDisplayer() {
return DialogDisplayer.getDefault();
}
/**
* Show a message of the specified type
*
* @param message The message to display
* @param messageType As in {@link org.openide.NotifyDescriptor#NotifyDescriptor(java.lang.Object, java.lang.String, int, int, java.lang.Object[], java.lang.Object) } message type constants.
*/
public static void show(String message, MessageType messageType) {
getDialogDisplayer().notify(new NotifyDescriptor.Message(message,
messageType.getNotifyDescriptorType()));
}
/**
* Show an exception message dialog
*
* @param message The message to display
* @param exception The exception to display
*/
public static void showException(String message, Throwable exception) {
getDialogDisplayer().notify(
new NotifyDescriptor.Confirmation(exception, message,
NotifyDescriptor.DEFAULT_OPTION,
NotifyDescriptor.ERROR_MESSAGE));
}
/**
* Show an information dialog
* @param message The message to display
*/
public static void info(String message) {
show(message, MessageType.INFO);
}
/**
* Show an error dialog
* @param message The message to display
*/
public static void error(String message) {
show(message, MessageType.ERROR);
}
/**
* Show an error dialog for an exception
* @param message The message to display
* @param exception The exception to display
*/
public static void error(String message, Throwable exception) {
showException(message, exception);
}
/**
* Show an question dialog
* @param message The message to display
*/
public static void question(String message) {
show(message, MessageType.QUESTION);
}
/**
* Show an warning dialog
* @param message The message to display
*/
public static void warn(String message) {
show(message, MessageType.WARNING);
}
/**
* Show an plain dialog
* @param message The message to display
*/
public static void plain(String message) {
show(message, MessageType.PLAIN);
}
}