[1783] | 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.
|
---|
[1819] | 14 |
|
---|
[1783] | 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 |
|
---|
| 21 | /**
|
---|
| 22 | * <p>
|
---|
| 23 | * Base class for all Android GUI elements.
|
---|
| 24 | * </p>
|
---|
| 25 | *
|
---|
| 26 | * @version 1.0
|
---|
| 27 | * @author Florian Unger
|
---|
| 28 | */
|
---|
[1819] | 29 | public class ANDROIDGUIElement extends AbstractDefaultGUIElement {
|
---|
[1783] | 30 |
|
---|
[1819] | 31 | /**
|
---|
[1783] | 32 | * <p>
|
---|
| 33 | * Id for object serialization.
|
---|
| 34 | * </p>
|
---|
| 35 | */
|
---|
| 36 | private static final long serialVersionUID = 1L;
|
---|
[1819] | 37 |
|
---|
[1783] | 38 | /**
|
---|
| 39 | * <p>
|
---|
| 40 | * Specification of the GUI Element
|
---|
| 41 | * </p>
|
---|
| 42 | */
|
---|
[1790] | 43 | private ANDROIDGUIElementSpec specification;
|
---|
[1819] | 44 |
|
---|
[1783] | 45 | /**
|
---|
| 46 | * <p>
|
---|
| 47 | * Constructor. Creates a new JFCGUIElement.
|
---|
| 48 | * </p>
|
---|
| 49 | *
|
---|
| 50 | * @param specification
|
---|
| 51 | * specification of created GUI element
|
---|
| 52 | * @param parent
|
---|
| 53 | * parent of the created GUI element; null means that the element is a top-level
|
---|
| 54 | * window
|
---|
| 55 | */
|
---|
[1790] | 56 | public ANDROIDGUIElement(ANDROIDGUIElementSpec specification, ANDROIDGUIElement parent) {
|
---|
[1819] | 57 | super(specification, parent);
|
---|
| 58 | this.specification = specification;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
[1783] | 61 | /*
|
---|
| 62 | * (non-Javadoc)
|
---|
| 63 | *
|
---|
| 64 | * @see
|
---|
| 65 | * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest
|
---|
| 66 | * .eventcore .guimodel.IGUIElementSpec)
|
---|
| 67 | */
|
---|
| 68 | @Override
|
---|
[1819] | 69 | public void updateSpecification(IGUIElementSpec furtherSpec) {
|
---|
| 70 | // nothing do do here up to now.
|
---|
| 71 | }
|
---|
[1783] | 72 |
|
---|
| 73 | /*
|
---|
| 74 | * (non-Javadoc)
|
---|
| 75 | *
|
---|
| 76 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement)
|
---|
| 77 | */
|
---|
[1819] | 78 | @Override
|
---|
| 79 | public double getDistanceTo(IGUIElement otherElement) {
|
---|
| 80 | throw new UnsupportedOperationException("not implemented yet");
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | /**
|
---|
[1783] | 84 | * <p>
|
---|
| 85 | * Returns the type of the GUI element, i.e., the name of its Java class.
|
---|
| 86 | * </p>
|
---|
| 87 | *
|
---|
| 88 | * @return the Java class name
|
---|
| 89 | */
|
---|
| 90 | public String getSpecType() {
|
---|
| 91 | return specification.getType();
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[1819] | 94 | /*
|
---|
[1783] | 95 | * (non-Javadoc)
|
---|
| 96 | *
|
---|
| 97 | * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
|
---|
| 98 | */
|
---|
[1819] | 99 | @Override
|
---|
| 100 | public String getPlatform() {
|
---|
| 101 | return "Android";
|
---|
| 102 | }
|
---|
[1869] | 103 |
|
---|
| 104 | /**
|
---|
| 105 | * <p>
|
---|
| 106 | * Returns the type of the GUI element, i.e., the name of its Android class.
|
---|
| 107 | * </p>
|
---|
| 108 | *
|
---|
| 109 | * @return the Android class name
|
---|
| 110 | */
|
---|
| 111 | public String getAndroidType() {
|
---|
| 112 | return specification.getType();
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | /**
|
---|
| 116 | * <p>
|
---|
| 117 | * Returns the name of the GUI element.
|
---|
| 118 | * </p>
|
---|
| 119 | *
|
---|
| 120 | * @return the name
|
---|
| 121 | */
|
---|
| 122 | public String getName() {
|
---|
| 123 | return specification.getName();
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | /**
|
---|
| 127 | * <p>
|
---|
| 128 | * Returns the path of the GUI element.
|
---|
| 129 | * </p>
|
---|
| 130 | *
|
---|
| 131 | * @return the path
|
---|
| 132 | */
|
---|
| 133 | public String getPath() {
|
---|
| 134 | return specification.getPath();
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | /**
|
---|
| 138 | * <p>
|
---|
| 139 | * Returns the GUI element identifier.
|
---|
| 140 | * </p>
|
---|
| 141 | *
|
---|
| 142 | * @return identifier of the GUI element
|
---|
| 143 | */
|
---|
| 144 | int getIndex() {
|
---|
| 145 | return specification.getIndex();
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | /**
|
---|
| 149 | * <p>
|
---|
| 150 | * Returns the object hash of the GUI element.
|
---|
| 151 | * </p>
|
---|
| 152 | *
|
---|
| 153 | * @return the object hash
|
---|
| 154 | */
|
---|
| 155 | int getElementHash() {
|
---|
| 156 | return specification.getElementHash();
|
---|
| 157 | }
|
---|
[1783] | 158 |
|
---|
[1819] | 159 | /*
|
---|
[1783] | 160 | * (non-Javadoc)
|
---|
| 161 | *
|
---|
| 162 | * @see java.lang.Object#toString()
|
---|
| 163 | */
|
---|
[1819] | 164 | @Override
|
---|
| 165 | public String getStringIdentifier() {
|
---|
| 166 | String str = this.toString();
|
---|
[1783] | 167 | if (getParent() != null) {
|
---|
| 168 | return str + "<-" + getParent().getStringIdentifier();
|
---|
| 169 | }
|
---|
| 170 | return str;
|
---|
[1819] | 171 | }
|
---|
[1869] | 172 |
|
---|
| 173 | /*
|
---|
| 174 | * (non-Javadoc)
|
---|
| 175 | *
|
---|
| 176 | * @see java.lang.Object#toString()
|
---|
| 177 | */
|
---|
| 178 | @Override
|
---|
| 179 | public String toString() {
|
---|
| 180 | String str =
|
---|
| 181 | getElementDescriptor() + "(" + getName() + "," + getElementHash() + "," + getPath() +
|
---|
| 182 | "," + getIndex() + ")";
|
---|
| 183 | return str;
|
---|
| 184 | }
|
---|
[1819] | 185 |
|
---|
| 186 | /**
|
---|
[1783] | 187 | * <p>
|
---|
| 188 | * A short string describing the GUI element, e.g., Button, Canvas, or ScrollBar.
|
---|
| 189 | * </p>
|
---|
| 190 | *
|
---|
| 191 | * @return short element descriptor
|
---|
| 192 | */
|
---|
| 193 | protected String getElementDescriptor() {
|
---|
| 194 | return "Default";
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | }
|
---|