Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 147826 Details for
Bug 208564
[Preferences] preferenceTransfer: Allow wildcards on keys
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Slightly modified Semion's patch
patch Match 10.txt (text/plain), 20.11 KB, created by
Oleg Besedin
on 2009-09-22 15:04:06 EDT
(
hide
)
Description:
Slightly modified Semion's patch
Filename:
MIME Type:
Creator:
Oleg Besedin
Created:
2009-09-22 15:04:06 EDT
Size:
20.11 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.runtime >Index: src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java,v >retrieving revision 1.23 >diff -u -r1.23 PreferencesServiceTest.java >--- src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java 19 Sep 2005 15:14:55 -0000 1.23 >+++ src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java 22 Sep 2009 18:51:31 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * Copyright (c) 2004, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Semion Chichelnitsky (semion@il.ibm.com) - bug 208564 > *******************************************************************************/ > package org.eclipse.core.tests.internal.preferences; > >@@ -1076,6 +1077,58 @@ > verifier.verify(); > } > >+ /* >+ * See Bug 208564 - [Preferences] preferenceTransfer: Allow wildcards on keys >+ * Since 3.6 preferenceTransfer allows to define common prefix for group of >+ * preferences >+ */ >+ public void testExportWithTransfers4() { >+ final String VALID_QUALIFIER = getUniqueString(); >+ final String COMMON_PREFIX = "PREFIX."; >+ IPreferenceFilter transfer = new IPreferenceFilter() { >+ Map result; >+ >+ public Map getMapping(String scope) { >+ if (result == null) { >+ result = new HashMap(); >+ result.put(VALID_QUALIFIER, new PreferenceFilterEntry[] {new PreferenceFilterEntry(COMMON_PREFIX, "prefix")}); >+ } >+ return result; >+ } >+ >+ public String[] getScopes() { >+ return new String[] {InstanceScope.SCOPE}; >+ } >+ }; >+ IPreferenceFilter[] matching = null; >+ IPreferencesService service = Platform.getPreferencesService(); >+ >+ IEclipsePreferences node = new InstanceScope().getNode(VALID_QUALIFIER); >+ String VALID_KEY_1 = COMMON_PREFIX + "key1"; >+ String VALID_KEY_2 = COMMON_PREFIX + "key2"; >+ String VALID_KEY_3 = "key3"; >+ String VALID_KEY_4 = "key4"; >+ node.put(VALID_KEY_1, "value1"); >+ node.put(VALID_KEY_2, "value2"); >+ node.put(VALID_KEY_3, "value3"); >+ node.put(VALID_KEY_4, "value4"); >+ >+ try { >+ matching = service.matches(service.getRootNode(), new IPreferenceFilter[] {transfer}); >+ } catch (CoreException e) { >+ fail("1.00", e); >+ } >+ assertEquals("2.00", 1, matching.length); >+ >+ ExportVerifier verifier = new ExportVerifier(service.getRootNode(), new IPreferenceFilter[] {transfer}); >+ verifier.addVersion(); >+ verifier.addExportRoot(service.getRootNode()); >+ verifier.addExpected(node.absolutePath(), VALID_KEY_1); >+ verifier.addExpected(node.absolutePath(), VALID_KEY_2); >+ verifier.verify(); >+ >+ } >+ > public void testApplyWithTransfers() { > // todo > } >#P org.eclipse.equinox.preferences >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.preferences/META-INF/MANIFEST.MF,v >retrieving revision 1.26 >diff -u -r1.26 MANIFEST.MF >--- META-INF/MANIFEST.MF 20 Feb 2009 22:43:58 -0000 1.26 >+++ META-INF/MANIFEST.MF 22 Sep 2009 18:51:32 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName > Bundle-SymbolicName: org.eclipse.equinox.preferences; singleton:=true >-Bundle-Version: 3.2.300.qualifier >+Bundle-Version: 3.3.0.qualifier > Bundle-Activator: org.eclipse.core.internal.preferences.Activator > Bundle-Vendor: %providerName > Bundle-Localization: plugin >Index: src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java,v >retrieving revision 1.2 >diff -u -r1.2 PreferenceFilterEntry.java >--- src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java 17 Apr 2008 14:45:47 -0000 1.2 >+++ src/org/eclipse/core/runtime/preferences/PreferenceFilterEntry.java 22 Sep 2009 18:51:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Semion Chichelnitsky (semion@il.ibm.com) - bug 208564 > *******************************************************************************/ > package org.eclipse.core.runtime.preferences; > >@@ -21,6 +22,7 @@ > public final class PreferenceFilterEntry { > > private String key; >+ private String matchType; > > /** > * Constructor for the class. Create a new preference filter entry with the given >@@ -36,6 +38,24 @@ > } > > /** >+ * Constructor for the class. Create a new preference filter entry with the given >+ * key and match type. The key must <em>not</em> be <code>null</code> or empty. >+ * <p> >+ * Setting matchType to "prefix" treats the key as if it were a regular expression >+ * with an asterisk at the end. If matchType is <code>null</code>, the key must be >+ * an exact match. >+ * </p> >+ * @param key the name of the preference key >+ * @param matchType specifies key match type, may be <code>null</null> to indicate >+ * that exact match is required >+ * @since 3.3 >+ */ >+ public PreferenceFilterEntry(String key, String matchType) { >+ this(key); >+ this.matchType = matchType; >+ } >+ >+ /** > * Return the name of the preference key for this filter entry. > * It will <em>not</em> return <code>null</code> or the > * empty string. >@@ -45,4 +65,15 @@ > public String getKey() { > return key; > } >+ >+ /** >+ * Return the match type specified for this filter. May return <code>null</code> >+ * to indicate that exact match is used. >+ * @return matchType the match type, might be <code>null</code> indicating that >+ * exact match is used >+ * @since 3.3 >+ */ >+ public String getMatchType() { >+ return matchType; >+ } > } >Index: src/org/eclipse/core/internal/preferences/PreferencesService.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java,v >retrieving revision 1.13 >diff -u -r1.13 PreferencesService.java >--- src/org/eclipse/core/internal/preferences/PreferencesService.java 23 Apr 2009 20:42:06 -0000 1.13 >+++ src/org/eclipse/core/internal/preferences/PreferencesService.java 22 Sep 2009 18:51:32 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Semion Chichelnitsky (semion@il.ibm.com) - bug 208564 > *******************************************************************************/ > package org.eclipse.core.internal.preferences; > >@@ -31,6 +32,7 @@ > * strings. > */ > private static final long STRING_SHARING_INTERVAL = 300000; >+ private static final String MATCH_TYPE_PREFIX = "prefix"; //$NON-NLS-1$ > > // cheat here and add "project" even though we really shouldn't know about it > // because of plug-in dependencies and it being defined in the resources plug-in >@@ -774,7 +776,12 @@ > } else { > // otherwise check to see if we have any applicable keys > for (int j = 0; j < entries.length; j++) { >- if (entries[j] != null && child.get(entries[j].getKey(), null) != null) >+ if (entries[j] == null) >+ continue; >+ if (entries[j].getMatchType() == null) { >+ if (child.get(entries[j].getKey(), null) != null) >+ return true; >+ } else if (internalMatchesWithMatchType(entries[j], child.keys())) > return true; > } > } >@@ -796,6 +803,23 @@ > } > > /* >+ * Internal method that check the matching preferences for entry with specific match type. >+ */ >+ private boolean internalMatchesWithMatchType(PreferenceFilterEntry entry, String[] keys) { >+ if (keys == null || keys.length == 0) >+ return false; >+ String key = entry.getKey(); >+ String matchType = entry.getMatchType(); >+ if (!matchType.equalsIgnoreCase(MATCH_TYPE_PREFIX)) >+ return false; >+ for (int i = 0; i < keys.length; i++) { >+ if (keys[i].startsWith(key)) >+ return true; >+ } >+ return false; >+ } >+ >+ /* > * Returns a boolean value indicating whether or not the given Properties > * object is the result of a preference export previous to Eclipse 3.0. > * >@@ -961,6 +985,7 @@ > String childPath = nodeFullPath.substring(treePath.length()); > childPath = EclipsePreferences.makeRelative(childPath); > if (tree.nodeExists(childPath)) { >+ Preferences child = tree.node(childPath); > PreferenceFilterEntry[] entries; > // protect against wrong classes since this is passed in by the user > try { >@@ -974,7 +999,7 @@ > ArrayList list = new ArrayList(); > for (int j = 0; j < entries.length; j++) { > if (entries[j] != null) >- list.add(entries[j].getKey()); >+ addMatchedKeys(list, entries[j], child.keys()); > } > keys = (String[]) list.toArray(new String[list.size()]); > } >@@ -986,6 +1011,24 @@ > return result; > } > >+ /* >+ * Internal method that adds to the given list the matching preferences for entry with or without specific match type. >+ */ >+ private void addMatchedKeys(ArrayList list, PreferenceFilterEntry entry, String[] keys) { >+ String matchType = entry.getMatchType(); >+ if (matchType == null) { >+ list.add(entry.getKey()); >+ return; >+ } >+ if (keys == null) >+ return; >+ String key = entry.getKey(); >+ for (int i = 0; i < keys.length; i++) { >+ if (matchType.equals(MATCH_TYPE_PREFIX) && keys[i].startsWith(key)) >+ list.add(keys[i]); >+ } >+ } >+ > /** > * Compares two plugin version identifiers to see if their preferences > * are compatible. If they are not compatible, a warning message is >#P org.eclipse.core.runtime >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.runtime/META-INF/MANIFEST.MF,v >retrieving revision 1.67 >diff -u -r1.67 MANIFEST.MF >--- META-INF/MANIFEST.MF 19 Jun 2009 19:54:48 -0000 1.67 >+++ META-INF/MANIFEST.MF 22 Sep 2009 18:51:33 -0000 >@@ -1,7 +1,7 @@ > Manifest-Version: 1.0 > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName >-Bundle-Version: 3.5.100.qualifier >+Bundle-Version: 3.6.0.qualifier > Bundle-SymbolicName: org.eclipse.core.runtime; singleton:=true > Bundle-Vendor: %providerName > Bundle-Activator: org.eclipse.core.internal.runtime.PlatformActivator >@@ -13,7 +13,7 @@ > org.eclipse.equinox.common;bundle-version="[3.5.0,4.0.0)";visibility:=reexport, > org.eclipse.core.jobs;bundle-version="[3.2.0,4.0.0)";visibility:=reexport, > org.eclipse.equinox.registry;bundle-version="[3.4.0,4.0.0)";visibility:=reexport, >- org.eclipse.equinox.preferences;bundle-version="[3.2.0,4.0.0)";visibility:=reexport, >+ org.eclipse.equinox.preferences;bundle-version="[3.3.0,4.0.0)";visibility:=reexport, > org.eclipse.core.contenttype;bundle-version="[3.3.0,4.0.0)";visibility:=reexport, > org.eclipse.core.runtime.compatibility.auth;bundle-version="[3.2.0,4.0.0)";resolution:=optional, > org.eclipse.equinox.app;bundle-version="[1.0.0,2.0.0)";visibility:=reexport >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java,v >retrieving revision 1.41 >diff -u -r1.41 IWorkbenchRegistryConstants.java >--- Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java 25 May 2009 20:52:15 -0000 1.41 >+++ Eclipse UI/org/eclipse/ui/internal/registry/IWorkbenchRegistryConstants.java 22 Sep 2009 18:51:34 -0000 >@@ -10,6 +10,7 @@ > * Dan Rubel <dan_rubel@instantiations.com> > * - Fix for bug 11490 - define hidden view (placeholder for view) in plugin.xml > * Markus Alexander Kuppe, Versant Corporation - bug #215797 >+ * Semion Chichelnitsky (semion@il.ibm.com) - bug 208564 > *******************************************************************************/ > package org.eclipse.ui.internal.registry; > >@@ -328,6 +329,11 @@ > public static String ATT_NAME = "name"; //$NON-NLS-1$ > > /** >+ * Match type attribute. Value <code>match</code>. >+ */ >+ public static String ATT_MATCH_TYPE = "match"; //$NON-NLS-1$ >+ >+ /** > * Name filter attribute. Value <code>nameFilter</code>. > */ > public static String ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$ >Index: Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java,v >retrieving revision 1.13 >diff -u -r1.13 PreferenceTransferRegistryReader.java >--- Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java 30 Nov 2006 19:39:49 -0000 1.13 >+++ Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java 22 Sep 2009 18:51:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Semion Chichelnitsky (semion@il.ibm.com) - bug 208564 > *******************************************************************************/ > > package org.eclipse.ui.internal.registry; >@@ -18,7 +19,6 @@ > import java.util.HashMap; > import java.util.List; > import java.util.Map; >- > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtensionRegistry; > import org.eclipse.core.runtime.Platform; >@@ -170,7 +170,9 @@ > for (int j = 0; j < keys.length; j++) { > IConfigurationElement keyElement = keys[j]; > prefFilters[j] = new PreferenceFilterEntry(keyElement >- .getAttribute(IWorkbenchRegistryConstants.ATT_NAME)); >+ .getAttribute(IWorkbenchRegistryConstants.ATT_NAME), >+ keyElement >+ .getAttribute(IWorkbenchRegistryConstants.ATT_MATCH_TYPE)); > } > } > map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE), >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/META-INF/MANIFEST.MF,v >retrieving revision 1.66 >diff -u -r1.66 MANIFEST.MF >--- META-INF/MANIFEST.MF 3 Sep 2009 20:00:44 -0000 1.66 >+++ META-INF/MANIFEST.MF 22 Sep 2009 18:51:34 -0000 >@@ -91,7 +91,7 @@ > org.eclipse.ui.themes, > org.eclipse.ui.views, > org.eclipse.ui.wizards >-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", >+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)", > org.eclipse.help;bundle-version="[3.2.0,4.0.0)", > org.eclipse.jface;bundle-version="[3.5.0,4.0.0)", > org.eclipse.swt;bundle-version="[3.5.0,4.0.0)", >#P org.eclipse.ui >Index: schema/preferenceTransfer.exsd >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui/schema/preferenceTransfer.exsd,v >retrieving revision 1.18 >diff -u -r1.18 preferenceTransfer.exsd >--- schema/preferenceTransfer.exsd 28 Jun 2007 20:14:28 -0000 1.18 >+++ schema/preferenceTransfer.exsd 22 Sep 2009 18:51:35 -0000 >@@ -1,6 +1,6 @@ > <?xml version='1.0' encoding='UTF-8'?> > <!-- Schema file written by PDE --> >-<schema targetNamespace="org.eclipse.ui"> >+<schema targetNamespace="org.eclipse.ui" xmlns="http://www.w3.org/2001/XMLSchema"> > <annotation> > <appInfo> > <meta.schema plugin="org.eclipse.ui" id="preferenceTransfer" name="Preference Transfer"/> >@@ -14,6 +14,11 @@ > </annotation> > > <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> > <complexType> > <sequence> > <element ref="transfer" minOccurs="0" maxOccurs="unbounded"/> >@@ -148,10 +153,23 @@ > <attribute name="name" type="string" use="required"> > <annotation> > <documentation> >- 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. >+ Specifies the preference key to be transferred. Specifying the key attribute without specifying a matching node will result in a runtime error. > </documentation> > </annotation> > </attribute> >+ <attribute name="match"> >+ <annotation> >+ <documentation> >+ Setting match to "prefix" treats the name as if it were a regular expression with an asterisk at the end. Otherwise name must be an exact match. Added in 3.6. >+ </documentation> >+ </annotation> >+ <simpleType> >+ <restriction base="string"> >+ <enumeration value="prefix"> >+ </enumeration> >+ </restriction> >+ </simpleType> >+ </attribute> > </complexType> > </element> > >@@ -265,10 +283,11 @@ > id="org.eclipse.ui.tests.all"> > <mapping scope="instance"> > <entry node="org.eclipse.ui"> >- <key name="showIntro,DOCK_PERSPECTIVE_BAR"/> >+ <key name="DOCK_PERSPECTIVE_BAR"/> > </entry> > <entry node="org.eclipse.ui.workbench"> >- <key name="bogus,RUN_IN_BACKGROUND"/> >+ <key name="RUN_IN_BACKGROUND"/> >+ <key name="OPEN_" match="prefix"/> > </entry> > <entry node="org.eclipse.ui.ide"/> > <entry node="org.eclipse.core.resources"/> >@@ -284,30 +303,14 @@ > </documentation> > </annotation> > >- <annotation> >- <appInfo> >- <meta.section type="apiInfo"/> >- </appInfo> >- <documentation> >- >- </documentation> >- </annotation> > >- <annotation> >- <appInfo> >- <meta.section type="implementation"/> >- </appInfo> >- <documentation> >- >- </documentation> >- </annotation> > > <annotation> > <appInfo> > <meta.section type="copyright"/> > </appInfo> > <documentation> >- Copyright (c) 2005, 2006 IBM Corporation and others.<br> >+ Copyright (c) 2005, 2009 IBM Corporation and others.<br> > All rights reserved. This program and the accompanying materials are made > available under the terms of the Eclipse Public License v1.0 which accompanies > this distribution, and is available at <a
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208564
:
146061
|
146749
|
147088
|
147111
|
147765
| 147826