Coverage Report - org.eclipse.swtbot.swt.finder.SWTBotWidget
 
Classes in this File Line Coverage Branch Coverage Complexity
SWTBotWidget
N/A
N/A
0
 
 1  
 /*******************************************************************************
 2  
  * Copyright (c) 2008 Ketan Padegaonkar and others.
 3  
  * All rights reserved. This program and the accompanying materials
 4  
  * are made available under the terms of the Eclipse Public License v1.0
 5  
  * which accompanies this distribution, and is available at
 6  
  * http://www.eclipse.org/legal/epl-v10.html
 7  
  *
 8  
  * Contributors:
 9  
  *     Ketan Padegaonkar - initial API and implementation
 10  
  *******************************************************************************/
 11  
 package org.eclipse.swtbot.swt.finder;
 12  
 
 13  
 import static java.lang.annotation.ElementType.TYPE;
 14  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.ID_KEY_VALUE;
 15  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.ID_VALUE;
 16  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.IN_GROUP;
 17  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.LABEL;
 18  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.MNEMONIC;
 19  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.NONE;
 20  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.TEXT;
 21  
 import static org.eclipse.swtbot.swt.finder.ReferenceBy.TOOLTIP;
 22  
 
 23  
 import java.lang.annotation.Retention;
 24  
 import java.lang.annotation.RetentionPolicy;
 25  
 import java.lang.annotation.Target;
 26  
 
 27  
 import org.eclipse.swt.SWT;
 28  
 import org.eclipse.swt.widgets.Widget;
 29  
 
 30  
 /**
 31  
  * Marks a SWTBot widget so tools recognise them. This anotation is primarily used to describe the convinience API that
 32  
  * should be generated for a class annotated with the specified widget.
 33  
  * <p>
 34  
  * Usage:
 35  
  * 
 36  
  * <pre>
 37  
  * &#064;SWTBotWidget(clasz = Button.class, style = @Style(name = &quot;SWT.PUSH&quot;, value = SWT.PUSH), preferredName = &quot;button&quot;, referenceBy = { ReferenceBy.LABEL, ReferenceBy.MNEMONIC, ReferenceBy.TOOLTIP })
 38  
  * public class SWTBotButton ...{
 39  
  *   // the implement 
 40  
  * }
 41  
  * </pre>
 42  
  * 
 43  
  * The above represents:
 44  
  * <ul>
 45  
  * <li>widget of type 'Button.class'</li>
 46  
  * <li>with style bits 'SWT.PUSH'</li>
 47  
  * <li>the preferred name for the generated API would be 'button'</li>
 48  
  * <li>the widget can be referenced by: <strong>a combination</strong> of LABEL, MNEMONIC, TOOLTIP, in addition to the
 49  
  * defaults described in {@link #defaultReferenceBy()}</li>
 50  
  * </ul>
 51  
  * This annotation will generate the following convinience API to find buttons:
 52  
  * <ul>
 53  
  * <li>public SWTBotButton buttonWithLabel(String label)</li>
 54  
  * <li>public SWTBotButton buttonWithLabel(String label, int index)</li>
 55  
  * <li>public SWTBotButton button(String mnemonicText)</li>
 56  
  * <li>public SWTBotButton button(String mnemonicText, int index)</li>
 57  
  * <li>public SWTBotButton buttonWithTooltip(String tooltip)</li>
 58  
  * <li>public SWTBotButton buttonWithTooltip(String tooltip, int index)</li>
 59  
  * <li>public SWTBotButton buttonWithId(String key, String value)</li>
 60  
  * <li>public SWTBotButton buttonWithId(String key, String value, int index)</li>
 61  
  * <li>public SWTBotButton buttonWithId(String value)</li>
 62  
  * <li>public SWTBotButton buttonWithId(String value, int index)</li>
 63  
  * <li>public SWTBotButton buttonInGroup(String inGroup)</li>
 64  
  * <li>public SWTBotButton buttonInGroup(String inGroup, int index)</li>
 65  
  * <li>public SWTBotButton button()</li>
 66  
  * <li>public SWTBotButton button(int index)</li>
 67  
  * <li>public SWTBotButton buttonWithLabelInGroup(String label, String inGroup)</li>
 68  
  * <li>public SWTBotButton buttonWithLabelInGroup(String label, String inGroup, int index)</li>
 69  
  * <li>public SWTBotButton buttonInGroup(String mnemonicText, String inGroup)</li>
 70  
  * <li>public SWTBotButton buttonInGroup(String mnemonicText, String inGroup, int index)</li>
 71  
  * <li>public SWTBotButton buttonWithTooltipInGroup(String tooltip, String inGroup)</li>
 72  
  * <li>public SWTBotButton buttonWithTooltipInGroup(String tooltip, String inGroup, int index)</li>
 73  
  * </ul>
 74  
  * </p>
 75  
  * 
 76  
  * @author Ketan Padegaonkar &lt;KetanPadegaonkar [at] gmail [dot] com&gt;
 77  
  * @version $Id$
 78  
  * @since 2.0
 79  
  */
 80  
 @Retention(RetentionPolicy.RUNTIME)
 81  
 @Target( { TYPE })
 82  
 public @interface SWTBotWidget {
 83  
         /** Widget can be found using the following methods */
 84  
         ReferenceBy[] referenceBy() default { ID_KEY_VALUE, ID_VALUE, IN_GROUP, LABEL, MNEMONIC, NONE, TEXT, TOOLTIP };
 85  
 
 86  
         /** Widget is of the specified class */
 87  
         Class<? extends Widget> clasz();
 88  
 
 89  
         /** If a the specified widget can have different styles, specify one of the styles in {@link SWT} */
 90  
         Style style() default @Style();
 91  
 
 92  
         /** The preferred name for the widget */
 93  
         String preferredName();
 94  
 
 95  
         /** Default reference by */
 96  
         ReferenceBy[] defaultReferenceBy() default { ReferenceBy.ID_KEY_VALUE, ReferenceBy.ID_VALUE, ReferenceBy.IN_GROUP, ReferenceBy.NONE };
 97  
 
 98  
         Class<?> returnType() default Object.class;
 99  
 }