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.mfc.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 that represents GUI element in MFC GUIs.
|
---|
24 | * </p>
|
---|
25 | *
|
---|
26 | * @version 1.0
|
---|
27 | * @author Patrick Harms
|
---|
28 | */
|
---|
29 | public abstract class MFCGUIElement extends AbstractDefaultGUIElement {
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * <p>
|
---|
33 | * Id for object serialization.
|
---|
34 | * </p>
|
---|
35 | */
|
---|
36 | private static final long serialVersionUID = 1L;
|
---|
37 |
|
---|
38 | /**
|
---|
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
|
---|
48 | */
|
---|
49 | public MFCGUIElement(MFCGUIElementSpec specification, MFCGUIElement parent) {
|
---|
50 | super(specification, parent);
|
---|
51 | }
|
---|
52 |
|
---|
53 | /*
|
---|
54 | * (non-Javadoc)
|
---|
55 | *
|
---|
56 | * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
|
---|
57 | */
|
---|
58 | @Override
|
---|
59 | public String getPlatform() {
|
---|
60 | return "MFC";
|
---|
61 | }
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * <p>
|
---|
65 | * Returns the HWND (Id) of the GUI element.
|
---|
66 | * </p>
|
---|
67 | *
|
---|
68 | * @return the HWND (Id)
|
---|
69 | */
|
---|
70 | public String getId() {
|
---|
71 | return Long.toString(((MFCGUIElementSpec) super.getSpecification()).getHwnd());
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * <p>
|
---|
76 | * Returns the type of the GUI element.
|
---|
77 | * </p>
|
---|
78 | *
|
---|
79 | * @return the type
|
---|
80 | */
|
---|
81 | public String getType() {
|
---|
82 | return ((MFCGUIElementSpec) super.getSpecification()).getType();
|
---|
83 | }
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * <p>
|
---|
87 | * Returns the name of the GUI element.
|
---|
88 | * </p>
|
---|
89 | *
|
---|
90 | * @return the name
|
---|
91 | */
|
---|
92 | public String getName() {
|
---|
93 | return ((MFCGUIElementSpec) super.getSpecification()).getName();
|
---|
94 | }
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * <p>
|
---|
98 | * Returns the modality of the GUI element.
|
---|
99 | * </p>
|
---|
100 | *
|
---|
101 | * @return the modality
|
---|
102 | */
|
---|
103 | public boolean isModal() {
|
---|
104 | return ((MFCGUIElementSpec) super.getSpecification()).isModal();
|
---|
105 | }
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * <p>
|
---|
109 | * Returns the resource Id of the GUI element.
|
---|
110 | * </p>
|
---|
111 | *
|
---|
112 | * @return the resource Id
|
---|
113 | */
|
---|
114 | public int getResourceId() {
|
---|
115 | return ((MFCGUIElementSpec) super.getSpecification()).getResourceId();
|
---|
116 | }
|
---|
117 |
|
---|
118 | /*
|
---|
119 | * (non-Javadoc)
|
---|
120 | *
|
---|
121 | * @see
|
---|
122 | * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest.eventcore
|
---|
123 | * .guimodel.IGUIElementSpec)
|
---|
124 | */
|
---|
125 | @Override
|
---|
126 | public void updateSpecification(IGUIElementSpec furtherSpec) {
|
---|
127 | ((MFCGUIElementSpec) super.getSpecification()).update(furtherSpec);
|
---|
128 | }
|
---|
129 |
|
---|
130 | /*
|
---|
131 | * (non-Javadoc)
|
---|
132 | *
|
---|
133 | * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getStringIdentifier()
|
---|
134 | */
|
---|
135 | @Override
|
---|
136 | public String getStringIdentifier() {
|
---|
137 | String str = this.toString();
|
---|
138 | if (getParent() != null) {
|
---|
139 | return str + "<-" + getParent().getStringIdentifier();
|
---|
140 | }
|
---|
141 | return str;
|
---|
142 | }
|
---|
143 |
|
---|
144 | /*
|
---|
145 | * (non-Javadoc)
|
---|
146 | *
|
---|
147 | * @see java.lang.Object#toString()
|
---|
148 | */
|
---|
149 | @Override
|
---|
150 | public String toString() {
|
---|
151 | return super.getSpecification().toString();
|
---|
152 | }
|
---|
153 |
|
---|
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 |
|
---|
162 | /**
|
---|
163 | * <p>
|
---|
164 | * Returns the XML representation of the GUI element.
|
---|
165 | * </p>
|
---|
166 | *
|
---|
167 | * @return the XML representation
|
---|
168 | */
|
---|
169 | public String toXML() {
|
---|
170 | if (getParent() != null) {
|
---|
171 | return ((MFCGUIElement) getParent()).toXML() +
|
---|
172 | ((MFCGUIElementSpec) super.getSpecification()).toXML();
|
---|
173 | }
|
---|
174 | else {
|
---|
175 | return ((MFCGUIElementSpec) super.getSpecification()).toXML();
|
---|
176 | }
|
---|
177 | }
|
---|
178 | }
|
---|