1 /** 2 * . 3 */ 4 package org.sirius.client.win32.annotations; 5 6 import java.lang.annotation.ElementType; 7 import java.lang.annotation.Retention; 8 import java.lang.annotation.RetentionPolicy; 9 import java.lang.annotation.Target; 10 11 import org.junit.Assert; 12 import org.sirius.client.win32.Win32Client; 13 import org.sirius.client.win32.classes.Aliases; 14 import org.sirius.client.win32.classes.MainWindow; 15 import org.sirius.client.win32.classes.controls.Button; 16 import org.sirius.client.win32.classes.controls.Edit; 17 import org.sirius.client.win32.types.Win32Locator; 18 19 /** 20 * <p> 21 * This annotation is used to assign global name to some specific control. 22 * The global name will be accessible at any place of code. 23 * </p> 24 * <p> 25 * <b>Initialization example:</b> 26 * <pre> 27 * public class Test1LevelWindow extends MainWindow { 28 * 29 * <b>@Alias(name="Sample Text")</b> 30 * @Locator(winClass="Edit",caption="Sample text",index=0) 31 * public Edit edtText; 32 * 33 * <b>@Alias(name="Sample Button")</b> 34 * @Locator(winClass="Button",caption="Test Button",index=2) 35 * public Button btnTestButton; 36 * 37 * public Test1LevelWindow(Win32Client client) { 38 * super(client, new Win32Locator("Test",0)); 39 * } 40 * } 41 * </pre> 42 * After that the annotated controls are accessed from {@link Aliases} object 43 * by given alias name. 44 * </p> 45 * <p> 46 * <b>Usage example:</b> 47 * <pre> 48 * Win32Client client = new Win32Client(); 49 * Test1LevelWindow win = new Test1LevelWindow(client); 50 * <b>((Edit)Aliases.get("Sample Text"))</b>.setText("Hello"); 51 * </pre> 52 * </p> 53 * <p> 54 * <b>NOTE:</b> global aliases storage is initialized together with locators initialization. 55 * So, it's recommended using aliases together with {@link Locator} annotations. 56 * Also, the external storage requires unique names for the aliases. Otherwise they will be overwritten. 57 * </p> 58 * @see {@link Aliases} 59 * @see {@link Locator} 60 * @author Myk Kolisnyk 61 */ 62 @Target(ElementType.FIELD) 63 @Retention(value = RetentionPolicy.RUNTIME) 64 public @interface Alias { 65 /** 66 * The actual text which should be treated as global name. 67 */ 68 String name(); 69 }