blob: 499ffb89a22aef476b87e95dd253d67492bde563 (
plain) (
blame)
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
|
/*******************************************************************************
* Copyright (c) 2009 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.tests.ui.util;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
import org.eclipse.swtbot.swt.finder.results.Result;
import org.hamcrest.Description;
/**
* a matcher for widgets that have an id with a specified key with any not-null value.
*
* @author David Green
*/
public class HasId<T extends Widget> extends AbstractMatcher<T> {
private String key;
public HasId(String key) {
super();
this.key = key;
}
@Override
protected boolean doMatch(final Object obj) {
Object data = UIThreadRunnable.syncExec(new Result<Object>() {
public Object run() {
return ((Widget) obj).getData(key);
}
});
return data != null;
}
public void describeTo(Description description) {
description.appendText("with key (").appendText(key).appendText(")"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
|