Search in sources :

Example 1 with OutputWriter

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();
}
Also used : InputOutput(org.openide.windows.InputOutput) OutputWriter(org.openide.windows.OutputWriter)

Example 2 with OutputWriter

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"));
        }
    });
}
Also used : OutputWriter(org.openide.windows.OutputWriter)

Example 3 with OutputWriter

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);
        }
    });
}
Also used : OutputWriter(org.openide.windows.OutputWriter)

Example 4 with OutputWriter

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);
        }
    });
}
Also used : OutputWriter(org.openide.windows.OutputWriter)

Example 5 with OutputWriter

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);
    }
}
Also used : InputOutput(org.openide.windows.InputOutput) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) OutputWriter(org.openide.windows.OutputWriter) Preferences(java.util.prefs.Preferences) NbPreferences(org.openide.util.NbPreferences) File(java.io.File)

Aggregations

OutputWriter (org.openide.windows.OutputWriter)11 Date (java.util.Date)3 InputOutput (org.openide.windows.InputOutput)3 ArrayList (java.util.ArrayList)2 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 Preferences (java.util.prefs.Preferences)1 Action (javax.swing.Action)1 NbPreferences (org.openide.util.NbPreferences)1 IOContainer (org.openide.windows.IOContainer)1