use of org.knime.workbench.editor2.model.WorkflowPortBar in project knime-core by knime.
the class ChangeWorkflowPortBarCommand method execute.
/**
* Sets the new bounds.
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
WorkflowPortBar barModel = (WorkflowPortBar) m_bar.getModel();
NodeUIInformation uiInfo = NodeUIInformation.builder().setNodeLocation(m_newBounds.x, m_newBounds.y, m_newBounds.width, m_newBounds.height).build();
// must set explicitly so that event is fired by container
barModel.setUIInfo(uiInfo);
IFigure fig = m_bar.getFigure();
fig.setBounds(m_newBounds);
fig.getParent().setConstraint(fig, m_newBounds);
m_bar.getParent().refresh();
}
use of org.knime.workbench.editor2.model.WorkflowPortBar in project knime-core by knime.
the class ChangeWorkflowPortBarCommand method undo.
/**
* Sets the old bounds.
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void undo() {
WorkflowPortBar barModel = (WorkflowPortBar) m_bar.getModel();
NodeUIInformation uiInfo = NodeUIInformation.builder().setNodeLocation(m_oldBounds.x, m_oldBounds.y, m_oldBounds.width, m_oldBounds.height).build();
// must set explicitly so that event is fired by container
barModel.setUIInfo(uiInfo);
IFigure fig = m_bar.getFigure();
fig.setBounds(m_oldBounds);
fig.getParent().setConstraint(fig, m_oldBounds);
m_bar.getParent().refresh();
}
use of org.knime.workbench.editor2.model.WorkflowPortBar in project knime-core by knime.
the class AbstractWorkflowPortBarEditPart method getMinMaxXcoordInWorkflow.
/**
* returns the minX coordinate and the maxX coordinate of all nodes, annotations and bendpoints in the flow (taking
* the size of the elements into account). Or Integer.MIN/MAX_value if no elements exist.
* @return new int[] {minX, maxX};
*/
protected int[] getMinMaxXcoordInWorkflow() {
int maxX = Integer.MIN_VALUE;
int minX = Integer.MAX_VALUE;
// find the smallest and the biggest X coordinate in all the UI infos in the flow
WorkflowManagerUI manager = ((WorkflowPortBar) getModel()).getWorkflowManager();
for (NodeContainerUI nc : manager.getNodeContainers()) {
int nodeWidth = NodeContainerFigure.WIDTH;
NodeAnnotation nodeAnno = nc.getNodeAnnotation();
if ((nodeAnno != null) && (nodeAnno.getWidth() > nodeWidth)) {
nodeWidth = nodeAnno.getWidth();
}
NodeUIInformation uiInfo = nc.getUIInformation();
if (uiInfo != null) {
int x = uiInfo.getBounds()[0];
// right border of node
x = x + (nodeWidth / 2);
if (maxX < x) {
maxX = x;
}
// left border of node
x = x - nodeWidth;
if (minX > x) {
minX = x;
}
}
}
for (WorkflowAnnotation anno : manager.getWorkflowAnnotations()) {
int x = anno.getX();
if (minX > x) {
minX = x;
}
x = x + anno.getWidth();
if (maxX < x) {
maxX = x;
}
}
for (ConnectionContainerUI conn : manager.getConnectionContainers()) {
ConnectionUIInformation uiInfo = conn.getUIInfo();
if (uiInfo != null) {
int[][] bendpoints = uiInfo.getAllBendpoints();
if (bendpoints != null) {
for (int[] b : bendpoints) {
if (maxX < b[0]) {
maxX = b[0];
}
if (minX > b[0]) {
minX = b[0];
}
}
}
}
}
return new int[] { minX, maxX };
}
use of org.knime.workbench.editor2.model.WorkflowPortBar in project knime-core by knime.
the class AbstractWorkflowPortBarEditPart method refreshVisuals.
/**
* {@inheritDoc}
*/
@Override
protected void refreshVisuals() {
NodeUIInformation uiInfo = ((WorkflowPortBar) getModel()).getUIInfo();
if (uiInfo != null && !((AbstractWorkflowPortBarFigure) getFigure()).isInitialized()) {
int[] bounds = uiInfo.getBounds();
((AbstractWorkflowPortBarFigure) getFigure()).setBounds(new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]));
}
super.refreshVisuals();
}
use of org.knime.workbench.editor2.model.WorkflowPortBar in project knime-core by knime.
the class WorkflowInPortBarEditPart method getModelChildren.
/**
* {@inheritDoc}
*/
@Override
protected List<NodePortUI> getModelChildren() {
WorkflowManagerUI manager = ((WorkflowPortBar) getModel()).getWorkflowManager();
List<NodePortUI> ports = new ArrayList<NodePortUI>();
for (int i = 0; i < manager.getNrWorkflowIncomingPorts(); i++) {
ports.add(manager.getInPort(i));
}
return ports;
}
Aggregations