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

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