|
Lines 13-18
Link Here
|
| 13 |
import java.io.*; |
13 |
import java.io.*; |
| 14 |
import java.lang.ref.WeakReference; |
14 |
import java.lang.ref.WeakReference; |
| 15 |
import java.util.*; |
15 |
import java.util.*; |
|
|
16 |
import java.util.regex.*; |
| 16 |
import org.eclipse.core.internal.runtime.RuntimeLog; |
17 |
import org.eclipse.core.internal.runtime.RuntimeLog; |
| 17 |
import org.eclipse.core.runtime.*; |
18 |
import org.eclipse.core.runtime.*; |
| 18 |
import org.eclipse.core.runtime.preferences.*; |
19 |
import org.eclipse.core.runtime.preferences.*; |
|
Lines 773-781
Link Here
|
| 773 |
return true; |
774 |
return true; |
| 774 |
} else { |
775 |
} else { |
| 775 |
// otherwise check to see if we have any applicable keys |
776 |
// otherwise check to see if we have any applicable keys |
|
|
777 |
for (int k = 0; k < entries.length; k++) { |
| 778 |
if (entries[k] != null && entries[k].isRegexp()) |
| 779 |
internalMatchesWithRegexp(entries[k], child.keys(), entries[k].getKey()); |
| 780 |
} |
| 776 |
for (int j = 0; j < entries.length; j++) { |
781 |
for (int j = 0; j < entries.length; j++) { |
| 777 |
if (entries[j] != null && child.get(entries[j].getKey(), null) != null) |
782 |
if (entries[j] != null) { |
| 778 |
return true; |
783 |
if (!entries[j].isRegexp() && child.get(entries[j].getKey(), null) != null) |
|
|
784 |
return true; |
| 785 |
else if (entries[j].isRegexp()) { |
| 786 |
if (entries[j].getMatches() != null) |
| 787 |
return true; |
| 788 |
} |
| 789 |
} |
| 779 |
} |
790 |
} |
| 780 |
} |
791 |
} |
| 781 |
} |
792 |
} |
|
Lines 785-790
Link Here
|
| 785 |
} |
796 |
} |
| 786 |
|
797 |
|
| 787 |
/* |
798 |
/* |
|
|
799 |
* Internal method that collects the matching preferences for the given regular expression. |
| 800 |
*/ |
| 801 |
private void internalMatchesWithRegexp(PreferenceFilterEntry entry, String[] keys, String exp) { |
| 802 |
if (keys == null || keys.length == 0 || exp == null || exp.length() == 0) |
| 803 |
return; |
| 804 |
Pattern pattern = null; |
| 805 |
try { |
| 806 |
pattern = Pattern.compile(exp); |
| 807 |
} catch (PatternSyntaxException e) { |
| 808 |
log(new Status(IStatus.ERROR, Activator.PI_PREFERENCES, PrefsMessages.preferences_regexpError, e)); |
| 809 |
} |
| 810 |
if (pattern == null) |
| 811 |
return; |
| 812 |
for (int i = 0; i < keys.length; i++) { |
| 813 |
Matcher matcher = pattern.matcher(keys[i]); |
| 814 |
if (matcher.find()) { |
| 815 |
entry.addMatch(keys[i]); |
| 816 |
} |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 820 |
/* |
| 788 |
* Internal method that collects the matching filters for the given tree and returns them. |
821 |
* Internal method that collects the matching filters for the given tree and returns them. |
| 789 |
*/ |
822 |
*/ |
| 790 |
private IPreferenceFilter[] internalMatches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException { |
823 |
private IPreferenceFilter[] internalMatches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException { |
|
Lines 973-980
Link Here
|
| 973 |
if (entries != null) { |
1006 |
if (entries != null) { |
| 974 |
ArrayList list = new ArrayList(); |
1007 |
ArrayList list = new ArrayList(); |
| 975 |
for (int j = 0; j < entries.length; j++) { |
1008 |
for (int j = 0; j < entries.length; j++) { |
| 976 |
if (entries[j] != null) |
1009 |
if (entries[j] != null) { |
| 977 |
list.add(entries[j].getKey()); |
1010 |
if (!entries[j].isRegexp()) |
|
|
1011 |
list.add(entries[j].getKey()); |
| 1012 |
else if (entries[j].getMatches() != null) { |
| 1013 |
Object[] matches = entries[j].getMatches(); |
| 1014 |
for (int k = 0; k < matches.length; k++) { |
| 1015 |
list.add(matches[k]); |
| 1016 |
} |
| 1017 |
} |
| 1018 |
} |
| 978 |
} |
1019 |
} |
| 979 |
keys = (String[]) list.toArray(new String[list.size()]); |
1020 |
keys = (String[]) list.toArray(new String[list.size()]); |
| 980 |
} |
1021 |
} |