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 / +35 lines)
Lines 773-781 Link Here
773
							return true;
773
							return true;
774
					} else {
774
					} else {
775
						// otherwise check to see if we have any applicable keys
775
						// otherwise check to see if we have any applicable keys
776
						for (int k = 0; k < entries.length; k++) {
777
							if (entries[k] != null && entries[k].isPrefix())
778
								internalMatchesWithRegexp(entries[k], child.keys(), entries[k].getKey());
779
						}
776
						for (int j = 0; j < entries.length; j++) {
780
						for (int j = 0; j < entries.length; j++) {
777
							if (entries[j] != null && child.get(entries[j].getKey(), null) != null)
781
							if (entries[j] != null) {
778
								return true;
782
								if (!entries[j].isPrefix() && child.get(entries[j].getKey(), null) != null)
783
									return true;
784
								else if (entries[j].isPrefix()) {
785
									if (entries[j].getMatches() != null)
786
										return true;
787
								}
788
							}
779
						}
789
						}
780
					}
790
					}
781
				}
791
				}
Lines 785-790 Link Here
785
	}
795
	}
786
796
787
	/*
797
	/*
798
	 * Internal method that collects the matching preferences for the given regular expression.
799
	 */
800
	private void internalMatchesWithRegexp(PreferenceFilterEntry entry, String[] keys, String prefix) {
801
		if (keys == null || keys.length == 0 || prefix == null || prefix.length() == 0)
802
			return;
803
		for (int i = 0; i < keys.length; i++) {
804
			if (keys[i].startsWith(prefix)) {
805
				entry.addMatch(keys[i]);
806
			}
807
		}
808
	}
809
810
	/*
788
	 * Internal method that collects the matching filters for the given tree and returns them.
811
	 * Internal method that collects the matching filters for the given tree and returns them.
789
	 */
812
	 */
790
	private IPreferenceFilter[] internalMatches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException {
813
	private IPreferenceFilter[] internalMatches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException {
Lines 973-980 Link Here
973
					if (entries != null) {
996
					if (entries != null) {
974
						ArrayList list = new ArrayList();
997
						ArrayList list = new ArrayList();
975
						for (int j = 0; j < entries.length; j++) {
998
						for (int j = 0; j < entries.length; j++) {
976
							if (entries[j] != null)
999
							if (entries[j] != null) {
977
								list.add(entries[j].getKey());
1000
								if (!entries[j].isPrefix())
1001
									list.add(entries[j].getKey());
1002
								else if (entries[j].getMatches() != null) {
1003
									Object[] matches = entries[j].getMatches();
1004
									for (int k = 0; k < matches.length; k++) {
1005
										list.add(matches[k]);
1006
									}
1007
								}
1008
							}
978
						}
1009
						}
979
						keys = (String[]) list.toArray(new String[list.size()]);
1010
						keys = (String[]) list.toArray(new String[list.size()]);
980
					}
1011
					}
(-)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 isPrefix;
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.isPrefix = 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 isPrefix) {
52
		super();
53
		if (key == null || key.length() == 0)
54
			throw new IllegalArgumentException();
55
		this.key = key;
56
		this.isPrefix = isPrefix;
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 isPrefix() {
76
		return isPrefix;
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 (!isPrefix)
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 (!isPrefix || matches == null)
100
			return null;
101
		return matches.toArray();
102
	}
48
}
103
}
(-)Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java (-2 / +8 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 isPrefix = !(keyElement
173
							.getAttribute(IWorkbenchRegistryConstants.ATT_MATCH_TYPE) == null || !keyElement
174
							.getAttribute(
175
									IWorkbenchRegistryConstants.ATT_MATCH_TYPE)
176
							.equalsIgnoreCase("prefix")); //$NON-NLS-1$
172
					prefFilters[j] = new PreferenceFilterEntry(keyElement
177
					prefFilters[j] = new PreferenceFilterEntry(keyElement
173
							.getAttribute(IWorkbenchRegistryConstants.ATT_NAME));
178
									.getAttribute(IWorkbenchRegistryConstants.ATT_NAME),
179
							isPrefix);
174
				}
180
				}
175
			}
181
			}
176
			map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE),
182
			map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE),
(-)Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java (+8 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
	 * Match type attribute. Value <code>match</code>.
333
	 * 
334
	 * @since 3.6
335
	 */
336
	public static String ATT_MATCH_TYPE = "match"; //$NON-NLS-1$
337
338
	/**
331
	 * Name filter attribute. Value <code>nameFilter</code>.
339
	 * Name filter attribute. Value <code>nameFilter</code>.
332
	 */
340
	 */
333
	public static String ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$
341
	public static String ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$
(-)schema/preferenceTransfer.exsd (-19 / +17 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="match" type="string">
161
            <annotation>
162
               <documentation>
163
                  This attribute specifies, how attribute &quot;name&quot; is used. If it is omitted or its value doesn&apos;t equal &lt;code&gt;prefix&lt;/code&gt;, &quot;name&quot; contains exact name of preference. In opposite case value of &quot;name&quot; is used for searching only such  preferences, which start with this value.
164
Since 3.6.
165
               </documentation>
166
            </annotation>
167
         </attribute>
155
      </complexType>
168
      </complexType>
156
   </element>
169
   </element>
157
170
Lines 265-274 Link Here
265
            id=&quot;org.eclipse.ui.tests.all&quot;&gt;
278
            id=&quot;org.eclipse.ui.tests.all&quot;&gt;
266
            &lt;mapping scope=&quot;instance&quot;&gt;
279
            &lt;mapping scope=&quot;instance&quot;&gt;
267
                &lt;entry node=&quot;org.eclipse.ui&quot;&gt;
280
                &lt;entry node=&quot;org.eclipse.ui&quot;&gt;
268
                   &lt;key name=&quot;showIntro,DOCK_PERSPECTIVE_BAR&quot;/&gt;
281
                   &lt;key name=&quot;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; match=&quot;prefix&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