View Javadoc

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  /**
12   * <p>
13   * The annotation is designed to assign window locators to the fields.
14   * When the containing class is initialized these fields are initialized automatically
15   * with the locator specified by the annotation.
16   * </p>
17   * <p>
18   * <b>Example:</b>
19   * <pre>
20   *    public class Test1LevelWindow extends MainWindow {
21   *    
22   *      &#64;Locator(winClass="Edit",caption="Sample text",index=0)
23   *      public Edit edtText;
24   *      
25   *      &#64;Locator(winClass="Button",caption="Test Button",index=2)
26   *      public Button btnTestButton;
27   *      
28   *      public Test1LevelWindow(Win32Client client) {
29   *          super(client, new Win32Locator("Test",0));
30   *      }
31   *    }
32   * </pre>
33   * After that we may initialize just main window object like:
34   * <pre>
35   *      Win32Client client = new Win32Client();
36   *      Test1LevelWindow win = new Test1LevelWindow(client);
37   * </pre>
38   * and then the <b>edtText</b> and <b>btnTestButton</b> fields will be initialized.
39   * </p>
40   * <p>
41   * <b>NOTE:</b> the initialization is limited to object instances creation and locator value assignments. 
42   * So, these objects wouldn't contain any HWND information. It's done this way because actual window objects
43   * may be unavailable at the time of the initialization. So, these elements would be filled with actual HWNDs
44   * as soon as we start using them first.
45   * </p>
46   * @author Myk Kolisnyk
47   */
48  @Target(ElementType.FIELD)
49  @Retention(value = RetentionPolicy.RUNTIME)
50  public @interface Locator {
51      String winClass() default "(.*)";
52      String caption() default "(.*)";
53      int index() default 0;
54  }