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 146061 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]
First version of patch
patch208564 (text/plain), 13.69 KB, created by
Semion Chichelnitsky
on 2009-08-31 09:16:37 EDT
(
hide
)
Description:
First version of patch
Filename:
MIME Type:
Creator:
Semion Chichelnitsky
Created:
2009-08-31 09:16:37 EDT
Size:
13.69 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 31 Aug 2009 12:57:40 -0000 >@@ -13,6 +13,7 @@ > import java.io.*; > import java.lang.ref.WeakReference; > import java.util.*; >+import java.util.regex.*; > import org.eclipse.core.internal.runtime.RuntimeLog; > import org.eclipse.core.runtime.*; > import org.eclipse.core.runtime.preferences.*; >@@ -773,9 +774,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].isRegexp()) >+ 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].isRegexp() && child.get(entries[j].getKey(), null) != null) >+ return true; >+ else if (entries[j].isRegexp()) { >+ if (entries[j].getMatches() != null) >+ return true; >+ } >+ } > } > } > } >@@ -785,6 +796,28 @@ > } > > /* >+ * Internal method that collects the matching preferences for the given regular expression. >+ */ >+ private void internalMatchesWithRegexp(PreferenceFilterEntry entry, String[] keys, String exp) { >+ if (keys == null || keys.length == 0 || exp == null || exp.length() == 0) >+ return; >+ Pattern pattern = null; >+ try { >+ pattern = Pattern.compile(exp); >+ } catch (PatternSyntaxException e) { >+ log(new Status(IStatus.ERROR, Activator.PI_PREFERENCES, PrefsMessages.preferences_regexpError, e)); >+ } >+ if (pattern == null) >+ return; >+ for (int i = 0; i < keys.length; i++) { >+ Matcher matcher = pattern.matcher(keys[i]); >+ if (matcher.find()) { >+ 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 +1006,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].isRegexp()) >+ 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/internal/preferences/messages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/messages.properties,v >retrieving revision 1.4 >diff -u -r1.4 messages.properties >--- src/org/eclipse/core/internal/preferences/messages.properties 24 Feb 2009 19:37:17 -0000 1.4 >+++ src/org/eclipse/core/internal/preferences/messages.properties 31 Aug 2009 12:57:41 -0000 >@@ -34,3 +34,4 @@ > preferences_saveProblems=Problems saving preferences. > preferences_validate=Some preferences may not be compatible with the currently installed plug-ins. > preferences_validationException=Exception while validating bundle versions. >+preferences_regexpError=Error occurred while searching preferences which match some regular expression >Index: src/org/eclipse/core/internal/preferences/PrefsMessages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/compendium/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PrefsMessages.java,v >retrieving revision 1.4 >diff -u -r1.4 PrefsMessages.java >--- src/org/eclipse/core/internal/preferences/PrefsMessages.java 24 Feb 2009 19:37:17 -0000 1.4 >+++ src/org/eclipse/core/internal/preferences/PrefsMessages.java 31 Aug 2009 12:57:41 -0000 >@@ -47,6 +47,7 @@ > public static String preferences_saveProblems; > public static String preferences_validate; > public static String preferences_validationException; >+ public static String preferences_regexpError; > > static { > // load message values from bundle file >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 31 Aug 2009 12:57:41 -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 isRegexp; > > /** > * 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.isRegexp = 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 isRegexp) { >+ super(); >+ if (key == null || key.length() == 0) >+ throw new IllegalArgumentException(); >+ this.key = key; >+ this.isRegexp = isRegexp; > } > > /** >@@ -45,4 +66,38 @@ > public String getKey() { > return key; > } >+ >+ /** >+ * Return regular expression flag. >+ * >+ * @return the regular expression flag >+ */ >+ public boolean isRegexp() { >+ return isRegexp; >+ } >+ >+ /** >+ * 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 (!isRegexp) >+ 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 (!isRegexp || 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 31 Aug 2009 12:57:44 -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,10 @@ > prefFilters = new PreferenceFilterEntry[keys.length]; > for (int j = 0; j < keys.length; j++) { > IConfigurationElement keyElement = keys[j]; >+ boolean regExp = !(keyElement.getAttribute(IWorkbenchRegistryConstants.REG_EXP) == null || >+ !keyElement.getAttribute(IWorkbenchRegistryConstants.REG_EXP).equalsIgnoreCase("true")); //$NON-NLS-1$ > prefFilters[j] = new PreferenceFilterEntry(keyElement >- .getAttribute(IWorkbenchRegistryConstants.ATT_NAME)); >+ .getAttribute(IWorkbenchRegistryConstants.ATT_NAME), regExp); > } > } > 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 31 Aug 2009 12:57:44 -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$ > > /** >+ * Name as regular expression attribute. Value <code>regexp</code>. >+ */ >+ public static String REG_EXP = "regexp"; //$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 31 Aug 2009 12:57:46 -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="regexp" type="boolean"> >+ <annotation> >+ <documentation> >+ This attribute specifies, how attribute "name" is used. If it is omitted or set to "false", "name" contains exact name of preference. In opposite case value of "name" is used as a regular expression for searching in the set of preferences. >+Since 3.6. >+ </documentation> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -268,7 +281,8 @@ > <key name="showIntro,DOCK_PERSPECTIVE_BAR"/> > </entry> > <entry node="org.eclipse.ui.workbench"> >- <key name="bogus,RUN_IN_BACKGROUND"/> >+ <key name="RUN_IN_BACKGROUND"/> >+ <key name="OPEN*" regexp="true"/> > </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