View Javadoc

1   /**
2    * .
3    */
4   package org.sirius.client.web.classes;
5   
6   import java.rmi.RemoteException;
7   
8   import org.sirius.client.web.WebClient;
9   import org.sirius.client.web.core.Dimension;
10  import org.sirius.client.web.core.Point;
11  
12  /**
13   * @author Myk Kolisnyk
14   * .
15   */
16  public class WebControl {
17  
18      /**
19       * .
20       */
21      private WebClient client        = null;
22      /**
23       * .
24       */
25      private Frame     parent        = null;
26      /**
27       * .
28       */
29      private String    parentElement = null;
30      /**
31       * .
32       */
33      private String    locator       = null;
34  
35      /**
36       * @return the client
37       */
38      public final WebClient getClient() {
39          return client;
40      }
41  
42      /**
43       * @param clientValue the client to set
44       */
45      public final void setClient(final WebClient clientValue) {
46          this.client = clientValue;
47      }
48  
49      /**
50       * @return the parent
51       */
52      public final Frame getParent() {
53          return parent;
54      }
55  
56      /**
57       * @param parentValue the parent to set
58       */
59      public final void setParent(final Frame parentValue) {
60          this.parent = parentValue;
61      }
62  
63      /**
64       * @return the parentElement
65       */
66      public final String getParentElement() {
67          return parentElement;
68      }
69  
70      /**
71       * @param parentElementValue the parentElement to set
72       */
73      public final void setParentElement(final String parentElementValue) {
74          this.parentElement = parentElementValue;
75      }
76  
77      /**
78       * @return the locator
79       */
80      public final String getLocator() {
81          return locator;
82      }
83  
84      /**
85       * @param locatorValue the locator to set
86       */
87      public final void setLocator(final String locatorValue) {
88          this.locator = locatorValue;
89      }
90  
91      /**
92       * .
93       * @param parentValue .
94       * @param locatorValue .
95       */
96      public WebControl(final Frame parentValue, final String locatorValue) {
97          this(parentValue, null, locatorValue);
98      }
99  
100     /**
101      * .
102      * @param parentValue .
103      * @param parentElementValue .
104      * @param locatorValue .
105      */
106     public WebControl(final Frame parentValue, final String parentElementValue,
107             final String locatorValue) {
108         this.parent = parentValue;
109         this.parentElement = parentElementValue;
110         this.locator = locatorValue;
111     }
112 
113     /**
114      * .
115      * @throws Exception .
116      */
117     public final void click() throws Exception {
118         client().core().click(parentElement, locator);
119     }
120 
121     /**
122      * .
123      * @return .
124      */
125     protected final WebClient client() {
126         if (client == null) {
127             client = getParent().getClient();
128         }
129         return client;
130     }
131 
132     /**
133      * .
134      * @param attribute .
135      * @return .
136      * @throws RemoteException .
137      */
138     public final String getAttribute(final String attribute)
139             throws RemoteException {
140         return client().core().getAttribute(
141                 parentElement,
142                 locator,
143                 attribute);
144     }
145 
146     /**
147      * .
148      * @return .
149      * @throws RemoteException .
150      */
151     public final Point getLocation() throws RemoteException {
152         return client().core().getLocation(parentElement, locator);
153     }
154 
155     /**
156      * .
157      * @return .
158      * @throws RemoteException .
159      */
160     public final Dimension getSize() throws RemoteException {
161         return client().core().getSize(parentElement, locator);
162     }
163 
164     /**
165      * .
166      * @return .
167      * @throws RemoteException .
168      */
169     public final String getValue() throws RemoteException {
170         return getAttribute("value");
171     }
172 
173     /**
174      * .
175      * @return .
176      * @throws RemoteException .
177      */
178     public final String innerHtml() throws RemoteException {
179         return client().core()
180                 .getAttribute(parentElement, locator, "innerHTML");
181     }
182 
183     /**
184      * .
185      * @return .
186      * @throws RemoteException .
187      */
188     public final String innerText() throws RemoteException {
189         return client().core()
190                 .getAttribute(parentElement, locator, "innerText");
191     }
192 
193     /**
194      * .
195      * @return .
196      * @throws RemoteException .
197      */
198     public final boolean isFocused() throws RemoteException {
199         return false;
200     }
201 }