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

(-)schema/preferenceTransfer.exsd (-21 / +25 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 148-157 Link Here
148
         <attribute name="name" type="string" use="required">
153
         <attribute name="name" type="string" use="required">
149
            <annotation>
154
            <annotation>
150
               <documentation>
155
               <documentation>
151
                  an attribute specifing a comma separated list of preference keys within the given node to be transferred, specifying the key attribute without specifying a matching node will result in a runtime error.
156
                  an attribute specifing preference key within the given node to be transferred, specifying the key attribute without specifying a matching node will result in a runtime error.
152
               </documentation>
157
               </documentation>
153
            </annotation>
158
            </annotation>
154
         </attribute>
159
         </attribute>
160
         <attribute name="match">
161
            <annotation>
162
               <documentation>
163
                  this attribute specifies, how attribute &quot;name&quot; is used. Setting match to &quot;prefix&quot; treats the name as if it were a regular expression with an asterisk at the end. Otherwise name must be an exact match.
164
Added in 3.6.
165
               </documentation>
166
            </annotation>
167
            <simpleType>
168
               <restriction base="string">
169
                  <enumeration value="prefix">
170
                  </enumeration>
171
               </restriction>
172
            </simpleType>
173
         </attribute>
155
      </complexType>
174
      </complexType>
156
   </element>
175
   </element>
157
176
Lines 265-274 Link Here
265
            id=&quot;org.eclipse.ui.tests.all&quot;&gt;
284
            id=&quot;org.eclipse.ui.tests.all&quot;&gt;
266
            &lt;mapping scope=&quot;instance&quot;&gt;
285
            &lt;mapping scope=&quot;instance&quot;&gt;
267
                &lt;entry node=&quot;org.eclipse.ui&quot;&gt;
286
                &lt;entry node=&quot;org.eclipse.ui&quot;&gt;
268
                   &lt;key name=&quot;showIntro,DOCK_PERSPECTIVE_BAR&quot;/&gt;
287
                   &lt;key name=&quot;DOCK_PERSPECTIVE_BAR&quot;/&gt;
269
                &lt;/entry&gt;
288
                &lt;/entry&gt;
270
                &lt;entry node=&quot;org.eclipse.ui.workbench&quot;&gt;
289
                &lt;entry node=&quot;org.eclipse.ui.workbench&quot;&gt;
271
                   &lt;key name=&quot;bogus,RUN_IN_BACKGROUND&quot;/&gt;
290
                   &lt;key name=&quot;RUN_IN_BACKGROUND&quot;/&gt;
291
                   &lt;key name=&quot;OPEN_&quot; match=&quot;prefix&quot;/&gt;
272
                &lt;/entry&gt;   
292
                &lt;/entry&gt;   
273
                &lt;entry node=&quot;org.eclipse.ui.ide&quot;/&gt;
293
                &lt;entry node=&quot;org.eclipse.ui.ide&quot;/&gt;
274
                &lt;entry node=&quot;org.eclipse.core.resources&quot;/&gt;
294
                &lt;entry node=&quot;org.eclipse.core.resources&quot;/&gt;
Lines 284-313 Link Here
284
      </documentation>
304
      </documentation>
285
   </annotation>
305
   </annotation>
286
306
287
   <annotation>
288
      <appInfo>
289
         <meta.section type="apiInfo"/>
290
      </appInfo>
291
      <documentation>
292
         
293
      </documentation>
294
   </annotation>
295
307
296
   <annotation>
297
      <appInfo>
298
         <meta.section type="implementation"/>
299
      </appInfo>
300
      <documentation>
301
         
302
      </documentation>
303
   </annotation>
304
308
305
   <annotation>
309
   <annotation>
306
      <appInfo>
310
      <appInfo>
307
         <meta.section type="copyright"/>
311
         <meta.section type="copyright"/>
308
      </appInfo>
312
      </appInfo>
309
      <documentation>
313
      <documentation>
310
         Copyright (c) 2005, 2006 IBM Corporation and others.&lt;br&gt;
314
         Copyright (c) 2005, 2009 IBM Corporation and others.&lt;br&gt;
311
All rights reserved. This program and the accompanying materials are made
315
All rights reserved. This program and the accompanying materials are made
312
available under the terms of the Eclipse Public License v1.0 which accompanies
316
available under the terms of the Eclipse Public License v1.0 which accompanies
313
this distribution, and is available at &lt;a 
317
this distribution, and is available at &lt;a 
(-)Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java (-3 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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 170-176 Link Here
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
					prefFilters[j] = new PreferenceFilterEntry(keyElement
172
					prefFilters[j] = new PreferenceFilterEntry(keyElement
173
							.getAttribute(IWorkbenchRegistryConstants.ATT_NAME));
173
									.getAttribute(IWorkbenchRegistryConstants.ATT_NAME),
174
							keyElement
175
									.getAttribute(IWorkbenchRegistryConstants.ATT_MATCH_TYPE));
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 (+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$
(-)src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java (-1 / +54 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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
package org.eclipse.core.tests.internal.preferences;
12
package org.eclipse.core.tests.internal.preferences;
12
13
Lines 1076-1081 Link Here
1076
		verifier.verify();
1077
		verifier.verify();
1077
	}
1078
	}
1078
1079
1080
	/*
1081
	 * See Bug 208564 - [Preferences] preferenceTransfer: Allow wildcards on keys
1082
	 * Since 3.6 preferenceTransfer allows to define common prefix for group of 
1083
	 * preferences 
1084
	 */
1085
	public void testExportWithTransfers4() {
1086
		final String VALID_QUALIFIER = getUniqueString();
1087
		final String COMMON_PREFIX = "PREFIX.";
1088
		IPreferenceFilter transfer = new IPreferenceFilter() {
1089
			Map result;
1090
1091
			public Map getMapping(String scope) {
1092
				if (result == null) {
1093
					result = new HashMap();
1094
					result.put(VALID_QUALIFIER, new PreferenceFilterEntry[] {new PreferenceFilterEntry(COMMON_PREFIX, "prefix")});
1095
				}
1096
				return result;
1097
			}
1098
1099
			public String[] getScopes() {
1100
				return new String[] {InstanceScope.SCOPE};
1101
			}
1102
		};
1103
		IPreferenceFilter[] matching = null;
1104
		IPreferencesService service = Platform.getPreferencesService();
1105
1106
		IEclipsePreferences node = new InstanceScope().getNode(VALID_QUALIFIER);
1107
		String VALID_KEY_1 = COMMON_PREFIX + "key1";
1108
		String VALID_KEY_2 = COMMON_PREFIX + "key2";
1109
		String VALID_KEY_3 = "key3";
1110
		String VALID_KEY_4 = "key4";
1111
		node.put(VALID_KEY_1, "value1");
1112
		node.put(VALID_KEY_2, "value2");
1113
		node.put(VALID_KEY_3, "value3");
1114
		node.put(VALID_KEY_4, "value4");
1115
1116
		try {
1117
			matching = service.matches(service.getRootNode(), new IPreferenceFilter[] {transfer});
1118
		} catch (CoreException e) {
1119
			fail("1.00", e);
1120
		}
1121
		assertEquals("2.00", 1, matching.length);
1122
1123
		ExportVerifier verifier = new ExportVerifier(service.getRootNode(), new IPreferenceFilter[] {transfer});
1124
		verifier.addVersion();
1125
		verifier.addExportRoot(service.getRootNode());
1126
		verifier.addExpected(node.absolutePath(), VALID_KEY_1);
1127
		verifier.addExpected(node.absolutePath(), VALID_KEY_2);
1128
1129
		verifier.verify();
1130
	}
1131
1079
	public void testApplyWithTransfers() {
1132
	public void testApplyWithTransfers() {
1080
		// todo
1133
		// todo
1081
	}
1134
	}
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.equinox.preferences; singleton:=true
4
Bundle-SymbolicName: org.eclipse.equinox.preferences; singleton:=true
5
Bundle-Version: 3.2.300.qualifier
5
Bundle-Version: 3.3.0.qualifier
6
Bundle-Activator: org.eclipse.core.internal.preferences.Activator
6
Bundle-Activator: org.eclipse.core.internal.preferences.Activator
7
Bundle-Vendor: %providerName
7
Bundle-Vendor: %providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
(-)src/org/eclipse/core/internal/preferences/PreferencesService.java (-2 / +46 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
package org.eclipse.core.internal.preferences;
12
package org.eclipse.core.internal.preferences;
12
13
Lines 31-36 Link Here
31
	 * strings.
32
	 * strings.
32
	 */
33
	 */
33
	private static final long STRING_SHARING_INTERVAL = 300000;
34
	private static final long STRING_SHARING_INTERVAL = 300000;
35
	private static final String MATCH_TYPE_PREFIX = "prefix"; //$NON-NLS-1$
34
36
35
	// cheat here and add "project" even though we really shouldn't know about it
37
	// cheat here and add "project" even though we really shouldn't know about it
36
	// because of plug-in dependencies and it being defined in the resources plug-in
38
	// because of plug-in dependencies and it being defined in the resources plug-in
Lines 774-780 Link Here
774
					} else {
776
					} else {
775
						// otherwise check to see if we have any applicable keys
777
						// otherwise check to see if we have any applicable keys
776
						for (int j = 0; j < entries.length; j++) {
778
						for (int j = 0; j < entries.length; j++) {
777
							if (entries[j] != null && child.get(entries[j].getKey(), null) != null)
779
							if (entries[j] == null)
780
								continue;
781
							if (entries[j].getMatchType() == null) {
782
								if (child.get(entries[j].getKey(), null) != null)
783
									return true;
784
							} else if (internalMatchesWithMatchType(entries[j], child.keys()))
778
								return true;
785
								return true;
779
						}
786
						}
780
					}
787
					}
Lines 796-801 Link Here
796
	}
803
	}
797
804
798
	/*
805
	/*
806
	 * Internal method that check the matching preferences for entry with specific match type.
807
	 */
808
	private boolean internalMatchesWithMatchType(PreferenceFilterEntry entry, String[] keys) {
809
		if (keys == null || keys.length == 0)
810
			return false;
811
		String key = entry.getKey();
812
		String matchType = entry.getMatchType();
813
		if (!matchType.equalsIgnoreCase(MATCH_TYPE_PREFIX))
814
			return false;
815
		for (int i = 0; i < keys.length; i++) {
816
			if (keys[i].startsWith(key)) {
817
				return true;
818
			}
819
		}
820
		return false;
821
	}
822
823
	/*
799
	 * Returns a boolean value indicating whether or not the given Properties
824
	 * Returns a boolean value indicating whether or not the given Properties
800
	 * object is the result of a preference export previous to Eclipse 3.0.
825
	 * object is the result of a preference export previous to Eclipse 3.0.
801
	 * 
826
	 * 
Lines 961-966 Link Here
961
				String childPath = nodeFullPath.substring(treePath.length());
986
				String childPath = nodeFullPath.substring(treePath.length());
962
				childPath = EclipsePreferences.makeRelative(childPath);
987
				childPath = EclipsePreferences.makeRelative(childPath);
963
				if (tree.nodeExists(childPath)) {
988
				if (tree.nodeExists(childPath)) {
989
					Preferences child = tree.node(childPath);
964
					PreferenceFilterEntry[] entries;
990
					PreferenceFilterEntry[] entries;
965
					// protect against wrong classes since this is passed in by the user
991
					// protect against wrong classes since this is passed in by the user
966
					try {
992
					try {
Lines 974-980 Link Here
974
						ArrayList list = new ArrayList();
1000
						ArrayList list = new ArrayList();
975
						for (int j = 0; j < entries.length; j++) {
1001
						for (int j = 0; j < entries.length; j++) {
976
							if (entries[j] != null)
1002
							if (entries[j] != null)
977
								list.add(entries[j].getKey());
1003
								addMatchedKeys(list, entries[j], child.keys());
978
						}
1004
						}
979
						keys = (String[]) list.toArray(new String[list.size()]);
1005
						keys = (String[]) list.toArray(new String[list.size()]);
980
					}
1006
					}
Lines 986-991 Link Here
986
		return result;
1012
		return result;
987
	}
1013
	}
988
1014
1015
	/*
1016
	 * Internal method that adds to the given list the matching preferences for entry with or without specific match type.
1017
	 */
1018
	private void addMatchedKeys(ArrayList list, PreferenceFilterEntry entry, String[] keys) {
1019
		String matchType = entry.getMatchType();
1020
		if (matchType == null) {
1021
			list.add(entry.getKey());
1022
			return;
1023
		}
1024
		if (keys == null)
1025
			return;
1026
		String key = entry.getKey();
1027
		for (int i = 0; i < keys.length; i++) {
1028
			if (matchType.equals(MATCH_TYPE_PREFIX) && keys[i].startsWith(key))
1029
				list.add(keys[i]);
1030
		}
1031
	}
1032
989
	/**
1033
	/**
990
	 * Compares two plugin version identifiers to see if their preferences
1034
	 * Compares two plugin version identifiers to see if their preferences
991
	 * are compatible.  If they are not compatible, a warning message is 
1035
	 * are compatible.  If they are not compatible, a warning message is 
(-)src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java (-1 / +32 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
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
package org.eclipse.core.runtime.preferences;
12
package org.eclipse.core.runtime.preferences;
12
13
Lines 21-26 Link Here
21
public final class PreferenceFilterEntry {
22
public final class PreferenceFilterEntry {
22
23
23
	private String key;
24
	private String key;
25
	String matchType;
24
26
25
	/**
27
	/**
26
	 * Constructor for the class. Create a new preference filter entry with the given 
28
	 * Constructor for the class. Create a new preference filter entry with the given 
Lines 36-41 Link Here
36
	}
38
	}
37
39
38
	/**
40
	/**
41
	 * Constructor for the class. Create a new preference filter entry with the given 
42
	 * key and match type. The key must <em>not</em> be <code>null</code> or empty.
43
	 * The matchType specifies if key may be treated as some
44
	 * kind of regular expression or requires exact match.
45
	 * matchType may be set to <code>null</code>, which means, that filter requires
46
	 * exact match.
47
	 * 
48
	 * @param key the name of the preference key
49
	 * @param matchType the way of using key    
50
	 *        
51
	 * @since 3.6       
52
	 */
53
	public PreferenceFilterEntry(String key, String matchType) {
54
		this(key);
55
		this.matchType = matchType;
56
	}
57
58
	/**
39
	 * Return the name of the preference key for this filter entry.
59
	 * Return the name of the preference key for this filter entry.
40
	 * It will <em>not</em> return <code>null</code> or the
60
	 * It will <em>not</em> return <code>null</code> or the
41
	 * empty string.
61
	 * empty string.
Lines 45-48 Link Here
45
	public String getKey() {
65
	public String getKey() {
46
		return key;
66
		return key;
47
	}
67
	}
68
69
	/**
70
	 * Return type of match, specified for this filter.
71
	 * 
72
	 * @return matchType the type of match
73
	 * 
74
	 * @since 3.6
75
	 */
76
	public String getMatchType() {
77
		return matchType;
78
	}
48
}
79
}

Return to bug 208564