Search in sources :

Example 6 with DropPaneConfig

use of org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig in project knime-core by knime.

the class ManualSelectionConfiguration method saveSettingsTo.

@Override
public void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    settings.addInt("numberOfPanels", m_panelList.size());
    List<DropPaneConfig> values = Arrays.asList(m_panelList.values().toArray(new DropPaneConfig[m_panelList.size()]));
    Collections.sort(values);
    for (int i = 0; i < values.size(); i++) {
        DropPaneConfig dpc = values.get(i);
        PaneConfigurationDialog p = dpc.getDialog();
        NodeSettings n = new NodeSettings("dialogSettings_" + i);
        p.saveSettingsTo(n);
        settings.addNodeSettings(n);
        settings.addString("panelIndex_" + i, dpc.getSelectionAsString());
    // settings.addInt("panelIndex" + i, p.getIndex());
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) DropPaneConfig(org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig)

Example 7 with DropPaneConfig

use of org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig in project knime-core by knime.

the class ManualSelectionConfiguration method loadSettingsFrom.

@Override
public void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    List<ArrayList<String>> data = new ArrayList<ArrayList<String>>();
    int size = 0;
    try {
        size = settings.getInt("numberOfPanels");
    } catch (InvalidSettingsException e1) {
    // TODO Auto-generated catch block
    }
    List<String> inputList = new ArrayList<String>();
    if (m_filter != null) {
        for (DataColumnSpec s : specs[0]) {
            if (m_filter.include(s)) {
                inputList.add(s.getName());
            }
        }
    } else {
        inputList.addAll(Arrays.asList(specs[0].getColumnNames()));
    }
    for (int i = 0; i < size; i++) {
        try {
            data.add(new ArrayList<String>(Arrays.asList(settings.getString("panelIndex_" + i).split("\n"))));
        } catch (InvalidSettingsException e) {
        // TODO Auto-generated catch block
        }
    }
    for (int i = 0; i < data.size(); i++) {
        ArrayList<String> list = data.get(i);
        for (int j = 0; j < list.size(); j++) {
            String string = list.get(j);
            if (!inputList.remove(string)) {
                // append one space (column names never end with whitespace --> unique char)
                string += " ";
                list.set(j, string);
            }
        }
        data.set(i, list);
    }
    for (int i = 0; i < data.size(); i++) {
        PaneConfigurationDialog dp = m_fac.getNewInstance();
        NodeSettingsRO n;
        try {
            n = settings.getNodeSettings("dialogSettings_" + i);
            dp.loadSettingsFrom(n, specs);
        } catch (InvalidSettingsException e) {
        // TODO Auto-generated catch block
        }
        DropPaneConfig dpc = new DropPaneConfig();
        dpc.getSelection().addAll(data.get(i));
        dpc.setDialog(dp);
        dpc.setPosition(i);
        m_panelList.put(dpc.getPosition(), dpc);
    }
    for (int i = 0; i < inputList.size(); i++) {
        m_inputListModel.addElement(inputList.get(i));
    }
    m_index = m_panelList.size();
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ArrayList(java.util.ArrayList) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) DropPaneConfig(org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig)

Example 8 with DropPaneConfig

use of org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig in project knime-core by knime.

the class TypeSelectionConfiguration method drop.

/**
 * {@inheritDoc}
 */
@Override
public int drop(final String s) {
    PaneConfigurationDialog dp = m_fac.getNewInstance();
    DropPaneConfig dpc = new DropPaneConfig();
    dpc.setPosition(m_index++);
    dpc.getSelection().add(s);
    dpc.setDialog(dp);
    m_panelList.put(dpc.getPosition(), dpc);
    return m_index - 1;
}
Also used : DropPaneConfig(org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig)

Example 9 with DropPaneConfig

use of org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig in project knime-core by knime.

the class TypeSelectionConfiguration method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
public void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    if (m_filter != null) {
        if (m_filter.include(new DataColumnSpecCreator("dummy", StringCell.TYPE).createSpec())) {
            m_inputListModel.addElement("StringCell");
        } else if (m_filter.include(new DataColumnSpecCreator("dummy", IntCell.TYPE).createSpec())) {
            m_inputListModel.addElement("IntCell");
        } else if (m_filter.include(new DataColumnSpecCreator("dummy", DoubleCell.TYPE).createSpec())) {
            m_inputListModel.addElement("DoubleCell");
        } else if (m_filter.include(new DataColumnSpecCreator("dummy", LongCell.TYPE).createSpec())) {
            m_inputListModel.addElement("LongCell");
        } else if (m_filter.include(new DataColumnSpecCreator("dummy", DateAndTimeCell.TYPE).createSpec())) {
            m_inputListModel.addElement("DateAndTimeCell");
        } else if (m_filter.include(new DataColumnSpecCreator("dummy", XMLCell.TYPE).createSpec())) {
            m_inputListModel.addElement("XMLCell");
        } else if (m_filter.include(new DataColumnSpecCreator("dummy", PMMLCell.TYPE).createSpec())) {
            m_inputListModel.addElement("PMMLCell");
        }
    } else {
        m_inputListModel.addElement("StringCell");
        m_inputListModel.addElement("IntCell");
        m_inputListModel.addElement("DoubleCell");
        m_inputListModel.addElement("LongCell");
        m_inputListModel.addElement("DateAndTimeCell");
        m_inputListModel.addElement("XMLCell");
        m_inputListModel.addElement("PMMLCell");
    }
    int size = 0;
    try {
        size = settings.getInt("numberOfPanels");
    } catch (InvalidSettingsException e1) {
    // TODO Auto-generated catch block
    }
    List<String> data = new ArrayList<String>();
    for (int i = 0; i < size; i++) {
        try {
            data.add(settings.getString("panelIndex_" + i));
            m_inputListModel.removeElement(data.get(i));
        } catch (InvalidSettingsException e) {
        // TODO Auto-generated catch block
        }
    }
    for (int i = 0; i < data.size(); i++) {
        PaneConfigurationDialog dp = m_fac.getNewInstance();
        NodeSettingsRO n;
        try {
            n = settings.getNodeSettings("dialogSettings_" + i);
            dp.loadSettingsFrom(n, specs);
        } catch (InvalidSettingsException e) {
        // TODO Auto-generated catch block
        }
        DropPaneConfig dpc = new DropPaneConfig();
        dpc.getSelection().add(data.get(i));
        dpc.setDialog(dp);
        dpc.setPosition(i);
        m_panelList.put(dpc.getPosition(), dpc);
    }
    m_index = m_panelList.size();
}
Also used : DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ArrayList(java.util.ArrayList) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) DropPaneConfig(org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig)

Example 10 with DropPaneConfig

use of org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig in project knime-core by knime.

the class TypeSelectionConfiguration method configure.

@Override
public List<Pair<String, PaneConfigurationDialog>> configure(final DataTableSpec spec) {
    List<Pair<String, PaneConfigurationDialog>> r = new ArrayList<Pair<String, PaneConfigurationDialog>>();
    for (DropPaneConfig dpc : m_panelList.values()) {
        String type = dpc.getSelection().get(0);
        DataType t = StringCell.TYPE;
        if (type.equals("IntCell")) {
            t = IntCell.TYPE;
        } else if (type.equals("DoubleCell")) {
            t = DoubleCell.TYPE;
        } else if (type.equals("LongCell")) {
            t = LongCell.TYPE;
        } else if (type.equals("DateAndTimeCell")) {
            t = DateAndTimeCell.TYPE;
        } else if (type.equals("XMLCell")) {
            t = XMLCell.TYPE;
        } else if (type.equals("PMMLCell")) {
            t = PMMLCell.TYPE;
        }
        for (DataColumnSpec dcs : spec) {
            if (dcs.getType().equals(t)) {
                r.add(new Pair<String, PaneConfigurationDialog>(dcs.getName(), dpc.getDialog()));
            }
        }
    }
    return r;
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) ArrayList(java.util.ArrayList) DataType(org.knime.core.data.DataType) DropPaneConfig(org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig) Pair(org.knime.core.util.Pair)

Aggregations

DropPaneConfig (org.knime.base.node.preproc.draganddroppanel.droppanes.DropPaneConfig)13 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)6 NodeSettings (org.knime.core.node.NodeSettings)4 ArrayList (java.util.ArrayList)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)1 DataType (org.knime.core.data.DataType)1 Pair (org.knime.core.util.Pair)1