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
1 /*******************************************************************************
2 * Copyright (c) 2015, 2016 Ericsson
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
13 package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared;
14
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.graphics.Point;
17 import org.eclipse.swt.graphics.Rectangle;
18 import org.eclipse.swt.widgets.Event;
19 import org.eclipse.swt.widgets.Sash;
20 import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
21 import org.eclipse.swtbot.swt.finder.results.Result;
22 import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
23
24 /**
25 * SWTBot class representing a Sash
26 */
27 public class SWTBotSash extends AbstractSWTBotControl<Sash> {
28
29 /**
30 * The widget wrapper
31 *
32 * @param w
33 * the sash
34 * @throws WidgetNotFoundException
35 * if there is no widget
36 */
37 public SWTBotSash(Sash w) throws WidgetNotFoundException {
38 super(w);
39 }
40
41 @Override
42 public Rectangle getBounds() {
43 return super.getBounds();
44 }
45
46 /**
47 * Drag the sash from its middle point to the destination point
48 *
49 * @param dst
50 * the destination point relative to the parent
51 */
52 public void drag(final Point dst) {
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 }
68
69 private Event createSelectionEvent(int x, int y, int stateMask) {
70 return syncExec(new Result<Event>() {
71 @Override
72 public Event run() {
73 boolean vertical = (widget.getStyle() & SWT.VERTICAL) != 0;
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;
81 }
82 });
83 }
84 }
This page took 0.034655 seconds and 6 git commands to generate.