Search in sources :

Example 1 with WorkflowAnnotationFigure

use of org.knime.workbench.editor2.figures.WorkflowAnnotationFigure 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);
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) WorkflowAnnotationFigure(org.knime.workbench.editor2.figures.WorkflowAnnotationFigure) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 2 with WorkflowAnnotationFigure

use of org.knime.workbench.editor2.figures.WorkflowAnnotationFigure in project knime-core by knime.

the class AnnotationEditPart method getDragTracker.

/**
 * {@inheritDoc}
 * If dragging started on the "move" icon (top left corner) return the normal edit part dragger tool, otherwise
 * return the marquee selection tool.
 */
@Override
public DragTracker getDragTracker(final Request request) {
    Object object = request.getExtendedData().get(WorkflowSelectionTool.DRAG_START_LOCATION);
    IFigure f = getFigure();
    if (object instanceof Point && f instanceof WorkflowAnnotationFigure && getSelected() == SELECTED_NONE) {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite();
        Rectangle iconBounds = ((WorkflowAnnotationFigure) f).getEditIconBounds().getCopy();
        if (!iconBounds.contains((Point) object)) {
            return new WorkflowMarqueeSelectionTool();
        }
    }
    // "normal" edit part dragging
    return new WorkflowSelectionDragEditPartsTracker(this);
}
Also used : WorkflowAnnotationFigure(org.knime.workbench.editor2.figures.WorkflowAnnotationFigure) WorkflowMarqueeSelectionTool(org.knime.workbench.editor2.WorkflowMarqueeSelectionTool) Rectangle(org.eclipse.draw2d.geometry.Rectangle) WorkflowSelectionDragEditPartsTracker(org.knime.workbench.editor2.WorkflowSelectionDragEditPartsTracker) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with WorkflowAnnotationFigure

use of org.knime.workbench.editor2.figures.WorkflowAnnotationFigure in project knime-core by knime.

the class AnnotationEditPart method createFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure createFigure() {
    Annotation anno = getModel();
    NodeAnnotationFigure f = new WorkflowAnnotationFigure(anno);
    if (anno instanceof WorkflowAnnotation) {
        f.setBounds(new Rectangle(anno.getX(), anno.getY(), anno.getWidth(), anno.getHeight()));
    }
    return f;
}
Also used : WorkflowAnnotationFigure(org.knime.workbench.editor2.figures.WorkflowAnnotationFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeAnnotationFigure(org.knime.workbench.editor2.figures.NodeAnnotationFigure) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) Annotation(org.knime.core.node.workflow.Annotation) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Aggregations

Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 WorkflowAnnotationFigure (org.knime.workbench.editor2.figures.WorkflowAnnotationFigure)3 IFigure (org.eclipse.draw2d.IFigure)2 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 Point (org.eclipse.draw2d.geometry.Point)1 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 Annotation (org.knime.core.node.workflow.Annotation)1 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)1 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)1 WorkflowMarqueeSelectionTool (org.knime.workbench.editor2.WorkflowMarqueeSelectionTool)1 WorkflowSelectionDragEditPartsTracker (org.knime.workbench.editor2.WorkflowSelectionDragEditPartsTracker)1 AbstractWorkflowPortBarEditPart (org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart)1 AnnotationEditPart (org.knime.workbench.editor2.editparts.AnnotationEditPart)1 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)1 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)1 NodeAnnotationFigure (org.knime.workbench.editor2.figures.NodeAnnotationFigure)1