Ignore:
Timestamp:
09/10/12 20:52:49 (12 years ago)
Author:
fglaser
Message:
  • new helper class JFCReplayIDValidator added, that is able to extract all IDs from

GUITAR Gui file and to check if a given (generated) replayID is contained in this GUI file.

  • JFCReplayIDCalculator modified for test purposes (can be initialized with a Validator

to check if IDs that are generated "on the way" are valid)

  • Test Case extended for JFCReplayIDCalculator extended
  • extended guimapping for freemind
  • added new JFCReplayIDCalculator test ressources
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-plugin-jfc/src/main/java/de/ugoe/cs/quest/plugin/jfc/JFCReplayIDCalculator.java

    r796 r806  
    3030         
    3131        static final int prime = 31; 
     32        private JFCReplayIDValidator validator; 
     33         
     34        public JFCReplayIDCalculator() { 
     35                this.validator = null; 
     36        } 
     37         
     38        public JFCReplayIDCalculator(JFCReplayIDValidator validator){ 
     39                this.validator = validator; 
     40        } 
    3241         
    3342        /** 
     
    7382           long propagatedHashCode = windowHashCode; 
    7483            
    75            // construct looks complicated but avoids going back and force through path 
     84           // added validator to check if generated component ids are known 
     85           if (validator != null){ 
     86                   if (validator.validateReplayID("w" + windowHashCode)){ 
     87                           System.out.println("ID w" + windowHashCode + " is valid."); 
     88                   } 
     89                   else{ 
     90                           System.err.println(currentSpec + " describes an unknown component."); 
     91                           System.err.println("ID w" + windowHashCode + " is unknown." ); 
     92                           System.err.println(); 
     93                   } 
     94                            
     95           } 
     96            
     97           // construct looks complicated but avoids going back and forth through path 
    7698           if (iterator.hasNext()) 
    7799                   currentSpec = iterator.next(); 
    78            else 
     100           else{ 
    79101                   currentSpec = null; 
     102                   // there are no subcomponents, so we use windowHashCode as hashCode 
     103                   hashCode = windowHashCode; 
     104           } 
    80105 
    81106           // walk through component path and calculate hashcode 
     
    84109                   hashCode = propagatedHashCode * prime + localHashCode; 
    85110                   hashCode = (hashCode * 2) & 0xffffffffL; 
     111                    
     112                   // added validator to check if generated component ids are known 
     113                   if (validator != null){ 
     114                           if (validator.validateReplayID("w" + hashCode)){ 
     115                                   System.out.println("ID w" + hashCode + " is valid."); 
     116                           } 
     117                           else{ 
     118                                    System.err.println(currentSpec + " describes an unknown component."); 
     119                                        System.err.println("ID w" + hashCode + " is unknown." ); 
     120                                        System.err.println(); 
     121                           } 
     122                   } 
    86123 
    87124                   if (iterator.hasNext()){ 
     
    111148                 
    112149                IEventTarget target = event.getTarget(); 
    113                 JFCGUIElement jfcTarget = (JFCGUIElement) target; 
     150                if (!target.getPlatform().equals("JFC")){ 
     151                        throw new IllegalArgumentException("Event target must be of type JFC."); 
     152                } 
     153                 
     154                JFCGUIElement currentTarget = (JFCGUIElement) target; 
    114155                 
    115156                // extract element path 
    116                 JFCGUIElement currentTarget = jfcTarget; 
    117157                while (currentTarget != null){ 
    118158                        JFCGUIElementSpec currentSpec = (JFCGUIElementSpec) currentTarget.getSpecification(); 
     159                         
     160                        // new specification must be inserted at the beginning of the list 
    119161                        guiElementPath.add(0, currentSpec); 
    120162                        currentTarget = (JFCGUIElement) currentTarget.getParent(); 
Note: See TracChangeset for help on using the changeset viewer.