diff options
author | Sarika Sinha | 2016-01-22 12:51:59 +0000 |
---|---|---|
committer | Sarika Sinha | 2016-01-22 12:51:59 +0000 |
commit | b11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8 (patch) | |
tree | a69936f5c60f2ab82bc922a381764cf483aa80d8 | |
parent | eb152262968725de3dc0014287f621169ba5ca5e (diff) | |
download | eclipse.platform.debug-b11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8.tar.gz eclipse.platform.debug-b11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8.tar.xz eclipse.platform.debug-b11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8.zip |
Bug 486157 - Adapt to ListenerList changesI20160125-0400I20160124-2000
Change-Id: If4f1f4d0ccb2f8451b4901a2139aa6537542d41e
28 files changed, 212 insertions, 271 deletions
diff --git a/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java b/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java index 09668bad7..533cfb31d 100644 --- a/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java +++ b/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringVariableManager.java @@ -76,7 +76,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc /** * Variable listeners */ - private ListenerList fListeners; + private ListenerList<IValueVariableListener> fListeners; // notifications private static final int ADDED = 0; @@ -157,9 +157,12 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc public void notify(IValueVariable[] variables, int update) { fVariables = variables; fType = update; - Object[] copiedListeners= fListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IValueVariableListener)copiedListeners[i]; + /* + * Object[] copiedListeners= fListeners.getListeners(); for (int i= + * 0; i < copiedListeners.length; i++) { + */ + for (IValueVariableListener iValueVariableListener : fListeners) { + fListener = iValueVariableListener; SafeRunner.run(this); } fVariables = null; @@ -194,7 +197,7 @@ public class StringVariableManager implements IStringVariableManager, IPreferenc * Constructs a new string variable manager. */ private StringVariableManager() { - fListeners = new ListenerList(); + fListeners = new ListenerList<IValueVariableListener>(); } /** diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java index 665ffc876..8ca4c9a77 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -358,12 +358,12 @@ public class DebugPlugin extends Plugin { /** * The collection of debug event listeners. */ - private ListenerList fEventListeners = new ListenerList(); + private ListenerList<IDebugEventSetListener> fEventListeners = new ListenerList<>(); /** * Event filters, or <code>null</code> if none. */ - private ListenerList fEventFilters = new ListenerList(); + private ListenerList<IDebugEventFilter> fEventFilters = new ListenerList<>(); /** * Whether this plug-in is in the process of shutting @@ -920,16 +920,6 @@ public class DebugPlugin extends Plugin { fShuttingDown = value; } - /** - * Returns the collection of debug event listeners registered - * with this plug-in. - * - * @return list of registered debug event listeners, instances - * of <code>IDebugEventSetListeners</code> - */ - private Object[] getEventListeners() { - return fEventListeners.getListeners(); - } /** * Adds the given debug event filter to the registered @@ -1173,27 +1163,25 @@ public class DebugPlugin extends Plugin { */ void dispatch(DebugEvent[] events) { fEvents = events; - Object[] filters = fEventFilters.getListeners(); - if (filters.length > 0) { + if (!fEventFilters.isEmpty()) { fMode = NOTIFY_FILTERS; - for (int i = 0; i < filters.length; i++) { - fFilter = (IDebugEventFilter)filters[i]; - SafeRunner.run(this); - if (fEvents == null || fEvents.length == 0) { - return; - } + } + for (IDebugEventFilter iDebugEventFilter : fEventFilters) { + fFilter = iDebugEventFilter; + SafeRunner.run(this); + if (fEvents == null || fEvents.length == 0) { + return; } } fMode = NOTIFY_EVENTS; - Object[] listeners= getEventListeners(); if (DebugOptions.DEBUG_EVENTS) { for (int i = 0; i < fEvents.length; i++) { DebugOptions.trace(fEvents[i].toString()); } } - for (int i= 0; i < listeners.length; i++) { - fListener = (IDebugEventSetListener)listeners[i]; + for (IDebugEventSetListener iDebugEventSetListener : fEventListeners) { + fListener = iDebugEventSetListener; SafeRunner.run(this); } fEvents = null; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java index b6cebf1be..b9875728f 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -131,12 +131,12 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis /** * Collection of breakpoint listeners. */ - private ListenerList fBreakpointListeners= new ListenerList(); + private ListenerList<IBreakpointListener> fBreakpointListeners= new ListenerList<>(); /** * Collection of (plural) breakpoint listeners. */ - private ListenerList fBreakpointsListeners= new ListenerList(); + private ListenerList<IBreakpointsListener> fBreakpointsListeners= new ListenerList<>(); /** * Singleton resource delta visitor which handles marker @@ -148,7 +148,7 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis * Collection of breakpoint manager listeners which are * notified when this manager's state changes. */ - private ListenerList fBreakpointManagerListeners= new ListenerList(); + private ListenerList<IBreakpointManagerListener> fBreakpointManagerListeners= new ListenerList<>(); /** * Listens to POST_CHANGE notifications of breakpoint markers to detect when @@ -1061,9 +1061,8 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis */ public void notify(IBreakpoint[] breakpoints, IMarkerDelta[] deltas, int update) { fType = update; - Object[] copiedListeners= fBreakpointListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IBreakpointListener)copiedListeners[i]; + for (IBreakpointListener iBreakpointListener : fBreakpointListeners) { + fListener = iBreakpointListener; for (int j = 0; j < breakpoints.length; j++) { fBreakpoint = breakpoints[j]; fDelta = deltas[j]; @@ -1131,10 +1130,9 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis fType = update; fNotifierBreakpoints = breakpoints; fDeltas = deltas; - Object[] copiedListeners = fBreakpointsListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IBreakpointsListener)copiedListeners[i]; - SafeRunner.run(this); + for (IBreakpointsListener iBreakpointsListener : fBreakpointsListeners) { + fListener = iBreakpointsListener; + SafeRunner.run(this); } fDeltas = null; fNotifierBreakpoints = null; @@ -1227,9 +1225,8 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis */ public void notify(boolean enabled) { fManagerEnabled= enabled; - Object[] copiedListeners = fBreakpointManagerListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IBreakpointManagerListener)copiedListeners[i]; + for (IBreakpointManagerListener iBreakpointManagerListener : fBreakpointManagerListeners) { + fListener = iBreakpointManagerListener; SafeRunner.run(this); } fListener = null; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java index 8df5726ba..927499070 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -61,12 +61,12 @@ public class ExpressionManager extends PlatformObject implements IExpressionMana /** * List of expression listeners */ - private ListenerList fListeners = null; + private ListenerList<IExpressionListener> fListeners = null; /** * List of expressions listeners (plural) */ - private ListenerList fExpressionsListeners = null; + private ListenerList<IExpressionsListener> fExpressionsListeners = null; /** * Mapping of debug model identifiers (String) to @@ -467,7 +467,7 @@ public class ExpressionManager extends PlatformObject implements IExpressionMana @Override public void addExpressionListener(IExpressionListener listener) { if (fListeners == null) { - fListeners = new ListenerList(); + fListeners = new ListenerList<>(); } fListeners.add(listener); } @@ -540,7 +540,7 @@ public class ExpressionManager extends PlatformObject implements IExpressionMana @Override public void addExpressionListener(IExpressionsListener listener) { if (fExpressionsListeners == null) { - fExpressionsListeners = new ListenerList(); + fExpressionsListeners = new ListenerList<>(); } fExpressionsListeners.add(listener); } @@ -609,9 +609,8 @@ public class ExpressionManager extends PlatformObject implements IExpressionMana public void notify(IExpression[] expressions, int update) { if (fListeners != null) { fType = update; - Object[] copiedListeners= fListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IExpressionListener)copiedListeners[i]; + for (IExpressionListener iExpressionListener : fListeners) { + fListener = iExpressionListener; for (int j = 0; j < expressions.length; j++) { fExpression = expressions[j]; SafeRunner.run(this); @@ -697,9 +696,8 @@ public class ExpressionManager extends PlatformObject implements IExpressionMana fNotifierExpressions = expressions; fType = update; fIndex = index; - Object[] copiedListeners = fExpressionsListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IExpressionsListener)copiedListeners[i]; + for (IExpressionsListener iExpressionsListener : fExpressionsListeners) { + fListener = iExpressionsListener; SafeRunner.run(this); } } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java index 4973e3f52..74a7638b3 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -202,12 +202,9 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe public void notify(ILaunchConfiguration configuration, int update) { fConfiguration = configuration; fType = update; - if (fLaunchConfigurationListeners.size() > 0) { - Object[] listeners = fLaunchConfigurationListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - fListener = (ILaunchConfigurationListener)listeners[i]; - SafeRunner.run(this); - } + for (ILaunchConfigurationListener iLaunchConfigurationListener : fLaunchConfigurationListeners) { + fListener = iLaunchConfigurationListener; + SafeRunner.run(this); } fConfiguration = null; fListener = null; @@ -264,9 +261,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe fNotifierLaunches = launches; fType = update; fRegistered = null; - Object[] copiedListeners= fLaunchesListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (ILaunchesListener)copiedListeners[i]; + for (ILaunchesListener iLaunchesListener : fLaunchesListeners) { + fListener = iLaunchesListener; SafeRunner.run(this); } fNotifierLaunches = null; @@ -432,9 +428,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe public void notify(ILaunch launch, int update) { fLaunch = launch; fType = update; - Object[] copiedListeners= fListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (ILaunchListener)copiedListeners[i]; + for (ILaunchListener iLaunchListener : fListeners) { + fListener = iLaunchListener; SafeRunner.run(this); } fLaunch = null; @@ -635,13 +630,13 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe /** * Collection of listeners */ - private ListenerList fListeners = new ListenerList(); + private ListenerList<ILaunchListener> fListeners = new ListenerList<>(); /** * Collection of "plural" listeners. * @since 2.1 */ - private ListenerList fLaunchesListeners = new ListenerList(); + private ListenerList<ILaunchesListener> fLaunchesListeners = new ListenerList<>(); /** * Visitor used to process resource deltas, @@ -666,7 +661,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe /** * Launch configuration listeners */ - private ListenerList fLaunchConfigurationListeners = new ListenerList(); + private ListenerList<ILaunchConfigurationListener> fLaunchConfigurationListeners = new ListenerList<>(); /** * Table of source locator extensions. Keys @@ -2365,9 +2360,9 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe * Clears launch configuration types. */ public void shutdown() { - fListeners = new ListenerList(); - fLaunchesListeners = new ListenerList(); - fLaunchConfigurationListeners = new ListenerList(); + fListeners = new ListenerList<>(); + fLaunchesListeners = new ListenerList<>(); + fLaunchConfigurationListeners = new ListenerList<>(); ILaunch[] launches = getLaunches(); ILaunch launch = null; for (int i= 0; i < launches.length; i++) { diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java index b16235d43..0b35caa54 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -38,7 +38,7 @@ public class OutputStreamMonitor implements IFlushableStreamMonitor { /** * A collection of listeners */ - private ListenerList fListeners= new ListenerList(); + private ListenerList<IStreamListener> fListeners = new ListenerList<>(); /** * Whether content is being buffered @@ -105,7 +105,7 @@ public class OutputStreamMonitor implements IFlushableStreamMonitor { thread.join(); } catch (InterruptedException ie) { } - fListeners = new ListenerList(); + fListeners = new ListenerList<>(); } } @@ -272,10 +272,9 @@ public class OutputStreamMonitor implements IFlushableStreamMonitor { return; } fText = text; - Object[] copiedListeners= fListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IStreamListener) copiedListeners[i]; - SafeRunner.run(this); + for (IStreamListener iStreamListener : fListeners) { + fListener = iStreamListener; + SafeRunner.run(this); } fListener = null; fText = null; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java index 5337908f8..f9588cd4f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -73,7 +73,7 @@ public class LazyModelPresentation implements IDebugModelPresentation, IDebugEdi * Temp holding for listeners - we do not add to presentation until * it needs to be instantiated. */ - protected ListenerList fListeners= new ListenerList(); + protected ListenerList<ILabelProviderListener> fListeners = new ListenerList<>(); /** * Non-null when nested inside a delegating model presentation @@ -294,7 +294,7 @@ public class LazyModelPresentation implements IDebugModelPresentation, IDebugEdi if (fPresentation != null) { getPresentation().removeListener(listener); } - ListenerList listeners = fListeners; + ListenerList<ILabelProviderListener> listeners = fListeners; if (listeners != null) { listeners.remove(listener); } @@ -315,9 +315,8 @@ public class LazyModelPresentation implements IDebugModelPresentation, IDebugEdi IDebugModelPresentation tempPresentation= (IDebugModelPresentation) DebugUIPlugin.createExtension(fConfig, "class"); //$NON-NLS-1$ // configure it if (fListeners != null) { - Object[] list = fListeners.getListeners(); - for (int i= 0; i < list.length; i++) { - tempPresentation.addListener((ILabelProviderListener)list[i]); + for (ILabelProviderListener iLabelProviderListener : fListeners) { + tempPresentation.addListener(iLabelProviderListener); } } for (Entry<String, Object> entry : fAttributes.entrySet()) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java index 1d3f5ddc5..8531b8ea7 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 IBM Corporation and others. + * Copyright (c) 2008, 2016 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 @@ -447,7 +447,7 @@ public class ToggleBreakpointsTargetManager implements IToggleBreakpointsTargetM /** * List of listeners to changes in the preferred toggle targets list. */ - private ListenerList fChangedListners = new ListenerList(); + private ListenerList<IToggleBreakpointsTargetManagerListener> fChangedListners = new ListenerList<>(); /** * Initializes the collection of known factories from extension point contributions. @@ -722,9 +722,8 @@ public class ToggleBreakpointsTargetManager implements IToggleBreakpointsTargetM * Notifies the change listeners that the preferred targets changed. */ private void firePreferredTargetsChanged() { - Object[] listeners = fChangedListners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - ((IToggleBreakpointsTargetManagerListener)listeners[i]).preferredTargetsChanged(); + for (IToggleBreakpointsTargetManagerListener iToggleBreakpointsTargetManagerListener : fChangedListners) { + iToggleBreakpointsTargetManagerListener.preferredTargetsChanged(); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java index 3a766774b..07b46874c 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2013 IBM Corporation and others. + * Copyright (c) 2007, 2016 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 @@ -87,7 +87,7 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo /** *The set of label update listeners */ - private ListenerList fLabelListeners = new ListenerList(); + private ListenerList<ILaunchLabelChangedListener> fLabelListeners = new ListenerList<>(); /** * The map of ToolBars that have mouse tracker listeners associated with them: @@ -228,13 +228,13 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo ILaunchGroup group = null; ILaunchConfiguration config = null; String label = null; - Object[] listeners = fLabelListeners.getListeners(); + SelectedResourceManager srm = SelectedResourceManager.getDefault(); IStructuredSelection selection = srm.getCurrentSelection(); List<LaunchShortcutExtension> shortcuts = null; IResource resource = srm.getSelectedResource(); - for(int i = 0; i < listeners.length; i++) { - group = ((ILaunchLabelChangedListener)listeners[i]).getLaunchGroup(); + for (ILaunchLabelChangedListener iLaunchLabelChangedListener : fLabelListeners) { + group = iLaunchLabelChangedListener.getLaunchGroup(); if(group != null) { if(isContextLaunchEnabled(group.getIdentifier())) { shortcuts = getShortcutsForSelection(selection, group.getMode()); @@ -260,9 +260,8 @@ public class LaunchingResourceManager implements IPropertyChangeListener, IWindo * Notifies all registered listeners that the known labels have changed */ protected void notifyLabelChanged() { - Object[] listeners = fLabelListeners.getListeners(); - for(int i = 0; i < listeners.length; i++) { - ((ILaunchLabelChangedListener)listeners[i]).labelChanged(); + for (ILaunchLabelChangedListener iLaunchLabelChangedListener : fLabelListeners) { + iLaunchLabelChangedListener.labelChanged(); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java index 68c35f283..ad5227117 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugContextManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 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 @@ -35,7 +35,7 @@ public class DebugContextManager implements IDebugContextManager { private static DebugContextManager fgDefault; private Map<IWorkbenchWindow, DebugWindowContextService> fServices = new HashMap<IWorkbenchWindow, DebugWindowContextService>(); - private ListenerList fGlobalListeners = new ListenerList(); + private ListenerList<IDebugContextListener> fGlobalListeners = new ListenerList<>(); /** * A debug context service that does nothing (used for windows that have been closed) @@ -163,10 +163,8 @@ public class DebugContextManager implements IDebugContextManager { service = new DebugWindowContextService(window, evaluationService); fServices.put(window, service); // register global listeners - Object[] listeners = fGlobalListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - IDebugContextListener listener = (IDebugContextListener) listeners[i]; - service.addDebugContextListener(listener); + for (IDebugContextListener iDebugContextListener : fGlobalListeners) { + service.addDebugContextListener(iDebugContextListener); } } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java index 0c15eda06..b23ca4564 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugWindowContextService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. + * Copyright (c) 2005, 2016 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 @@ -46,9 +46,9 @@ import org.eclipse.ui.services.IEvaluationService; */ public class DebugWindowContextService implements IDebugContextService, IPartListener2, IDebugContextListener { - private Map<String, ListenerList> fListenersByPartId = new HashMap<String, ListenerList>(); + private Map<String, ListenerList<IDebugContextListener>> fListenersByPartId = new HashMap<>(); private Map<String, IDebugContextProvider> fProvidersByPartId = new HashMap<String, IDebugContextProvider>(); - private Map<String, ListenerList> fPostListenersByPartId = new HashMap<String, ListenerList>(); + private Map<String, ListenerList<IDebugContextListener>> fPostListenersByPartId = new HashMap<>(); private IWorkbenchWindow fWindow; private List<IDebugContextProvider> fProviders = new ArrayList<IDebugContextProvider>(); @@ -146,9 +146,9 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis @Override public void addPostDebugContextListener(IDebugContextListener listener, String partId) { - ListenerList list = fPostListenersByPartId.get(partId); + ListenerList<IDebugContextListener> list = fPostListenersByPartId.get(partId); if (list == null) { - list = new ListenerList(); + list = new ListenerList<>(); fPostListenersByPartId.put(partId, list); } list.add(listener); @@ -161,7 +161,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis @Override public void removePostDebugContextListener(IDebugContextListener listener, String partId) { - ListenerList list = fPostListenersByPartId.get(partId); + ListenerList<IDebugContextListener> list = fPostListenersByPartId.get(partId); if (list != null) { list.remove(listener); } @@ -244,8 +244,8 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis String id = null; if (part != null) { id = getCombinedPartId(part); - ListenerList listenerList = fListenersByPartId.get(id); - return listenerList != null ? listenerList.getListeners() : new Object[0]; + ListenerList<IDebugContextListener> listenerList = fListenersByPartId.get(id); + return listenerList != null ? listenerList.getListeners() : new Object[0]; } else { List<Object> retVal = new ArrayList<Object>(); retVal.addAll(Arrays.asList(fListenersByPartId.get(null).getListeners()) ); @@ -277,11 +277,11 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis String id = null; if (part != null) { id = getCombinedPartId(part); - ListenerList listenerList = fPostListenersByPartId.get(id); + ListenerList<IDebugContextListener> listenerList = fPostListenersByPartId.get(id); return listenerList != null ? listenerList.getListeners() : new Object[0]; } else { List<Object> retVal = new ArrayList<Object>(); - ListenerList postListenersList = fPostListenersByPartId.get(null); + ListenerList<IDebugContextListener> postListenersList = fPostListenersByPartId.get(null); if (postListenersList != null) { retVal.addAll( Arrays.asList(postListenersList.getListeners()) ); } @@ -307,9 +307,9 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis */ @Override public synchronized void addDebugContextListener(IDebugContextListener listener, String partId) { - ListenerList list = fListenersByPartId.get(partId); + ListenerList<IDebugContextListener> list = fListenersByPartId.get(partId); if (list == null) { - list = new ListenerList(); + list = new ListenerList<>(); fListenersByPartId.put(partId, list); } list.add(listener); @@ -320,7 +320,7 @@ public class DebugWindowContextService implements IDebugContextService, IPartLis */ @Override public void removeDebugContextListener(IDebugContextListener listener, String partId) { - ListenerList list = fListenersByPartId.get(partId); + ListenerList<IDebugContextListener> list = fListenersByPartId.get(partId); if (list != null) { list.remove(listener); if (list.size() == 0) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java index 3621dbe9d..26a08c53d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. + * Copyright (c) 2005, 2016 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 @@ -31,7 +31,7 @@ import org.eclipse.debug.ui.contexts.ISuspendTriggerListener; */ public class LaunchSuspendTrigger implements ISuspendTrigger, IDebugEventSetListener { - private ListenerList fListeners = new ListenerList(); + private ListenerList<ISuspendTriggerListener> fListeners = new ListenerList<>(); private SuspendTriggerAdapterFactory fFactory = null; private ILaunch fLaunch = null; @@ -116,11 +116,10 @@ public class LaunchSuspendTrigger implements ISuspendTrigger, IDebugEventSetList context = source; } final Object temp = context; - ListenerList list = fListeners; + ListenerList<ISuspendTriggerListener> list = fListeners; if (list != null) { - Object[] listeners = list.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final ISuspendTriggerListener listener = (ISuspendTriggerListener) listeners[i]; + for (ISuspendTriggerListener iSuspendTriggerListener : list) { + final ISuspendTriggerListener listener = iSuspendTriggerListener; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java index 37d0fac29..304369f20 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 IBM Corporation and others. + * Copyright (c) 2008, 2016 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 @@ -71,7 +71,7 @@ public abstract class BreadcrumbViewer extends StructuredViewer { private final int fStyle; private final Composite fContainer; private final ArrayList<BreadcrumbItem> fBreadcrumbItems; - private final ListenerList fMenuListeners; + private final ListenerList<MenuDetectListener> fMenuListeners; private Image fGradientBackground; private BreadcrumbItem fSelectedItem; @@ -94,7 +94,7 @@ public abstract class BreadcrumbViewer extends StructuredViewer { public BreadcrumbViewer(Composite parent, int style) { fStyle = style; fBreadcrumbItems = new ArrayList<BreadcrumbItem>(); - fMenuListeners= new ListenerList(); + fMenuListeners= new ListenerList<>(); fContainer= new Composite(parent, SWT.NONE); GridData layoutData= new GridData(SWT.FILL, SWT.TOP, true, false); @@ -543,9 +543,8 @@ public abstract class BreadcrumbViewer extends StructuredViewer { * @param event the event issued the menu detection */ void fireMenuDetect(MenuDetectEvent event) { - Object[] listeners= fMenuListeners.getListeners(); - for (int i= 0; i < listeners.length; i++) { - ((MenuDetectListener)listeners[i]).menuDetected(event); + for (MenuDetectListener menuDetectListener : fMenuListeners) { + menuDetectListener.menuDetected(event); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java index f56601bba..0522d316b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2014 IBM Corporation and others. + * Copyright (c) 2006, 2016 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 @@ -102,12 +102,12 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon /** * Model listeners */ - private ListenerList fModelListeners = new ListenerList(); + private ListenerList<IModelChangedListener> fModelListeners = new ListenerList<>(); /** * Viewer update listeners */ - private ListenerList fUpdateListeners = new ListenerList(); + private ListenerList<IViewerUpdateListener> fUpdateListeners = new ListenerList<>(); /** * Flag indicating whether we are currently in a model sequence. @@ -427,10 +427,9 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon trigger(null); // Call model listeners after updating the viewer model. - Object[] listeners = fModelListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - ((IModelChangedListener) listeners[i]).modelChanged(delta, proxy); - } + for (IModelChangedListener iModelChangedListener : fModelListeners) { + iModelChangedListener.modelChanged(delta, proxy); + } } } @@ -731,9 +730,8 @@ public class TreeModelContentProvider implements ITreeModelContentProvider, ICon */ private void notifyUpdate(final int type, final IViewerUpdate update) { if (!fUpdateListeners.isEmpty()) { - Object[] listeners = fUpdateListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IViewerUpdateListener listener = (IViewerUpdateListener) listeners[i]; + for (IViewerUpdateListener iViewerUpdateListener : fUpdateListeners) { + final IViewerUpdateListener listener = iViewerUpdateListener; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java index 3aeea632b..cce0f4947 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelLabelProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2016 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 @@ -80,7 +80,7 @@ public class TreeModelLabelProvider extends ColumnLabelProvider /** * Label listeners */ - private ListenerList fLabelListeners = new ListenerList(); + private ListenerList<ILabelUpdateListener> fLabelListeners = new ListenerList<>(); /** * Updates waiting to be sent to the label provider. The map contains @@ -478,9 +478,8 @@ public class TreeModelLabelProvider extends ColumnLabelProvider private void notifyUpdate(final int type, final ILabelUpdate update) { if (!fLabelListeners.isEmpty()) { - Object[] listeners = fLabelListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final ILabelUpdateListener listener = (ILabelUpdateListener) listeners[i]; + for (ILabelUpdateListener iLabelUpdateListener : fLabelListeners) { + final ILabelUpdateListener listener = iLabelUpdateListener; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java index b208e5af4..e951d65a4 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2013 Wind River Systems and others. + * Copyright (c) 2011, 2016 Wind River Systems 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 @@ -164,7 +164,7 @@ class ViewerStateTracker { /** * State update listeners */ - private ListenerList fStateUpdateListeners = new ListenerList(); + private ListenerList<IStateUpdateListener> fStateUpdateListeners = new ListenerList<>(); /** * Postpone restoring REVEAL element until the current updates are complete. @@ -1547,9 +1547,8 @@ class ViewerStateTracker { void notifyStateUpdate(final Object input, final int type, final IViewerUpdate update) { if (!fStateUpdateListeners.isEmpty()) { - Object[] listeners = fStateUpdateListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IStateUpdateListener listener = (IStateUpdateListener) listeners[i]; + for (IStateUpdateListener iStateUpdateListener : fStateUpdateListeners) { + final IStateUpdateListener listener = iStateUpdateListener; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java index 2a92a47c2..805187af3 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/PresentationContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2016 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 @@ -44,7 +44,7 @@ public class PresentationContext implements IPresentationContext { private static final String PERSISTABLE = "PERSISTABLE"; //$NON-NLS-1$ final private String fId; - final private ListenerList fListeners = new ListenerList(); + final private ListenerList<IPropertyChangeListener> fListeners = new ListenerList<>(); final private Map<String, Object> fProperties = new HashMap<String, Object>(); private IWorkbenchWindow fWindow; private IWorkbenchPart fPart; @@ -113,9 +113,8 @@ public class PresentationContext implements IPresentationContext { protected void firePropertyChange(String property, Object oldValue, Object newValue) { if (!fListeners.isEmpty()) { final PropertyChangeEvent event = new PropertyChangeEvent(this, property, oldValue, newValue); - Object[] listeners = fListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i]; + for (IPropertyChangeListener iPropertyChangeListener : fListeners) { + final IPropertyChangeListener listener = iPropertyChangeListener; SafeRunner.run(new SafeRunnable() { @Override public void run() throws Exception { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java index 1098dc999..6c1e961c9 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractModelProxy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2016 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 @@ -41,11 +41,11 @@ public abstract class AbstractModelProxy implements IModelProxy2 { private Job fInstallJob; - private ListenerList fListeners = new ListenerList(); + private ListenerList<IModelChangedListener> fListeners = new ListenerList<>(); - protected Object[] getListeners() { + protected ListenerList<IModelChangedListener> getListeners() { synchronized (fListeners) { - return fListeners.getListeners(); + return fListeners; } } @@ -80,9 +80,8 @@ public abstract class AbstractModelProxy implements IModelProxy2 { } final IModelDelta root = getRootDelta(delta); - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IModelChangedListener listener = (IModelChangedListener) listeners[i]; + for (IModelChangedListener iModelChangedListener : getListeners()) { + final IModelChangedListener listener = iModelChangedListener; ISafeRunnable safeRunnable = new ISafeRunnable() { @Override public void handleException(Throwable exception) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java index 46ea5d76d..9d1355048 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AsyncVirtualContentTableViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2016 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 @@ -43,15 +43,15 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableVi private ArrayList<Object> fTopIndexQueue = new ArrayList<Object>(); private boolean fPendingResizeColumns; - private ListenerList fVirtualContentListeners; + private ListenerList<IVirtualContentListener> fVirtualContentListeners; private SelectionListener fScrollSelectionListener; - private ListenerList fPresentationErrorListeners; + private ListenerList<IPresentationErrorListener> fPresentationErrorListeners; private Object fTopIndexKey; public AsyncVirtualContentTableViewer(Composite parent, int style) { super(parent, style); - fVirtualContentListeners = new ListenerList(); - fPresentationErrorListeners = new ListenerList(); + fVirtualContentListeners = new ListenerList<>(); + fPresentationErrorListeners = new ListenerList<>(); initScrollBarListener(); } @@ -228,10 +228,8 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableVi protected void notifyListenersAtBufferStart() { int topIdx = getTable().getTopIndex(); - Object[] listeners = fVirtualContentListeners.getListeners(); - - for (int i = 0; i < listeners.length; i++) { - final IVirtualContentListener listener = (IVirtualContentListener) listeners[i]; + for (IVirtualContentListener iVirtualContentListener : fVirtualContentListeners) { + final IVirtualContentListener listener = iVirtualContentListener; if (topIdx < listener.getThreshold(IVirtualContentListener.BUFFER_START)) { SafeRunner.run(new ISafeRunnable() { @Override @@ -249,14 +247,13 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableVi } protected void notifyListenersAtBufferEnd() { - Object[] listeners = fVirtualContentListeners.getListeners(); int topIdx = getTable().getTopIndex(); int bottomIdx = topIdx + getNumberOfVisibleLines(); int elementsCnt = getVirtualContentModel().getElements().length; int numLinesLeft = elementsCnt - bottomIdx; - for (int i = 0; i < listeners.length; i++) { - final IVirtualContentListener listener = (IVirtualContentListener) listeners[i]; + for (IVirtualContentListener iVirtualContentListener : fVirtualContentListeners) { + final IVirtualContentListener listener = iVirtualContentListener; if (numLinesLeft <= listener.getThreshold(IVirtualContentListener.BUFFER_END)) { SafeRunner.run(new ISafeRunnable() { @Override @@ -332,12 +329,8 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableVi } private void notifyPresentationError(final IStatusMonitor monitor, final IStatus status) { - Object[] listeners = fPresentationErrorListeners.getListeners(); - - for (int i = 0; i < listeners.length; i++) { - - if (listeners[i] instanceof IPresentationErrorListener) { - final IPresentationErrorListener listener = (IPresentationErrorListener) listeners[i]; + for (IPresentationErrorListener iPresentationErrorListener : fPresentationErrorListeners) { + final IPresentationErrorListener listener = iPresentationErrorListener; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { @@ -349,7 +342,6 @@ abstract public class AsyncVirtualContentTableViewer extends AsynchronousTableVi DebugUIPlugin.log(exception); } }); - } } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java index 5eacce101..a83f7a210 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -151,7 +151,7 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis * Forwards all selection changed events of the active selection provider. */ private static class SelectionProviderWrapper implements ISelectionProvider { - private final ListenerList fListenerList = new ListenerList(ListenerList.IDENTITY); + private final ListenerList<ISelectionChangedListener> fListenerList = new ListenerList<>(ListenerList.IDENTITY); private final ISelectionChangedListener fListener = new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { @@ -184,10 +184,8 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis } private void fireSelectionChanged(SelectionChangedEvent event) { - Object[] listeners = fListenerList.getListeners(); - for (int i = 0; i < listeners.length; i++) { - ISelectionChangedListener listener = (ISelectionChangedListener) listeners[i]; - listener.selectionChanged(event); + for (ISelectionChangedListener iSelectionChangedListener : fListenerList) { + iSelectionChangedListener.selectionChanged(event); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java index da231f3c8..b7e01ae38 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 IBM Corporation and others. + * Copyright (c) 2006, 2016 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 @@ -69,7 +69,7 @@ public class DetailPaneProxy implements ISaveablePart { /** * Property listeners */ - private ListenerList fListeners = new ListenerList(); + private ListenerList<IPropertyListener> fListeners = new ListenerList<>(); /** * Constructor that sets up the detail pane for a view. Note that no default pane @@ -135,9 +135,8 @@ public class DetailPaneProxy implements ISaveablePart { * Fires dirty property change. */ private void fireDirty() { - Object[] listeners = fListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - ((IPropertyListener)listeners[i]).propertyChanged(this, PROP_DIRTY); + for (IPropertyListener iPropertyListener : fListeners) { + iPropertyListener.propertyChanged(this, PROP_DIRTY); } } @@ -216,9 +215,8 @@ public class DetailPaneProxy implements ISaveablePart { fCurrentPane.init(workbenchPartSite); IDetailPane3 saveable = getSaveable(); if (saveable != null) { - Object[] listeners = fListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - saveable.addPropertyListener((IPropertyListener) listeners[i]); + for (IPropertyListener iPropertyListener : fListeners) { + saveable.addPropertyListener(iPropertyListener); } } fCurrentControl = fCurrentPane.createControl(fParentContainer.getParentComposite()); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractBreakpointOrganizerDelegate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractBreakpointOrganizerDelegate.java index 913984ff8..fd2e85931 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractBreakpointOrganizerDelegate.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractBreakpointOrganizerDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -30,7 +30,7 @@ import org.eclipse.jface.util.PropertyChangeEvent; public abstract class AbstractBreakpointOrganizerDelegate implements IBreakpointOrganizerDelegate { // property change listeners - private ListenerList fListeners = new ListenerList(); + private ListenerList<IPropertyChangeListener> fListeners = new ListenerList<>(); /* (non-Javadoc) * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#addBreakpoint(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable) @@ -77,7 +77,7 @@ public abstract class AbstractBreakpointOrganizerDelegate implements IBreakpoint */ @Override public void dispose() { - fListeners = new ListenerList(); + fListeners = new ListenerList<>(); } /* (non-Javadoc) @@ -106,9 +106,8 @@ public abstract class AbstractBreakpointOrganizerDelegate implements IBreakpoint return; } final PropertyChangeEvent event = new PropertyChangeEvent(this, P_CATEGORY_CHANGED, category, null); - Object[] listeners = fListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i]; + for (IPropertyChangeListener iPropertyChangeListener : fListeners) { + final IPropertyChangeListener listener = iPropertyChangeListener; ISafeRunnable runnable = new ISafeRunnable() { @Override public void handleException(Throwable exception) { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java index 15c18d638..e19bd7991 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/AbstractDebugContextProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2016 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 @@ -28,7 +28,7 @@ public abstract class AbstractDebugContextProvider implements IDebugContextProvi /** * Event listeners */ - private ListenerList fListeners = new ListenerList(); + private ListenerList<IDebugContextListener> fListeners = new ListenerList<>(); /** * Part or <code>null</code> @@ -74,10 +74,9 @@ public abstract class AbstractDebugContextProvider implements IDebugContextProvi * @param event debug context event */ protected void fire(final DebugContextEvent event) { - Object[] listeners = fListeners.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IDebugContextListener listener = (IDebugContextListener) listeners[i]; - SafeRunner.run(new ISafeRunnable() { + for (IDebugContextListener iDebugContextListener : fListeners) { + final IDebugContextListener listener = iDebugContextListener; + SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { listener.debugContextChanged(event); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java index 935614696..ab9dcdd90 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRendering.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2016 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 @@ -58,7 +58,7 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements private IMemoryBlock fMemoryBlock; private IMemoryRenderingContainer fContainer; - private ListenerList fPropertyListeners; + private ListenerList<IPropertyChangeListener> fPropertyListeners; private boolean fVisible = true; private MenuManager fPopupMenuMgr; private String fRenderingId; @@ -218,7 +218,7 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements public void addPropertyChangeListener(IPropertyChangeListener listener) { if (fPropertyListeners == null) - fPropertyListeners = new ListenerList(); + fPropertyListeners = new ListenerList<>(); fPropertyListeners.add(listener); } @@ -390,12 +390,9 @@ public abstract class AbstractMemoryRendering extends PlatformObject implements { if (fPropertyListeners == null) return; - - Object[] listeners = fPropertyListeners.getListeners(); - - for (int i=0; i<listeners.length; i++) - { - PropertyChangeNotifier notifier = new PropertyChangeNotifier((IPropertyChangeListener)listeners[i], event); + + for (IPropertyChangeListener iPropertyChangeListener : fPropertyListeners) { + PropertyChangeNotifier notifier = new PropertyChangeNotifier(iPropertyChangeListener, event); SafeRunner.run(notifier); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRenderingBindingsProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRenderingBindingsProvider.java index aaec45a6d..f49b04a28 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRenderingBindingsProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractMemoryRenderingBindingsProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 IBM Corporation and others. + * Copyright (c) 2004, 2016 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 @@ -26,7 +26,7 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin; public abstract class AbstractMemoryRenderingBindingsProvider implements IMemoryRenderingBindingsProvider { // list of binding listeners - private ListenerList fListeners; + private ListenerList<IMemoryRenderingBindingsListener> fListeners; /* (non-Javadoc) * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#addListener(org.eclipse.debug.ui.memory.IMemoryRenderingBindingsListener) @@ -34,7 +34,7 @@ public abstract class AbstractMemoryRenderingBindingsProvider implements IMemory @Override public void addListener(IMemoryRenderingBindingsListener listener) { if (fListeners == null) { - fListeners = new ListenerList(); + fListeners = new ListenerList<>(); } fListeners.add(listener); } @@ -56,22 +56,20 @@ public abstract class AbstractMemoryRenderingBindingsProvider implements IMemory return; } - Object[] listeners = fListeners.getListeners(); - - for (int i=0; i<listeners.length; i++) { - if (listeners[i] instanceof IMemoryRenderingBindingsListener) { - final IMemoryRenderingBindingsListener listener = (IMemoryRenderingBindingsListener)listeners[i]; - ISafeRunnable runnable = new ISafeRunnable () { - @Override - public void handleException(Throwable exception) { - DebugUIPlugin.log(exception); - } - @Override - public void run() throws Exception { - listener.memoryRenderingBindingsChanged(); - }}; - SafeRunner.run(runnable); - } + for (IMemoryRenderingBindingsListener iMemoryRenderingBindingsListener : fListeners) { + final IMemoryRenderingBindingsListener listener = iMemoryRenderingBindingsListener; + ISafeRunnable runnable = new ISafeRunnable() { + @Override + public void handleException(Throwable exception) { + DebugUIPlugin.log(exception); + } + + @Override + public void run() throws Exception { + listener.memoryRenderingBindingsChanged(); + } + }; + SafeRunner.run(runnable); } } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java index 14f7c058a..301729a2a 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -31,7 +31,7 @@ import org.eclipse.ui.internal.console.ConsoleMessages; public abstract class AbstractConsole implements IConsole { // property listeners - private ListenerList fListeners; + private ListenerList<IPropertyChangeListener> fListeners; /** * Console name @@ -106,9 +106,8 @@ public abstract class AbstractConsole implements IConsole { return; } fEvent = event; - Object[] copiedListeners= fListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IPropertyChangeListener)copiedListeners[i]; + for (IPropertyChangeListener iPropertyChangeListener : fListeners) { + fListener = iPropertyChangeListener; SafeRunner.run(this); } fListener = null; @@ -202,7 +201,7 @@ public abstract class AbstractConsole implements IConsole { @Override public void addPropertyChangeListener(IPropertyChangeListener listener) { if (fListeners == null) { - fListeners = new ListenerList(); + fListeners = new ListenerList<>(); } fListeners.add(listener); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java index fe6413ed4..db73423cd 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -56,7 +56,7 @@ public class ConsoleManager implements IConsoleManager { /** * Console listeners */ - private ListenerList fListeners = null; + private ListenerList<IConsoleListener> fListeners = null; /** * List of registered consoles @@ -174,9 +174,8 @@ public class ConsoleManager implements IConsoleManager { } fChanged = consoles; fType = update; - Object[] copiedListeners= fListeners.getListeners(); - for (int i= 0; i < copiedListeners.length; i++) { - fListener = (IConsoleListener)copiedListeners[i]; + for (IConsoleListener iConsoleListener : fListeners) { + fListener = iConsoleListener; SafeRunner.run(this); } fChanged = null; @@ -201,7 +200,7 @@ public class ConsoleManager implements IConsoleManager { @Override public void addConsoleListener(IConsoleListener listener) { if (fListeners == null) { - fListeners = new ListenerList(); + fListeners = new ListenerList<>(); } fListeners.add(listener); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java index bf598b42e..0f68c92e7 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 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 @@ -92,7 +92,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /** * Map of consoles to array of page participants */ - private Map<IConsole, ListenerList> fConsoleToPageParticipants; + private Map<IConsole, ListenerList<IConsolePageParticipant>> fConsoleToPageParticipants; /** * Map of parts to consoles @@ -195,11 +195,10 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL private void activateParticipants(IConsole console) { // activate if (console != null && fActive) { - final ListenerList listeners = getParticipants(console); + final ListenerList<IConsolePageParticipant> listeners = getParticipants(console); if (listeners != null) { - Object[] participants = listeners.getListeners(); - for (int i = 0; i < participants.length; i++) { - final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; + for (IConsolePageParticipant iConsolePageParticipant : listeners) { + final IConsolePageParticipant participant = iConsolePageParticipant; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { @@ -259,11 +258,10 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL IConsole console = fPartToConsole.get(part); // dispose page participants - ListenerList listeners = fConsoleToPageParticipants.remove(console); + ListenerList<IConsolePageParticipant> listeners = fConsoleToPageParticipants.remove(console); if (listeners != null) { - Object[] participants = listeners.getListeners(); - for (int i = 0; i < participants.length; i++) { - final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; + for (IConsolePageParticipant iConsolePageParticipant : listeners) { + final IConsolePageParticipant participant = iConsolePageParticipant; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { @@ -300,7 +298,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL * @param console the console * @return registered page participants or <code>null</code> */ - private ListenerList getParticipants(IConsole console) { + private ListenerList<IConsolePageParticipant> getParticipants(IConsole console) { return fConsoleToPageParticipants.get(console); } @@ -315,14 +313,13 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL // initialize page participants IConsolePageParticipant[] consoleParticipants = ((ConsoleManager)getConsoleManager()).getPageParticipants(console); - final ListenerList participants = new ListenerList(); + final ListenerList<IConsolePageParticipant> participants = new ListenerList<>(); for (int i = 0; i < consoleParticipants.length; i++) { participants.add(consoleParticipants[i]); } fConsoleToPageParticipants.put(console, participants); - Object[] listeners = participants.getListeners(); - for (int i = 0; i < listeners.length; i++) { - final IConsolePageParticipant participant = (IConsolePageParticipant) listeners[i]; + for (IConsolePageParticipant iConsolePageParticipant : participants) { + final IConsolePageParticipant participant = iConsolePageParticipant; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { @@ -443,7 +440,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL super(); fConsoleToPart = new HashMap<IConsole, ConsoleWorkbenchPart>(); fPartToConsole = new HashMap<ConsoleWorkbenchPart, IConsole>(); - fConsoleToPageParticipants = new HashMap<IConsole, ListenerList>(); + fConsoleToPageParticipants = new HashMap<IConsole, ListenerList<IConsolePageParticipant>>(); ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager(); consoleManager.registerConsoleView(this); @@ -635,12 +632,11 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL if (adpater == null) { IConsole console = getConsole(); if (console != null) { - ListenerList listeners = getParticipants(console); + ListenerList<IConsolePageParticipant> listeners = getParticipants(console); // an adapter can be asked for before the console participants are created if (listeners != null) { - Object[] participants = listeners.getListeners(); - for (int i = 0; i < participants.length; i++) { - IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; + for (IConsolePageParticipant iConsolePageParticipant : listeners) { + IConsolePageParticipant participant = iConsolePageParticipant; adpater = participant.getAdapter(key); if (adpater != null) { return (T) adpater; @@ -717,11 +713,10 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL private void deactivateParticipants(IConsole console) { // deactivate if (console != null) { - final ListenerList listeners = getParticipants(console); + final ListenerList<IConsolePageParticipant> listeners = getParticipants(console); if (listeners != null) { - Object[] participants = listeners.getListeners(); - for (int i = 0; i < participants.length; i++) { - final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; + for (IConsolePageParticipant iConsolePageParticipant : listeners) { + final IConsolePageParticipant participant = iConsolePageParticipant; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { |