use of org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart in project knime-core by knime.
the class WorkflowMarqueeSelectionTool method calculateNewSelection.
private void calculateNewSelection(final Collection<GraphicalEditPart> newSelections, final Collection<GraphicalEditPart> deselections) {
Rectangle marqueeRect = getMarqueeSelectionRectangle();
for (Iterator<GraphicalEditPart> itr = getAllChildren().iterator(); itr.hasNext(); ) {
GraphicalEditPart child = itr.next();
IFigure figure = child.getFigure();
if (!child.isSelectable() || child.getTargetEditPart(MARQUEE_REQUEST) != child || !isFigureVisible(figure) || !figure.isShowing()) {
continue;
}
if (!(child instanceof NodeContainerEditPart || child instanceof ConnectionContainerEditPart || child instanceof AbstractWorkflowPortBarEditPart || child instanceof AnnotationEditPart)) {
continue;
}
Rectangle r = figure.getBounds().getCopy();
figure.translateToAbsolute(r);
boolean included = false;
if (child instanceof ConnectionEditPart && marqueeRect.intersects(r)) {
Rectangle relMarqueeRect = Rectangle.SINGLETON;
figure.translateToRelative(relMarqueeRect.setBounds(marqueeRect));
included = ((PolylineConnection) figure).getPoints().intersects(relMarqueeRect);
} else if (child instanceof AnnotationEditPart) {
// select WorkflowAnnotations only if they are fully included in the selection
if (figure instanceof WorkflowAnnotationFigure) {
included = marqueeRect.contains(r);
}
} else if (marqueeBehavior == BEHAVIOR_NODES_AND_CONNECTIONS_TOUCHED) {
included = marqueeRect.intersects(r);
} else {
included = marqueeRect.contains(r);
}
if (included) {
if (isToggle()) {
if (wasSelected(child)) {
deselections.add(child);
} else {
newSelections.add(child);
}
} else {
newSelections.add(child);
}
} else if (isToggle()) {
// readded if it was in the selection before
if (wasSelected(child)) {
newSelections.add(child);
} else {
deselections.add(child);
}
}
}
if (marqueeBehavior == BEHAVIOR_NODES_AND_CONNECTIONS_TOUCHED) {
calculateConnections(newSelections, deselections);
}
}
use of org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart in project knime-core by knime.
the class NewWorkflowXYLayoutPolicy method createChangeConstraintCommand.
/**
* Creates command to move / resize <code>NodeContainer</code> components on
* the project's client area.
*
* {@inheritDoc}
*/
@Override
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
// only rectangular constraints are supported
if (!(constraint instanceof Rectangle)) {
return null;
}
Command command = null;
Rectangle rect = ((Rectangle) constraint).getCopy();
if (child.getModel() instanceof NodeContainerUI) {
NodeContainerUI container = (NodeContainerUI) child.getModel();
if (!Wrapper.wraps(container, NodeContainer.class)) {
// not supported for others than ordinary NodeContainers
return null;
}
NodeContainerEditPart nodePart = (NodeContainerEditPart) child;
command = new ChangeNodeBoundsCommand(Wrapper.unwrapNC(container), (NodeContainerFigure) nodePart.getFigure(), rect);
} else if (child instanceof AbstractWorkflowPortBarEditPart) {
command = new ChangeWorkflowPortBarCommand((AbstractWorkflowPortBarEditPart) child, rect);
} else if (child instanceof AnnotationEditPart) {
AnnotationEditPart annoPart = (AnnotationEditPart) child;
// TODO the workflow annotation could know what its WFM is?
WorkflowRootEditPart root = (WorkflowRootEditPart) annoPart.getParent();
WorkflowManagerUI wm = root.getWorkflowManager();
if (!Wrapper.wraps(wm, WorkflowManager.class)) {
// not supported for others than an ordinary workflow manager
return null;
}
command = new ChangeAnnotationBoundsCommand(Wrapper.unwrapWFM(wm), annoPart, rect);
}
return command;
}
use of org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart in project knime-core by knime.
the class WorkflowSelectionDragEditPartsTracker method getEmbracedConnections.
/**
* Returns the connections whose source and target is contained in the argument list.
* @param parts list of selected nodes
* @return the connections whose source and target is contained in the argument list.
*/
public static ConnectionContainerEditPart[] getEmbracedConnections(final List<EditPart> parts) {
// result list
List<ConnectionContainerEditPart> result = new ArrayList<ConnectionContainerEditPart>();
for (EditPart part : parts) {
if (part instanceof NodeContainerEditPart || part instanceof AbstractWorkflowPortBarEditPart) {
EditPart containerPart = part;
ConnectionContainerEditPart[] outPortConnectionParts = getOutportConnections(containerPart);
// selected list, the connections bendpoints must be adapted
for (ConnectionContainerEditPart connectionPart : outPortConnectionParts) {
// get the in-port-node part of the connection and check
AbstractPortEditPart inPortPart = null;
if (connectionPart.getTarget() != null && ((AbstractPortEditPart) connectionPart.getTarget()).isInPort()) {
inPortPart = (AbstractPortEditPart) connectionPart.getTarget();
} else if (connectionPart.getSource() != null) {
inPortPart = (AbstractPortEditPart) connectionPart.getSource();
}
if (inPortPart != null && isPartInList(inPortPart.getParent(), parts)) {
result.add(connectionPart);
}
}
}
}
return result.toArray(new ConnectionContainerEditPart[result.size()]);
}
Aggregations