use of org.knime.core.node.workflow.ConnectionUIInformation in project knime-core by knime.
the class NewBendpointCreateCommand method redo.
/**
* {@inheritDoc}
*/
@Override
public void redo() {
ConnectionContainer connection = getConnectionContainer();
ConnectionUIInformation uiInfo = getUIInfo(connection);
Point location = m_location.getCopy();
WorkflowEditor.adaptZoom(m_zoomManager, location, true);
uiInfo = ConnectionUIInformation.builder(uiInfo).addBendpoint(location.x, location.y, m_index).build();
// we need this to fire some update event up
connection.setUIInfo(uiInfo);
}
use of org.knime.core.node.workflow.ConnectionUIInformation in project knime-core by knime.
the class NewBendpointMoveCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() {
ConnectionContainer connection = getConnection();
ConnectionUIInformation uiInfo = connection.getUIInfo();
ConnectionUIInformation.Builder uiInfoBuilder = ConnectionUIInformation.builder(connection.getUIInfo());
int[] p = uiInfo.getBendpoint(m_index);
m_oldLocation = new Point(p[0], p[1]);
Point newLocation = m_newLocation.getCopy();
WorkflowEditor.adaptZoom(m_zoomManager, newLocation, true);
// TODO for every single bendpoint move a new ConnectionUIInformation object needs to be created
uiInfoBuilder.removeBendpoint(m_index);
uiInfoBuilder.addBendpoint(newLocation.x, newLocation.y, m_index);
// issue notification
connection.setUIInfo(uiInfoBuilder.build());
}
use of org.knime.core.node.workflow.ConnectionUIInformation in project knime-core by knime.
the class ConnectionContainerEditPart method refreshVisuals.
/**
* {@inheritDoc}
*/
@Override
protected void refreshVisuals() {
super.refreshVisuals();
LOGGER.debug("refreshing visuals for: " + getModel());
ConnectionUIInformation ei = null;
ei = getModel().getUIInfo();
LOGGER.debug("modelling info: " + ei);
// make flow variable port connections look red.
CurvedPolylineConnection fig = (CurvedPolylineConnection) getFigure();
if (getModel().isFlowVariablePortConnection()) {
fig.setForegroundColor(AbstractPortFigure.getFlowVarPortColor());
}
// update 'curved' settings and line width
EditorUIInformation uiInfo = getCurrentEditorSettings();
fig.setCurved(uiInfo.getHasCurvedConnections());
fig.setLineWidth(uiInfo.getConnectionLineWidth());
// recreate list of bendpoints
ArrayList<AbsoluteBendpoint> constraint = new ArrayList<AbsoluteBendpoint>();
if (ei != null) {
int[][] p = ei.getAllBendpoints();
for (int i = 0; i < p.length; i++) {
AbsoluteBendpoint bp = new AbsoluteBendpoint(p[i][0], p[i][1]);
constraint.add(bp);
}
}
fig.setRoutingConstraint(constraint);
}
use of org.knime.core.node.workflow.ConnectionUIInformation 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.ConnectionUIInformation 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));
}
}
Aggregations