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);
}
}
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;
}
Aggregations