use of org.knime.core.node.NodeProgressMonitorView in project knime-core by knime.
the class TableNodeView method writeToCSV.
/**
* Called by the JMenu item "Write to CVS", it write the table as shown in
* table view to a CSV file.
*
* @param file the file to write to
*/
private void writeToCSV(final File file) {
// CSV Writer supports ExecutionMonitor. Some table may be big.
DefaultNodeProgressMonitor progMon = new DefaultNodeProgressMonitor();
ExecutionMonitor e = new ExecutionMonitor(progMon);
// Frame of m_tableView (if any)
Frame f = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, m_tableView);
final NodeProgressMonitorView progView = new NodeProgressMonitorView(f, progMon);
// CSV Writer does not support 1-100 progress (unknown row count)
progView.setShowProgress(false);
// Writing is done in a thread (allows repainting of GUI)
final CSVWriterThread t = new CSVWriterThread(file, e);
t.start();
// A thread that waits for t to finish and then disposes the prog view
new Thread(new Runnable() {
@Override
public void run() {
try {
t.join();
} catch (InterruptedException ie) {
// do nothing. Only dispose the view
} finally {
progView.dispose();
}
}
}).start();
progView.pack();
progView.setLocationRelativeTo(m_tableView);
progView.setVisible(true);
}
Aggregations