source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/HandlerCreate.java @ 145

Last change on this file since 145 was 145, checked in by jhall, 13 years ago

added storing of all hwnd in GlobalDataContainer?

File size: 2.2 KB
Line 
1package de.ugoe.cs.eventbench.windows;
2
3import java.util.ArrayList;
4import java.util.List;
5
6import de.ugoe.cs.eventbench.data.GlobalDataContainer;
7import de.ugoe.cs.eventbench.windows.data.WindowTree;
8import de.ugoe.cs.util.console.Console;
9
10public class HandlerCreate extends MessageHandler {
11
12        public HandlerCreate() {
13                super();
14        }
15
16        private String windowName;
17        private int hwnd;
18        private int parentHwnd;
19        private int resourceId;
20        private String className;
21        private boolean isModal;
22       
23        @SuppressWarnings("unchecked")
24        @Override
25        public void onEndElement() {
26                if( hwnd!=0 ) {
27                        WindowTree.getInstance().add(parentHwnd, hwnd, windowName, resourceId, className, isModal);
28                       
29                        //store hwnd in GlobalDataContainer to be able to work on with them in DlgInsert
30                        List<String> listTargets = new ArrayList<String>();
31                       
32                        if(GlobalDataContainer.getInstance().getData("ListTargets") == null) {
33                                GlobalDataContainer.getInstance().addData("ListTargets", listTargets);
34                        }               
35                       
36                        try {
37                                listTargets = (List<String>) GlobalDataContainer.getInstance().getData("ListTargets");
38                        }
39                        catch (ClassCastException e) {
40                                Console.println("Not able to cast data in GlobalDataContainer to list of targets (String)");
41                        }
42                       
43                        listTargets.add(WindowTree.getInstance().find(hwnd).xmlRepresentation());
44                }
45        }
46
47        @Override
48        public void onParameter(String name, String value) {
49                if( name.equals("window.hwnd") ) {
50                        hwnd = Integer.parseInt(value);
51                }
52                else if( name.equals("window.name") ) {
53                        windowName = value;
54                }
55                else if( name.equals("window.parent.hwnd") ) {
56                        parentHwnd = Integer.parseInt(value);
57                }
58                else if( name.equals("window.resourceId") ) {
59                        resourceId = Integer.parseInt(value);
60                }
61                else if( name.equals("window.class") ) {
62                        if( value.startsWith("Afx:") ) {
63                                className = "Afx:";
64                        } else {
65                                className = value;
66                        }
67                }
68                else if( name.equals("window.ismodal") ) {
69                        if( value.equals("true") || value.equals("1") ) {
70                                isModal = true;
71                        }
72                }
73        }
74
75        @Override
76        public void onStartElement() {
77                windowName = "";
78                hwnd = 0;
79                parentHwnd = 0;
80                resourceId = 0;
81                className = "";
82                isModal = false;
83        }
84
85}
Note: See TracBrowser for help on using the repository browser.