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