use of org.openide.windows.OutputWriter in project netbeans-rcp-lite by outersky.
the class SearchDisplayer method prepareOutput.
/**
*/
void prepareOutput() {
String tabName = NbBundle.getMessage(ResultView.class, // NOI18N
"TITLE_SEARCH_RESULTS");
InputOutput searchIO = IOProvider.getDefault().getIO(tabName, false);
ow = searchIO.getOut();
owRef = new WeakReference<OutputWriter>(ow);
searchIO.select();
}
use of org.openide.windows.OutputWriter in project almond by trixon.
the class NbPrint method err.
public void err(String x) {
SwingUtilities.invokeLater(() -> {
try (OutputWriter outputWriter = mInputOutput.getErr()) {
printDate(outputWriter);
outputWriter.println(StringUtils.defaultString(x, "NULL"));
}
});
}
use of org.openide.windows.OutputWriter in project almond by trixon.
the class NbLog method printErr.
private static void printErr(String levelClass, String message) {
SwingUtilities.invokeLater(() -> {
try (OutputWriter outputWriter = sInputOutput.getErr()) {
printDate(outputWriter);
outputWriter.print(levelClass + " ");
outputWriter.println(message);
}
});
}
use of org.openide.windows.OutputWriter in project almond by trixon.
the class NbLog method print.
private static void print(String levelClass, String message) {
SwingUtilities.invokeLater(() -> {
try (OutputWriter outputWriter = sInputOutput.getOut()) {
printDate(outputWriter);
outputWriter.print(levelClass + " ");
outputWriter.println(message);
}
});
}
use of org.openide.windows.OutputWriter in project constellation by constellation-app.
the class StartJupyterNotebookAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
WebServer.start();
final Preferences prefs = NbPreferences.forModule(ApplicationPreferenceKeys.class);
final String dir = prefs.get(ApplicationPreferenceKeys.JUPYTER_NOTEBOOK_DIR, ApplicationPreferenceKeys.JUPYTER_NOTEBOOK_DIR_DEFAULT);
try {
// Start the jupyter-notebook process with its stderr redirected to
// its stdout, and stdout being fed into an InputOutput window.
final InputOutput io = IOProvider.getDefault().getIO(JUPYTER_OUTPUT, false);
io.select();
final List<String> exe = new ArrayList<>();
exe.add(JUPYTER_NOTEBOOK);
final ProcessBuilder pb = new ProcessBuilder(exe).directory(new File(dir)).redirectErrorStream(true);
final Process jupyter = pb.start();
final Thread out = new Thread(() -> {
final InputStream fromProcess = jupyter.getInputStream();
final OutputWriter ow = io.getOut();
ow.format("Starting %s in directory %s ...\n\n", JUPYTER_NOTEBOOK, dir);
final byte[] buf = new byte[1024];
while (!Thread.currentThread().isInterrupted()) {
try {
final int len = fromProcess.read(buf);
if (len == -1) {
break;
}
final String s = new String(buf, 0, len, StandardCharsets.ISO_8859_1);
ow.write(s);
} catch (final IOException ex) {
break;
}
}
});
out.start();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
out.interrupt();
jupyter.destroy();
io.closeInputOutput();
}));
} catch (final IOException ex) {
final String msg = String.format("Failed to start %s: %s", JUPYTER_NOTEBOOK, ex.getMessage());
NotificationDisplayer.getDefault().notify("Jupyter notebook", UserInterfaceIconProvider.WARNING.buildIcon(16, ConstellationColor.DARK_ORANGE.getJavaColor()), msg, null);
}
}
Aggregations