/** * Prints a message to the console with a new line. * * @param message the message to print */ protected void println(String message) { console.println(message); }
/** * Prompts for a value from a set of values. * * @param prompt the prompt to display * @param values the valid values * @return the user input value; if the user input is empty (return key pressed) return defaultValue */ public String prompt(String prompt, String[] values) { return prompt(prompt, values, ""); }
public void printMessageBox(String title, String message) { int termWidth = 80; boolean wrapLineFull = true; if (consoleReader != null) { Terminal terminal = consoleReader.getTerminal(); termWidth = terminal.getWidth(); } if (title != null && title.length() > termWidth) { title = WordUtil.wordWrap(title, termWidth, wrapLineFull); } if (message != null && message.length() > termWidth) { message = WordUtil.wordWrap(message, termWidth, wrapLineFull); } int len = title != null ? Math.max(title.length(), message.length()) : message.length(); int width = Math.min(termWidth, len); print('-', width); println(); if (title != null) { println(title); println(); } println(message); print('-', width); println(); }
protected void printHeadLine(InstallData installData, Console console) { final String headline = getI18nStringForClass("headline", installData); if (headline != null) { console.println(); console.printFilledLine('\u2500'); console.println(headline); console.printFilledLine('\u2500'); console.println(); } }
/** * Displays a prompt and waits for input. * * @param prompt the prompt to display * @param defaultValue the default value to use, if no input is entered * @return the user input value; if the user input is empty (return key pressed) return defaultValue */ public String prompt(String prompt, String defaultValue) { String result; try { println(prompt); result = readLine(); if (result != null && result.isEmpty()) { result = defaultValue; } } catch (IOException e) { result = null; logger.log(Level.WARNING, e.getMessage(), e); } return result; }
default: Iterator<String> iterator = displayNames.keySet().iterator(); console.println("Select your language"); int i = 0; while (iterator.hasNext()) console.println(i + " [" + (i == 0 ? "x" : " ") + "] " + iterator.next()); i++; int numberOfUniqueLanguage = console.prompt(installData.getMessages().get("ConsoleInstaller.inputSelection"), 0, displayNames.keySet().size() - 1, 0, 0); String[] keys = displayNames.keySet().toArray(new String[0]); propagateLocale(keys[numberOfUniqueLanguage]); console.println(uie.getMessage()); console.println("[ Console installation ABORTED by the user! ]"); housekeeper.shutDown(1);
strPath = console.promptLocation("Select JDK path [" + defaultValue + "] ", defaultValue); if (strPath == null) String strIn = console.prompt(errorMessage, (String)null); if (strIn == null) console.println(messages.get("PathInputPanel.notValid"));
try passwd = readPasswordDefaultInput(defaultValue, "%s\n", prompt); return new String(passwd); StringBuilder stringBuilder = new StringBuilder(); println(prompt); boolean submitted = false; try case '\n': case '\r': println(""); result = stringBuilder.toString(); submitted = true; if (stringBuilder.length() > 0) print(backspace); stringBuilder.setLength(stringBuilder.length() - 1); print(echoCharacter); stringBuilder.append((char) ch);
filePath = console.promptLocation("Select the installation script (path must be absolute)[" + file.getAbsolutePath() + "]", file.getAbsolutePath()); console.println("Path of the installation script must be absolute"); promptRerunPanel(installData, console);
public void printMultiLine(String text, boolean wrap, boolean paging) throws IOException { if (wrap) { int width = 80; boolean wrapLineFull = true; if (consoleReader != null) { Terminal terminal = consoleReader.getTerminal(); width = terminal.getWidth(); wrapLineFull = terminal.hasWeirdWrap(); } text = WordUtil.wordWrap(text, width, wrapLineFull); } if (paging) { paging(text); } else { println(text); } }
String no = messages.get("ConsolePrompt.no"); console.printMessageBox(title, message); if (options == Options.OK_CANCEL) String selected = console.prompt(okCancelPrompt, new String[]{ok, cancel}, defaultValue); if (ok.equals(selected)) String selected = console.prompt(yesNoCancelPrompt, new String[]{yes, no, cancel}, defaultValue); if (yes.equals(selected)) String selected = console.prompt(yesNoPrompt, new String[]{yes, no}, defaultValue); if (yes.equals(selected))
/** * Prints a message to the console without a new line. * * @param message the message to print */ protected void print(String message) { console.print(message); }
/** * Constructs a <tt>Console</tt> with <tt>System.in</tt> and <tt>System.out</tt> as the I/O streams. */ public Console(InstallData installData, ConsolePrefs prefs) { this.installData = installData; Log.setOutput(new PrintStream(new OutputStream() { @Override public void write(int b) throws IOException { } })); if (prefs.enableConsoleReader) { initConsoleReader(); } if (consoleReader == null) { console = System.console(); } }
String path = console.promptLocation(installData.getMessages().get("TargetPanel.info") + " [" + defaultPath + "] ", defaultPath); if (path != null) console.println(getIncompatibleInstallationMsg(installData)); continue; } else if (!PathInputBase.isWritable(normalizedPath)) console.println(installData.getMessages().get("UserPathPanel.notwritable")); continue; } else if (!normalizedPath.isEmpty()) console.println(installData.getMessages().get("PathInputPanel.isfile")); continue; } else if (pathFile.exists()) console.println(installData.getMessages().get("TargetPanel.syntax.error")); continue;
/** * Prints a message to the console. * * @param message the message to print */ @Override public void print(String message) { super.print(message); output.add(message); }
/** * Prompts to re-run the panel or quit. * <p/> * This displays a prompt to redisplay the panel or quit. On redisplay, it invokes * {@link #run(InstallData, Console)}. * * @param installData the installation date * @param console the console to use * @return {@code true} to re-display, {@code false} to quit. If redisplaying the panel, the result of * {@link #run(InstallData, Console)} is returned */ protected boolean promptRerunPanel(InstallData installData, Console console) { boolean result; final Messages messages = installData.getMessages(); String prompt = messages.get("ConsoleInstaller.redisplayQuit"); console.println(); int value = console.prompt(prompt, 1, 2, 2); switch (value) { case 2: throw new UserInterruptException(messages.get("ConsoleInstaller.aborted.PressedQuit")); default: result = run(installData, console); break; } return result; }
@Override public void emitNotification(String message) { console.println(message); } };