Search in sources :

Example 16 with NodeSettings

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

the class MissingNodeDialog method onClose.

/**
 * {@inheritDoc}
 */
@Override
public void onClose() {
    super.onClose();
    m_settings = null;
    m_tree.setModel(new DefaultTreeModel(new NodeSettings("ignored")));
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 17 with NodeSettings

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

the class MissingNodeModel method loadValidatedSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_settings = new NodeSettings("copy");
    settings.copyTo(m_settings);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings)

Example 18 with NodeSettings

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

the class ConfigEditJTree method main.

/**
 * Public testing method that displays a simple tree with no flow
 * variable stack, though.
 * @param args command line args, ignored here.
 */
public static void main(final String[] args) {
    NodeSettings settings = new NodeSettings("Demo");
    settings.addString("String_Demo", "This is a demo string");
    settings.addInt("Int_Demo", 32);
    settings.addDoubleArray("DoubleArray_Demo", new double[] { 3.2, 97.4 });
    NodeSettingsWO sub = settings.addNodeSettings("SubElement_Demo");
    sub.addString("String_Demo", "Yet another string");
    sub.addString("String_Demo2", "One more");
    JFrame frame = new JFrame("Tree View Demo");
    Container content = frame.getContentPane();
    ConfigEditTreeModel treeModel = ConfigEditTreeModel.create(settings);
    ConfigEditJTree tree = new ConfigEditJTree(treeModel);
    JPanel p = new JPanel(new BorderLayout());
    p.add(new JScrollPane(tree), BorderLayout.CENTER);
    content.add(p);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) NodeSettings(org.knime.core.node.NodeSettings) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) JFrame(javax.swing.JFrame)

Example 19 with NodeSettings

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

the class PMMLPreprocPortObjectSpec method saveTo.

/**
 * @param out zipped stream to write the entries to
 * @throws IOException if something goes wrong
 */
public void saveTo(final PortObjectSpecZipOutputStream out) throws IOException {
    NodeSettings settings = new NodeSettings(COLUMN_NAMES_KEY);
    settings.addStringArray(COLUMNS_KEY, m_columnNames.toArray(new String[m_columnNames.size()]));
    settings.saveToXML(out);
    out.close();
}
Also used : NodeSettings(org.knime.core.node.NodeSettings)

Example 20 with NodeSettings

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

the class NodeExecutionJobManagerPool method merge.

/**
 * Get the common settings for a set of job managers.
 * Used from {@link WorkflowManager#getCommonSettings(org.knime.core.node.workflow.NodeID...)}.
 * @param jobManagers ...
 * @return ...
 * @since 2.7
 */
public static NodeContainerSettings merge(final NodeExecutionJobManager[] jobManagers) {
    String factoryID = null;
    NodeSettings mgrSettings = null;
    boolean isFirst = true;
    for (NodeExecutionJobManager jobManager : jobManagers) {
        String curFactoryID;
        NodeSettings curMgrSettings;
        if (jobManager == null) {
            curFactoryID = null;
            curMgrSettings = null;
        } else {
            curFactoryID = jobManager.getID();
            NodeSettings temp = new NodeSettings(CFG_JOB_MANAGER_SETTINGS);
            jobManager.save(temp);
            curMgrSettings = temp;
        }
        if (isFirst) {
            isFirst = false;
            factoryID = curFactoryID;
            mgrSettings = curMgrSettings;
        } else if (ConvenienceMethods.areEqual(factoryID, curFactoryID)) {
            if (!ConvenienceMethods.areEqual(mgrSettings, curMgrSettings)) {
                mgrSettings = null;
            }
        } else {
            // different job managers
            // unassigned
            curFactoryID = null;
        }
    }
    if (factoryID == null) {
        return null;
    }
    NodeExecutionJobManagerFactory jobManagerFactory = getJobManagerFactory(factoryID);
    assert jobManagerFactory != null : "Factory ID " + factoryID + " unknown although job manager present";
    NodeExecutionJobManager instance = jobManagerFactory.getInstance();
    if (mgrSettings != null) {
        try {
            instance.load(mgrSettings);
        } catch (InvalidSettingsException e) {
            LOGGER.error("Settings could not be applied to job manager although " + "they retrieved from another identical instance.", e);
        }
    }
    NodeContainerSettings result = new NodeContainerSettings();
    result.setJobManager(instance);
    return result;
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeContainerSettings(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings) NodeExecutionJobManagerFactory(org.knime.core.node.workflow.NodeExecutionJobManagerFactory) ThreadNodeExecutionJobManagerFactory(org.knime.core.node.exec.ThreadNodeExecutionJobManagerFactory) NodeExecutionJobManager(org.knime.core.node.workflow.NodeExecutionJobManager)

Aggregations

NodeSettings (org.knime.core.node.NodeSettings)156 File (java.io.File)58 FileOutputStream (java.io.FileOutputStream)57 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)37 GZIPOutputStream (java.util.zip.GZIPOutputStream)27 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)17 Test (org.junit.Test)16 NodeSettingsWO (org.knime.core.node.NodeSettingsWO)16 DefaultHiLiteMapper (org.knime.core.node.property.hilite.DefaultHiLiteMapper)16 IOException (java.io.IOException)14 OutputStream (java.io.OutputStream)12 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)11 BufferedOutputStream (java.io.BufferedOutputStream)9 Map (java.util.Map)8 RowKey (org.knime.core.data.RowKey)8 Config (org.knime.core.node.config.Config)8 LinkedHashMap (java.util.LinkedHashMap)7 DataTableSpec (org.knime.core.data.DataTableSpec)7 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)6 ArrayList (java.util.ArrayList)5