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