use of org.eclipse.swt.events.MouseMoveListener in project cubrid-manager by CUBRID.
the class SelectedLoactionComparator method bindListener.
/**
*
* Bind the linsteners
*/
private void bindListener() {
tableCursor.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent event) {
handleMouseUp(event);
}
public void mouseDown(MouseEvent event) {
handleMouseDown(event);
}
public void mouseDoubleClick(MouseEvent event) {
handleMouseDoubleClick(event);
}
});
tableCursor.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
handleMouseMove(event);
}
});
table.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent event) {
handleMouseUp(event);
}
public void mouseDown(MouseEvent event) {
handleMouseDown(event);
}
public void mouseDoubleClick(MouseEvent event) {
handleMouseDoubleClick(event);
}
});
table.addMouseTrackListener(new MouseTrackAdapter() {
public void mouseExit(MouseEvent e) {
Rectangle bound = table.getClientArea();
if (!bound.contains(e.x, e.y)) {
handleMouseExit(e);
}
}
});
table.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent event) {
handleMouseMove(event);
}
});
table.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent event) {
handleKeyReleased(event);
}
public void keyPressed(KeyEvent event) {
handleKeyPressed(event);
}
});
tableCursor.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent event) {
handleKeyReleased(event);
}
public void keyPressed(KeyEvent event) {
handleKeyPressed(event);
if (ctrlPressed) {
if (event.keyCode == SWT.ARROW_DOWN) {
int maxY = getMaxY();
int minX = getMinX();
int maxX = getMaxX();
int y = maxY + 1;
if (maxY > -1 && minX > -1 && maxX > -1 && y < table.getItemCount()) {
tableCursor.setSelection(y, maxX);
for (int x = minX; x <= maxX; x++) {
Point p = new Point(x, y);
addSelectPoint(p, true);
drawSelectedItem(p, true);
}
}
} else if (event.keyCode == SWT.ARROW_UP) {
int maxY = getMaxY();
int minX = getMinX();
int maxX = getMaxX();
int y = maxY;
if (maxY > -1 && minX > -1 && maxX > -1 && y > 0) {
tableCursor.setSelection(y - 1, maxX);
for (int x = minX; x <= maxX; x++) {
Point p = new Point(x, y);
removeSelectPoint(p, true);
drawUnselectedItem(p, true);
}
}
} else if (event.keyCode == SWT.ARROW_LEFT) {
int maxY = getMaxY();
int minY = getMinY();
int maxX = getMaxX();
if (maxY > -1 && minY > -1 && maxX > 0) {
tableCursor.setSelection(maxY, maxX - 1);
for (int y = minY; y <= maxY; y++) {
Point p = new Point(maxX, y);
removeSelectPoint(p, true);
drawUnselectedItem(p, true);
}
}
} else if (event.keyCode == SWT.ARROW_RIGHT) {
int maxY = getMaxY();
int minY = getMinY();
int maxX = getMaxX();
int columnCount = table.getColumnCount();
if (maxY > -1 && minY > -1 && maxX + 1 < columnCount) {
int x = maxX + 1;
tableCursor.setSelection(maxY, x);
for (int y = minY; y <= maxY; y++) {
Point p = new Point(x, y);
addSelectPoint(p, true);
drawSelectedItem(p, true);
}
}
}
} else if (!ctrlPressed && !shiftPressed) {
if (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT) {
selectedList.clear();
int y = table.indexOf(tableCursor.getRow());
int x = tableCursor.getColumn();
Point p = new Point(x, y);
addSelectPoint(p, true);
drawSelectedItems(true);
}
}
}
});
}
use of org.eclipse.swt.events.MouseMoveListener in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Control method test_addMouseMoveListenerLorg_eclipse_swt_events_MouseMoveListener.
@Test
public void test_addMouseMoveListenerLorg_eclipse_swt_events_MouseMoveListener() {
MouseMoveListener listener = e -> eventOccurred = true;
control.addMouseMoveListener(listener);
eventOccurred = false;
control.notifyListeners(SWT.MouseMove, new Event());
assertTrue(eventOccurred);
control.removeMouseMoveListener(listener);
}
use of org.eclipse.swt.events.MouseMoveListener in project eclipse.platform.text by eclipse.
the class AbstractInformationControl method addResizeSupportIfNecessary.
private void addResizeSupportIfNecessary(final Composite bars) {
// XXX: workarounds for
// - https://bugs.eclipse.org/bugs/show_bug.cgi?id=219139 : API to add resize grip / grow box in lower right corner of shell
// - https://bugs.eclipse.org/bugs/show_bug.cgi?id=23980 : platform specific shell resize behavior
String platform = SWT.getPlatform();
// $NON-NLS-1$
final boolean isWin = platform.equals("win32");
if (// $NON-NLS-1$
!isWin && !platform.equals("gtk"))
return;
final Canvas resizer = new Canvas(bars, SWT.NONE);
int size = getResizeHandleSize(bars);
GridData data = new GridData(SWT.END, SWT.END, false, true);
data.widthHint = size;
data.heightHint = size;
resizer.setLayoutData(data);
resizer.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
Point s = resizer.getSize();
int x = s.x - 2;
int y = s.y - 2;
int min = Math.min(x, y);
if (isWin) {
// draw dots
e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
int end = min - 1;
for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2 - i; j++) e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2);
end--;
e.gc.setBackground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2 - i; j++) e.gc.fillRectangle(end - 4 * i, end - 4 * j, 2, 2);
} else {
// draw diagonal lines
e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
for (int i = 1; i < min; i += 4) {
e.gc.drawLine(i, y, x, i);
}
e.gc.setForeground(resizer.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
for (int i = 2; i < min; i += 4) {
e.gc.drawLine(i, y, x, i);
}
}
}
});
final boolean isRTL = (resizer.getShell().getStyle() & SWT.RIGHT_TO_LEFT) != 0;
resizer.setCursor(resizer.getDisplay().getSystemCursor(isRTL ? SWT.CURSOR_SIZESW : SWT.CURSOR_SIZESE));
MouseAdapter resizeSupport = new MouseAdapter() {
private MouseMoveListener fResizeListener;
@Override
public void mouseDown(MouseEvent e) {
Rectangle shellBounds = fShell.getBounds();
final int shellX = shellBounds.x;
final int shellY = shellBounds.y;
final int shellWidth = shellBounds.width;
final int shellHeight = shellBounds.height;
Point mouseLoc = resizer.toDisplay(e.x, e.y);
final int mouseX = mouseLoc.x;
final int mouseY = mouseLoc.y;
fResizeListener = new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e2) {
Point mouseLoc2 = resizer.toDisplay(e2.x, e2.y);
int dx = mouseLoc2.x - mouseX;
int dy = mouseLoc2.y - mouseY;
if (isRTL) {
setLocation(new Point(shellX + dx, shellY));
setSize(shellWidth - dx, shellHeight + dy);
} else {
setSize(shellWidth + dx, shellHeight + dy);
}
}
};
resizer.addMouseMoveListener(fResizeListener);
}
@Override
public void mouseUp(MouseEvent e) {
resizer.removeMouseMoveListener(fResizeListener);
fResizeListener = null;
}
};
resizer.addMouseListener(resizeSupport);
}
use of org.eclipse.swt.events.MouseMoveListener in project eclipse.platform.text by eclipse.
the class ProjectionRulerColumn method createControl.
@Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
Control control = super.createControl(parentRuler, parentControl);
// set background
Color background = getCachedTextViewer().getTextWidget().getBackground();
control.setBackground(background);
// install hover listener
control.addMouseTrackListener(new MouseTrackAdapter() {
@Override
public void mouseExit(MouseEvent e) {
if (clearCurrentAnnotation())
redraw();
}
});
// install mouse move listener
control.addMouseMoveListener(new MouseMoveListener() {
@Override
public void mouseMove(MouseEvent e) {
boolean redraw = false;
ProjectionAnnotation annotation = findAnnotation(toDocumentLineNumber(e.y), false);
if (annotation != fCurrentAnnotation) {
if (fCurrentAnnotation != null) {
fCurrentAnnotation.setRangeIndication(false);
redraw = true;
}
fCurrentAnnotation = annotation;
if (fCurrentAnnotation != null && !fCurrentAnnotation.isCollapsed()) {
fCurrentAnnotation.setRangeIndication(true);
redraw = true;
}
}
if (redraw)
redraw();
}
});
return control;
}
Aggregations