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 147088 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]
Third patch
patch208564_3 (text/plain), 11.81 KB, created by
Semion Chichelnitsky
on 2009-09-14 06:04:43 EDT
(
hide
)
Description:
Third patch
Filename:
MIME Type:
Creator:
Semion Chichelnitsky
Created:
2009-09-14 06:04:43 EDT
Size:
11.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.equinox.preferences >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 14 Sep 2009 10:03:56 -0000 >@@ -773,9 +773,19 @@ > return true; > } else { > // otherwise check to see if we have any applicable keys >+ for (int k = 0; k < entries.length; k++) { >+ if (entries[k] != null && entries[k].isPrefix()) >+ internalMatchesWithRegexp(entries[k], child.keys(), entries[k].getKey()); >+ } > for (int j = 0; j < entries.length; j++) { >- if (entries[j] != null && child.get(entries[j].getKey(), null) != null) >- return true; >+ if (entries[j] != null) { >+ if (!entries[j].isPrefix() && child.get(entries[j].getKey(), null) != null) >+ return true; >+ else if (entries[j].isPrefix()) { >+ if (entries[j].getMatches() != null) >+ return true; >+ } >+ } > } > } > } >@@ -785,6 +795,19 @@ > } > > /* >+ * Internal method that collects the matching preferences for the given regular expression. >+ */ >+ private void internalMatchesWithRegexp(PreferenceFilterEntry entry, String[] keys, String prefix) { >+ if (keys == null || keys.length == 0 || prefix == null || prefix.length() == 0) >+ return; >+ for (int i = 0; i < keys.length; i++) { >+ if (keys[i].startsWith(prefix)) { >+ entry.addMatch(keys[i]); >+ } >+ } >+ } >+ >+ /* > * Internal method that collects the matching filters for the given tree and returns them. > */ > private IPreferenceFilter[] internalMatches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws BackingStoreException { >@@ -973,8 +996,16 @@ > if (entries != null) { > ArrayList list = new ArrayList(); > for (int j = 0; j < entries.length; j++) { >- if (entries[j] != null) >- list.add(entries[j].getKey()); >+ if (entries[j] != null) { >+ if (!entries[j].isPrefix()) >+ list.add(entries[j].getKey()); >+ else if (entries[j].getMatches() != null) { >+ Object[] matches = entries[j].getMatches(); >+ for (int k = 0; k < matches.length; k++) { >+ list.add(matches[k]); >+ } >+ } >+ } > } > keys = (String[]) list.toArray(new String[list.size()]); > } >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 14 Sep 2009 10:03:56 -0000 >@@ -10,6 +10,8 @@ > *******************************************************************************/ > package org.eclipse.core.runtime.preferences; > >+import java.util.HashSet; >+ > /** > * Class which represents and preference filter entry to be used during preference > * import/export (for example). >@@ -21,6 +23,8 @@ > public final class PreferenceFilterEntry { > > private String key; >+ private HashSet matches; >+ boolean isPrefix; > > /** > * Constructor for the class. Create a new preference filter entry with the given >@@ -33,6 +37,23 @@ > if (key == null || key.length() == 0) > throw new IllegalArgumentException(); > this.key = key; >+ this.isPrefix = false; >+ } >+ >+ /** >+ * Constructor for the class. Create a new preference filter entry with the given >+ * key and value of regexp flag. The key must <em>not</em> be <code>null</code> or empty. >+ * >+ * @param key the name of the preference key >+ * @param regexp flag shows how name is used: >+ * "true" - as regular expression, "false" - exactly >+ */ >+ public PreferenceFilterEntry(String key, boolean isPrefix) { >+ super(); >+ if (key == null || key.length() == 0) >+ throw new IllegalArgumentException(); >+ this.key = key; >+ this.isPrefix = isPrefix; > } > > /** >@@ -45,4 +66,38 @@ > public String getKey() { > return key; > } >+ >+ /** >+ * Return regular expression flag. >+ * >+ * @return the regular expression flag >+ */ >+ public boolean isPrefix() { >+ return isPrefix; >+ } >+ >+ /** >+ * Adding into collection of preferences names, matches the regular expression, >+ * which is contained in the <code>key</code>. >+ * >+ * @param name the name of the preference, matches the regular expression, contained in the key >+ */ >+ public void addMatch(String name) { >+ if (!isPrefix) >+ return; >+ if (matches == null) >+ matches = new HashSet(); >+ matches.add(name); >+ } >+ >+ /** >+ * Return the array of preferences' names, matches the regular expression, contained in the key >+ * >+ * @return the array of the preferencs' names, matches the regular expression, contained in the key >+ */ >+ public Object[] getMatches() { >+ if (!isPrefix || matches == null) >+ return null; >+ return matches.toArray(); >+ } > } >#P org.eclipse.ui.workbench >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 14 Sep 2009 10:03:58 -0000 >@@ -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; >@@ -169,8 +169,14 @@ > prefFilters = new PreferenceFilterEntry[keys.length]; > for (int j = 0; j < keys.length; j++) { > IConfigurationElement keyElement = keys[j]; >+ boolean isPrefix = !(keyElement >+ .getAttribute(IWorkbenchRegistryConstants.ATT_MATCH_TYPE) == null || !keyElement >+ .getAttribute( >+ IWorkbenchRegistryConstants.ATT_MATCH_TYPE) >+ .equalsIgnoreCase("prefix")); //$NON-NLS-1$ > prefFilters[j] = new PreferenceFilterEntry(keyElement >- .getAttribute(IWorkbenchRegistryConstants.ATT_NAME)); >+ .getAttribute(IWorkbenchRegistryConstants.ATT_NAME), >+ isPrefix); > } > } > map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE), >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 14 Sep 2009 10:03:58 -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,13 @@ > public static String ATT_NAME = "name"; //$NON-NLS-1$ > > /** >+ * Match type attribute. Value <code>match</code>. >+ * >+ * @since 3.6 >+ */ >+ 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$ >#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 14 Sep 2009 10:04:00 -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"/> >@@ -152,6 +157,14 @@ > </documentation> > </annotation> > </attribute> >+ <attribute name="match" type="string"> >+ <annotation> >+ <documentation> >+ This attribute specifies, how attribute "name" is used. If it is omitted or its value doesn't equal <code>prefix</code>, "name" contains exact name of preference. In opposite case value of "name" is used for searching only such preferences, which start with this value. >+Since 3.6. >+ </documentation> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -265,10 +278,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,23 +298,7 @@ > </documentation> > </annotation> > >- <annotation> >- <appInfo> >- <meta.section type="apiInfo"/> >- </appInfo> >- <documentation> >- >- </documentation> >- </annotation> > >- <annotation> >- <appInfo> >- <meta.section type="implementation"/> >- </appInfo> >- <documentation> >- >- </documentation> >- </annotation> > > <annotation> > <appInfo>
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