/** * @param title The title of the dialog * @param message The message of the dialog * @param silentDefault The default return value if installer is running silently * @return true if user click YES option. In silent mode return <code>silentDefault</code> */ public static boolean showYesNoDialog( final String title, final String message, final boolean silentDefault) { initLAF(); switch (UiMode.getCurrentUiMode()) { case SWING: LogManager.logIndent("... showing Yes/No dialog"); LogManager.log("title: " + title); LogManager.log("message: " + message); final int result = JOptionPane.showConfirmDialog(null, message, title, YES_NO_OPTION); LogManager.logUnindent( "... dialog closed, choice : " + (result == YES_OPTION ? "yes" : (result == NO_OPTION ? "no" : "closed"))); return result == YES_OPTION; case SILENT: LogManager.log(message); final String option = StringUtils.format( ResourceUtils.getString( UiUtils.class, silentDefault ? RESOURCE_SILENT_DEFAULT_YES : RESOURCE_SILENT_DEFAULT_NO)); System.err.println(message); System.err.println(option); LogManager.log(message); LogManager.log(option); return silentDefault; } // never get this line... return true; }
public static boolean showMessageDialog( final String message, final String title, final MessageType messageType) { initLAF(); boolean exitInstaller = false; switch (UiMode.getCurrentUiMode()) { case SWING: int intMessageType = JOptionPane.INFORMATION_MESSAGE; LogManager.logIndent("... show message dialog"); LogManager.log("title: " + title); LogManager.log("message: " + message); if (messageType == MessageType.WARNING) { intMessageType = JOptionPane.WARNING_MESSAGE; } else if (messageType == MessageType.CRITICAL) { intMessageType = JOptionPane.ERROR_MESSAGE; exitInstaller = true; } if (messageType == MessageType.ERROR) { int result = JOptionPane.showOptionDialog( null, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, null, JOptionPane.YES_OPTION); if (result == JOptionPane.NO_OPTION) { exitInstaller = true; LogManager.logUnindent("... user selected: NO"); } else { LogManager.logUnindent("... user selected: YES"); } } else { JOptionPane.showMessageDialog(null, message, title, intMessageType); } LogManager.logUnindent("... dialog closed"); break; case SILENT: LogManager.log(message); System.err.println(message); break; } return exitInstaller; }
/** * @param title The title of the dialog * @param message The message of the dialog * @param silentDefault The dafault return value if installer is running silently * @return true if user click YES option. In silent mode return <code>silentDefault</code> */ public static int showYesNoCancelDialog( final String title, final String message, final int silentDefault) { initLAF(); switch (UiMode.getCurrentUiMode()) { case SWING: LogManager.logIndent("... show Yes/No/Cancel dialog"); LogManager.log("title: " + title); LogManager.log("message: " + message); int result = JOptionPane.showConfirmDialog(null, message, title, YES_NO_CANCEL_OPTION); LogManager.logUnindent( "... dialog closed, choice : " + (result == YES_OPTION ? "yes" : (result == NO_OPTION ? "no" : (result == CANCEL_OPTION ? "cancel" : "closed")))); return result; case SILENT: LogManager.log(message); String resource; switch (silentDefault) { case YES_OPTION: resource = RESOURCE_SILENT_DEFAULT_YES; break; case NO_OPTION: resource = RESOURCE_SILENT_DEFAULT_NO; break; case CANCEL_OPTION: resource = RESOURCE_SILENT_DEFAULT_CANCEL; break; default: resource = StringUtils.EMPTY_STRING; break; } final String option = StringUtils.format(ResourceUtils.getString(UiUtils.class, resource)); System.err.println(message); System.err.println(option); LogManager.log(message); LogManager.log(option); return silentDefault; } // never get this line... return silentDefault; }