[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.eventcore.guimodel.IGUIElementSpec;
|
---|
| 19 | import de.ugoe.cs.autoquest.plugin.mfc.guimodel.MFCGUIElementSpec;
|
---|
[1] | 20 |
|
---|
[171] | 21 | /**
|
---|
| 22 | * <p>
|
---|
[1008] | 23 | * Message handler for {@code WM_CREATE} messages. The handler maintains the {@link GUIElementTree}.
|
---|
[171] | 24 | * </p>
|
---|
| 25 | *
|
---|
| 26 | * @author Steffen Herbold
|
---|
| 27 | * @version 1.0
|
---|
| 28 | */
|
---|
[1] | 29 | public class HandlerCreate extends MessageHandler {
|
---|
| 30 |
|
---|
[619] | 31 | /**
|
---|
| 32 | * <p>
|
---|
| 33 | * Constructor. Creates a new HandlerCreate.
|
---|
| 34 | * </p>
|
---|
| 35 | *
|
---|
[1006] | 36 | * @param guiElementTree the tree of GUI element specifications to be created and adapted during
|
---|
[619] | 37 | * parsing
|
---|
| 38 | */
|
---|
[1006] | 39 | public HandlerCreate(GUIElementTree guiElementTree) {
|
---|
| 40 | super(guiElementTree);
|
---|
[619] | 41 | }
|
---|
[1] | 42 |
|
---|
[619] | 43 | /**
|
---|
| 44 | * <p>
|
---|
[1008] | 45 | * Name of the created GUI element.
|
---|
[619] | 46 | * </p>
|
---|
| 47 | */
|
---|
[1008] | 48 | private String guiElementName;
|
---|
[171] | 49 |
|
---|
[619] | 50 | /**
|
---|
| 51 | * <p>
|
---|
[1008] | 52 | * HWND of the created GUI element.
|
---|
[619] | 53 | * </p>
|
---|
| 54 | */
|
---|
| 55 | private long hwnd;
|
---|
[171] | 56 |
|
---|
[619] | 57 | /**
|
---|
| 58 | * <p>
|
---|
[1008] | 59 | * HWND of the created GUI elements's parent.
|
---|
[619] | 60 | * </p>
|
---|
| 61 | */
|
---|
| 62 | private long parentHwnd;
|
---|
[171] | 63 |
|
---|
[619] | 64 | /**
|
---|
| 65 | * <p>
|
---|
[1008] | 66 | * Resource Id of the created element.
|
---|
[619] | 67 | * </p>
|
---|
| 68 | */
|
---|
| 69 | private int resourceId;
|
---|
[171] | 70 |
|
---|
[619] | 71 | /**
|
---|
| 72 | * <p>
|
---|
[1008] | 73 | * GUI element class of the created element.
|
---|
[619] | 74 | * </p>
|
---|
| 75 | */
|
---|
| 76 | private String className;
|
---|
[171] | 77 |
|
---|
[619] | 78 | /**
|
---|
| 79 | * <p>
|
---|
[1008] | 80 | * Modality of the created GUI element.
|
---|
[619] | 81 | * </p>
|
---|
| 82 | */
|
---|
| 83 | private boolean isModal;
|
---|
[171] | 84 |
|
---|
[619] | 85 | /*
|
---|
| 86 | * (non-Javadoc)
|
---|
| 87 | *
|
---|
[922] | 88 | * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onEndElement()
|
---|
[619] | 89 | */
|
---|
| 90 | @Override
|
---|
| 91 | public void onEndElement() {
|
---|
| 92 | if (hwnd != 0) {
|
---|
[1008] | 93 | IGUIElementSpec spec = new MFCGUIElementSpec(hwnd, guiElementName, resourceId, className, isModal);
|
---|
[1006] | 94 | super.getGUIElementTree().add(hwnd, parentHwnd, spec);
|
---|
[619] | 95 | }
|
---|
| 96 | }
|
---|
[1] | 97 |
|
---|
[619] | 98 | /*
|
---|
| 99 | * (non-Javadoc)
|
---|
| 100 | *
|
---|
[922] | 101 | * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onParameter(java.lang.String ,
|
---|
[619] | 102 | * java.lang.String)
|
---|
| 103 | */
|
---|
| 104 | @Override
|
---|
| 105 | public void onParameter(String name, String value) {
|
---|
| 106 | if (name.equals("window.hwnd")) {
|
---|
| 107 | hwnd = Long.parseLong(value);
|
---|
| 108 | }
|
---|
| 109 | else if (name.equals("window.name")) {
|
---|
[1008] | 110 | guiElementName = value;
|
---|
[619] | 111 | }
|
---|
| 112 | else if (name.equals("window.parent.hwnd")) {
|
---|
| 113 | parentHwnd = Long.parseLong(value);
|
---|
| 114 | }
|
---|
| 115 | else if (name.equals("window.resourceId")) {
|
---|
| 116 | resourceId = Integer.parseInt(value);
|
---|
| 117 | }
|
---|
| 118 | else if (name.equals("window.class")) {
|
---|
| 119 | if (value.startsWith("Afx:")) {
|
---|
| 120 | className = "Afx:";
|
---|
| 121 | }
|
---|
| 122 | else {
|
---|
| 123 | className = value;
|
---|
| 124 | }
|
---|
| 125 | }
|
---|
| 126 | else if (name.equals("window.ismodal")) {
|
---|
| 127 | if (value.equals("true") || value.equals("1")) {
|
---|
| 128 | isModal = true;
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | }
|
---|
[1] | 132 |
|
---|
[619] | 133 | /*
|
---|
| 134 | * (non-Javadoc)
|
---|
| 135 | *
|
---|
[922] | 136 | * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onStartElement()
|
---|
[619] | 137 | */
|
---|
| 138 | @Override
|
---|
| 139 | public void onStartElement() {
|
---|
[1008] | 140 | guiElementName = "";
|
---|
[619] | 141 | hwnd = 0;
|
---|
| 142 | parentHwnd = 0;
|
---|
| 143 | resourceId = 0;
|
---|
| 144 | className = "";
|
---|
| 145 | isModal = false;
|
---|
| 146 | }
|
---|
[1] | 147 |
|
---|
| 148 | }
|
---|