1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
2 | //
|
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
4 | // you may not use this file except in compliance with the License.
|
---|
5 | // You may obtain a copy of the License at
|
---|
6 | //
|
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
8 | //
|
---|
9 | // Unless required by applicable law or agreed to in writing, software
|
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
12 | // See the License for the specific language governing permissions and
|
---|
13 | // limitations under the License.
|
---|
14 |
|
---|
15 | package de.ugoe.cs.autoquest.plugin.android.guimodel;
|
---|
16 |
|
---|
17 | import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement;
|
---|
18 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
|
---|
19 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
|
---|
20 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIView;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * <p>
|
---|
24 | * Base class for all Android GUI elements.
|
---|
25 | * </p>
|
---|
26 | *
|
---|
27 | * @version 1.0
|
---|
28 | * @author Florian Unger
|
---|
29 | */
|
---|
30 | public class ANDROIDGUIElement extends AbstractDefaultGUIElement {
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * <p>
|
---|
34 | * Id for object serialization.
|
---|
35 | * </p>
|
---|
36 | */
|
---|
37 | private static final long serialVersionUID = 1L;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * <p>
|
---|
41 | * Specification of the GUI Element
|
---|
42 | * </p>
|
---|
43 | */
|
---|
44 | private ANDROIDGUIElementSpec specification;
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * <p>
|
---|
48 | * Constructor. Creates a new JFCGUIElement.
|
---|
49 | * </p>
|
---|
50 | *
|
---|
51 | * @param specification
|
---|
52 | * specification of created GUI element
|
---|
53 | * @param parent
|
---|
54 | * parent of the created GUI element; null means that the element is a top-level
|
---|
55 | * window
|
---|
56 | */
|
---|
57 | public ANDROIDGUIElement(ANDROIDGUIElementSpec specification, ANDROIDGUIElement parent) {
|
---|
58 | super(specification, parent);
|
---|
59 | this.specification = specification;
|
---|
60 | }
|
---|
61 |
|
---|
62 | /*
|
---|
63 | * (non-Javadoc)
|
---|
64 | *
|
---|
65 | * @see
|
---|
66 | * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest
|
---|
67 | * .eventcore .guimodel.IGUIElementSpec)
|
---|
68 | */
|
---|
69 | @Override
|
---|
70 | public void updateSpecification(IGUIElementSpec furtherSpec) {
|
---|
71 | // nothing do do here up to now.
|
---|
72 | }
|
---|
73 |
|
---|
74 | /* (non-Javadoc)
|
---|
75 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getView()
|
---|
76 | */
|
---|
77 | @Override
|
---|
78 | public IGUIView getView() {
|
---|
79 | throw new UnsupportedOperationException();
|
---|
80 | }
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * (non-Javadoc)
|
---|
84 | *
|
---|
85 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement)
|
---|
86 | */
|
---|
87 | @Override
|
---|
88 | public double getDistanceTo(IGUIElement otherElement) {
|
---|
89 | throw new UnsupportedOperationException("not implemented yet");
|
---|
90 | }
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * (non-Javadoc)
|
---|
94 | *
|
---|
95 | * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
|
---|
96 | */
|
---|
97 | @Override
|
---|
98 | public String getPlatform() {
|
---|
99 | return "Android";
|
---|
100 | }
|
---|
101 |
|
---|
102 | /**
|
---|
103 | * <p>
|
---|
104 | * Returns the type of the GUI element, i.e., the name of its Android class.
|
---|
105 | * </p>
|
---|
106 | *
|
---|
107 | * @return the Android class name
|
---|
108 | */
|
---|
109 | public String getAndroidType() {
|
---|
110 | return specification.getType();
|
---|
111 | }
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * <p>
|
---|
115 | * Returns the name of the GUI element.
|
---|
116 | * </p>
|
---|
117 | *
|
---|
118 | * @return the name
|
---|
119 | */
|
---|
120 | public String getName() {
|
---|
121 | return specification.getName();
|
---|
122 | }
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * <p>
|
---|
126 | * Returns the path of the GUI element.
|
---|
127 | * </p>
|
---|
128 | *
|
---|
129 | * @return the path
|
---|
130 | */
|
---|
131 | public String getPath() {
|
---|
132 | return specification.getPath();
|
---|
133 | }
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * <p>
|
---|
137 | * Returns the GUI element identifier.
|
---|
138 | * </p>
|
---|
139 | *
|
---|
140 | * @return identifier of the GUI element
|
---|
141 | */
|
---|
142 | int getIndex() {
|
---|
143 | return specification.getIndex();
|
---|
144 | }
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * <p>
|
---|
148 | * Returns the object hash of the GUI element.
|
---|
149 | * </p>
|
---|
150 | *
|
---|
151 | * @return the object hash
|
---|
152 | */
|
---|
153 | int getElementHash() {
|
---|
154 | return specification.getElementHash();
|
---|
155 | }
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * (non-Javadoc)
|
---|
159 | *
|
---|
160 | * @see java.lang.Object#toString()
|
---|
161 | */
|
---|
162 | @Override
|
---|
163 | public String getStringIdentifier() {
|
---|
164 | String str = this.toString();
|
---|
165 | if (getParent() != null) {
|
---|
166 | return str + "<-" + getParent().getStringIdentifier();
|
---|
167 | }
|
---|
168 | return str;
|
---|
169 | }
|
---|
170 |
|
---|
171 | /*
|
---|
172 | * (non-Javadoc)
|
---|
173 | *
|
---|
174 | * @see java.lang.Object#toString()
|
---|
175 | */
|
---|
176 | @Override
|
---|
177 | public String toString() {
|
---|
178 | String str =
|
---|
179 | getElementDescriptor() + "(" + getName() + "," + getElementHash() + "," + getPath() +
|
---|
180 | "," + getIndex() + ")";
|
---|
181 | return str;
|
---|
182 | }
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * <p>
|
---|
186 | * A short string describing the GUI element, e.g., Button, Canvas, or ScrollBar.
|
---|
187 | * </p>
|
---|
188 | *
|
---|
189 | * @return short element descriptor
|
---|
190 | */
|
---|
191 | protected String getElementDescriptor() {
|
---|
192 | return "Default";
|
---|
193 | }
|
---|
194 |
|
---|
195 | }
|
---|