source: trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/HandlerCreate.java @ 1008

Last change on this file since 1008 was 1008, checked in by fglaser, 12 years ago
  • autoquest-plugin-mfc subproject refactored to use GUI element naming convention were appropriate
  • MFCWindowTree marked as deprecated (one should use generalized GUIElementTree instead)
File size: 3.9 KB
Line 
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
15package de.ugoe.cs.autoquest.plugin.mfc;
16
17import de.ugoe.cs.autoquest.eventcore.guimodel.GUIElementTree;
18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
19import de.ugoe.cs.autoquest.plugin.mfc.guimodel.MFCGUIElementSpec;
20
21/**
22 * <p>
23 * Message handler for {@code WM_CREATE} messages. The handler maintains the {@link GUIElementTree}.
24 * </p>
25 *
26 * @author Steffen Herbold
27 * @version 1.0
28 */
29public class HandlerCreate extends MessageHandler {
30
31    /**
32     * <p>
33     * Constructor. Creates a new HandlerCreate.
34     * </p>
35     *
36     * @param guiElementTree the tree of GUI element specifications to be created and adapted during
37     *                   parsing
38     */
39    public HandlerCreate(GUIElementTree guiElementTree) {
40        super(guiElementTree);
41    }
42
43    /**
44     * <p>
45     * Name of the created GUI element.
46     * </p>
47     */
48    private String guiElementName;
49
50    /**
51     * <p>
52     * HWND of the created GUI element.
53     * </p>
54     */
55    private long hwnd;
56
57    /**
58     * <p>
59     * HWND of the created GUI elements's parent.
60     * </p>
61     */
62    private long parentHwnd;
63
64    /**
65     * <p>
66     * Resource Id of the created element.
67     * </p>
68     */
69    private int resourceId;
70
71    /**
72     * <p>
73     * GUI element class of the created element.
74     * </p>
75     */
76    private String className;
77
78    /**
79     * <p>
80     * Modality of the created GUI element.
81     * </p>
82     */
83    private boolean isModal;
84
85    /*
86     * (non-Javadoc)
87     *
88     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onEndElement()
89     */
90    @Override
91    public void onEndElement() {
92        if (hwnd != 0) {
93                IGUIElementSpec spec = new MFCGUIElementSpec(hwnd, guiElementName, resourceId, className, isModal);
94            super.getGUIElementTree().add(hwnd, parentHwnd, spec);
95        }
96    }
97
98    /*
99     * (non-Javadoc)
100     *
101     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onParameter(java.lang.String ,
102     * java.lang.String)
103     */
104    @Override
105    public void onParameter(String name, String value) {
106        if (name.equals("window.hwnd")) {
107            hwnd = Long.parseLong(value);
108        }
109        else if (name.equals("window.name")) {
110            guiElementName = value;
111        }
112        else if (name.equals("window.parent.hwnd")) {
113            parentHwnd = Long.parseLong(value);
114        }
115        else if (name.equals("window.resourceId")) {
116            resourceId = Integer.parseInt(value);
117        }
118        else if (name.equals("window.class")) {
119            if (value.startsWith("Afx:")) {
120                className = "Afx:";
121            }
122            else {
123                className = value;
124            }
125        }
126        else if (name.equals("window.ismodal")) {
127            if (value.equals("true") || value.equals("1")) {
128                isModal = true;
129            }
130        }
131    }
132
133    /*
134     * (non-Javadoc)
135     *
136     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onStartElement()
137     */
138    @Override
139    public void onStartElement() {
140        guiElementName = "";
141        hwnd = 0;
142        parentHwnd = 0;
143        resourceId = 0;
144        className = "";
145        isModal = false;
146    }
147
148}
Note: See TracBrowser for help on using the repository browser.