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 146749 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]
Second patch
patch208564_2 (text/plain), 15.98 KB, created by
Semion Chichelnitsky
on 2009-09-09 09:38:30 EDT
(
hide
)
Description:
Second patch
Filename:
MIME Type:
Creator:
Semion Chichelnitsky
Created:
2009-09-09 09:38:30 EDT
Size:
15.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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 9 Sep 2009 13:30:49 -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; >@@ -24,6 +25,7 @@ > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.preferences.PreferenceFilterEntry; > import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.preferences.PreferenceMatcher; > import org.eclipse.ui.internal.preferences.PreferenceTransferElement; > > /** >@@ -169,8 +171,19 @@ > prefFilters = new PreferenceFilterEntry[keys.length]; > for (int j = 0; j < keys.length; j++) { > IConfigurationElement keyElement = keys[j]; >- prefFilters[j] = new PreferenceFilterEntry(keyElement >- .getAttribute(IWorkbenchRegistryConstants.ATT_NAME)); >+ boolean regExp = !(keyElement >+ .getAttribute(IWorkbenchRegistryConstants.REG_EXP) == null || !keyElement >+ .getAttribute(IWorkbenchRegistryConstants.REG_EXP) >+ .equalsIgnoreCase("true")); //$NON-NLS-1$ >+ if (!regExp) >+ prefFilters[j] = new PreferenceFilterEntry( >+ keyElement >+ .getAttribute(IWorkbenchRegistryConstants.ATT_NAME)); >+ else >+ prefFilters[j] = new PreferenceFilterEntry( >+ keyElement >+ .getAttribute(IWorkbenchRegistryConstants.ATT_NAME), >+ new PreferenceMatcher()); > } > } > 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 9 Sep 2009 13:30:49 -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$ >Index: Eclipse UI/org/eclipse/ui/internal/preferences/PreferenceMatcher.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/preferences/PreferenceMatcher.java >diff -N Eclipse UI/org/eclipse/ui/internal/preferences/PreferenceMatcher.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/preferences/PreferenceMatcher.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.preferences; >+ >+import java.util.regex.Matcher; >+import java.util.regex.Pattern; >+import java.util.regex.PatternSyntaxException; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.preferences.IPreferenceMatcher; >+import org.eclipse.ui.internal.WorkbenchPlugin; >+import org.eclipse.ui.internal.misc.StatusUtil; >+ >+/** >+ * @since 3.6 >+ * >+ */ >+public class PreferenceMatcher implements IPreferenceMatcher { >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.core.runtime.preferences.IPreferenceMatcher#find(java.lang >+ * .String, java.lang.String) >+ */ >+ public boolean find(String expression, String key) { >+ if (key == null || key.length() == 0 || expression == null >+ || expression.length() == 0) >+ return false; >+ Pattern pattern = null; >+ try { >+ pattern = Pattern.compile(expression); >+ } catch (PatternSyntaxException e) { >+ WorkbenchPlugin >+ .log( >+ "Error occurred while searching preferences which match some regular expression", //$NON-NLS-1$ >+ StatusUtil.newStatus(IStatus.ERROR, e.getMessage(), >+ e)); >+ } >+ if (pattern == null) >+ return false; >+ Matcher matcher = pattern.matcher(key); >+ if (matcher.find()) >+ return true; >+ return false; >+ } >+} >#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 9 Sep 2009 13:31:00 -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].isRegexp()) >+ internalMatchesWithRegexp(entries[k], child.keys()); >+ } > 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 +795,17 @@ > } > > /* >+ * Internal method that collects the matching preferences for the given regular expression. >+ */ >+ private void internalMatchesWithRegexp(PreferenceFilterEntry entry, String[] keys) { >+ if (keys == null || keys.length == 0) >+ return; >+ for (int i = 0; i < keys.length; i++) { >+ 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 +994,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/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 9 Sep 2009 13:31:00 -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,9 @@ > public final class PreferenceFilterEntry { > > private String key; >+ private HashSet matches; >+ private IPreferenceMatcher matcher; >+ boolean isRegexp; > > /** > * Constructor for the class. Create a new preference filter entry with the given >@@ -36,6 +41,28 @@ > } > > /** >+ * Constructor for the class. Create a new preference filter entry with the key, given >+ * in the form of regular expression and implementation of {@link IPreferenceMatcher}, >+ * used to find preferences with names, which are suitable for this regular expression. >+ * The key must <em>not</em> be <code>null</code> or empty. >+ * >+ * @param key the name of the preference key >+ * @param matcher used to find preferences with names, which are suitable for key >+ * @see org.eclipse.core.runtime.preferences.IPreferenceMatcher >+ * >+ * @since 3.6 >+ */ >+ public PreferenceFilterEntry(String key, IPreferenceMatcher matcher) { >+ super(); >+ if (key == null || key.length() == 0) >+ throw new IllegalArgumentException(); >+ this.key = key; >+ this.matcher = matcher; >+ if (matcher != null) >+ isRegexp = true; >+ } >+ >+ /** > * 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 +72,46 @@ > public String getKey() { > return key; > } >+ >+ /** >+ * Return regular expression flag. >+ * >+ * @return the regular expression flag >+ * >+ * @since 3.6 >+ */ >+ public boolean isRegexp() { >+ return isRegexp; >+ } >+ >+ /** >+ * Adding into collection of preferences names, match 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 >+ * >+ * @since 3.6 >+ */ >+ public void addMatch(String name) { >+ if (!isRegexp) >+ return; >+ if (matches == null) >+ matches = new HashSet(); >+ if (matcher.find(key, name)) >+ 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 >+ * >+ * @since 3.6 >+ */ >+ public Object[] getMatches() { >+ if (!isRegexp || matches == null || matches.size() == 0) >+ return null; >+ return matches.toArray(); >+ } >+ > } >Index: src/org/eclipse/core/runtime/preferences/IPreferenceMatcher.java >=================================================================== >RCS file: src/org/eclipse/core/runtime/preferences/IPreferenceMatcher.java >diff -N src/org/eclipse/core/runtime/preferences/IPreferenceMatcher.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/runtime/preferences/IPreferenceMatcher.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,31 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.runtime.preferences; >+ >+/** >+ * Preference matcher is used to find preferences, which are suitable >+ * for given regular expression. >+ * <p> >+ * Clients may implement this interface. >+ * </p> >+ * >+ * @since 3.6 >+ */ >+public interface IPreferenceMatcher { >+ /** >+ * Return <code>true</code> if key match given regular expression >+ * >+ * @param expression regular expression >+ * @param key preference name >+ * @return true if key match given regular expression, false in opposite case >+ */ >+ public boolean find(String expression, String key); >+} >#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 9 Sep 2009 13:31:02 -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