source: trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/guimodel/ANDROIDGUIElement.java @ 1876

Last change on this file since 1876 was 1876, checked in by pharms, 9 years ago
  • added support for views in GUIs
  • Property svn:mime-type set to text/plain
File size: 5.2 KB
Line 
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
15package de.ugoe.cs.autoquest.plugin.android.guimodel;
16
17import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement;
18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
19import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
20import 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 */
30public 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     * <p>
94     * Returns the type of the GUI element, i.e., the name of its Java class.
95     * </p>
96     *
97     * @return the Java class name
98     */
99    public String getSpecType() {
100        return specification.getType();
101    }
102
103    /*
104     * (non-Javadoc)
105     *
106     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
107     */
108    @Override
109    public String getPlatform() {
110        return "Android";
111    }
112
113    /**
114     * <p>
115     * Returns the type of the GUI element, i.e., the name of its Android class.
116     * </p>
117     *
118     * @return the Android class name
119     */
120    public String getAndroidType() {
121        return specification.getType();
122    }
123   
124    /**
125     * <p>
126     * Returns the name of the GUI element.
127     * </p>
128     *
129     * @return the name
130     */
131    public String getName() {
132        return specification.getName();
133    }
134   
135    /**
136     * <p>
137     * Returns the path of the GUI element.
138     * </p>
139     *
140     * @return the path
141     */
142    public String getPath() {
143        return specification.getPath();
144    }
145   
146    /**
147     * <p>
148     * Returns the GUI element identifier.
149     * </p>
150     *
151     * @return identifier of the GUI element
152     */
153    int getIndex() {
154        return specification.getIndex();
155    }
156   
157    /**
158     * <p>
159     * Returns the object hash of the GUI element.
160     * </p>
161     *
162     * @return the object hash
163     */
164    int getElementHash() {
165        return specification.getElementHash();
166    }
167
168    /*
169     * (non-Javadoc)
170     *
171     * @see java.lang.Object#toString()
172     */
173    @Override
174    public String getStringIdentifier() {
175        String str = this.toString();
176        if (getParent() != null) {
177            return str + "<-" + getParent().getStringIdentifier();
178        }
179        return str;
180    }
181
182    /*
183     * (non-Javadoc)
184     *
185     * @see java.lang.Object#toString()
186     */
187    @Override
188    public String toString() {
189        String str =
190            getElementDescriptor() + "(" + getName() + "," + getElementHash() + "," + getPath() +
191                "," + getIndex() + ")";
192        return str;
193    }
194
195    /**
196     * <p>
197     * A short string describing the GUI element, e.g., Button, Canvas, or ScrollBar.
198     * </p>
199     *
200     * @return short element descriptor
201     */
202    protected String getElementDescriptor() {
203        return "Default";
204    }
205
206}
Note: See TracBrowser for help on using the repository browser.