tmf.ui.swtbot: Fix missing @Override in SWTBotSash.getBounds()
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui.swtbot.tests / shared / org / eclipse / tracecompass / tmf / ui / swtbot / tests / shared / SWTBotSash.java
CommitLineData
ff93f0e2 1/*******************************************************************************
2d594808 2 * Copyright (c) 2015, 2016 Ericsson
ff93f0e2
MK
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
12
13package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared;
14
2d594808 15import org.eclipse.swt.SWT;
ff93f0e2 16import org.eclipse.swt.graphics.Point;
2d594808
PT
17import org.eclipse.swt.graphics.Rectangle;
18import org.eclipse.swt.widgets.Event;
ff93f0e2
MK
19import org.eclipse.swt.widgets.Sash;
20import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
ff93f0e2 21import org.eclipse.swtbot.swt.finder.results.Result;
ff93f0e2 22import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
ff93f0e2
MK
23
24/**
2d594808 25 * SWTBot class representing a Sash
ff93f0e2
MK
26 */
27public class SWTBotSash extends AbstractSWTBotControl<Sash> {
28
29 /**
30 * The widget wrapper
31 *
32 * @param w
33 * the sash
ff93f0e2
MK
34 * @throws WidgetNotFoundException
35 * if there is no widget
36 */
2d594808
PT
37 public SWTBotSash(Sash w) throws WidgetNotFoundException {
38 super(w);
ff93f0e2
MK
39 }
40
922cfc89 41 @Override
2d594808 42 public Rectangle getBounds() {
922cfc89 43 return super.getBounds();
ff93f0e2
MK
44 }
45
46 /**
2d594808 47 * Drag the sash from its middle point to the destination point
ff93f0e2
MK
48 *
49 * @param dst
2d594808 50 * the destination point relative to the parent
ff93f0e2
MK
51 */
52 public void drag(final Point dst) {
2d594808
PT
53 Rectangle bounds = getBounds();
54 int x = bounds.width / 2;
55 int y = bounds.height / 2;
56 notify(SWT.MouseEnter);
57 notify(SWT.Activate);
58 notify(SWT.Selection, createSelectionEvent(bounds.x + x, bounds.y + y, SWT.NONE));
59 notify(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1));
60 notify(SWT.DragDetect, createMouseEvent(x, y, 0, SWT.NONE, 0));
61 notify(SWT.Move);
62 notify(SWT.Selection, createSelectionEvent(dst.x, dst.y, SWT.NONE));
63 notify(SWT.MouseMove, createMouseEvent(x, y, 0, SWT.BUTTON1, 0));
64 notify(SWT.Selection, createSelectionEvent(dst.x, dst.y, SWT.BUTTON1));
65 notify(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.NONE, 1));
66 notify(SWT.MouseExit);
67 }
ff93f0e2 68
2d594808
PT
69 private Event createSelectionEvent(int x, int y, int stateMask) {
70 return syncExec(new Result<Event>() {
71 @Override
72 public Event run() {
bb3a831c 73 boolean vertical = (widget.getStyle() & SWT.VERTICAL) != 0;
2d594808
PT
74 Point size = widget.getSize();
75 Event event = createSelectionEvent(stateMask);
76 event.x = vertical ? x : 0;
77 event.y = vertical ? 0 : y;
78 event.width = size.x;
79 event.height = size.y;
80 return event;
ff93f0e2 81 }
2d594808 82 });
ff93f0e2 83 }
ff93f0e2 84}
This page took 0.052815 seconds and 5 git commands to generate.