Search in sources :

Example 1 with WorkflowInPortFigure

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

the class WorkflowInPortEditPart method createFigure.

/**
 * Creates {@link WorkflowInPortFigure}, sets the tooltip and adds a
 * {@link MouseListener} to the figure in order to detect if the figure was
 * clicked and a context menu entry should be provided to open the port
 * view.
 *
 * @see WorkflowContextMenuProvider#buildContextMenu(
 * org.eclipse.jface.action.IMenuManager)
 * @see WorkflowInPortFigure
 *
 * {@inheritDoc}
 */
@Override
protected IFigure createFigure() {
    NodeOutPortUI port = getManager().getInPort(getIndex()).getUnderlyingPort();
    String tooltip = getTooltipText(PORT_NAME + ": " + getIndex(), port);
    WorkflowInPortFigure f = new WorkflowInPortFigure(getType(), getManager().getNrInPorts(), getIndex(), tooltip);
    f.addMouseListener(new MouseListener() {

        @Override
        public void mouseDoubleClicked(final MouseEvent me) {
        }

        /**
         * Set the selection state of the figure to true. This is
         * evaluated in the context menu. If it is selected a context menu
         * entry is provided to open the port view.
         *
         * @see WorkflowContextMenuProvider#buildContextMenu(
         *  org.eclipse.jface.action.IMenuManager)
         *
         * {@inheritDoc}
         */
        @Override
        public void mousePressed(final MouseEvent me) {
            setSelected(true);
        }

        /**
         * Set the selection state of the figure to true. This is
         * evaluated in the context menu. If it is selected a context menu
         * entry is provided to open the port view.
         *
         * @see WorkflowContextMenuProvider#buildContextMenu(
         *  org.eclipse.jface.action.IMenuManager)
         *
         * {@inheritDoc}
         */
        @Override
        public void mouseReleased(final MouseEvent me) {
            setSelected(false);
        }
    });
    return f;
}
Also used : WorkflowInPortFigure(org.knime.workbench.editor2.figures.WorkflowInPortFigure) NodeOutPortUI(org.knime.core.ui.node.workflow.NodeOutPortUI) MouseListener(org.eclipse.draw2d.MouseListener) MouseEvent(org.eclipse.draw2d.MouseEvent)

Aggregations

MouseEvent (org.eclipse.draw2d.MouseEvent)1 MouseListener (org.eclipse.draw2d.MouseListener)1 NodeOutPortUI (org.knime.core.ui.node.workflow.NodeOutPortUI)1 WorkflowInPortFigure (org.knime.workbench.editor2.figures.WorkflowInPortFigure)1