Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2016-01-22 07:51:59 -0500
committerSarika Sinha2016-01-22 07:51:59 -0500
commitb11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8 (patch)
treea69936f5c60f2ab82bc922a381764cf483aa80d8 /org.eclipse.ui.console
parenteb152262968725de3dc0014287f621169ba5ca5e (diff)
downloadeclipse.platform.debug-b11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8.tar.gz
eclipse.platform.debug-b11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8.tar.xz
eclipse.platform.debug-b11c99ce0d8d77c7d8f4d6a8c42acc95125a05e8.zip
Bug 486157 - Adapt to ListenerList changesI20160125-0400I20160124-2000
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java11
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java11
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java43
3 files changed, 29 insertions, 36 deletions
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 {

Back to the top