Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2016-01-20 17:56:46 +0000
committerMarkus Keller2016-01-20 17:56:46 +0000
commit96a04a8d6c92787774bd44844c3993a32643d748 (patch)
treebe424cc7ee27626347dac228ccbcec883afb1320 /bundles/org.eclipse.equinox.preferences
parent284795918e217a56a255dc18d1854233dcc7fffe (diff)
downloadrt.equinox.bundles-96a04a8d6c92787774bd44844c3993a32643d748.tar.gz
rt.equinox.bundles-96a04a8d6c92787774bd44844c3993a32643d748.tar.xz
rt.equinox.bundles-96a04a8d6c92787774bd44844c3993a32643d748.zip
Diffstat (limited to 'bundles/org.eclipse.equinox.preferences')
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java16
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferenceServiceRegistryHelper.java13
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java5
3 files changed, 13 insertions, 21 deletions
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
index 8cd69f39..d38508e2 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/EclipsePreferences.java
@@ -61,8 +61,8 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
// the parent of an EclipsePreference node is always an EclipsePreference node. (or null)
protected final EclipsePreferences parent;
protected boolean removed = false;
- private ListenerList nodeChangeListeners;
- private ListenerList preferenceChangeListeners;
+ private ListenerList<INodeChangeListener> nodeChangeListeners;
+ private ListenerList<IPreferenceChangeListener> preferenceChangeListeners;
private ScopeDescriptor descriptor;
public static boolean DEBUG_PREFERENCE_GENERAL = false;
@@ -131,7 +131,7 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
public void addNodeChangeListener(INodeChangeListener listener) {
checkRemoved();
if (nodeChangeListeners == null)
- nodeChangeListeners = new ListenerList();
+ nodeChangeListeners = new ListenerList<>();
nodeChangeListeners.add(listener);
if (DEBUG_PREFERENCE_GENERAL)
PrefsMessages.message("Added preference node change listener: " + listener + " to: " + absolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -142,7 +142,7 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
public void addPreferenceChangeListener(IPreferenceChangeListener listener) {
checkRemoved();
if (preferenceChangeListeners == null)
- preferenceChangeListeners = new ListenerList();
+ preferenceChangeListeners = new ListenerList<>();
preferenceChangeListeners.add(listener);
if (DEBUG_PREFERENCE_GENERAL)
PrefsMessages.message("Added preference property change listener: " + listener + " to: " + absolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
@@ -769,9 +769,7 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
protected void fireNodeEvent(final NodeChangeEvent event, final boolean added) {
if (nodeChangeListeners == null)
return;
- Object[] listeners = nodeChangeListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final INodeChangeListener listener = (INodeChangeListener) listeners[i];
+ for (final INodeChangeListener listener : nodeChangeListeners) {
ISafeRunnable job = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {
@@ -837,10 +835,8 @@ public class EclipsePreferences implements IEclipsePreferences, IScope {
protected void firePreferenceEvent(String key, Object oldValue, Object newValue) {
if (preferenceChangeListeners == null)
return;
- Object[] listeners = preferenceChangeListeners.getListeners();
final PreferenceChangeEvent event = new PreferenceChangeEvent(this, key, oldValue, newValue);
- for (int i = 0; i < listeners.length; i++) {
- final IPreferenceChangeListener listener = (IPreferenceChangeListener) listeners[i];
+ for (final IPreferenceChangeListener listener : preferenceChangeListeners) {
ISafeRunnable job = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferenceServiceRegistryHelper.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferenceServiceRegistryHelper.java
index 5f55d954..0b151376 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferenceServiceRegistryHelper.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferenceServiceRegistryHelper.java
@@ -35,7 +35,7 @@ public class PreferenceServiceRegistryHelper implements IRegistryChangeListener
// Store this around for performance
private final static IExtension[] EMPTY_EXTENSION_ARRAY = new IExtension[0];
private static final Map<String, Object> scopeRegistry = Collections.synchronizedMap(new HashMap<String, Object>());
- private ListenerList modifyListeners;
+ private ListenerList<PreferenceModifyListener> modifyListeners;
private final PreferencesService service;
private final IExtensionRegistry registry;
@@ -93,7 +93,7 @@ public class PreferenceServiceRegistryHelper implements IRegistryChangeListener
log(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, PrefsMessages.preferences_classCastListener, null));
return;
}
- modifyListeners.add(listener);
+ modifyListeners.add((PreferenceModifyListener) listener);
} catch (CoreException e) {
log(e.getStatus());
}
@@ -194,9 +194,9 @@ public class PreferenceServiceRegistryHelper implements IRegistryChangeListener
* Return a list of the preference modify listeners. They are called during preference
* import and given the chance to modify the imported tree.
*/
- public PreferenceModifyListener[] getModifyListeners() {
+ public ListenerList<PreferenceModifyListener> getModifyListeners() {
if (modifyListeners == null) {
- modifyListeners = new ListenerList();
+ modifyListeners = new ListenerList<>();
IExtension[] extensions = getPrefExtensions();
for (int i = 0; i < extensions.length; i++) {
IConfigurationElement[] elements = extensions[i].getConfigurationElements();
@@ -205,10 +205,7 @@ public class PreferenceServiceRegistryHelper implements IRegistryChangeListener
addModifyListener(elements[j]);
}
}
- Object[] source = modifyListeners.getListeners();
- PreferenceModifyListener[] result = new PreferenceModifyListener[source.length];
- System.arraycopy(source, 0, result, 0, source.length);
- return result;
+ return modifyListeners;
}
/*
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
index 94cf4414..6c441582 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/PreferencesService.java
@@ -436,9 +436,8 @@ public class PreferencesService implements IPreferencesService {
if (registryHelper == null)
return tree;
final IEclipsePreferences[] result = new IEclipsePreferences[] {tree};
- PreferenceModifyListener[] listeners = ((PreferenceServiceRegistryHelper) registryHelper).getModifyListeners();
- for (int i = 0; i < listeners.length; i++) {
- final PreferenceModifyListener listener = listeners[i];
+ ListenerList<PreferenceModifyListener> listeners = ((PreferenceServiceRegistryHelper) registryHelper).getModifyListeners();
+ for (final PreferenceModifyListener listener : listeners) {
ISafeRunnable job = new ISafeRunnable() {
@Override
public void handleException(Throwable exception) {

Back to the top