Search in sources :

Example 1 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class JoinerJoinAnyTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
    m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
Also used : NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) NodeFactory(org.knime.core.node.NodeFactory) HashMap(java.util.HashMap) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) Node(org.knime.core.node.Node) PortType(org.knime.core.node.port.PortType) Before(org.junit.Before)

Example 2 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor 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);
}
Also used : Frame(java.awt.Frame) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) NodeProgressMonitorView(org.knime.core.node.NodeProgressMonitorView)

Example 3 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class AbstractColumnTableSorterTest method setUp.

/**
 * @throws java.lang.Exception
 */
@SuppressWarnings("rawtypes")
@Before
public void setUp() throws Exception {
    @SuppressWarnings("unchecked") NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
    m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
    DataColumnSpec[] colSpecs = new DataColumnSpec[] { new DataColumnSpecCreator(FEATURE1, DoubleCell.TYPE).createSpec(), new DataColumnSpecCreator(FEATURE2, DoubleCell.TYPE).createSpec(), new DataColumnSpecCreator(STRING_FEATURE, StringCell.TYPE).createSpec(), new DataColumnSpecCreator(CLASS, StringCell.TYPE).createSpec() };
    DataTableSpec spec = new DataTableSpec(colSpecs);
    final BufferedDataContainer container = m_exec.createDataContainer(spec);
    int i = 0;
    container.addRowToTable(creatRow(i++, 1, 8, "A", "AClass8"));
    container.addRowToTable(creatRow(i++, 2, 2, "Z", "ZClass2"));
    container.addRowToTable(creatRow(i++, 3, 5, "B", "BClass5"));
    container.addRowToTable(creatRow(i++, 4, 0, "E", "EClass0"));
    container.addRowToTable(creatRow(i++, 5, 1, "F", "FClass1"));
    container.addRowToTable(creatRow(i++, 6, 7, "G", "GClass7"));
    container.addRowToTable(creatRow(i++, 7, 9, "H", "HClass9"));
    container.addRowToTable(creatRow(i++, 8, 8, null, "Class8"));
    container.close();
    testTable = container.getTable();
    final BufferedDataContainer emptyContainer = m_exec.createDataContainer(spec);
    emptyContainer.close();
    emptyTestTable = emptyContainer.getTable();
    MemoryAlertSystemTest.forceGC();
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) HashMap(java.util.HashMap) Node(org.knime.core.node.Node) NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) DataColumnSpec(org.knime.core.data.DataColumnSpec) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) NodeFactory(org.knime.core.node.NodeFactory) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) PortType(org.knime.core.node.port.PortType) Before(org.junit.Before)

Example 4 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class Enh1536_CancelDuringLoad method testCancelWhileLoad.

@Test
public void testCancelWhileLoad() throws Exception {
    int previousChildCount = WorkflowManager.ROOT.getNodeContainers().size();
    LOAD_NODE_STATE_THREAD_LOCAL.set(LoadNodeState.Default);
    DefaultNodeProgressMonitor progMon = NODE_PROGRESS_THREAD_LOCAL.get();
    try {
        final WorkflowLoadHelper loadHelper = new WorkflowLoadHelper(m_workflowDirectory);
        WorkflowManager.ROOT.load(m_workflowDirectory, new ExecutionMonitor(progMon), loadHelper, true);
        fail("Workflow should not load as it's canceled");
    } catch (CanceledExecutionException e) {
        assertEquals(LoadNodeState.MiddleNodeCanceled, LOAD_NODE_STATE_THREAD_LOCAL.get());
    } finally {
        LOAD_NODE_STATE_THREAD_LOCAL.set(null);
    }
    assertEquals(previousChildCount, WorkflowManager.ROOT.getNodeContainers().size());
}
Also used : CanceledExecutionException(org.knime.core.node.CanceledExecutionException) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) Test(org.junit.Test)

Example 5 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class CovarianceMatrixCalculatorTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    @SuppressWarnings({ "unchecked", "rawtypes" }) NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
    m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
Also used : NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) NodeFactory(org.knime.core.node.NodeFactory) HashMap(java.util.HashMap) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) Node(org.knime.core.node.Node) PortType(org.knime.core.node.port.PortType) Before(org.junit.Before)

Aggregations

DefaultNodeProgressMonitor (org.knime.core.node.DefaultNodeProgressMonitor)10 Before (org.junit.Before)7 HashMap (java.util.HashMap)6 ExecutionContext (org.knime.core.node.ExecutionContext)6 Node (org.knime.core.node.Node)6 NodeFactory (org.knime.core.node.NodeFactory)6 NodeModel (org.knime.core.node.NodeModel)5 PortType (org.knime.core.node.port.PortType)5 VirtualParallelizedChunkPortObjectInNodeFactory (org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory)5 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)4 DataTableSpec (org.knime.core.data.DataTableSpec)2 Frame (java.awt.Frame)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)1 DataTable (org.knime.core.data.DataTable)1 ContainerTable (org.knime.core.data.container.ContainerTable)1 DataTableSorter (org.knime.core.data.sort.DataTableSorter)1 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)1