package com.vci.client.ui.swing;
|
|
import java.awt.Component;
|
import java.awt.Frame;
|
import java.awt.HeadlessException;
|
import java.util.Locale;
|
|
import javax.swing.JOptionPane;
|
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.corba.common.VCIError;
|
|
public class VCIOptionPane extends JOptionPane{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 3800121423347621658L;
|
|
public VCIOptionPane() {
|
|
}
|
|
public static void showMessageDialog(Frame frame, Component parentComponent, Object message,
|
String title, int messageType) throws HeadlessException {
|
if (parentComponent != null) {
|
showMessageDialog(parentComponent, message, title, messageType, null);
|
} else {
|
showMessageDialog(frame, message, title, messageType, null);
|
}
|
}
|
|
public static int showConfirmDialog(Frame frame, Component parentComponent,
|
Object message, String title, int optionType, int messageType)
|
throws HeadlessException {
|
if(parentComponent != null) {
|
return showConfirmDialog(parentComponent, message, title, optionType, messageType, null);
|
} else {
|
return showConfirmDialog(frame, message, title, optionType, messageType, null);
|
}
|
}
|
|
/**
|
* 消息提示
|
* @param parentComponent 父容器
|
* @param message 消息内容
|
*/
|
public static void showMessage(Component parentComponent, String message){
|
String title = LocaleDisplay.getI18nString("rmip.framework.info.message.dialog.title", "RMIPFramework", parentComponent.getLocale());
|
VCIOptionPane.showMessageDialog(parentComponent, message, title, VCIOptionPane.INFORMATION_MESSAGE);
|
}
|
/**
|
* 消息提示
|
* @param parentComponent 父容器
|
* @param message 消息内容
|
*/
|
public static void showMessage(Component parentComponent, VCIError e){
|
String title = LocaleDisplay.getI18nString("rmip.framework.info.message.dialog.title", "RMIPFramework", parentComponent.getLocale());
|
String message = getCustomErrorMessage(e);
|
VCIOptionPane.showMessageDialog(parentComponent, message, title, VCIOptionPane.INFORMATION_MESSAGE);
|
}
|
|
/**
|
* 错误消息提示
|
* @param parentComponent 父容器
|
* @param message 消息内容
|
*/
|
public static void showError(Component parentComponent, String message){
|
String title = LocaleDisplay.getI18nString("rmip.framework.error.message.dialog.title", "RMIPFramework", parentComponent.getLocale());
|
VCIOptionPane.showMessageDialog(parentComponent, message, title, VCIOptionPane.ERROR_MESSAGE);
|
}
|
|
/**
|
* 错误消息提示
|
* @param parentComponent 父容器
|
* @param message 消息内容
|
*/
|
public static void showError(Component parentComponent, VCIError e){
|
String title = LocaleDisplay.getI18nString("rmip.framework.error.message.dialog.title", "RMIPFramework", parentComponent.getLocale());
|
String message = getCustomErrorMessage(e);
|
VCIOptionPane.showMessageDialog(parentComponent, message, title, VCIOptionPane.ERROR_MESSAGE);
|
}
|
|
/**
|
*
|
* <p>Description: 更加错误异常信息显示提示对话框</p>
|
*
|
* @author Administrator
|
* @time 2011-7-13
|
* @param parentComponent 父容器
|
* @param fileName 国际化文件名称
|
* @param exp 错误异常信息
|
*/
|
public static void showError(Component parentComponent, String fileName, VCIException exp) {
|
String title = LocaleDisplay.getI18nString("rmip.framework.error.message.dialog.title", "RMIPFramework", parentComponent.getLocale());
|
String message = LocaleDisplay.getI18nString(exp, fileName, Locale.getDefault());
|
VCIOptionPane.showMessageDialog(parentComponent, message, title, VCIOptionPane.ERROR_MESSAGE);
|
}
|
|
/**
|
* 警告消息提示
|
* @param parentComponent 父容器
|
* @param message 消息内容
|
*/
|
public static void showWarning(Component parentComponent, String message){
|
String title = LocaleDisplay.getI18nString("rmip.framework.warn.message.dialog.title", "RMIPFramework", parentComponent.getLocale());
|
VCIOptionPane.showMessageDialog(parentComponent, message, title, VCIOptionPane.WARNING_MESSAGE);
|
}
|
/**
|
* 询问消息提示
|
* @param parentComponent 父容器
|
* @param message 消息内容
|
*/
|
public static int showQuestion(Component parentComponent, String message){
|
String title = LocaleDisplay.getI18nString("rmip.framework.friend.message.dialog.title", "RMIPFramework", parentComponent.getLocale());
|
return VCIOptionPane.showConfirmDialog(parentComponent, message, title, VCIOptionPane.YES_NO_OPTION);
|
}
|
|
/***
|
* 确认操作框
|
*/
|
public static int showQuestion(Frame frame){
|
String title = LocaleDisplay.getI18nString("rmip.framework.friend.message.dialog.title", "RMIPFramework", frame.getLocale());
|
String msg = LocaleDisplay.getI18nString("rmip.framework.friend.message.dialog.title", "RMIPFramework", frame.getLocale());
|
return VCIOptionPane.showConfirmDialog(frame, msg, title, VCIOptionPane.YES_NO_OPTION);
|
}
|
|
private static String getCustomErrorMessage(VCIError e){
|
String message = LocaleDisplay.getI18nString(String.valueOf(e.code), "RMIPCode", Locale.getDefault());
|
Object[] messages = (Object[])e.messages;
|
if(messages.length != 0){
|
message = String.format(message, messages);
|
}
|
return message;
|
}
|
}
|