diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java index 83d74ba34b4..84bd19e5d1e 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/PreferenceForwarder.java @@ -47,10 +47,12 @@ public class PreferenceForwarder extends Preferences implements IEclipsePreferen /* * Used for test suites only. */ + @Deprecated public PreferenceForwarder(String pluginID) { this(null, pluginID); } + @Deprecated public PreferenceForwarder(Object plugin, String pluginID) { super(); this.plugin = plugin; @@ -60,6 +62,7 @@ public PreferenceForwarder(Object plugin, String pluginID) { /* * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) */ + @Deprecated @Override public synchronized void added(IEclipsePreferences.NodeChangeEvent event) { if (listeners.size() > 0 && pluginID.equals(event.getChild().name())) { @@ -75,6 +78,7 @@ public synchronized void added(IEclipsePreferences.NodeChangeEvent event) { /* * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) */ + @Deprecated @Override public synchronized void removed(IEclipsePreferences.NodeChangeEvent event) { // Do nothing. We can't remove ourselves from the node's list of preference change @@ -87,6 +91,7 @@ public synchronized void removed(IEclipsePreferences.NodeChangeEvent event) { * * @param listener a property change listener */ + @Deprecated @Override public synchronized void addPropertyChangeListener(IPropertyChangeListener listener) { if (listeners.size() == 0) { @@ -103,6 +108,7 @@ public synchronized void addPropertyChangeListener(IPropertyChangeListener liste /* * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) */ + @Deprecated @Override public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) { // if we are the ones making this change, then don't broadcast @@ -145,6 +151,7 @@ private IEclipsePreferences getDefaultPreferences() { * * @param listener a property change listener */ + @Deprecated @Override public synchronized void removePropertyChangeListener(IPropertyChangeListener listener) { listeners.remove(listener); @@ -194,6 +201,7 @@ private Object getDefault(String key, Object obj) { * @return true if either a current value or a default * value is known for the named property, and falseotherwise */ + @Deprecated @Override public boolean contains(String name) { if (name == null) { @@ -216,6 +224,7 @@ public boolean contains(String name) { * @param name the name of the property * @return the boolean-valued property */ + @Deprecated @Override public boolean getBoolean(String name) { return getPluginPreferences(true).getBoolean(name, getDefaultPreferences().getBoolean(name, BOOLEAN_DEFAULT_DEFAULT)); @@ -240,6 +249,7 @@ public boolean getBoolean(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated @Override public void setValue(String name, boolean value) { Boolean oldValue = getBoolean(name) ? Boolean.TRUE : Boolean.FALSE; @@ -270,6 +280,7 @@ public void setValue(String name, boolean value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated @Override public boolean getDefaultBoolean(String name) { return getDefaultPreferences().getBoolean(name, BOOLEAN_DEFAULT_DEFAULT); @@ -290,6 +301,7 @@ public boolean getDefaultBoolean(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated @Override public void setDefault(String name, boolean value) { getDefaultPreferences().putBoolean(name, value); @@ -305,6 +317,7 @@ public void setDefault(String name, boolean value) { * @param name the name of the property * @return the double-valued property */ + @Deprecated @Override public double getDouble(String name) { return getPluginPreferences(true).getDouble(name, getDefaultPreferences().getDouble(name, DOUBLE_DEFAULT_DEFAULT)); @@ -330,6 +343,7 @@ public double getDouble(String name) { * @param value the new current value of the property; must be * a number (not a NaN) */ + @Deprecated @Override public void setValue(String name, double value) { if (Double.isNaN(value)) { @@ -364,6 +378,7 @@ public void setValue(String name, double value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated @Override public double getDefaultDouble(String name) { return getDefaultPreferences().getDouble(name, DOUBLE_DEFAULT_DEFAULT); @@ -385,6 +400,7 @@ public double getDefaultDouble(String name) { * @param value the new default value for the property; must be * a number (not a NaN) */ + @Deprecated @Override public void setDefault(String name, double value) { if (Double.isNaN(value)) { @@ -403,6 +419,7 @@ public void setDefault(String name, double value) { * @param name the name of the property * @return the float-valued property */ + @Deprecated @Override public float getFloat(String name) { return getPluginPreferences(true).getFloat(name, getDefaultPreferences().getFloat(name, FLOAT_DEFAULT_DEFAULT)); @@ -428,6 +445,7 @@ public float getFloat(String name) { * @param value the new current value of the property; must be * a number (not a NaN) */ + @Deprecated @Override public void setValue(String name, float value) { if (Float.isNaN(value)) { @@ -462,6 +480,7 @@ public void setValue(String name, float value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated @Override public float getDefaultFloat(String name) { return getDefaultPreferences().getFloat(name, FLOAT_DEFAULT_DEFAULT); @@ -483,6 +502,7 @@ public float getDefaultFloat(String name) { * @param value the new default value for the property; must be * a number (not a NaN) */ + @Deprecated @Override public void setDefault(String name, float value) { if (Float.isNaN(value)) { @@ -501,6 +521,7 @@ public void setDefault(String name, float value) { * @param name the name of the property * @return the int-valued property */ + @Deprecated @Override public int getInt(String name) { return getPluginPreferences(true).getInt(name, getDefaultPreferences().getInt(name, INT_DEFAULT_DEFAULT)); @@ -525,6 +546,7 @@ public int getInt(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated @Override public void setValue(String name, int value) { final int intValue = getInt(name); @@ -556,6 +578,7 @@ public void setValue(String name, int value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated @Override public int getDefaultInt(String name) { return getDefaultPreferences().getInt(name, INT_DEFAULT_DEFAULT); @@ -576,6 +599,7 @@ public int getDefaultInt(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated @Override public void setDefault(String name, int value) { getDefaultPreferences().putInt(name, value); @@ -591,6 +615,7 @@ public void setDefault(String name, int value) { * @param name the name of the property * @return the long-valued property */ + @Deprecated @Override public long getLong(String name) { return getPluginPreferences(true).getLong(name, getDefaultPreferences().getLong(name, LONG_DEFAULT_DEFAULT)); @@ -615,6 +640,7 @@ public long getLong(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated @Override public void setValue(String name, long value) { final long longValue = getLong(name); @@ -646,6 +672,7 @@ public void setValue(String name, long value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated @Override public long getDefaultLong(String name) { return getDefaultPreferences().getLong(name, LONG_DEFAULT_DEFAULT); @@ -666,6 +693,7 @@ public long getDefaultLong(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated @Override public void setDefault(String name, long value) { getDefaultPreferences().putLong(name, value); @@ -680,6 +708,7 @@ public void setDefault(String name, long value) { * @param name the name of the property * @return the string-valued property */ + @Deprecated @Override public String getString(String name) { return getPluginPreferences(true).get(name, getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT)); @@ -704,6 +733,7 @@ public String getString(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated @Override public void setValue(String name, String value) { if (value == null) { @@ -736,6 +766,7 @@ public void setValue(String name, String value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated @Override public String getDefaultString(String name) { return getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT); @@ -756,6 +787,7 @@ public String getDefaultString(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated @Override public void setDefault(String name, String value) { if (value == null) { @@ -773,6 +805,7 @@ public void setDefault(String name, String value) { * and false otherwise (including the case where the property * is unknown to this object) */ + @Deprecated @Override public boolean isDefault(String name) { if (name == null) { @@ -800,6 +833,7 @@ public boolean isDefault(String name) { * * @param name the name of the property */ + @Deprecated @Override public void setToDefault(String name) { IEclipsePreferences preferences = getPluginPreferences(true); @@ -815,6 +849,7 @@ public void setToDefault(String name) { * * @return an array of property names */ + @Deprecated @Override public String[] propertyNames() { return getPluginPreferences(true).keys(); @@ -826,6 +861,7 @@ public String[] propertyNames() { * * @return an array of property names */ + @Deprecated @Override public String[] defaultPropertyNames() { try { @@ -844,6 +880,7 @@ public String[] defaultPropertyNames() { * known to this preference object has a current value different from its * default value, and false otherwise */ + @Deprecated @Override public boolean needsSaving() { return getPluginPreferences(true).isDirty(); @@ -852,6 +889,7 @@ public boolean needsSaving() { /** * Flush the values of these plug-in preferences to disk. */ + @Deprecated public void flush() throws BackingStoreException { IEclipsePreferences node = getPluginPreferences(false); if (node != null) { @@ -870,6 +908,7 @@ private void logError(String message, Exception e) { /* * @see org.eclipse.core.runtime.Preferences#load(java.io.InputStream) */ + @Deprecated @Override public void load(InputStream in) throws IOException { Properties result = new Properties(); @@ -888,6 +927,7 @@ public void load(InputStream in) throws IOException { /* * @see org.eclipse.core.runtime.Preferences#store(java.io.OutputStream, java.lang.String) */ + @Deprecated @Override public void store(OutputStream out, String header) throws IOException { Properties result = convertToProperties(); @@ -913,6 +953,7 @@ private void convertFromProperties(Properties props) { } } + @Deprecated @Override public String toString() { return "PreferenceForwarder(" + pluginID + ")"; //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java index dfdc23c44b8..96c2146c057 100644 --- a/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java +++ b/runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Preferences.java @@ -98,43 +98,51 @@ public class Preferences { /** * The default-default value for boolean properties (false). */ + @Deprecated public static final boolean BOOLEAN_DEFAULT_DEFAULT = false; /** * The default-default value for double properties (0.0). */ + @Deprecated public static final double DOUBLE_DEFAULT_DEFAULT = 0.0; /** * The default-default value for float properties (0.0f). */ + @Deprecated public static final float FLOAT_DEFAULT_DEFAULT = 0.0f; /** * The default-default value for int properties (0). */ + @Deprecated public static final int INT_DEFAULT_DEFAULT = 0; /** * The default-default value for long properties (0L). */ + @Deprecated public static final long LONG_DEFAULT_DEFAULT = 0L; /** * The default-default value for String properties (""). */ + @Deprecated public static final String STRING_DEFAULT_DEFAULT = ""; //$NON-NLS-1$ /** * The string representation used for true * ("true"). */ + @Deprecated protected static final String TRUE = "true"; //$NON-NLS-1$ /** * The string representation used for false * ("false"). */ + @Deprecated protected static final String FALSE = "false"; //$NON-NLS-1$ /** @@ -150,6 +158,7 @@ public class Preferences { * * @since 3.2 */ + @Deprecated public static final String PT_PREFERENCES = "preferences"; //$NON-NLS-1$ /** @@ -168,6 +177,7 @@ public class Preferences { * @see Preferences#addPropertyChangeListener(Preferences.IPropertyChangeListener) * @see Preferences.IPropertyChangeListener */ + @Deprecated public static class PropertyChangeEvent extends EventObject { /** * All serializable objects should have a stable serialVersionUID @@ -272,6 +282,7 @@ public Object getOldValue() { * three cases in their implementation of the property change listener. *

*/ + @Deprecated @FunctionalInterface public interface IPropertyChangeListener extends EventListener { @@ -294,6 +305,7 @@ public interface IPropertyChangeListener extends EventListener { * These listeners are to be informed when the current value of a property * changes. */ + @Deprecated protected ListenerList listeners = new ListenerList<>(); /** @@ -313,6 +325,7 @@ public interface IPropertyChangeListener extends EventListener { * Indicates whether a value has been changed by setToDefault * or setValue; initially false. */ + @Deprecated protected boolean dirty = false; /** @@ -330,6 +343,7 @@ public interface IPropertyChangeListener extends EventListener { * @see #importPreferences(IPath) * @see #validatePreferenceVersions(IPath) */ + @Deprecated public static void exportPreferences(IPath path) throws CoreException { File file = path.toFile(); if (file.exists()) { @@ -372,6 +386,7 @@ public static void exportPreferences(IPath path) throws CoreException { * @see #exportPreferences(IPath) * @see #validatePreferenceVersions(IPath) */ + @Deprecated public static void importPreferences(IPath path) throws CoreException { if (!path.toFile().exists()) { String msg = NLS.bind(PrefsMessages.preferences_fileNotFound, path.toOSString()); @@ -410,6 +425,7 @@ public static void importPreferences(IPath path) throws CoreException { * @see #exportPreferences(IPath) * @see #importPreferences(IPath) */ + @Deprecated public static IStatus validatePreferenceVersions(IPath file) { PreferencesService service = PreferencesService.getDefault(); return service.validateVersions(file); @@ -424,6 +440,7 @@ public static IStatus validatePreferenceVersions(IPath file) { * @see #load(InputStream) * @see #store(OutputStream, String) */ + @Deprecated public Preferences() { defaultProperties = new Properties(); properties = new Properties(defaultProperties); @@ -441,6 +458,7 @@ public Preferences() { *

* @param listener a property change listener */ + @Deprecated public void addPropertyChangeListener(IPropertyChangeListener listener) { listeners.add(listener); } @@ -451,6 +469,7 @@ public void addPropertyChangeListener(IPropertyChangeListener listener) { * * @param listener a property change listener */ + @Deprecated public void removePropertyChangeListener(IPropertyChangeListener listener) { listeners.remove(listener); } @@ -464,6 +483,7 @@ public void removePropertyChangeListener(IPropertyChangeListener listener) { * @return true if either a current value or a default * value is known for the named property, and falseotherwise */ + @Deprecated public boolean contains(String name) { return (properties.containsKey(name) || defaultProperties.containsKey(name)); } @@ -479,6 +499,7 @@ public boolean contains(String name) { * @param newValue the new value, or null if not known or not * relevant */ + @Deprecated protected void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { if (name == null) { throw new IllegalArgumentException(); @@ -515,6 +536,7 @@ public void run() throws Exception { * @param name the name of the property * @return the boolean-valued property */ + @Deprecated public boolean getBoolean(String name) { String value = properties.getProperty(name); if (value == null) { @@ -542,6 +564,7 @@ public boolean getBoolean(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated public void setValue(String name, boolean value) { boolean defaultValue = getDefaultBoolean(name); boolean oldValue = getBoolean(name); @@ -573,6 +596,7 @@ public void setValue(String name, boolean value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated public boolean getDefaultBoolean(String name) { String value = defaultProperties.getProperty(name); if (value == null) { @@ -596,6 +620,7 @@ public boolean getDefaultBoolean(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated public void setDefault(String name, boolean value) { defaultProperties.put(name, value ? Preferences.TRUE : Preferences.FALSE); } @@ -611,6 +636,7 @@ public void setDefault(String name, boolean value) { * @param name the name of the property * @return the double-valued property */ + @Deprecated public double getDouble(String name) { return convertToDouble(properties.getProperty(name), DOUBLE_DEFAULT_DEFAULT); } @@ -635,6 +661,7 @@ public double getDouble(String name) { * @param value the new current value of the property; must be * a number (not a NaN) */ + @Deprecated public void setValue(String name, double value) { if (Double.isNaN(value)) { throw new IllegalArgumentException(); @@ -669,6 +696,7 @@ public void setValue(String name, double value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated public double getDefaultDouble(String name) { return convertToDouble(defaultProperties.getProperty(name), DOUBLE_DEFAULT_DEFAULT); } @@ -689,6 +717,7 @@ public double getDefaultDouble(String name) { * @param value the new default value for the property; must be * a number (not a NaN) */ + @Deprecated public void setDefault(String name, double value) { if (Double.isNaN(value)) { throw new IllegalArgumentException(); @@ -729,6 +758,7 @@ private double convertToDouble(String rawPropertyValue, double defaultValue) { * @param name the name of the property * @return the float-valued property */ + @Deprecated public float getFloat(String name) { return convertToFloat(properties.getProperty(name), FLOAT_DEFAULT_DEFAULT); } @@ -753,6 +783,7 @@ public float getFloat(String name) { * @param value the new current value of the property; must be * a number (not a NaN) */ + @Deprecated public void setValue(String name, float value) { if (Float.isNaN(value)) { throw new IllegalArgumentException(); @@ -787,6 +818,7 @@ public void setValue(String name, float value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated public float getDefaultFloat(String name) { return convertToFloat(defaultProperties.getProperty(name), FLOAT_DEFAULT_DEFAULT); } @@ -807,6 +839,7 @@ public float getDefaultFloat(String name) { * @param value the new default value for the property; must be * a number (not a NaN) */ + @Deprecated public void setDefault(String name, float value) { if (Float.isNaN(value)) { throw new IllegalArgumentException(); @@ -847,6 +880,7 @@ private float convertToFloat(String rawPropertyValue, float defaultValue) { * @param name the name of the property * @return the int-valued property */ + @Deprecated public int getInt(String name) { return convertToInt(properties.getProperty(name), INT_DEFAULT_DEFAULT); } @@ -870,6 +904,7 @@ public int getInt(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated public void setValue(String name, int value) { int defaultValue = getDefaultInt(name); int oldValue = getInt(name); @@ -901,6 +936,7 @@ public void setValue(String name, int value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated public int getDefaultInt(String name) { return convertToInt(defaultProperties.getProperty(name), INT_DEFAULT_DEFAULT); } @@ -920,6 +956,7 @@ public int getDefaultInt(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated public void setDefault(String name, int value) { defaultProperties.put(name, Integer.toString(value)); } @@ -957,6 +994,7 @@ private int convertToInt(String rawPropertyValue, int defaultValue) { * @param name the name of the property * @return the long-valued property */ + @Deprecated public long getLong(String name) { return convertToLong(properties.getProperty(name), LONG_DEFAULT_DEFAULT); } @@ -980,6 +1018,7 @@ public long getLong(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated public void setValue(String name, long value) { long defaultValue = getDefaultLong(name); long oldValue = getLong(name); @@ -1011,6 +1050,7 @@ public void setValue(String name, long value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated public long getDefaultLong(String name) { return convertToLong(defaultProperties.getProperty(name), LONG_DEFAULT_DEFAULT); } @@ -1030,6 +1070,7 @@ public long getDefaultLong(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated public void setDefault(String name, long value) { defaultProperties.put(name, Long.toString(value)); } @@ -1066,6 +1107,7 @@ private long convertToLong(String rawPropertyValue, long defaultValue) { * @param name the name of the property * @return the string-valued property */ + @Deprecated public String getString(String name) { String value = properties.getProperty(name); return (value != null ? value : STRING_DEFAULT_DEFAULT); @@ -1090,6 +1132,7 @@ public String getString(String name) { * @param name the name of the property * @param value the new current value of the property */ + @Deprecated public void setValue(String name, String value) { if (value == null) { throw new IllegalArgumentException(); @@ -1124,6 +1167,7 @@ public void setValue(String name, String value) { * @param name the name of the property * @return the default value of the named property */ + @Deprecated public String getDefaultString(String name) { String value = defaultProperties.getProperty(name); return (value != null ? value : STRING_DEFAULT_DEFAULT); @@ -1144,6 +1188,7 @@ public String getDefaultString(String name) { * @param name the name of the property * @param value the new default value for the property */ + @Deprecated public void setDefault(String name, String value) { if (value == null) { throw new IllegalArgumentException(); @@ -1161,6 +1206,7 @@ public void setDefault(String name, String value) { * and false otherwise (including the case where the property * is unknown to this object) */ + @Deprecated public boolean isDefault(String name) { return !properties.containsKey(name); } @@ -1184,6 +1230,7 @@ public boolean isDefault(String name) { * * @param name the name of the property */ + @Deprecated public void setToDefault(String name) { Object oldPropertyValue = properties.remove(name); if (oldPropertyValue != null) { @@ -1201,6 +1248,7 @@ public void setToDefault(String name) { * * @return an array of property names */ + @Deprecated public String[] propertyNames() { return properties.keySet().toArray(EMPTY_STRING_ARRAY); } @@ -1211,6 +1259,7 @@ public String[] propertyNames() { * * @return an array of property names */ + @Deprecated public String[] defaultPropertyNames() { return defaultProperties.keySet().toArray(EMPTY_STRING_ARRAY); } @@ -1223,6 +1272,7 @@ public String[] defaultPropertyNames() { * known to this preference object has a current value different from its * default value, and false otherwise */ + @Deprecated public boolean needsSaving() { return dirty; } @@ -1242,6 +1292,7 @@ public boolean needsSaving() { * @exception IOException if there is a problem saving this preference object * @see Properties#store(OutputStream,String) */ + @Deprecated public void store(OutputStream out, String header) throws IOException { properties.store(out, header); dirty = false; @@ -1258,6 +1309,7 @@ public void store(OutputStream out, String header) throws IOException { * object * @see java.util.Properties#load(InputStream) */ + @Deprecated public void load(InputStream in) throws IOException { properties.load(in); dirty = false;