use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.
the class DeleteCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
// select the new ones....
if (m_viewer != null && m_viewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
((WorkflowRootEditPart) m_viewer.getRootEditPart().getContents()).setFutureSelection(m_nodeIDs);
m_viewer.deselectAll();
}
WorkflowManager hostWFM = getHostWFM();
if (m_undoPersitor != null) {
hostWFM.paste(m_undoPersitor);
}
for (ConnectionContainer cc : m_connections) {
ConnectionContainer newCC = hostWFM.addConnection(cc.getSource(), cc.getSourcePort(), cc.getDest(), cc.getDestPort());
newCC.setUIInfo(cc.getUIInfo());
}
}
use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.
the class NewBendpointDeleteCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
ConnectionContainer connection = getConnectionContainer();
ConnectionUIInformation uiInfo = getUIInfo(connection);
m_point = uiInfo.getBendpoint(m_index);
uiInfo = ConnectionUIInformation.builder(uiInfo).removeBendpoint(m_index).build();
// issue notification
connection.setUIInfo(uiInfo);
}
use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.
the class PasteFromWorkflowPersistorCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
WorkflowManager manager = m_editor.getWorkflowManager().get();
WorkflowPersistor copyPersistor = m_clipboardObject.getCopyPersistor();
m_pastedContent = manager.paste(copyPersistor);
NodeID[] pastedNodes = m_pastedContent.getNodeIDs();
WorkflowAnnotation[] pastedAnnos = m_pastedContent.getAnnotations();
// fast lookup below
Set<NodeID> newIDs = new HashSet<NodeID>();
List<int[]> insertedElementBounds = new ArrayList<int[]>();
for (NodeID i : pastedNodes) {
NodeContainer nc = manager.getNodeContainer(i);
NodeUIInformation ui = nc.getUIInformation();
int[] bounds = ui.getBounds();
insertedElementBounds.add(bounds);
}
for (WorkflowAnnotation a : pastedAnnos) {
int[] bounds = new int[] { a.getX(), a.getY(), a.getWidth(), a.getHeight() };
insertedElementBounds.add(bounds);
}
int[] moveDist = m_shiftCalculator.calculateShift(insertedElementBounds, manager, m_clipboardObject);
// for redo-operations we need the exact same shift.
m_shiftCalculator = new FixedShiftCalculator(moveDist);
for (NodeID id : pastedNodes) {
newIDs.add(id);
NodeContainer nc = manager.getNodeContainer(id);
NodeUIInformation oldUI = nc.getUIInformation();
NodeUIInformation newUI = NodeUIInformation.builder(oldUI).translate(moveDist).build();
nc.setUIInformation(newUI);
}
for (ConnectionContainer conn : manager.getConnectionContainers()) {
if (newIDs.contains(conn.getDest()) && newIDs.contains(conn.getSource())) {
// get bend points and move them
ConnectionUIInformation oldUI = conn.getUIInfo();
if (oldUI != null) {
ConnectionUIInformation newUI = ConnectionUIInformation.builder(oldUI).translate(moveDist).build();
conn.setUIInfo(newUI);
}
}
}
for (WorkflowAnnotation a : pastedAnnos) {
a.shiftPosition(moveDist[0], moveDist[1]);
}
EditPartViewer partViewer = m_editor.getViewer();
partViewer.deselectAll();
// select the new ones....
if (partViewer.getRootEditPart().getContents() != null && partViewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
WorkflowRootEditPart rootEditPart = (WorkflowRootEditPart) partViewer.getRootEditPart().getContents();
rootEditPart.setFutureSelection(pastedNodes);
rootEditPart.setFutureAnnotationSelection(Arrays.asList(pastedAnnos));
}
}
use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.
the class AutoLayoutCommand method undo.
/**
* {@inheritDoc}
*/
@Override
public void undo() {
Map<NodeID, NodeUIInformation> oldPositions = m_layoutMgr.getOldNodeCoordinates();
Map<ConnectionID, ConnectionUIInformation> oldBendpoints = m_layoutMgr.getOldBendpoints();
// re-position nodes
for (Map.Entry<NodeID, NodeUIInformation> e : oldPositions.entrySet()) {
NodeContainer nc = m_wfm.getNodeContainer(e.getKey());
if (nc == null) {
continue;
}
nc.setUIInformation(e.getValue());
}
// re-create bendpoints
for (Map.Entry<ConnectionID, ConnectionUIInformation> e : oldBendpoints.entrySet()) {
ConnectionContainer cc = m_wfm.getConnection(e.getKey());
if (cc == null) {
continue;
}
cc.setUIInfo(e.getValue());
}
}
use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.
the class SandboxedNodeCreator method setupConnectionProgressEventListeners.
/**
* For each connection in the sandbox add a progress listener that fires an event on the original connection.
*/
private void setupConnectionProgressEventListeners(final NodeContainer origNC, final NodeContainer sandboxNC) {
WorkflowManager origWFM;
WorkflowManager sandboxWFM;
if (origNC instanceof WorkflowManager) {
origWFM = (WorkflowManager) origNC;
sandboxWFM = (WorkflowManager) sandboxNC;
} else if (origNC instanceof SubNodeContainer) {
origWFM = ((SubNodeContainer) origNC).getWorkflowManager();
sandboxWFM = ((SubNodeContainer) sandboxNC).getWorkflowManager();
} else {
return;
}
for (ConnectionContainer cc : origWFM.getConnectionContainers()) {
NodeID sandboxTargetID = sandboxWFM.getID();
if (!cc.getDest().equals(origWFM.getID())) {
// real connection, not a wfm out or through connection
sandboxTargetID = new NodeID(sandboxTargetID, cc.getDest().getIndex());
}
ConnectionContainer sbCC = sandboxWFM.getConnection(new ConnectionID(sandboxTargetID, cc.getDestPort()));
sbCC.addProgressListener(pe -> cc.progressChanged(pe));
}
}
Aggregations