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