source: trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/HandlerSetText.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: 2.8 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.plugin.mfc.guimodel.MFCGUIElement;
19import de.ugoe.cs.autoquest.plugin.mfc.guimodel.MFCGUIElementSpec;
20import de.ugoe.cs.autoquest.plugin.mfc.guimodel.MFCWindowTree;
21
22/**
23 * <p>
24 * Handles {@code WM_SETTEXT} messages. Handler maintains the {@link MFCWindowTree}.
25 * </p>
26 *
27 * @author Steffen Herbold
28 * @author Fabian Glaser
29 * @version 1.0
30 */
31public class HandlerSetText extends MessageHandler {
32
33    /**
34     * <p>
35     * Constructor. Creates a new HanderSetText.
36     * </p>
37     *
38     * @param guiElementTree
39     *            the tree of GUI element specifications to be created and adapted during parsing
40     */
41    public HandlerSetText(GUIElementTree guiElementTree) {
42        super(guiElementTree);
43    }
44
45    /**
46     * <p>
47     * New name of the window.
48     * </p>
49     */
50    private String windowName;
51
52    /**
53     * <p>
54     * HWND of the window.
55     * </p>
56     */
57    private long hwnd;
58
59    /*
60     * (non-Javadoc)
61     *
62     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onEndElement()
63     */
64    @Override
65    public void onEndElement() {
66        if (hwnd != 0) {
67                MFCGUIElement element = (MFCGUIElement) super.getGUIElementTree().find(hwnd);
68                MFCGUIElementSpec spec = (MFCGUIElementSpec) element.getSpecification();
69            spec.setName(windowName);
70        }
71    }
72
73    /*
74     * (non-Javadoc)
75     *
76     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onParameter(java.lang.String ,
77     * java.lang.String)
78     */
79    @Override
80    public void onParameter(String name, String value) {
81        if (name.equals("window.hwnd")) {
82            hwnd = Long.parseLong(value);
83        }
84        else if (name.equals("window.newText")) {
85            windowName = value;
86        }
87    }
88
89    /*
90     * (non-Javadoc)
91     *
92     * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onStartElement()
93     */
94    @Override
95    public void onStartElement() {
96        windowName = "";
97        hwnd = 0;
98    }
99}
Note: See TracBrowser for help on using the repository browser.