/
CTabFolderHandler.java
85 lines (76 loc) · 2.14 KB
/
CTabFolderHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*******************************************************************************
* Copyright (c) 2017 Red Hat, Inc and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc - initial API and implementation
*******************************************************************************/
package org.eclipse.reddeer.core.handler;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.reddeer.common.util.Display;
import org.eclipse.reddeer.common.util.ResultRunnable;
/**
* Contains methods for handling UI operations on {@link CTabFolder} widgets.
*
* @author Lucia Jelinkova
*
*/
public class CTabFolderHandler extends ControlHandler{
private static CTabFolderHandler instance;
/**
* Gets instance of CTabFolderHandler.
*
* @return instance of CTabFolderHandler
*/
public static CTabFolderHandler getInstance(){
if(instance == null){
instance = new CTabFolderHandler();
}
return instance;
}
/**
* Sets focus on specified {@link CTabFolder}.
*
* @param folder folder to handle
*/
public void setFocus(final CTabFolder folder) {
Display.syncExec(new Runnable() {
@Override
public void run() {
folder.forceFocus();
}
});
}
/**
* Gets tab items nested in specified {@link CTabFolder}.
*
* @param tabFolder tab folder to handle
* @return tab items nested in specified tab folder
*/
public CTabItem[] getTabItems(final CTabFolder tabFolder) {
return Display.syncExec(new ResultRunnable<CTabItem[]>() {
@Override
public CTabItem[] run() {
return tabFolder.getItems();
}
});
}
/**
* Gets selected tab item
* @param tabFolder to get selected item of
* @return selected tab item or null if none is selected
*/
public CTabItem getSelection(final CTabFolder tabFolder) {
return Display.syncExec(new ResultRunnable<CTabItem>() {
@Override
public CTabItem run() {
return tabFolder.getSelection();
}
});
}
}