1 /*******************************************************************************
2 * Copyright (c) 2015, 2016 Ericsson
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
10 * Matthew Khouzam - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.swtbot
.tests
.shared
;
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
;
25 * SWTBot class representing a Sash
27 public class SWTBotSash
extends AbstractSWTBotControl
<Sash
> {
34 * @throws WidgetNotFoundException
35 * if there is no widget
37 public SWTBotSash(Sash w
) throws WidgetNotFoundException
{
42 * Get the bounds of the sash
44 * @return the bounds relative to the parent
46 public Rectangle
getBounds() {
47 return syncExec(new Result
<Rectangle
>() {
49 public Rectangle
run() {
50 return widget
.getBounds();
56 * Drag the sash from its middle point to the destination point
59 * the destination point relative to the parent
61 public void drag(final Point dst
) {
62 Rectangle bounds
= getBounds();
63 int x
= bounds
.width
/ 2;
64 int y
= bounds
.height
/ 2;
65 notify(SWT
.MouseEnter
);
67 notify(SWT
.Selection
, createSelectionEvent(bounds
.x
+ x
, bounds
.y
+ y
, SWT
.NONE
));
68 notify(SWT
.MouseDown
, createMouseEvent(x
, y
, 1, SWT
.NONE
, 1));
69 notify(SWT
.DragDetect
, createMouseEvent(x
, y
, 0, SWT
.NONE
, 0));
71 notify(SWT
.Selection
, createSelectionEvent(dst
.x
, dst
.y
, SWT
.NONE
));
72 notify(SWT
.MouseMove
, createMouseEvent(x
, y
, 0, SWT
.BUTTON1
, 0));
73 notify(SWT
.Selection
, createSelectionEvent(dst
.x
, dst
.y
, SWT
.BUTTON1
));
74 notify(SWT
.MouseUp
, createMouseEvent(x
, y
, 1, SWT
.NONE
, 1));
75 notify(SWT
.MouseExit
);
78 private Event
createSelectionEvent(int x
, int y
, int stateMask
) {
79 return syncExec(new Result
<Event
>() {
82 boolean vertical
= (widget
.getStyle() & SWT
.VERTICAL
) != 0;
83 Point size
= widget
.getSize();
84 Event event
= createSelectionEvent(stateMask
);
85 event
.x
= vertical ? x
: 0;
86 event
.y
= vertical ?
0 : y
;
88 event
.height
= size
.y
;
This page took 0.031694 seconds and 5 git commands to generate.