| 1 | 0 | |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
package org.eclipse.swtbot.swt.finder.widgets; |
| 12 | |
|
| 13 | |
import org.eclipse.swt.SWT; |
| 14 | |
import org.eclipse.swt.widgets.Button; |
| 15 | |
import org.eclipse.swtbot.swt.finder.ReferenceBy; |
| 16 | |
import org.eclipse.swtbot.swt.finder.SWTBotWidget; |
| 17 | |
import org.eclipse.swtbot.swt.finder.Style; |
| 18 | |
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; |
| 19 | |
import org.eclipse.swtbot.swt.finder.utils.MessageFormat; |
| 20 | |
import org.eclipse.swtbot.swt.finder.utils.SWTUtils; |
| 21 | |
import org.eclipse.swtbot.swt.finder.utils.internal.Assert; |
| 22 | |
import org.hamcrest.SelfDescribing; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
@SWTBotWidget(clasz = Button.class, style = @Style(name = "SWT.PUSH", value = SWT.PUSH), preferredName = "button", referenceBy = { ReferenceBy.LABEL, ReferenceBy.MNEMONIC, ReferenceBy.TOOLTIP }) |
| 34 | |
public class SWTBotButton extends AbstractSWTBotControl<Button> { |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
public SWTBotButton(Button button) { |
| 44 | 0 | this(button, null); |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
public SWTBotButton(Button button, SelfDescribing description) { |
| 56 | 165 | super(button, description); |
| 57 | 165 | Assert.isTrue(SWTUtils.hasStyle(button, SWT.PUSH), "Expecting a push button."); |
| 58 | 165 | } |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
public SWTBotButton click() { |
| 64 | 144 | log.debug(MessageFormat.format("Clicking on {0}", SWTUtils.getText(widget))); |
| 65 | 144 | waitForEnabled(); |
| 66 | 144 | notify(SWT.MouseEnter); |
| 67 | 144 | notify(SWT.MouseMove); |
| 68 | 144 | notify(SWT.Activate); |
| 69 | 144 | notify(SWT.FocusIn); |
| 70 | 144 | notify(SWT.MouseDown); |
| 71 | 144 | notify(SWT.MouseUp); |
| 72 | 144 | notify(SWT.Selection); |
| 73 | 144 | notify(SWT.MouseHover); |
| 74 | 144 | notify(SWT.MouseMove); |
| 75 | 144 | notify(SWT.MouseExit); |
| 76 | 144 | notify(SWT.Deactivate); |
| 77 | 144 | notify(SWT.FocusOut); |
| 78 | 144 | log.debug(MessageFormat.format("Clicked on {0}", SWTUtils.getText(widget))); |
| 79 | 144 | return this; |
| 80 | |
} |
| 81 | |
|
| 82 | |
} |