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 3553 Details for
Bug 31458
[runtime] Task Tags preference not exported
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch for runtime
patch (text/plain), 7.46 KB, created by
DJ Houghton
on 2003-02-18 13:01:40 EST
(
hide
)
Description:
patch for runtime
Filename:
MIME Type:
Creator:
DJ Houghton
Created:
2003-02-18 13:01:40 EST
Size:
7.46 KB
patch
obsolete
>Index: src/org/eclipse/core/internal/runtime/PreferenceExporter.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PreferenceExporter.java,v >retrieving revision 1.6 >diff -u -r1.6 PreferenceExporter.java >--- src/org/eclipse/core/internal/runtime/PreferenceExporter.java 21 Jun 2002 19:23:19 -0000 1.6 >+++ src/org/eclipse/core/internal/runtime/PreferenceExporter.java 18 Feb 2003 18:00:33 -0000 >@@ -11,9 +11,7 @@ > package org.eclipse.core.internal.runtime; > > import java.io.*; >-import java.util.HashMap; >-import java.util.Map; >- >+import java.util.*; > import org.eclipse.core.runtime.*; > > /** >@@ -40,8 +38,8 @@ > * @see Preferences#exportPreferences > */ > public static void exportPreferences(IPath file) throws CoreException { >- //collect all plugin preferences into a single global preference object >- Preferences globalPreferences = new Preferences(); >+ //collect all plugin preferences into a single global properties object >+ Properties globalPreferences = new Properties(); > IPluginDescriptor[] descriptors = Platform.getPluginRegistry().getPluginDescriptors(); > for (int i = 0; i < descriptors.length; i++) { > IPluginDescriptor descriptor = descriptors[i]; >@@ -52,7 +50,7 @@ > //now merge the plugin preferences into the global preference object > if (mergePluginPreferences(descriptor, globalPreferences)) { > //write the property that indicates the plugin version >- globalPreferences.setValue(descriptor.getUniqueIdentifier(), descriptor.getVersionIdentifier().toString()); >+ globalPreferences.put(descriptor.getUniqueIdentifier(), descriptor.getVersionIdentifier().toString()); > } > > } >@@ -66,11 +64,11 @@ > String msg = Policy.bind("preferences.fileNotFound", file.toOSString()); //$NON-NLS-1$ > throw new CoreException(new Status(IStatus.ERROR, Platform.PI_RUNTIME, 1, msg, null)); > } >- Map idsToPreferences = splitPreferences(file); >+ Map idsToProperties = splitPreferences(file); > IPluginDescriptor[] descriptors = Platform.getPluginRegistry().getPluginDescriptors(); > for (int i = 0; i < descriptors.length; i++) { > setPluginPreferences(descriptors[i], >- (Preferences) idsToPreferences.get(descriptors[i].getUniqueIdentifier())); >+ (Properties) idsToProperties.get(descriptors[i].getUniqueIdentifier())); > } > } > /** >@@ -108,7 +106,7 @@ > * preferences instance. Returns true if any properties were added, > * and false otherwise. > */ >- private static boolean mergePluginPreferences(IPluginDescriptor descriptor, Preferences preferences) throws CoreException { >+ private static boolean mergePluginPreferences(IPluginDescriptor descriptor, Properties globalProperties) throws CoreException { > boolean found = false; > IPath propertiesFile = InternalPlatform.getMetaArea().getPluginPreferenceLocation(descriptor, false); > if (propertiesFile.toFile().exists()) { >@@ -118,7 +116,7 @@ > found = keys.length > 0; > for (int i = 0; i < keys.length; i++) { > String longKey = pluginId + PLUGIN_SEPARATOR + keys[i]; >- preferences.setValue(longKey, pluginPreferences.getString(keys[i])); >+ globalProperties.put(longKey, pluginPreferences.getString(keys[i])); > } > } > return found; >@@ -130,7 +128,7 @@ > * given descriptor, overwriting any previously defined preferences. If > * the given preferences is null, all values are returned to their default value. > */ >- private static void setPluginPreferences(IPluginDescriptor descriptor, Preferences newPreferences) throws CoreException { >+ private static void setPluginPreferences(IPluginDescriptor descriptor, Properties newProperties) throws CoreException { > IPath location = InternalPlatform.getMetaArea().getPluginPreferenceLocation(descriptor, false); > if (descriptor.isPluginActivated()) { > Plugin plugin = descriptor.getPlugin(); >@@ -143,11 +141,10 @@ > oldPreferences.setToDefault(keys[i]); > } > //add new values >- if (newPreferences != null) { >- keys = newPreferences.propertyNames(); >- for (int i = 0; i < keys.length; i++) { >- keys[i] = keys[i].intern(); >- oldPreferences.setValue(keys[i], newPreferences.getString(keys[i])); >+ if (newProperties != null) { >+ for (Enumeration e = newProperties.propertyNames(); e.hasMoreElements();) { >+ String key = ((String)e.nextElement()).intern(); >+ oldPreferences.setValue(key, newProperties.getProperty(key)); > } > } > //save the preferences file >@@ -155,7 +152,7 @@ > } > } else { > //if the plugin isn't loaded, just save the preferences file directly >- storePreferences(location, newPreferences); >+ storePreferences(location, newProperties); > } > } > /** >@@ -166,7 +163,7 @@ > private static Map splitPreferences(IPath file) throws CoreException { > Preferences globalPreferences = loadPreferences(file, new Preferences()); > validatePreferenceFileFormat(globalPreferences); >- Map idsToPreferences = new HashMap(); >+ Map idsToProperties = new HashMap(); > String[] keys = globalPreferences.propertyNames(); > for (int i = 0; i < keys.length; i++) { > String longKey = keys[i]; >@@ -174,15 +171,15 @@ > if (index >= 0) { > String pluginId = longKey.substring(0, index); > String key = longKey.substring(index + 1); >- Preferences preferences = (Preferences) idsToPreferences.get(pluginId); >- if (preferences == null) { >- preferences = new Preferences(); >- idsToPreferences.put(pluginId, preferences); >+ Properties properties = (Properties) idsToProperties.get(pluginId); >+ if (properties == null) { >+ properties = new Properties(); >+ idsToProperties.put(pluginId, properties); > } >- preferences.setValue(key, globalPreferences.getString(longKey)); >+ properties.put(key, globalPreferences.getString(longKey)); > } > } >- return idsToPreferences; >+ return idsToProperties; > } > > >@@ -191,21 +188,27 @@ > /** > * Writes the given preferences to the given file. If the preferences are > * null or empty, the file is deleted. >+ * @param preferences either a Properties or Preferences object > */ >- private static void storePreferences(IPath destination, Preferences preferences) throws CoreException { >+ private static void storePreferences(IPath destination, Object preferences) throws CoreException { > File propertiesFile = destination.toFile(); >- if (preferences == null || preferences.propertyNames().length == 0) { >+ //if the preferences is null or empty, delete the file and return >+ if (preferences == null || >+ (preferences instanceof Properties && ((Properties)preferences).size() == 0) || >+ (preferences instanceof Preferences &&((Preferences)preferences).propertyNames().length == 0)) { > propertiesFile.delete(); > return; > } > File parent = propertiesFile.getParentFile(); >- if (!parent.exists()) { >+ if (!parent.exists()) > parent.mkdirs(); >- } > OutputStream out = null; > try { > out = new BufferedOutputStream(new FileOutputStream(propertiesFile)); >- preferences.store(out, null); >+ if (preferences instanceof Properties) >+ ((Properties)preferences).store(out, null); >+ else >+ ((Preferences)preferences).store(out, null); > } catch (IOException e) { > String msg = Policy.bind("preferences.errorWriting", propertiesFile.toString(), e.getMessage()); //$NON-NLS-1$ > throw new CoreException(new Status(IStatus.ERROR, Platform.PI_RUNTIME, 1, msg, e)); >@@ -218,7 +221,7 @@ > } > } > } >- } >+ } > /** > * Compares two plugin version identifiers to see if their preferences > * are compatible. If they are not compatible, a warning message is
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 31458
: 3553