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
}
});
}
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);
}
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);
}
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);
}
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();
}
}
});
}
Aggregations