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

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