Ignore:
Timestamp:
08/27/12 11:45:09 (12 years ago)
Author:
pharms
Message:
  • adapted implementation to now generate a full GUI model as well as concrete GUI interaction events
Location:
trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/eventcore
Files:
3 added
5 deleted
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/eventcore/MFCEvent.java

    r578 r619  
     1 
    12package de.ugoe.cs.quest.plugin.mfc.eventcore; 
    23 
    3 import java.security.InvalidParameterException; 
    4 import java.util.HashMap; 
    5 import java.util.Map; 
    6  
    7 import de.ugoe.cs.quest.IReplayDecorator; 
    8 import de.ugoe.cs.quest.eventcore.IReplayable; 
    9 import de.ugoe.cs.quest.plugin.mfc.MFCReplayDecorator; 
    10 import de.ugoe.cs.util.StringTools; 
     4import de.ugoe.cs.quest.eventcore.Event; 
     5import de.ugoe.cs.quest.eventcore.IEventType; 
     6import de.ugoe.cs.quest.eventcore.guimodel.GUIModel; 
     7import de.ugoe.cs.quest.plugin.mfc.guimodel.MFCGUIElement; 
    118 
    129/** 
    1310 * <p> 
    14  * Contains all informations about a windows message, i.e., all parameters that 
    15  * are read when a windows message is parsed as well as its target, hwnd, etc. 
     11 * Contains all informations about a windows message, i.e., all parameters that are read when a 
     12 * windows message is parsed as well as its target, hwnd, etc. 
    1613 * </p> 
    1714 *  
     
    2017 *  
    2118 */ 
    22 public class WindowsMessage implements IReplayable { 
     19public class MFCEvent extends Event { 
    2320 
    24         /** 
    25         * <p> 
    26         * Id for object serialization. 
    27         * </p> 
    28         */ 
    29         private static final long serialVersionUID = 1L; 
     21    /** 
     22    * <p> 
     23    * Id for object serialization. 
     24    * </p> 
     25    */ 
     26    private static final long serialVersionUID = 1L; 
    3027 
    31         /** 
    32          * <p> 
    33          * Type of the message. 
    34          * </p> 
    35          */ 
    36         final int type; 
     28    /** 
     29     * <p> 
     30     * TODO: comment 
     31     * </p> 
     32     * 
     33     * @param eventType 
     34     * @param target 
     35     * @param currentMessageParameters 
     36     */ 
     37    public MFCEvent(IEventType    eventType, 
     38                    MFCGUIElement target, 
     39                    GUIModel      guiModel) 
     40    { 
     41        super(eventType); 
     42        super.setTarget(target); 
     43    } 
    3744 
    38         /** 
    39          * <p> 
    40          * Window class of the message target. Default: "" 
    41          * </p> 
    42          */ 
    43         private String windowClass = ""; 
    44  
    45         /** 
    46          * <p> 
    47          * Resource Id of the message target. Default: 0 
    48          * </p> 
    49          */ 
    50         private int resourceId = 0; 
    51  
    52         /** 
    53          * <p> 
    54          * XML representation of the message target. 
    55          * </p> 
    56          */ 
    57         private String xmlWindowDescription = ""; 
    58  
    59         /** 
    60          * <p> 
    61          * String that contains the names of all parent widgets and itself, separated by dots, 
    62          * e.g., "GrandParent.Parent.self". 
    63          * </p> 
    64          */ 
    65         private String parentNames = null; 
    66  
    67         /** 
    68          * <p> 
    69          * String that contains the window class of the parent widget. 
    70          * </p> 
    71          */ 
    72         private String parentClass = null; 
    73  
    74         /** 
    75          * <p> 
    76          * LPARAM of the message. Default: 0 
    77          * </p> 
    78          */ 
    79         private long LPARAM = 0; 
    80  
    81         /** 
    82          * <p> 
    83          * WPARAM of the message. Default: 0 
    84          * </p> 
    85          */ 
    86         private long WPARAM = 0; 
    87  
    88         /** 
    89          * <p> 
    90          * If the LPARAM contains a HWND, this string stores the target of the HWND. 
    91          * </p> 
    92          */ 
    93         private String LPARAMasWindowDesc = null; 
    94  
    95         /** 
    96          * <p> 
    97          * If the WPARAM contains a HWND, this string stores the target of the HWND. 
    98          * </p> 
    99          */ 
    100         private String WPARAMasWindowDesc = null; 
    101  
    102         /** 
    103          * <p> 
    104          * Delay after sending the messages during a replay. Default: 0 
    105          * </p> 
    106          */ 
    107         private int delay = 0; 
    108  
    109         /** 
    110          * <p> 
    111          * A map of all parameters, associated with the message, created during the 
    112          * parsing of messages from the logs {@code param}-nodes. 
    113          * </p> 
    114          */ 
    115         private Map<String, String> params = new HashMap<String, String>(); 
    116  
    117         /** 
    118          * <p> 
    119          * Constructor. Creates a new message with a given message type. 
    120          * </p> 
    121          *  
    122          * @param type 
    123          *            type of the message 
    124          */ 
    125         public WindowsMessage(int type) { 
    126                 this.type = type; 
    127         } 
    128  
    129         /** 
    130          * <p> 
    131          * Adds a parameter to the message. 
    132          * </p> 
    133          *  
    134          * @param type 
    135          *            type descriptor of the parameter 
    136          * @param value 
    137          *            value of the parameter 
    138          */ 
    139         public void addParameter(String type, String value) { 
    140                 params.put(type, value); 
    141                 if (type.equals("LPARAM")) { 
    142                         LPARAM = Long.parseLong(value); 
    143                 } else if (type.equals("WPARAM")) { 
    144                         WPARAM = Long.parseLong(value); 
    145                 } 
    146         } 
    147  
    148         /** 
    149          * <p> 
    150          * Returns the type of the message. 
    151          * </p> 
    152          *  
    153          * @return type of the message 
    154          */ 
    155         public int getType() { 
    156                 return type; 
    157         } 
    158  
    159         /** 
    160          * <p> 
    161          * Returns the value of a parameter, given its type. If the parameter is not 
    162          * found, {@code null} is returned. 
    163          * </p> 
    164          *  
    165          * @param type 
    166          *            type of the parameter 
    167          * @return value of the parameter 
    168          */ 
    169         public String getParameter(String type) { 
    170                 return params.get(type); 
    171         } 
    172  
    173         /** 
    174          * <p> 
    175          * Returns the window class of the message target. 
    176          * </p> 
    177          *  
    178          * @return window class of the message target 
    179          */ 
    180         public String getWindowClass() { 
    181                 return windowClass; 
    182         } 
    183  
    184         /** 
    185          * <p> 
    186          * Returns the HWND the message is addressed to. 
    187          * </p> 
    188          *  
    189          * @return HWND the message is addressed to 
    190          */ 
    191         public int getHwnd() { 
    192                 int hwnd = -1; 
    193                 String hwndString = getParameter("window.hwnd"); // possible, as 
    194                                                                                                                         // "window.hwnd" is 
    195                                                                                                                         // mandatory 
    196                 if (hwndString != null) { 
    197                         hwnd = Integer.parseInt(hwndString); 
    198                 } 
    199                 return hwnd; 
    200         } 
    201  
    202         /** 
    203          * <p> 
    204          * Returns the resource Id of the message target. 
    205          * </p> 
    206          *  
    207          * @return resource Id of the message target 
    208          */ 
    209         public int getWindowResourceId() { 
    210                 return resourceId; 
    211         } 
    212  
    213         /** 
    214          * <p> 
    215          * Two {@link WindowsMessage} are equal, if their {@link #type}, 
    216          * {@link #xmlWindowDescription}, and {@link #params} are equal. 
    217          * </p> 
    218          *  
    219          * @see java.lang.Object#equals(java.lang.Object) 
    220          */ 
    221         @Override 
    222         public boolean equals(Object other) { 
    223                 if (other == this) { 
    224                         return true; 
    225                 } 
    226                 boolean isEqual = false; 
    227                 if (other instanceof WindowsMessage) { 
    228                         isEqual = ((WindowsMessage) other).type == this.type 
    229                                         && ((WindowsMessage) other).xmlWindowDescription 
    230                                                         .equals(this.xmlWindowDescription) 
    231                                         && ((WindowsMessage) other).params.equals(this.params); 
    232                 } 
    233                 return isEqual; 
    234         } 
    235  
    236         /* 
    237          * (non-Javadoc) 
    238          *  
    239          * @see java.lang.Object#hashCode() 
    240          */ 
    241         @Override 
    242         public int hashCode() { 
    243                 int multiplier = 17; 
    244                 int hash = 42; 
    245  
    246                 hash = multiplier * hash + type; 
    247                 hash = multiplier * hash + xmlWindowDescription.hashCode(); 
    248                 hash = multiplier * hash + params.hashCode(); 
    249  
    250                 return hash; 
    251         } 
    252  
    253         /** 
    254          * <p> 
    255          * Returns a string representation of the message of the form 
    256          * "msg[target=HWND;type=TYPE]". 
    257          * </p> 
    258          *  
    259          * @see java.lang.Object#toString() 
    260          */ 
    261         @Override 
    262         public String toString() { 
    263                 return "msg[target=" + getParameter("window.hwnd") + ";type=" + type 
    264                                 + "]"; 
    265         } 
    266  
    267         /** 
    268          * <p> 
    269          * Retrieves the target string of a message from a given {@link WindowTree} 
    270          * through looking up the HWND the message is addressed to in the window 
    271          * tree. 
    272          * </p> 
    273          *  
    274          * @param windowTree 
    275          *            {@link WindowTree} from which the target is extracted 
    276          * @throws InvalidParameterException 
    277          *             thrown if HWND is not contained in windowTree 
    278          */ 
    279         public void setTarget(WindowTree windowTree) 
    280                         throws InvalidParameterException { 
    281                 int hwnd = Integer.parseInt(getParameter("window.hwnd")); 
    282                 WindowTreeNode node = windowTree.find(hwnd); 
    283                 if (node == null) { 
    284                         throw new InvalidParameterException("No window with HWND " + hwnd 
    285                                         + " found in window tree!"); 
    286                 } else { 
    287                         windowClass = node.getClassName(); 
    288                         resourceId = node.getResourceId(); 
    289                         xmlWindowDescription = node.xmlRepresentation(); 
    290                         parentNames = node.getParentNames(); 
    291                         WindowTreeNode parent = node.getParent(); 
    292                         if (parent == null) { 
    293                                 parentClass = ""; 
    294                         } else { 
    295                                 parentClass = parent.getClassName(); 
    296                         } 
    297                 } 
    298         } 
    299  
    300         /** 
    301          * <p> 
    302          * Sets the LPARAM of a message. 
    303          * </p> 
    304          *  
    305          * @param paramValue 
    306          *            value of the LPARAM 
    307          */ 
    308         public void setLPARAM(long paramValue) { 
    309                 LPARAM = paramValue; 
    310         } 
    311  
    312         /** 
    313          * <p> 
    314          * Sets the WPARAM of a message. 
    315          * </p> 
    316          *  
    317          * @param paramValue 
    318          *            value of the WPARAM 
    319          */ 
    320         public void setWPARAM(long paramValue) { 
    321                 WPARAM = paramValue; 
    322         } 
    323  
    324         /** 
    325          * <p> 
    326          * Returns the LPARAM of a message. 
    327          * </p> 
    328          *  
    329          * @return LPARAM of the message 
    330          */ 
    331         public long getLPARAM() { 
    332                 return LPARAM; 
    333         } 
    334  
    335         /** 
    336          * <p> 
    337          * Returns the WPARAM of a message. 
    338          * </p> 
    339          *  
    340          * @return WPARAM of the message 
    341          */ 
    342         public long getWPARAM() { 
    343                 return WPARAM; 
    344         } 
    345  
    346         /** 
    347          * <p> 
    348          * If the LPARAM contains a HWND, this function can be used to set a target 
    349          * string to identify the HWND at run-time. 
    350          * </p> 
    351          *  
    352          * @param windowDesc 
    353          *            target string 
    354          */ 
    355         public void setLPARAMasWindowDesc(String windowDesc) { 
    356                 LPARAMasWindowDesc = windowDesc; 
    357         } 
    358  
    359         /** 
    360          * <p> 
    361          * If the WPARAM contains a HWND, this function can be used to set a target 
    362          * string to identify the HWND at run-time. 
    363          * </p> 
    364          *  
    365          * @param windowDesc 
    366          *            target string 
    367          */ 
    368         public void setWPARAMasWindowDesc(String windowDesc) { 
    369                 WPARAMasWindowDesc = windowDesc; 
    370         } 
    371  
    372         /** 
    373          * <p> 
    374          * If the LPARAM contains a HWND and the target string for the HWND is set, 
    375          * this function returns the target string. Otherwise, {@code null} is 
    376          * returned. 
    377          * </p> 
    378          *  
    379          * @return target string if available; {@code null} otherwise 
    380          */ 
    381         public String getLPARAMasWindowDesc() { 
    382                 return LPARAMasWindowDesc; 
    383         } 
    384  
    385         /** 
    386          * <p> 
    387          * If the WPARAM contains a HWND and the target string for the HWND is set, 
    388          * this function returns the target string. Otherwise, {@code null} is 
    389          * returned. 
    390          * </p> 
    391          *  
    392          * @return target string if available; {@code null} otherwise 
    393          */ 
    394         public String getWPARAMasWindowDesc() { 
    395                 return WPARAMasWindowDesc; 
    396         } 
    397  
    398         /** 
    399          * <p> 
    400          * Returns the target string of the message. 
    401          * </p> 
    402          *  
    403          * @return target string of the message 
    404          */ 
    405         public String getXmlWindowDescription() { 
    406                 return xmlWindowDescription; 
    407         } 
    408  
    409         /** 
    410          * <p> 
    411          * Sets the target string manually. 
    412          * </p> 
    413          *  
    414          * @param xmlWindowDescription 
    415          *            target string 
    416          */ 
    417         public void setXmlWindowDescription(String xmlWindowDescription) { 
    418                 this.xmlWindowDescription = xmlWindowDescription; 
    419         } 
    420  
    421         /** 
    422          * <p> 
    423          * Returns the delay after this message during replays. 
    424          * </p> 
    425          *  
    426          * @return delay after this message 
    427          */ 
    428         public int getDelay() { 
    429                 return delay; 
    430         } 
    431  
    432         /** 
    433          * <p> 
    434          * Sets the delay after this message during replays. 
    435          * </p> 
    436          *  
    437          * @param delay 
    438          *            delay after this message 
    439          */ 
    440         public void setDelay(int delay) { 
    441                 this.delay = delay; 
    442         } 
    443  
    444         /** 
    445          * <p> 
    446          * Returns the parent names separated by dots, e.g., "GrandParent.Parent". 
    447          * </p> 
    448          *  
    449          * @return names of the parents 
    450          */ 
    451         public String getParentNames() { 
    452                 return parentNames; 
    453         } 
    454  
    455         /** 
    456          * <p> 
    457          * Returns the window class of the parent. 
    458          * </p> 
    459          *  
    460          * @return window classes of the parents 
    461          */ 
    462         public String getParentClass() { 
    463                 return parentClass; 
    464         } 
    465  
    466         /** 
    467          * <p> 
    468          * Returns the number of parameters stored together with this message. 
    469          * </p> 
    470          *  
    471          * @return number of parameters stored with this message 
    472          */ 
    473         public int getNumParams() { 
    474                 return params.size(); 
    475         } 
    476  
    477         /* 
    478          * (non-Javadoc) 
    479          *  
    480          * @see de.ugoe.cs.quest.eventcore.IReplayable#getReplay() 
    481          */ 
    482         @Override 
    483         public String getReplay() { 
    484                 StringBuilder currentMsgStr = new StringBuilder(400); 
    485                 currentMsgStr.append("  <msg type=\"" + type + "\" "); 
    486                 currentMsgStr.append("LPARAM=\"" + LPARAM + "\" "); 
    487                 currentMsgStr.append("WPARAM=\"" + WPARAM + "\" "); 
    488                 currentMsgStr.append("delay=\"" + delay + "\">"); 
    489                 if (LPARAMasWindowDesc != null) { 
    490                         currentMsgStr.append(StringTools.ENDLINE); 
    491                         currentMsgStr.append("   <LPARAM>"); 
    492                         currentMsgStr.append(StringTools.ENDLINE); 
    493                         currentMsgStr.append(LPARAMasWindowDesc); 
    494                         currentMsgStr.append(StringTools.ENDLINE); 
    495                         currentMsgStr.append("</LPARAM>"); 
    496                 } 
    497                 if (WPARAMasWindowDesc != null) { 
    498                         currentMsgStr.append(StringTools.ENDLINE); 
    499                         currentMsgStr.append("   <WPARAM>"); 
    500                         currentMsgStr.append(StringTools.ENDLINE); 
    501                         currentMsgStr.append(WPARAMasWindowDesc); 
    502                         currentMsgStr.append(StringTools.ENDLINE); 
    503                         currentMsgStr.append("   </WPARAM>"); 
    504                 } 
    505                 currentMsgStr.append(StringTools.ENDLINE); 
    506                 currentMsgStr.append(xmlWindowDescription); 
    507                 currentMsgStr.append(StringTools.ENDLINE); 
    508                 currentMsgStr.append("  </msg>"); 
    509                 currentMsgStr.append(StringTools.ENDLINE); 
    510                 return currentMsgStr.toString(); 
    511         } 
    512  
    513     /* (non-Javadoc) 
    514      * @see de.ugoe.cs.quest.eventcore.IReplayable#getDecorator() 
     45    /** 
     46     * <p> 
     47     * Two {@link WindowsMessage} are equal, if their {@link #type}, {@link #xmlWindowDescription}, 
     48     * and {@link #params} are equal. 
     49     * </p> 
     50     *  
     51     * @see java.lang.Object#equals(java.lang.Object) 
    51552     */ 
    51653    @Override 
    517     public IReplayDecorator getDecorator() { 
    518         return MFCReplayDecorator.getInstance(); 
     54    public boolean equals(Object other) { 
     55        if (other == this) { 
     56            return true; 
     57        } 
     58        boolean isEqual = false; 
     59        if (other instanceof MFCEvent) { 
     60            isEqual = 
     61                ((MFCEvent) other).type == this.type && 
     62                ((MFCEvent) other).target.equals(this.target); 
     63        } 
     64        return isEqual; 
    51965    } 
     66 
     67    /* 
     68     * (non-Javadoc) 
     69     *  
     70     * @see java.lang.Object#hashCode() 
     71     */ 
     72    @Override 
     73    public int hashCode() { 
     74        int multiplier = 17; 
     75        int hash = 42; 
     76 
     77        hash = multiplier * hash + type.hashCode(); 
     78        hash = multiplier * hash + target.hashCode(); 
     79 
     80        return hash; 
     81    } 
     82 
    52083} 
  • trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/eventcore/MFCEventType.java

    r566 r619  
    1  
     1// Module    : $RCSfile: MFCEventType.java,v $ 
     2// Version   : $Revision: 0.0 $  $Author: pharms $  $Date: 21.08.2012 $ 
     3// Project   : quest-plugin-mfc 
     4// Creation  : 2012 by pharms 
     5// Copyright : Patrick Harms, 2012 
    26package de.ugoe.cs.quest.plugin.mfc.eventcore; 
    37 
     
    913 * </p> 
    1014 *  
    11  * @version $Revision: $ $Date: Aug 17, 2012$ 
    12  * @author 2012, last modified by $Author: sherbold$ 
     15 * @version $Revision: $ $Date: 21.08.2012$ 
     16 * @author 2012, last modified by $Author: pharms$ 
    1317 */ 
    1418public class MFCEventType implements IEventType { 
    1519 
    16     /**  */ 
     20    /** */ 
    1721    private static final long serialVersionUID = 1L; 
     22     
     23    /** */ 
     24    private WindowsMessageType messageType; 
    1825 
    19     private final String typeString; 
    20      
    21     private String info = null; 
    22  
    23     public MFCEventType(String typeString) { 
    24         this.typeString = typeString; 
    25     } 
    26      
    27     public void setInfo(String info) { 
    28         this.info = info; 
     26    /** 
     27     * <p> 
     28     * TODO: comment 
     29     * </p> 
     30     * 
     31     * @param currentMessageType 
     32     */ 
     33    public MFCEventType(WindowsMessageType messageType) { 
     34        this.messageType = messageType; 
    2935    } 
    3036 
    31     /* 
    32      * (non-Javadoc) 
    33      *  
     37    /* (non-Javadoc) 
    3438     * @see de.ugoe.cs.quest.eventcore.IEventType#getName() 
    3539     */ 
    3640    @Override 
    3741    public String getName() { 
    38         return "MFCEventType"; 
    39     } 
    40  
    41     /* 
    42      * (non-Javadoc) 
    43      *  
    44      * @see java.lang.Object#toString() 
    45      */ 
    46     @Override 
    47     public String toString() { 
    48         String str = typeString; 
    49         if( info!=null ) { 
    50             str += "." + info; 
    51         } 
    52         return str; 
     42        return messageType.name(); 
    5343    } 
    5444 
  • trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/eventcore/WindowsMessage.java

    r566 r619  
     1 
    12package de.ugoe.cs.quest.plugin.mfc.eventcore; 
    23 
    3 import java.security.InvalidParameterException; 
    44import java.util.HashMap; 
    55import java.util.Map; 
    66 
    7 import de.ugoe.cs.quest.IReplayDecorator; 
    8 import de.ugoe.cs.quest.eventcore.IReplayable; 
    9 import de.ugoe.cs.quest.plugin.mfc.MFCReplayDecorator; 
    10 import de.ugoe.cs.util.StringTools; 
     7import de.ugoe.cs.quest.plugin.mfc.guimodel.MFCGUIElement; 
    118 
    129/** 
    1310 * <p> 
    14  * Contains all informations about a windows message, i.e., all parameters that 
    15  * are read when a windows message is parsed as well as its target, hwnd, etc. 
     11 * Contains all informations about a windows message, i.e., all parameters that are read when a 
     12 * windows message is parsed as well as its target, hwnd, etc. 
    1613 * </p> 
    1714 *  
     
    2017 *  
    2118 */ 
    22 public class WindowsMessage implements IReplayable { 
    23  
    24         /** 
    25          * <p> 
    26          * Id for object serialization. 
    27          * </p> 
    28          */ 
    29         private static final long serialVersionUID = 1L; 
    30  
    31         /** 
    32          * <p> 
    33          * Type of the message. 
    34          * </p> 
    35          */ 
    36         final int type; 
    37  
    38         /** 
    39          * <p> 
    40          * Window class of the message target. Default: "" 
    41          * </p> 
    42          */ 
    43         private String windowClass = ""; 
    44  
    45         /** 
    46          * <p> 
    47          * Resource Id of the message target. Default: 0 
    48          * </p> 
    49          */ 
    50         private int resourceId = 0; 
    51  
    52         /** 
    53          * <p> 
    54          * XML representation of the message target. 
    55          * </p> 
    56          */ 
    57         private String xmlWindowDescription = ""; 
    58  
    59         /** 
    60          * <p> 
    61          * String that contains the names of all parent widgets and itself, separated by dots, 
    62          * e.g., "GrandParent.Parent.self". 
    63          * </p> 
    64          */ 
    65         private String parentNames = null; 
    66  
    67         /** 
    68          * <p> 
    69          * String that contains the window class of the parent widget. 
    70          * </p> 
    71          */ 
    72         private String parentClass = null; 
    73  
    74         /** 
    75          * <p> 
    76          * LPARAM of the message. Default: 0 
    77          * </p> 
    78          */ 
    79         private long LPARAM = 0; 
    80  
    81         /** 
    82          * <p> 
    83          * WPARAM of the message. Default: 0 
    84          * </p> 
    85          */ 
    86         private long WPARAM = 0; 
    87  
    88         /** 
    89          * <p> 
    90          * If the LPARAM contains a HWND, this string stores the target of the HWND. 
    91          * </p> 
    92          */ 
    93         private String LPARAMasWindowDesc = null; 
    94  
    95         /** 
    96          * <p> 
    97          * If the WPARAM contains a HWND, this string stores the target of the HWND. 
    98          * </p> 
    99          */ 
    100         private String WPARAMasWindowDesc = null; 
    101  
    102         /** 
    103          * <p> 
    104          * Delay after sending the messages during a replay. Default: 0 
    105          * </p> 
    106          */ 
    107         private int delay = 0; 
    108  
    109         /** 
    110          * <p> 
    111          * A map of all parameters, associated with the message, created during the 
    112          * parsing of messages from the logs {@code param}-nodes. 
    113          * </p> 
    114          */ 
    115         private Map<String, String> params = new HashMap<String, String>(); 
    116  
    117         /** 
    118          * <p> 
    119          * Constructor. Creates a new message with a given message type. 
    120          * </p> 
    121          *  
    122          * @param type 
    123          *            type of the message 
    124          */ 
    125         public WindowsMessage(int type) { 
    126                 this.type = type; 
    127         } 
    128  
    129         /** 
    130          * <p> 
    131          * Adds a parameter to the message. 
    132          * </p> 
    133          *  
    134          * @param type 
    135          *            type descriptor of the parameter 
    136          * @param value 
    137          *            value of the parameter 
    138          */ 
    139         public void addParameter(String type, String value) { 
    140                 params.put(type, value); 
    141                 if (type.equals("LPARAM")) { 
    142                         LPARAM = Long.parseLong(value); 
    143                 } else if (type.equals("WPARAM")) { 
    144                         WPARAM = Long.parseLong(value); 
    145                 } 
    146         } 
    147  
    148         /** 
    149          * <p> 
    150          * Returns the type of the message. 
    151          * </p> 
    152          *  
    153          * @return type of the message 
    154          */ 
    155         public int getType() { 
    156                 return type; 
    157         } 
    158  
    159         /** 
    160          * <p> 
    161          * Returns the value of a parameter, given its type. If the parameter is not 
    162          * found, {@code null} is returned. 
    163          * </p> 
    164          *  
    165          * @param type 
    166          *            type of the parameter 
    167          * @return value of the parameter 
    168          */ 
    169         public String getParameter(String type) { 
    170                 return params.get(type); 
    171         } 
    172  
    173         /** 
    174          * <p> 
    175          * Returns the window class of the message target. 
    176          * </p> 
    177          *  
    178          * @return window class of the message target 
    179          */ 
    180         public String getWindowClass() { 
    181                 return windowClass; 
    182         } 
    183  
    184         /** 
    185          * <p> 
    186          * Returns the HWND the message is addressed to. 
    187          * </p> 
    188          *  
    189          * @return HWND the message is addressed to 
    190          */ 
    191         public int getHwnd() { 
    192                 int hwnd = -1; 
    193                 String hwndString = getParameter("window.hwnd"); // possible, as 
    194                                                                                                                         // "window.hwnd" is 
    195                                                                                                                         // mandatory 
    196                 if (hwndString != null) { 
    197                         hwnd = Integer.parseInt(hwndString); 
    198                 } 
    199                 return hwnd; 
    200         } 
    201  
    202         /** 
    203          * <p> 
    204          * Returns the resource Id of the message target. 
    205          * </p> 
    206          *  
    207          * @return resource Id of the message target 
    208          */ 
    209         public int getWindowResourceId() { 
    210                 return resourceId; 
    211         } 
    212  
    213         /** 
    214          * <p> 
    215          * Two {@link WindowsMessage} are equal, if their {@link #type}, 
    216          * {@link #xmlWindowDescription}, and {@link #params} are equal. 
    217          * </p> 
    218          *  
    219          * @see java.lang.Object#equals(java.lang.Object) 
    220          */ 
    221         @Override 
    222         public boolean equals(Object other) { 
    223                 if (other == this) { 
    224                         return true; 
    225                 } 
    226                 boolean isEqual = false; 
    227                 if (other instanceof WindowsMessage) { 
    228                         isEqual = ((WindowsMessage) other).type == this.type 
    229                                         && ((WindowsMessage) other).xmlWindowDescription 
    230                                                         .equals(this.xmlWindowDescription) 
    231                                         && ((WindowsMessage) other).params.equals(this.params); 
    232                 } 
    233                 return isEqual; 
    234         } 
    235  
    236         /* 
    237          * (non-Javadoc) 
    238          *  
    239          * @see java.lang.Object#hashCode() 
    240          */ 
    241         @Override 
    242         public int hashCode() { 
    243                 int multiplier = 17; 
    244                 int hash = 42; 
    245  
    246                 hash = multiplier * hash + type; 
    247                 hash = multiplier * hash + xmlWindowDescription.hashCode(); 
    248                 hash = multiplier * hash + params.hashCode(); 
    249  
    250                 return hash; 
    251         } 
    252  
    253         /** 
    254          * <p> 
    255          * Returns a string representation of the message of the form 
    256          * "msg[target=HWND;type=TYPE]". 
    257          * </p> 
    258          *  
    259          * @see java.lang.Object#toString() 
    260          */ 
    261         @Override 
    262         public String toString() { 
    263                 return "msg[target=" + getParameter("window.hwnd") + ";type=" + type 
    264                                 + "]"; 
    265         } 
    266  
    267         /** 
    268          * <p> 
    269          * Retrieves the target string of a message from a given {@link WindowTree} 
    270          * through looking up the HWND the message is addressed to in the window 
    271          * tree. 
    272          * </p> 
    273          *  
    274          * @param windowTree 
    275          *            {@link WindowTree} from which the target is extracted 
    276          * @throws InvalidParameterException 
    277          *             thrown if HWND is not contained in windowTree 
    278          */ 
    279         public void setTarget(WindowTree windowTree) 
    280                         throws InvalidParameterException { 
    281                 int hwnd = Integer.parseInt(getParameter("window.hwnd")); 
    282                 WindowTreeNode node = windowTree.find(hwnd); 
    283                 if (node == null) { 
    284                         throw new InvalidParameterException("No window with HWND " + hwnd 
    285                                         + " found in window tree!"); 
    286                 } else { 
    287                         windowClass = node.getClassName(); 
    288                         resourceId = node.getResourceId(); 
    289                         xmlWindowDescription = node.xmlRepresentation(); 
    290                         parentNames = node.getParentNames(); 
    291                         WindowTreeNode parent = node.getParent(); 
    292                         if (parent == null) { 
    293                                 parentClass = ""; 
    294                         } else { 
    295                                 parentClass = parent.getClassName(); 
    296                         } 
    297                 } 
    298         } 
    299  
    300         /** 
    301          * <p> 
    302          * Sets the LPARAM of a message. 
    303          * </p> 
    304          *  
    305          * @param paramValue 
    306          *            value of the LPARAM 
    307          */ 
    308         public void setLPARAM(long paramValue) { 
    309                 LPARAM = paramValue; 
    310         } 
    311  
    312         /** 
    313          * <p> 
    314          * Sets the WPARAM of a message. 
    315          * </p> 
    316          *  
    317          * @param paramValue 
    318          *            value of the WPARAM 
    319          */ 
    320         public void setWPARAM(long paramValue) { 
    321                 WPARAM = paramValue; 
    322         } 
    323  
    324         /** 
    325          * <p> 
    326          * Returns the LPARAM of a message. 
    327          * </p> 
    328          *  
    329          * @return LPARAM of the message 
    330          */ 
    331         public long getLPARAM() { 
    332                 return LPARAM; 
    333         } 
    334  
    335         /** 
    336          * <p> 
    337          * Returns the WPARAM of a message. 
    338          * </p> 
    339          *  
    340          * @return WPARAM of the message 
    341          */ 
    342         public long getWPARAM() { 
    343                 return WPARAM; 
    344         } 
    345  
    346         /** 
    347          * <p> 
    348          * If the LPARAM contains a HWND, this function can be used to set a target 
    349          * string to identify the HWND at run-time. 
    350          * </p> 
    351          *  
    352          * @param windowDesc 
    353          *            target string 
    354          */ 
    355         public void setLPARAMasWindowDesc(String windowDesc) { 
    356                 LPARAMasWindowDesc = windowDesc; 
    357         } 
    358  
    359         /** 
    360          * <p> 
    361          * If the WPARAM contains a HWND, this function can be used to set a target 
    362          * string to identify the HWND at run-time. 
    363          * </p> 
    364          *  
    365          * @param windowDesc 
    366          *            target string 
    367          */ 
    368         public void setWPARAMasWindowDesc(String windowDesc) { 
    369                 WPARAMasWindowDesc = windowDesc; 
    370         } 
    371  
    372         /** 
    373          * <p> 
    374          * If the LPARAM contains a HWND and the target string for the HWND is set, 
    375          * this function returns the target string. Otherwise, {@code null} is 
    376          * returned. 
    377          * </p> 
    378          *  
    379          * @return target string if available; {@code null} otherwise 
    380          */ 
    381         public String getLPARAMasWindowDesc() { 
    382                 return LPARAMasWindowDesc; 
    383         } 
    384  
    385         /** 
    386          * <p> 
    387          * If the WPARAM contains a HWND and the target string for the HWND is set, 
    388          * this function returns the target string. Otherwise, {@code null} is 
    389          * returned. 
    390          * </p> 
    391          *  
    392          * @return target string if available; {@code null} otherwise 
    393          */ 
    394         public String getWPARAMasWindowDesc() { 
    395                 return WPARAMasWindowDesc; 
    396         } 
    397  
    398         /** 
    399          * <p> 
    400          * Returns the target string of the message. 
    401          * </p> 
    402          *  
    403          * @return target string of the message 
    404          */ 
    405         public String getXmlWindowDescription() { 
    406                 return xmlWindowDescription; 
    407         } 
    408  
    409         /** 
    410          * <p> 
    411          * Sets the target string manually. 
    412          * </p> 
    413          *  
    414          * @param xmlWindowDescription 
    415          *            target string 
    416          */ 
    417         public void setXmlWindowDescription(String xmlWindowDescription) { 
    418                 this.xmlWindowDescription = xmlWindowDescription; 
    419         } 
    420  
    421         /** 
    422          * <p> 
    423          * Returns the delay after this message during replays. 
    424          * </p> 
    425          *  
    426          * @return delay after this message 
    427          */ 
    428         public int getDelay() { 
    429                 return delay; 
    430         } 
    431  
    432         /** 
    433          * <p> 
    434          * Sets the delay after this message during replays. 
    435          * </p> 
    436          *  
    437          * @param delay 
    438          *            delay after this message 
    439          */ 
    440         public void setDelay(int delay) { 
    441                 this.delay = delay; 
    442         } 
    443  
    444         /** 
    445          * <p> 
    446          * Returns the parent names separated by dots, e.g., "GrandParent.Parent". 
    447          * </p> 
    448          *  
    449          * @return names of the parents 
    450          */ 
    451         public String getParentNames() { 
    452                 return parentNames; 
    453         } 
    454  
    455         /** 
    456          * <p> 
    457          * Returns the window class of the parent. 
    458          * </p> 
    459          *  
    460          * @return window classes of the parents 
    461          */ 
    462         public String getParentClass() { 
    463                 return parentClass; 
    464         } 
    465  
    466         /** 
    467          * <p> 
    468          * Returns the number of parameters stored together with this message. 
    469          * </p> 
    470          *  
    471          * @return number of parameters stored with this message 
    472          */ 
    473         public int getNumParams() { 
    474                 return params.size(); 
    475         } 
    476  
    477         /* 
    478          * (non-Javadoc) 
    479          *  
    480          * @see de.ugoe.cs.quest.eventcore.IReplayable#getReplay() 
    481          */ 
    482         @Override 
    483         public String getReplay() { 
    484                 StringBuilder currentMsgStr = new StringBuilder(400); 
    485                 currentMsgStr.append("  <msg type=\"" + type + "\" "); 
    486                 currentMsgStr.append("LPARAM=\"" + LPARAM + "\" "); 
    487                 currentMsgStr.append("WPARAM=\"" + WPARAM + "\" "); 
    488                 currentMsgStr.append("delay=\"" + delay + "\">"); 
    489                 if (LPARAMasWindowDesc != null) { 
    490                         currentMsgStr.append(StringTools.ENDLINE); 
    491                         currentMsgStr.append("   <LPARAM>"); 
    492                         currentMsgStr.append(StringTools.ENDLINE); 
    493                         currentMsgStr.append(LPARAMasWindowDesc); 
    494                         currentMsgStr.append(StringTools.ENDLINE); 
    495                         currentMsgStr.append("</LPARAM>"); 
    496                 } 
    497                 if (WPARAMasWindowDesc != null) { 
    498                         currentMsgStr.append(StringTools.ENDLINE); 
    499                         currentMsgStr.append("   <WPARAM>"); 
    500                         currentMsgStr.append(StringTools.ENDLINE); 
    501                         currentMsgStr.append(WPARAMasWindowDesc); 
    502                         currentMsgStr.append(StringTools.ENDLINE); 
    503                         currentMsgStr.append("   </WPARAM>"); 
    504                 } 
    505                 currentMsgStr.append(StringTools.ENDLINE); 
    506                 currentMsgStr.append(xmlWindowDescription); 
    507                 currentMsgStr.append(StringTools.ENDLINE); 
    508                 currentMsgStr.append("  </msg>"); 
    509                 currentMsgStr.append(StringTools.ENDLINE); 
    510                 return currentMsgStr.toString(); 
    511         } 
    512  
    513     /* (non-Javadoc) 
    514      * @see de.ugoe.cs.quest.eventcore.IReplayable#getDecorator() 
     19public class WindowsMessage { 
     20 
     21    /** 
     22     * <p> 
     23     * Type of the message. 
     24     * </p> 
     25     */ 
     26    final WindowsMessageType type; 
     27 
     28    /** 
     29     * <p> 
     30     * LPARAM of the message. Default: 0 
     31     * </p> 
     32     */ 
     33    private long LPARAM = 0; 
     34 
     35    /** 
     36     * <p> 
     37     * WPARAM of the message. Default: 0 
     38     * </p> 
     39     */ 
     40    private long WPARAM = 0; 
     41 
     42    /** 
     43     * <p> 
     44     * A map of all parameters, associated with the message, created during the parsing of messages 
     45     * from the logs {@code param}-nodes. 
     46     * </p> 
     47     */ 
     48    private Map<String, Object> params = new HashMap<String, Object>(); 
     49 
     50    /** 
     51     * <p> 
     52     * the target GUI element to which the message was sent 
     53     * </p> 
     54     */ 
     55    private MFCGUIElement target; 
     56 
     57    /** 
     58     * <p> 
     59     * an XML representation of the target to preserve it as it was when this message was created 
     60     * </p> 
     61     */ 
     62    protected String targetXML; 
     63 
     64    /** 
     65     * <p> 
     66     * Constructor. Creates a new message with a given message type. 
     67     * </p> 
     68     *  
     69     * @param type 
     70     *            type of the message 
     71     * @param currentMessageParameters  
     72     * @param target  
     73     */ 
     74    public WindowsMessage(WindowsMessageType  type, 
     75                          MFCGUIElement       target, 
     76                          Map<String, Object> messageParameters) 
     77    { 
     78        this.type = type; 
     79        setTarget(target); 
     80         
     81        for (Map.Entry<String, Object> entry : messageParameters.entrySet()) { 
     82            addParameter(entry.getKey(), entry.getValue()); 
     83        } 
     84    } 
     85 
     86    /** 
     87     * <p> 
     88     * Constructor. Creates a new message with a given message type. 
     89     * </p> 
     90     *  
     91     * @param type 
     92     *            type of the message 
     93     */ 
     94    public WindowsMessage(WindowsMessageType type) 
     95    { 
     96        this.type = type; 
     97    } 
     98 
     99    /** 
     100     * <p> 
     101     * Adds a parameter to the message. 
     102     * </p> 
     103     *  
     104     * @param type 
     105     *            type descriptor of the parameter 
     106     * @param value 
     107     *            value of the parameter 
     108     */ 
     109    public void addParameter(String type, Object value) { 
     110        params.put(type, value); 
     111        if (type.equals("LPARAM")) { 
     112            LPARAM = (Long) value; 
     113        } 
     114        else if (type.equals("WPARAM")) { 
     115            WPARAM = (Long) value; 
     116        } 
     117    } 
     118 
     119    /** 
     120     * <p> 
     121     * Returns the type of the message. 
     122     * </p> 
     123     *  
     124     * @return type of the message 
     125     */ 
     126    public WindowsMessageType getType() { 
     127        return type; 
     128    } 
     129 
     130    /** 
     131     * <p> 
     132     * TODO: comment 
     133     * </p> 
     134     * 
     135     * @param target2 
     136     */ 
     137    public void setTarget(MFCGUIElement target) { 
     138        this.target = target; 
     139        this.targetXML = target.toXML(); 
     140    } 
     141 
     142    /** 
     143     * <p> 
     144     * TODO: comment 
     145     * </p> 
     146     * 
     147     * @return 
     148     */ 
     149    public MFCGUIElement getTarget() { 
     150        return target; 
     151    } 
     152     
     153    /** 
     154     * <p> 
     155     * Returns the value of a parameter, given its type. If the parameter is not found, {@code null} 
     156     * is returned. 
     157     * </p> 
     158     *  
     159     * @param type 
     160     *            type of the parameter 
     161     * @return value of the parameter 
     162     */ 
     163    public Object getParameter(String type) { 
     164        return params.get(type); 
     165    } 
     166 
     167    /** 
     168     * <p> 
     169     * Two {@link WindowsMessage} are equal, if their {@link #type}, {@link #xmlWindowDescription}, 
     170     * and {@link #params} are equal. 
     171     * </p> 
     172     *  
     173     * @see java.lang.Object#equals(java.lang.Object) 
    515174     */ 
    516175    @Override 
    517     public IReplayDecorator getDecorator() { 
    518         return MFCReplayDecorator.getInstance(); 
    519     } 
     176    public boolean equals(Object other) { 
     177        if (other == this) { 
     178            return true; 
     179        } 
     180        boolean isEqual = false; 
     181        if (other instanceof WindowsMessage) { 
     182            isEqual = 
     183                ((WindowsMessage) other).type == this.type && 
     184                ((WindowsMessage) other).target.equals(this.target) && 
     185                ((WindowsMessage) other).params.equals(this.params); 
     186        } 
     187        return isEqual; 
     188    } 
     189 
     190    /* 
     191     * (non-Javadoc) 
     192     *  
     193     * @see java.lang.Object#hashCode() 
     194     */ 
     195    @Override 
     196    public int hashCode() { 
     197        int multiplier = 17; 
     198        int hash = 42; 
     199 
     200        hash = multiplier * hash + type.hashCode(); 
     201        hash = multiplier * hash + target.hashCode(); 
     202        hash = multiplier * hash + params.hashCode(); 
     203 
     204        return hash; 
     205    } 
     206 
     207    /** 
     208     * <p> 
     209     * Returns a string representation of the message of the form "msg[target=HWND;type=TYPE]". 
     210     * </p> 
     211     *  
     212     * @see java.lang.Object#toString() 
     213     */ 
     214    @Override 
     215    public String toString() { 
     216        return "msg[target=" + getParameter("window.hwnd") + ";type=" + type + "]"; 
     217    } 
     218 
     219    /** 
     220     * <p> 
     221     * Returns the LPARAM of a message. 
     222     * </p> 
     223     *  
     224     * @return LPARAM of the message 
     225     */ 
     226    public long getLPARAM() { 
     227        return LPARAM; 
     228    } 
     229 
     230    /** 
     231     * <p> 
     232     * Returns the WPARAM of a message. 
     233     * </p> 
     234     *  
     235     * @return WPARAM of the message 
     236     */ 
     237    public long getWPARAM() { 
     238        return WPARAM; 
     239    } 
     240 
     241    /** 
     242     * <p> 
     243     * Returns the number of parameters stored together with this message. 
     244     * </p> 
     245     *  
     246     * @return number of parameters stored with this message 
     247     */ 
     248    public int getNumParams() { 
     249        return params.size(); 
     250    } 
     251 
     252    /** 
     253     * <p> 
     254     * TODO: comment 
     255     * </p> 
     256     * 
     257     * @return 
     258     */ 
     259    protected Map<String, Object> getParameters() { 
     260        return params; 
     261    } 
     262 
     263    /** 
     264     * <p> 
     265     * TODO: comment 
     266     * </p> 
     267     * 
     268     * @return 
     269     */ 
     270    public String getTargetXML() { 
     271        return targetXML; 
     272    } 
     273 
    520274} 
  • trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/eventcore/WindowsMessageType.java

    r578 r619  
     1// Module    : $RCSfile: MessageType.java,v $ 
     2// Version   : $Revision: 0.0 $  $Author: Patrick $  $Date: 26.11.2011 14:36:45 $ 
     3// Project   : TaskTreePerformanceTest 
     4// Creation  : 2011 by Patrick 
     5// Copyright : Patrick Harms, 2011 
    16 
    27package de.ugoe.cs.quest.plugin.mfc.eventcore; 
    38 
    4 import de.ugoe.cs.quest.eventcore.IEventType; 
    5  
    69/** 
    7  * <p> 
    810 * TODO comment 
    9  * </p> 
    1011 *  
    11  * @version $Revision: $ $Date: Aug 17, 2012$ 
    12  * @author 2012, last modified by $Author: sherbold$ 
     12 * @version $Revision: $ $Date: $ 
     13 * @author 2011, last modified by $Author: $ 
    1314 */ 
    14 public class MFCEventType implements IEventType { 
    15  
    16     /**  */ 
    17     private static final long serialVersionUID = 1L; 
    18  
    19     private final String typeString; 
     15public enum WindowsMessageType { 
    2016     
    21     private String info = null; 
    22  
    23     public MFCEventType(String typeString) { 
    24         this.typeString = typeString; 
    25     } 
    26      
    27     public void setInfo(String info) { 
    28         this.info = info; 
    29     } 
    30  
    31     /* 
    32      * (non-Javadoc) 
     17    WM_NULL(0), 
     18    WM_CREATE(1), 
     19    WM_DESTROY(2), 
     20    WM_MOVE(3), 
     21    WM_SIZE(5), 
     22    WM_ACTIVATE(6), 
     23    WM_SETFOCUS(7), 
     24    WM_KILLFOCUS(8), 
     25    WM_ENABLE(10), 
     26    WM_SETREDRAW(11), 
     27    WM_SETTEXT(12), 
     28    WM_GETTEXT(13), 
     29    WM_GETTEXTLENGTH(14), 
     30    WM_PAINT(15), 
     31    WM_CLOSE(16), 
     32    WM_QUERYENDSESSION(17), 
     33    WM_QUIT(18), 
     34    WM_QUERYOPEN(19), 
     35    WM_ERASEBKGND(20), 
     36    WM_SYSCOLORCHANGE(21), 
     37    WM_ENDSESSION(22), 
     38    WM_SHOWWINDOW(24), 
     39    WM_CTLCOLOR(25), 
     40    WM_WININICHANGE(26), 
     41    WM_DEVMODECHANGE(27), 
     42    WM_ACTIVATEAPP(28), 
     43    WM_FONTCHANGE(29), 
     44    WM_TIMECHANGE(30), 
     45    WM_CANCELMODE(31), 
     46    WM_SETCURSOR(32), 
     47    WM_MOUSEACTIVATE(33), 
     48    WM_CHILDACTIVATE(34), 
     49    WM_QUEUESYNC(35), 
     50    WM_GETMINMAXINFO(36), 
     51    WM_PAINTICON(38), 
     52    WM_ICONERASEBKGND(39), 
     53    WM_NEXTDLGCTL(40), 
     54    WM_SPOOLERSTATUS(42), 
     55    WM_DRAWITEM(43), 
     56    WM_MEASUREITEM(44), 
     57    WM_DELETEITEM(45), 
     58    WM_VKEYTOITEM(46), 
     59    WM_CHARTOITEM(47), 
     60    WM_SETFONT(48), 
     61    WM_GETFONT(49), 
     62    WM_SETHOTKEY(50), 
     63    WM_GETHOTKEY(51), 
     64    WM_QUERYDRAGICON(55), 
     65    WM_COMPAREITEM(57), 
     66    WM_GETOBJECT(61), 
     67    WM_COMPACTING(65), 
     68    WM_COMMNOTIFY(68), 
     69    WM_WINDOWPOSCHANGING(70), 
     70    WM_WINDOWPOSCHANGED(71), 
     71    WM_POWER(72), 
     72    WM_COPYDATA(74), 
     73    WM_CANCELJOURNAL(75), 
     74    WM_NOTIFY(78), 
     75    WM_INPUTLANGCHANGEREQUEST(80), 
     76    WM_INPUTLANGCHANGE(81), 
     77    WM_TCARD(82), 
     78    WM_HELP(83), 
     79    WM_USERCHANGED(84), 
     80    WM_NOTIFYFORMAT(85), 
     81    WM_CONTEXTMENU(123), 
     82    WM_STYLECHANGING(124), 
     83    WM_STYLECHANGED(125), 
     84    WM_DISPLAYCHANGE(126), 
     85    WM_GETICON(127), 
     86    WM_SETICON(128), 
     87    WM_NCCREATE(129), 
     88    WM_NCDESTROY(130), 
     89    WM_NCCALCSIZE(131), 
     90    WM_NCHITTEST(132), 
     91    WM_NCPAINT(133), 
     92    WM_NCACTIVATE(134), 
     93    WM_GETDLGCODE(135), 
     94    WM_SYNCPAINT(136), 
     95    WM_NCMOUSEMOVE(160), 
     96    WM_NCLBUTTONDOWN(161), 
     97    WM_NCLBUTTONUP(162), 
     98    WM_NCLBUTTONDBLCLK(163), 
     99    WM_NCRBUTTONDOWN(164), 
     100    WM_NCRBUTTONUP(165), 
     101    WM_NCRBUTTONDBLCLK(166), 
     102    WM_NCMBUTTONDOWN(167), 
     103    WM_NCMBUTTONUP(168), 
     104    WM_NCMBUTTONDBLCLK(169), 
     105    WM_NCXBUTTONDOWN(171), 
     106    WM_NCXBUTTONUP(172), 
     107    WM_NCXBUTTONDBLCLK(173), 
     108    SBM_SETPOS(224), 
     109    BM_CLICK(245), 
     110    WM_INPUT(255), 
     111    WM_KEYDOWN(256), 
     112    WM_KEYFIRST(256), 
     113    WM_KEYUP(257), 
     114    WM_CHAR(258), 
     115    WM_DEADCHAR(259), 
     116    WM_SYSKEYDOWN(260), 
     117    WM_SYSKEYUP(261), 
     118    WM_SYSCHAR(262), 
     119    WM_SYSDEADCHAR(263), 
     120    WM_KEYLAST(264), 
     121    WM_WNT_CONVERTREQUESTEX(265), 
     122    WM_CONVERTREQUEST(266), 
     123    WM_CONVERTRESULT(267), 
     124    WM_INTERIM(268), 
     125    WM_IME_STARTCOMPOSITION(269), 
     126    WM_IME_ENDCOMPOSITION(270), 
     127    WM_IME_COMPOSITION(271), 
     128    WM_IME_KEYLAST(271), 
     129    WM_INITDIALOG(272), 
     130    WM_COMMAND(273), 
     131    WM_SYSCOMMAND(274), 
     132    WM_TIMER(275), 
     133    WM_HSCROLL(276), 
     134    WM_VSCROLL(277), 
     135    WM_INITMENU(278), 
     136    WM_INITMENUPOPUP(279), 
     137    WM_MENUSELECT(287), 
     138    WM_MENUCHAR(288), 
     139    WM_ENTERIDLE(289), 
     140    WM_MENURBUTTONUP(290), 
     141    WM_MENUDRAG(291), 
     142    WM_MENUGETOBJECT(292), 
     143    WM_UNINTMENUPOPUP(293), 
     144    WM_MENUCOMMAND(294), 
     145    WM_CHANGEUISTATE(295), 
     146    WM_UPDATEUISTATE(296), 
     147    WM_QUERYUISTATE(297), 
     148    WM_CTLCOLORMSGBOX(306), 
     149    WM_CTLCOLOREDIT(307), 
     150    WM_CTLCOLORLISTBOX(308), 
     151    WM_CTLCOLORBTN(309), 
     152    WM_CTLCOLORDLG(310), 
     153    WM_CTLCOLORSCROLLBAR(311), 
     154    WM_CTLCOLORSTATIC(312), 
     155    CB_SHOWDROPDOWN(335), 
     156    LB_SETCURSEL(390), 
     157    WM_MOUSEFIRST(512), 
     158    WM_MOUSEMOVE(512), 
     159    WM_LBUTTONDOWN(513), 
     160    WM_LBUTTONUP(514), 
     161    WM_LBUTTONDBLCLK(515), 
     162    WM_RBUTTONDOWN(516), 
     163    WM_RBUTTONUP(517), 
     164    WM_RBUTTONDBLCLK(518), 
     165    WM_MBUTTONDOWN(519), 
     166    WM_MBUTTONUP(520), 
     167    WM_MBUTTONDBLCLK(521), 
     168    WM_MOUSELAST(521), 
     169    WM_MOUSEWHEEL(522), 
     170    WM_XBUTTONDOWN(523), 
     171    WM_XBUTTONUP(524), 
     172    WM_XBUTTONDBLCLK(525), 
     173    WM_USER(1024), 
     174    CB_SETCURSEL(334), 
     175    TBM_SETPOS(1029), 
     176    UDM_SETRANGE(1125), 
     177    TCM_SETCURSEL(4876); 
     178 
     179    /** the numerical representation of the message type */ 
     180    private int mNumber; 
     181 
     182    /** 
     183     * @param number 
     184     */ 
     185    WindowsMessageType(int number) { 
     186        mNumber = number; 
     187    } 
     188 
     189    /** 
     190     * @return Returns the number. 
     191     */ 
     192    public int getNumber() { 
     193        return mNumber; 
     194    } 
     195 
     196    /** 
     197     * <p> 
     198     * Checks if the type of a message generated is a keyboard interaction. 
     199     * </p> 
    33200     *  
    34      * @see de.ugoe.cs.quest.eventcore.IEventType#getName() 
    35      */ 
    36     @Override 
    37     public String getName() { 
    38         return "MFCEventType"; 
    39     } 
    40  
    41     /* 
    42      * (non-Javadoc) 
     201     * @param msgType 
     202     *            type of the message 
     203     * @return true if it is a keyboard interaction; false otherwise 
     204     */ 
     205    public boolean isKeyMessage() { 
     206        boolean isKeyMsg = false; 
     207        switch (this) 
     208        { 
     209            case WM_KEYDOWN: 
     210            case WM_KEYUP: 
     211            case WM_SYSKEYDOWN: 
     212            case WM_SYSKEYUP: 
     213                isKeyMsg = true; 
     214                break; 
     215            default: 
     216                break; 
     217        } 
     218        return isKeyMsg; 
     219    } 
     220 
     221    /** 
     222     * <p> 
     223     * Checks if the type of a message indicates that the mouse has been pressed down. 
     224     * </p> 
    43225     *  
    44      * @see java.lang.Object#toString() 
    45      */ 
    46     @Override 
    47     public String toString() { 
    48         String str = typeString; 
    49         if( info!=null ) { 
    50             str += "." + info; 
    51         } 
    52         return str; 
    53     } 
    54  
     226     * @param msgType 
     227     *            type of the message 
     228     * @return true if it is mouse-down message; false otherwise 
     229     */ 
     230    public boolean isDownMessage() { 
     231        boolean isDownMsg = false; 
     232        switch (this) 
     233        { 
     234            case WM_LBUTTONDOWN: 
     235            case WM_RBUTTONDOWN: 
     236            case WM_MBUTTONDOWN: 
     237            case WM_XBUTTONDOWN: 
     238            case WM_NCLBUTTONDOWN: 
     239            case WM_NCRBUTTONDOWN: 
     240            case WM_NCMBUTTONDOWN: 
     241            case WM_NCXBUTTONDOWN: 
     242                isDownMsg = true; 
     243                break; 
     244            default: 
     245                break; 
     246        } 
     247        return isDownMsg; 
     248    } 
     249 
     250    /** 
     251     * <p> 
     252     * Checks if the type of a message indicates that a double click has been performed. 
     253     * </p> 
     254     *  
     255     * @param msgType 
     256     *            type of the message 
     257     * @return true if it is a double click message; false otherwise 
     258     */ 
     259    public boolean isDblclkMessage() { 
     260        boolean isDblclkMsg = false; 
     261        switch (this) 
     262        { 
     263            case WM_LBUTTONDBLCLK: 
     264            case WM_RBUTTONDBLCLK: 
     265            case WM_MBUTTONDBLCLK: 
     266            case WM_XBUTTONDBLCLK: 
     267            case WM_NCLBUTTONDBLCLK: 
     268            case WM_NCRBUTTONDBLCLK: 
     269            case WM_NCMBUTTONDBLCLK: 
     270            case WM_NCXBUTTONDBLCLK: 
     271                isDblclkMsg = true; 
     272                break; 
     273            default: 
     274                break; 
     275        } 
     276        return isDblclkMsg; 
     277    } 
     278 
     279    /** 
     280     * <p> 
     281     * Checks if the type of a message indicates that the mouse has been released. 
     282     * </p> 
     283     *  
     284     * @param msgType 
     285     *            type of the message 
     286     * @return true if it is mouse-up message; false otherwise 
     287     */ 
     288    public boolean isUpMessage() { 
     289        boolean isUpMsg = false; 
     290        switch (this) 
     291        { 
     292            case WM_LBUTTONUP: 
     293            case WM_RBUTTONUP: 
     294            case WM_MBUTTONUP: 
     295            case WM_XBUTTONUP: 
     296            case WM_NCLBUTTONUP: 
     297            case WM_NCRBUTTONUP: 
     298            case WM_NCMBUTTONUP: 
     299            case WM_NCXBUTTONUP: 
     300                isUpMsg = true; 
     301                break; 
     302            default: 
     303                break; 
     304        } 
     305        return isUpMsg; 
     306    } 
     307 
     308    /** 
     309     * 
     310     */ 
     311    public static WindowsMessageType parseMessageType(String numberString) { 
     312        try { 
     313            int number = Integer.parseInt(numberString); 
     314            return valueOf(number); 
     315        } 
     316        catch (NumberFormatException e) { 
     317            return WindowsMessageType.valueOf(WindowsMessageType.class, numberString); 
     318        } 
     319    } 
     320 
     321    /** 
     322     * 
     323     */ 
     324    public static WindowsMessageType valueOf(int number) { 
     325        for (WindowsMessageType type : WindowsMessageType.values()) { 
     326            if (type.mNumber == number) { 
     327                return type; 
     328            } 
     329        } 
     330 
     331        throw new IllegalArgumentException("there is no message type with number " + number); 
     332    } 
    55333} 
Note: See TracChangeset for help on using the changeset viewer.