Search in sources :

Example 21 with MetaPortInfo

use of org.knime.core.node.port.MetaPortInfo in project knime-core by knime.

the class ConfigureMetaNodePortsPage method populateSelectionlistFromInfolist.

private void populateSelectionlistFromInfolist(final List selList, final java.util.List<MetaPortInfo> infoList, final String namePrefix) {
    selList.removeAll();
    for (int i = m_offset; i < infoList.size(); i++) {
        MetaPortInfo info = infoList.get(i);
        String listEntry = namePrefix + i + " (" + info.getType().getName() + ")";
        selList.add(listEntry);
    }
}
Also used : MetaPortInfo(org.knime.core.node.port.MetaPortInfo)

Example 22 with MetaPortInfo

use of org.knime.core.node.port.MetaPortInfo in project knime-core by knime.

the class ReconfigureMetaNodeWizard method performFinish.

/**
 * {@inheritDoc}
 */
@Override
public boolean performFinish() {
    NodeContainer node = m_metaNode != null ? m_metaNode : m_subNode;
    List<MetaPortInfo> inPorts = m_addPage.getInPorts();
    List<MetaPortInfo> outPorts = m_addPage.getOutPorts();
    String name = m_addPage.getMetaNodeName();
    // fix the indicies
    for (int i = 0; i < inPorts.size(); i++) {
        m_addPage.replaceInPortAtIndex(i, MetaPortInfo.builder(inPorts.get(i)).setNewIndex(i).build());
    }
    for (int i = 0; i < outPorts.size(); i++) {
        m_addPage.replaceOutPortAtIndex(i, MetaPortInfo.builder(outPorts.get(i)).setNewIndex(i).build());
    }
    inPorts = m_addPage.getInPorts();
    outPorts = m_addPage.getOutPorts();
    // determine what has changed
    boolean inPortChanges = node.getNrInPorts() != inPorts.size();
    for (MetaPortInfo inInfo : inPorts) {
        // new port types would create a new info object - which would have an unspecified old index -> change
        inPortChanges |= inInfo.getOldIndex() != inInfo.getNewIndex();
    }
    boolean outPortChanges = node.getNrOutPorts() != outPorts.size();
    for (MetaPortInfo outInfo : outPorts) {
        // new port types would create a new info object - which would have an unspecified old index -> change
        outPortChanges |= outInfo.getOldIndex() != outInfo.getNewIndex();
    }
    boolean nameChange = !node.getName().equals(name);
    StringBuilder infoStr = new StringBuilder();
    if (inPortChanges) {
        infoStr.append("the input ports - ");
    }
    if (outPortChanges) {
        infoStr.append("the output ports - ");
    }
    if (nameChange) {
        infoStr.append("the name - ");
    }
    if (infoStr.length() == 0) {
        LOGGER.info("No changes made in the configuration wizard. Nothing to do.");
        return true;
    }
    infoStr.insert(0, "Changing - ");
    infoStr.append("of MetaNode " + node.getID());
    LOGGER.info(infoStr);
    ReconfigureMetaNodeCommand reconfCmd = new ReconfigureMetaNodeCommand(node.getParent(), node.getID());
    if (nameChange) {
        reconfCmd.setNewName(name);
    }
    if (inPortChanges) {
        reconfCmd.setNewInPorts(inPorts);
    }
    if (outPortChanges) {
        reconfCmd.setNewOutPorts(outPorts);
    }
    m_viewer.getEditDomain().getCommandStack().execute(reconfCmd);
    return true;
}
Also used : NodeContainer(org.knime.core.node.workflow.NodeContainer) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) MetaPortInfo(org.knime.core.node.port.MetaPortInfo) ReconfigureMetaNodeCommand(org.knime.workbench.editor2.commands.ReconfigureMetaNodeCommand)

Aggregations

MetaPortInfo (org.knime.core.node.port.MetaPortInfo)22 PortType (org.knime.core.node.port.PortType)9 ArrayList (java.util.ArrayList)8 List (org.eclipse.swt.widgets.List)3 Test (org.junit.Test)3 NodeContainer (org.knime.core.node.workflow.NodeContainer)2 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)2 Pair (org.knime.core.util.Pair)2 ReconfigureMetaNodeCommand (org.knime.workbench.editor2.commands.ReconfigureMetaNodeCommand)2 Point (org.eclipse.draw2d.geometry.Point)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 PaintListener (org.eclipse.swt.events.PaintListener)1 GC (org.eclipse.swt.graphics.GC)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)1