Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 208564 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/preferences/PreferencesService.java (-4 / +45 lines)
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
					}
(-)src/org/eclipse/core/internal/preferences/messages.properties (+1 lines)
Lines 34-36 Link Here
34
preferences_saveProblems=Problems saving preferences.
34
preferences_saveProblems=Problems saving preferences.
35
preferences_validate=Some preferences may not be compatible with the currently installed plug-ins.
35
preferences_validate=Some preferences may not be compatible with the currently installed plug-ins.
36
preferences_validationException=Exception while validating bundle versions.
36
preferences_validationException=Exception while validating bundle versions.
37
preferences_regexpError=Error occurred while searching preferences which match some regular expression
(-)src/org/eclipse/core/internal/preferences/PrefsMessages.java (+1 lines)
Lines 47-52 Link Here
47
	public static String preferences_saveProblems;
47
	public static String preferences_saveProblems;
48
	public static String preferences_validate;
48
	public static String preferences_validate;
49
	public static String preferences_validationException;
49
	public static String preferences_validationException;
50
	public static String preferences_regexpError;
50
51
51
	static {
52
	static {
52
		// load message values from bundle file
53
		// load message values from bundle file
(-)src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java (+55 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.core.runtime.preferences;
11
package org.eclipse.core.runtime.preferences;
12
12
13
import java.util.HashSet;
14
13
/**
15
/**
14
 * Class which represents and preference filter entry to be used during preference
16
 * Class which represents and preference filter entry to be used during preference
15
 * import/export (for example).
17
 * import/export (for example).
Lines 21-26 Link Here
21
public final class PreferenceFilterEntry {
23
public final class PreferenceFilterEntry {
22
24
23
	private String key;
25
	private String key;
26
	private HashSet matches;
27
	boolean isRegexp;
24
28
25
	/**
29
	/**
26
	 * Constructor for the class. Create a new preference filter entry with the given 
30
	 * Constructor for the class. Create a new preference filter entry with the given 
Lines 33-38 Link Here
33
		if (key == null || key.length() == 0)
37
		if (key == null || key.length() == 0)
34
			throw new IllegalArgumentException();
38
			throw new IllegalArgumentException();
35
		this.key = key;
39
		this.key = key;
40
		this.isRegexp = false;
41
	}
42
43
	/**
44
	 * Constructor for the class. Create a new preference filter entry with the given 
45
	 * key and value of regexp flag. The key must <em>not</em> be <code>null</code> or empty. 
46
	 * 
47
	 * @param key the name of the preference key
48
	 * @param regexp flag shows how name is used:  
49
	 *        "true" - as regular expression, "false" - exactly
50
	 */
51
	public PreferenceFilterEntry(String key, boolean isRegexp) {
52
		super();
53
		if (key == null || key.length() == 0)
54
			throw new IllegalArgumentException();
55
		this.key = key;
56
		this.isRegexp = isRegexp;
36
	}
57
	}
37
58
38
	/**
59
	/**
Lines 45-48 Link Here
45
	public String getKey() {
66
	public String getKey() {
46
		return key;
67
		return key;
47
	}
68
	}
69
70
	/**
71
	 * Return regular expression flag.
72
	 * 
73
	 * @return the regular expression flag
74
	 */
75
	public boolean isRegexp() {
76
		return isRegexp;
77
	}
78
79
	/**
80
	 * Adding  into collection of preferences names, matches the regular expression,
81
	 * which is contained in the <code>key</code>.
82
	 * 
83
	 * @param name the name of the preference, matches the regular expression, contained in the key
84
	 */
85
	public void addMatch(String name) {
86
		if (!isRegexp)
87
			return;
88
		if (matches == null)
89
			matches = new HashSet();
90
		matches.add(name);
91
	}
92
93
	/**
94
	 * Return the array of preferences' names, matches the regular expression, contained in the key
95
	 * 
96
	 * @return the array of the preferencs' names, matches the regular expression, contained in the key
97
	 */
98
	public Object[] getMatches() {
99
		if (!isRegexp || matches == null)
100
			return null;
101
		return matches.toArray();
102
	}
48
}
103
}
(-)Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java (-2 / +4 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Semion Chichelnitsky (semion@il.ibm.com) - bug 208564
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.ui.internal.registry;
13
package org.eclipse.ui.internal.registry;
Lines 18-24 Link Here
18
import java.util.HashMap;
19
import java.util.HashMap;
19
import java.util.List;
20
import java.util.List;
20
import java.util.Map;
21
import java.util.Map;
21
22
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IConfigurationElement;
23
import org.eclipse.core.runtime.IExtensionRegistry;
23
import org.eclipse.core.runtime.IExtensionRegistry;
24
import org.eclipse.core.runtime.Platform;
24
import org.eclipse.core.runtime.Platform;
Lines 169-176 Link Here
169
				prefFilters = new PreferenceFilterEntry[keys.length];
169
				prefFilters = new PreferenceFilterEntry[keys.length];
170
				for (int j = 0; j < keys.length; j++) {
170
				for (int j = 0; j < keys.length; j++) {
171
					IConfigurationElement keyElement = keys[j];
171
					IConfigurationElement keyElement = keys[j];
172
					boolean regExp = !(keyElement.getAttribute(IWorkbenchRegistryConstants.REG_EXP) == null ||
173
							!keyElement.getAttribute(IWorkbenchRegistryConstants.REG_EXP).equalsIgnoreCase("true")); //$NON-NLS-1$
172
					prefFilters[j] = new PreferenceFilterEntry(keyElement
174
					prefFilters[j] = new PreferenceFilterEntry(keyElement
173
							.getAttribute(IWorkbenchRegistryConstants.ATT_NAME));
175
								.getAttribute(IWorkbenchRegistryConstants.ATT_NAME), regExp);
174
				}
176
				}
175
			}
177
			}
176
			map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE),
178
			map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE),
(-)Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java (+6 lines)
Lines 10-15 Link Here
10
 *     Dan Rubel <dan_rubel@instantiations.com>
10
 *     Dan Rubel <dan_rubel@instantiations.com>
11
 *     - Fix for bug 11490 - define hidden view (placeholder for view) in plugin.xml    
11
 *     - Fix for bug 11490 - define hidden view (placeholder for view) in plugin.xml    
12
 *     Markus Alexander Kuppe, Versant Corporation - bug #215797
12
 *     Markus Alexander Kuppe, Versant Corporation - bug #215797
13
 *     Semion Chichelnitsky (semion@il.ibm.com) - bug 208564
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.ui.internal.registry;
15
package org.eclipse.ui.internal.registry;
15
16
Lines 328-333 Link Here
328
	public static String ATT_NAME = "name"; //$NON-NLS-1$
329
	public static String ATT_NAME = "name"; //$NON-NLS-1$
329
330
330
	/**
331
	/**
332
	 * Name as regular expression attribute. Value <code>regexp</code>.
333
	 */
334
	public static String REG_EXP = "regexp"; //$NON-NLS-1$
335
336
	/**
331
	 * Name filter attribute. Value <code>nameFilter</code>.
337
	 * Name filter attribute. Value <code>nameFilter</code>.
332
	 */
338
	 */
333
	public static String ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$
339
	public static String ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$
(-)schema/preferenceTransfer.exsd (-18 / +16 lines)
Lines 1-6 Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.ui">
3
<schema targetNamespace="org.eclipse.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
4
<annotation>
5
      <appInfo>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.ui" id="preferenceTransfer" name="Preference Transfer"/>
6
         <meta.schema plugin="org.eclipse.ui" id="preferenceTransfer" name="Preference Transfer"/>
Lines 14-19 Link Here
14
   </annotation>
14
   </annotation>
15
15
16
   <element name="extension">
16
   <element name="extension">
17
      <annotation>
18
         <appInfo>
19
            <meta.element />
20
         </appInfo>
21
      </annotation>
17
      <complexType>
22
      <complexType>
18
         <sequence>
23
         <sequence>
19
            <element ref="transfer" minOccurs="0" maxOccurs="unbounded"/>
24
            <element ref="transfer" minOccurs="0" maxOccurs="unbounded"/>
Lines 152-157 Link Here
152
               </documentation>
157
               </documentation>
153
            </annotation>
158
            </annotation>
154
         </attribute>
159
         </attribute>
160
         <attribute name="regexp" type="boolean">
161
            <annotation>
162
               <documentation>
163
                  This attribute specifies, how attribute &quot;name&quot; is used. If it is omitted or set to &quot;false&quot;, &quot;name&quot; contains exact name of preference. In opposite case value of &quot;name&quot; is used as a regular expression for searching in the set of  preferences. 
164
Since 3.6.
165
               </documentation>
166
            </annotation>
167
         </attribute>
155
      </complexType>
168
      </complexType>
156
   </element>
169
   </element>
157
170
Lines 268-274 Link Here
268
                   &lt;key name=&quot;showIntro,DOCK_PERSPECTIVE_BAR&quot;/&gt;
281
                   &lt;key name=&quot;showIntro,DOCK_PERSPECTIVE_BAR&quot;/&gt;
269
                &lt;/entry&gt;
282
                &lt;/entry&gt;
270
                &lt;entry node=&quot;org.eclipse.ui.workbench&quot;&gt;
283
                &lt;entry node=&quot;org.eclipse.ui.workbench&quot;&gt;
271
                   &lt;key name=&quot;bogus,RUN_IN_BACKGROUND&quot;/&gt;
284
                   &lt;key name=&quot;RUN_IN_BACKGROUND&quot;/&gt;
285
                   &lt;key name=&quot;OPEN*&quot; regexp=&quot;true&quot;/&gt;
272
                &lt;/entry&gt;   
286
                &lt;/entry&gt;   
273
                &lt;entry node=&quot;org.eclipse.ui.ide&quot;/&gt;
287
                &lt;entry node=&quot;org.eclipse.ui.ide&quot;/&gt;
274
                &lt;entry node=&quot;org.eclipse.core.resources&quot;/&gt;
288
                &lt;entry node=&quot;org.eclipse.core.resources&quot;/&gt;
Lines 284-306 Link Here
284
      </documentation>
298
      </documentation>
285
   </annotation>
299
   </annotation>
286
300
287
   <annotation>
288
      <appInfo>
289
         <meta.section type="apiInfo"/>
290
      </appInfo>
291
      <documentation>
292
         
293
      </documentation>
294
   </annotation>
295
301
296
   <annotation>
297
      <appInfo>
298
         <meta.section type="implementation"/>
299
      </appInfo>
300
      <documentation>
301
         
302
      </documentation>
303
   </annotation>
304
302
305
   <annotation>
303
   <annotation>
306
      <appInfo>
304
      <appInfo>

Return to bug 208564