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