source: trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/guimodel/MFCGUIElement.java @ 1490

Last change on this file since 1490 was 1490, checked in by pharms, 10 years ago
  • added support and initial implementation of a platform specific distance measure between GUI elements
  • Property svn:executable set to *
File size: 4.7 KB
RevLine 
[927]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.
[837]14
[922]15package de.ugoe.cs.autoquest.plugin.mfc.guimodel;
[619]16
[922]17import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement;
[1490]18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
[922]19import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
[619]20
21/**
[837]22 * <p>
23 * Base class that represents GUI element in MFC GUIs.
24 * </p>
[619]25 *
[837]26 * @version 1.0
27 * @author Patrick Harms
[619]28 */
29public abstract class MFCGUIElement extends AbstractDefaultGUIElement {
[837]30
31    /**
32     * <p>
33     * Id for object serialization.
34     * </p>
35     */
[619]36    private static final long serialVersionUID = 1L;
37
38    /**
[837]39     * <p>
40     * Constructor. Creates a new MFCGUIElement.
41     * </p>
42     *
43     * @param specification
44     *            specification of created GUI element
45     * @param parent
46     *            parent of the created GUI element; null means that the element is a top-level
47     *            window
[619]48     */
49    public MFCGUIElement(MFCGUIElementSpec specification, MFCGUIElement parent) {
50        super(specification, parent);
51    }
52
[837]53    /*
54     * (non-Javadoc)
55     *
[922]56     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
[619]57     */
58    @Override
59    public String getPlatform() {
60        return "MFC";
61    }
62
63    /**
[837]64     * <p>
65     * Returns the HWND (Id) of the GUI element.
66     * </p>
67     *
68     * @return the HWND (Id)
[619]69     */
70    public String getId() {
71        return Long.toString(((MFCGUIElementSpec) super.getSpecification()).getHwnd());
72    }
73
74    /**
[837]75     * <p>
76     * Returns the type of the GUI element.
77     * </p>
78     *
79     * @return the type
[619]80     */
81    public String getType() {
82        return ((MFCGUIElementSpec) super.getSpecification()).getType();
83    }
84
85    /**
[837]86     * <p>
87     * Returns the name of the GUI element.
88     * </p>
89     *
90     * @return the name
[619]91     */
92    public String getName() {
93        return ((MFCGUIElementSpec) super.getSpecification()).getName();
94    }
95
96    /**
[837]97     * <p>
98     * Returns the modality of the GUI element.
99     * </p>
100     *
101     * @return the modality
[619]102     */
103    public boolean isModal() {
104        return ((MFCGUIElementSpec) super.getSpecification()).isModal();
105    }
106
107    /**
108     * <p>
[837]109     * Returns the resource Id of the GUI element.
[619]110     * </p>
[837]111     *
112     * @return the resource Id
[619]113     */
114    public int getResourceId() {
115        return ((MFCGUIElementSpec) super.getSpecification()).getResourceId();
116    }
117
[837]118    /*
119     * (non-Javadoc)
120     *
121     * @see
[922]122     * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest.eventcore
[837]123     * .guimodel.IGUIElementSpec)
[619]124     */
125    @Override
126    public void updateSpecification(IGUIElementSpec furtherSpec) {
127        ((MFCGUIElementSpec) super.getSpecification()).update(furtherSpec);
128    }
[837]129
130    /*
131     * (non-Javadoc)
132     *
[922]133     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getStringIdentifier()
[837]134     */
[681]135    @Override
136    public String getStringIdentifier() {
137        String str = this.toString();
[837]138        if (getParent() != null) {
[994]139            return str + "<-" + getParent().getStringIdentifier();
[681]140        }
141        return str;
142    }
[619]143
[837]144    /*
145     * (non-Javadoc)
146     *
[619]147     * @see java.lang.Object#toString()
148     */
149    @Override
150    public String toString() {
151        return super.getSpecification().toString();
152    }
153
[1490]154    /* (non-Javadoc)
155     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement)
156     */
157    @Override
158    public double getDistanceTo(IGUIElement otherElement) {
159        throw new UnsupportedOperationException("not implemented yet");
160    }
161
[619]162    /**
163     * <p>
[837]164     * Returns the XML representation of the GUI element.
[619]165     * </p>
[837]166     *
167     * @return the XML representation
[619]168     */
169    public String toXML() {
170        if (getParent() != null) {
[837]171            return ((MFCGUIElement) getParent()).toXML() +
[619]172                ((MFCGUIElementSpec) super.getSpecification()).toXML();
173        }
174        else {
175            return ((MFCGUIElementSpec) super.getSpecification()).toXML();
176        }
177    }
178}
Note: See TracBrowser for help on using the repository browser.