Search in sources :

Example 1 with MouseMotionListener

use of org.eclipse.draw2d.MouseMotionListener in project tdi-studio-se by Talend.

the class ToolBarButtonImageFigure method initlistener.

/**
     * DOC Administrator Comment method "initlistener".
     */
protected void initlistener() {
    listener = new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent me) {
        }

        @Override
        public void mouseHover(MouseEvent me) {
            addLineBorder();
            setHoverColor();
        }

        @Override
        public void mouseExited(MouseEvent me) {
            if (Clickable.STYLE_TOGGLE == getStyle()) {
                if (!isSelected()) {
                    removeLineBorder();
                    setBackgroundColor(getContainerBgColor(ToolBarButtonImageFigure.this));
                }
            } else {
                removeLineBorder();
                setBackgroundColor(getContainerBgColor(ToolBarButtonImageFigure.this));
            }
        }

        @Override
        public void mouseEntered(MouseEvent me) {
        }

        @Override
        public void mouseDragged(MouseEvent me) {
        }
    };
    this.addMouseMotionListener(listener);
    this.addMouseListener(new MouseListener() {

        @Override
        public void mousePressed(MouseEvent me) {
            toolBarButtonPressed(me);
        }

        @Override
        public void mouseReleased(MouseEvent me) {
        // TODO Auto-generated method stub
        }

        @Override
        public void mouseDoubleClicked(MouseEvent me) {
        // TODO Auto-generated method stub
        }
    });
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) MouseListener(org.eclipse.draw2d.MouseListener) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener)

Example 2 with MouseMotionListener

use of org.eclipse.draw2d.MouseMotionListener in project cubrid-manager by CUBRID.

the class RelationshipPart method addHoverListener.

/**
	 * Add hovering listener for the figure
	 */
protected void addHoverListener() {
    final IFigure figure = this.getFigure();
    hoverListener = new MouseMotionListener() {

        public void mouseEntered(MouseEvent me) {
            setHoverState(true);
            setRelationLinesFocus(true);
        }

        public void mouseExited(MouseEvent me) {
            setHoverState(false);
            setRelationLinesFocus(false);
            setSelectedTableColor();
        }

        public void mouseHover(MouseEvent me) {
        }

        public void mouseDragged(MouseEvent me) {
        }

        public void mouseMoved(MouseEvent me) {
        }
    };
    figure.addMouseMotionListener(hoverListener);
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) IFigure(org.eclipse.draw2d.IFigure)

Example 3 with MouseMotionListener

use of org.eclipse.draw2d.MouseMotionListener in project cubrid-manager by CUBRID.

the class TablePart method addHoverListener.

/**
	 * Add hovering listener for the figure
	 */
protected void addHoverListener() {
    final TablePart tablePart = this;
    final IFigure figure = this.getFigure();
    hoverListener = new MouseMotionListener() {

        public void mouseEntered(MouseEvent me) {
            if (hasChildPartSelected(tablePart) || tablePart.isDisableState()) {
                return;
            }
            setHoverState(true);
            setRelationLinesFocus(true);
            setRelationLinesSyncColor(false);
            figure.revalidate();
        }

        public void mouseExited(MouseEvent me) {
            if (hasChildPartSelected(tablePart) || tablePart.isDisableState()) {
                return;
            }
            setHoverState(false);
            setRelationLinesFocus(false);
            setRelationLinesSyncColor(true);
            figure.revalidate();
        }

        public void mouseHover(MouseEvent me) {
        }

        public void mouseDragged(MouseEvent me) {
        }

        public void mouseMoved(MouseEvent me) {
        }
    };
    figure.addMouseMotionListener(hoverListener);
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) IFigure(org.eclipse.draw2d.IFigure)

Example 4 with MouseMotionListener

use of org.eclipse.draw2d.MouseMotionListener in project tdi-studio-se by Talend.

the class BusinessItemShapeEditPart method refreshVisuals.

@Override
public void refreshVisuals() {
    super.refreshVisuals();
    NodeFigure nodeFigure = getNodeFigure();
    for (Object obj : nodeFigure.getChildren()) {
        if (obj instanceof BusinessItemShapeFigure) {
            BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) obj;
            for (Object figure : shapFigure.getChildren()) {
                if (figure instanceof BusinessItemNameFigure) {
                    BusinessItemNameFigure nameFigure = (BusinessItemNameFigure) figure;
                    nameFigure.addMouseMotionListener(new MouseMotionListener() {

                        @Override
                        public void mouseMoved(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseHover(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseExited(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseEntered(MouseEvent me) {
                            elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, editPart);
                        }

                        @Override
                        public void mouseDragged(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }
                    });
                    EObject object = ((Node) getModel()).getElement();
                    if (object instanceof BusinessItem) {
                        BusinessItem item = (BusinessItem) object;
                        String hAlignment = item.getHAlignment();
                        if (hAlignment == null) {
                            hAlignment = BusinessAlignment.LEFT.toString();
                        }
                        String vAlignment = item.getVAlignment();
                        if (vAlignment == null) {
                            vAlignment = BusinessAlignment.TOP.toString();
                        }
                        if (BusinessAlignment.HCENTRE.toString().equals(hAlignment)) {
                            if (BusinessAlignment.TOP.toString().equals(vAlignment)) {
                                nameFigure.setAlignment(PositionConstants.TOP);
                            } else if (BusinessAlignment.BOTTOM.toString().equals(vAlignment)) {
                                nameFigure.setAlignment(PositionConstants.BOTTOM);
                            } else {
                                nameFigure.setAlignment(PositionConstants.CENTER);
                            }
                        } else if (BusinessAlignment.VCENTRE.toString().equals(vAlignment)) {
                            if (BusinessAlignment.LEFT.toString().equals(hAlignment)) {
                                nameFigure.setAlignment(PositionConstants.LEFT);
                            } else if (BusinessAlignment.RIGHT.toString().equals(hAlignment)) {
                                nameFigure.setAlignment(PositionConstants.RIGHT);
                            } else {
                                nameFigure.setAlignment(PositionConstants.CENTER);
                            }
                        } else {
                            nameFigure.setAlignment(getPosition(hAlignment, BusinessAlignment.HORIZONTAL, item) | getPosition(vAlignment, BusinessAlignment.VERTICAL, item));
                        }
                    }
                }
            }
        }
    }
    elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, this);
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) NodeFigure(org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure) BusinessItemNameFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemNameFigure) EObject(org.eclipse.emf.ecore.EObject) Node(org.eclipse.gmf.runtime.notation.Node) EObject(org.eclipse.emf.ecore.EObject) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Example 5 with MouseMotionListener

use of org.eclipse.draw2d.MouseMotionListener in project netxms by netxms.

the class DecorationFigure method createResizeHandle.

/**
 * Create resize handle
 */
private void createResizeHandle(int pos) {
    final Figure handle = new Figure();
    add(handle);
    Dimension size = getSize();
    handle.setSize(8, 8);
    switch(pos) {
        case TOP_LEFT:
            handle.setLocation(new Point(-1, -1));
            handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENWSE));
            break;
        case TOP_RIGHT:
            handle.setLocation(new Point(size.width - 7, -1));
            handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENESW));
            break;
        case BOTTOM_LEFT:
            handle.setLocation(new Point(-1, size.height - 7));
            handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENESW));
            break;
        case BOTTOM_RIGHT:
            handle.setLocation(new Point(size.width - 7, size.height - 7));
            handle.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_SIZENWSE));
            break;
    }
    handle.addMouseListener(new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent me) {
            if (resize) {
                resize = false;
                Dimension size = getSize();
                decoration.setSize(size.width, size.height);
            }
        }

        @Override
        public void mousePressed(MouseEvent me) {
            if (me.button == 1) {
                resize = true;
                lastX = me.x;
                lastY = me.y;
                me.consume();
            }
        }

        @Override
        public void mouseDoubleClicked(MouseEvent me) {
        }
    });
    handle.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent me) {
        }

        @Override
        public void mouseHover(MouseEvent me) {
        }

        @Override
        public void mouseExited(MouseEvent me) {
        }

        @Override
        public void mouseEntered(MouseEvent me) {
        }

        @Override
        public void mouseDragged(MouseEvent me) {
            if (resize) {
                Dimension size = getSize();
                int dx = me.x - lastX;
                int dy = me.y - lastY;
                if ((dx < 0) && (size.width <= 40))
                    dx = 0;
                if ((dy < 0) && (size.height <= 20))
                    dy = 0;
                size.width += dx;
                size.height += dy;
                setSize(size);
                Point p = handle.getLocation();
                p.performTranslate(dx, dy);
                handle.setLocation(p);
                lastX = me.x;
                lastY = me.y;
                me.consume();
            }
        }
    });
}
Also used : MouseListener(org.eclipse.draw2d.MouseListener) MouseEvent(org.eclipse.draw2d.MouseEvent) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) Figure(org.eclipse.draw2d.Figure)

Aggregations

MouseEvent (org.eclipse.draw2d.MouseEvent)7 MouseMotionListener (org.eclipse.draw2d.MouseMotionListener)7 MouseListener (org.eclipse.draw2d.MouseListener)4 Figure (org.eclipse.draw2d.Figure)2 IFigure (org.eclipse.draw2d.IFigure)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Point (org.eclipse.draw2d.geometry.Point)2 EObject (org.eclipse.emf.ecore.EObject)1 NodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure)1 Node (org.eclipse.gmf.runtime.notation.Node)1 LinkFigure (org.eclipse.nebula.treemapper.internal.LinkFigure)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 BusinessItemNameFigure (org.talend.designer.business.diagram.custom.figures.BusinessItemNameFigure)1 BusinessItemShapeFigure (org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure)1 BusinessItem (org.talend.designer.business.model.business.BusinessItem)1