Changeset 539


Ignore:
Timestamp:
08/15/12 12:20:43 (12 years ago)
Author:
fglaser
Message:
  • getFuzzyTitle method of JFCReplayIDCalculator updated. Now it mimics GUITARs

behavior.

File:
1 edited

Legend:

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

    r538 r539  
    66import java.util.List; 
    77import java.util.Map; 
     8import java.util.regex.Matcher; 
     9import java.util.regex.Pattern; 
    810 
    911import de.ugoe.cs.quest.plugin.jfc.eventcore.JFCEvent; 
     
    135137         * Guitar has a special way to deal with window titles when 
    136138         * calculating unique widget IDs. This method mimics Guitar's 
    137          * behavior (compare compare guitar source code: edu.umd.cs.guitar. 
     139         * behavior (compare guitar source code: edu.umd.cs.guitar. 
    138140         * model.JFCDefaultIDGeneratorSimple). 
    139141         * @param title 
    140142         * @return 
    141143         */ 
    142          
     144 
    143145        private String getFuzzyTitle(String title){ 
    144                 return ".*FreeMind.*"; 
    145         } 
     146                final List<String> PATTERNS =  
     147                                Arrays.asList("Rachota .*", 
     148                                                "OmegaT-.*", 
     149                                                "Buddi.*", 
     150                                                "Open:.*", 
     151                                                "JabRef.*", 
     152                                                "GanttProject.*", 
     153                                                ".*Pauker.*", 
     154                                                ".*FreeMind.*", 
     155                                                ".* - ArgoUML.*", 
     156                                                "Save Project .*"); 
     157 
     158 
     159                for (String sPattern : PATTERNS) { 
     160                        if (matchRegex(title, sPattern)) { 
     161                                return sPattern; 
     162                        } 
     163                } 
     164 
     165                return title; 
     166        } 
     167 
     168        /** 
     169         * Determine if the input string matches the input regex pattern. 
     170         * This method mimics Guitars behavior. 
     171         * Attempt to match the pattern 'sPattern' with the string 'sInputString'. 
     172 
     173         * @param sInputString    Input string to match with pattern 
     174         * @param sPattern        Regex pattern to match with string 
     175         * @return                True if match, false otherwise 
     176         */ 
     177        private static boolean 
     178        matchRegex(String sInputString, 
     179                        String sPattern) 
     180        { 
     181                Pattern pattern; 
     182                Matcher matcher; 
     183 
     184                pattern = Pattern.compile(sPattern); 
     185                matcher = pattern.matcher(sInputString); 
     186                if (matcher.matches()) { 
     187                        return true; 
     188                } 
     189 
     190                return false; 
     191        } 
     192         
     193        /** 
     194         * Extracts the index from a component string 
     195         * @param targetPart String that represents the component 
     196         * @return Index of the component 
     197         */ 
    146198         
    147199        private Integer getIndex(String targetPart){ 
     
    150202                if (index.equals("-1")) 
    151203                                throw new AssertionError("Index should only be -1 for components" + 
    152                                                 "that have no parents."); 
     204                                                "that have no parent."); 
    153205                 
    154206                return Integer.parseInt(index); 
Note: See TracChangeset for help on using the changeset viewer.