1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +02:00

Generify ListenerList.

Generified, some lamnda conversions and some non-javadoc removal.

Change-Id: Ibf0493917ac3da7531de1ca591a9bfdc250ddf2a
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2017-03-23 09:25:24 +02:00
parent 4d47bff054
commit 93623a1a04
17 changed files with 78 additions and 172 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2016 QNX Software Systems and others. * Copyright (c) 2000, 2017 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -83,7 +83,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
* Reconciling listeners. * Reconciling listeners.
* @since 3.0 * @since 3.0
*/ */
private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY); private ListenerList<IReconcilingParticipant> fReconcilingListeners= new ListenerList<>(ListenerList.IDENTITY);
MakefileSourceConfiguration getMakefileSourceConfiguration() { MakefileSourceConfiguration getMakefileSourceConfiguration() {
@ -361,9 +361,8 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
@Override @Override
public void reconciled() { public void reconciled() {
// Notify listeners // Notify listeners
Object[] listeners = fReconcilingListeners.getListeners(); for (IReconcilingParticipant listener : fReconcilingListeners) {
for (Object listener : listeners) { listener.reconciled();
((IReconcilingParticipant)listener).reconciled();
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2014 QNX Software Systems and others. * Copyright (c) 2005, 2017 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -68,7 +68,7 @@ public class LanguageManager {
private boolean fIsFullyCached; private boolean fIsFullyCached;
private HashMap<String, ILanguageDescriptor> fIdToLanguageDescriptorCache;//= new HashMap(); private HashMap<String, ILanguageDescriptor> fIdToLanguageDescriptorCache;//= new HashMap();
private HashMap<String, List<ILanguageDescriptor>> fContentTypeToDescriptorListCache; private HashMap<String, List<ILanguageDescriptor>> fContentTypeToDescriptorListCache;
private ListenerList fLanguageChangeListeners = new ListenerList(ListenerList.IDENTITY); private ListenerList<ILanguageMappingChangeListener> fLanguageChangeListeners = new ListenerList<>(ListenerList.IDENTITY);
private WorkspaceLanguageConfiguration fWorkspaceMappings; private WorkspaceLanguageConfiguration fWorkspaceMappings;
public static LanguageManager getInstance() { public static LanguageManager getInstance() {
@ -615,10 +615,7 @@ public class LanguageManager {
* @param event the ILanguageMappingsChange event to be broadcast. * @param event the ILanguageMappingsChange event to be broadcast.
*/ */
public void notifyLanguageChangeListeners(ILanguageMappingChangeEvent event) { public void notifyLanguageChangeListeners(ILanguageMappingChangeEvent event) {
Object[] listeners = fLanguageChangeListeners.getListeners(); for (ILanguageMappingChangeListener listener : fLanguageChangeListeners) {
for (Object obj : listeners) {
ILanguageMappingChangeListener listener = (ILanguageMappingChangeListener) obj;
listener.handleLanguageMappingChangeEvent(event); listener.handleLanguageMappingChangeEvent(event);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 Andrew Gvozdev and others. * Copyright (c) 2009, 2017 Andrew Gvozdev and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -109,7 +109,7 @@ public class LanguageSettingsProvidersSerializer {
/** Cache of workspace providers wrappers */ /** Cache of workspace providers wrappers */
private static Map<String, ILanguageSettingsProvider> globalWorkspaceProviders = new HashMap<String, ILanguageSettingsProvider>(); private static Map<String, ILanguageSettingsProvider> globalWorkspaceProviders = new HashMap<String, ILanguageSettingsProvider>();
private static ListenerList fLanguageSettingsChangeListeners = new ListenerList(ListenerList.IDENTITY); private static ListenerList<ILanguageSettingsChangeListener> fLanguageSettingsChangeListeners = new ListenerList<>(ListenerList.IDENTITY);
private static ILock serializingLock = Job.getJobManager().newLock(); private static ILock serializingLock = Job.getJobManager().newLock();
private static ILock serializingLockWsp = Job.getJobManager().newLock(); private static ILock serializingLockWsp = Job.getJobManager().newLock();
@ -1407,8 +1407,8 @@ public class LanguageSettingsProvidersSerializer {
* @param event - the {@link ILanguageSettingsChangeEvent} event to be broadcast. * @param event - the {@link ILanguageSettingsChangeEvent} event to be broadcast.
*/ */
private static void notifyLanguageSettingsChangeListeners(ILanguageSettingsChangeEvent event) { private static void notifyLanguageSettingsChangeListeners(ILanguageSettingsChangeEvent event) {
for (Object listener : fLanguageSettingsChangeListeners.getListeners()) { for (ILanguageSettingsChangeListener listener : fLanguageSettingsChangeListeners) {
((ILanguageSettingsChangeListener) listener).handleEvent(event); listener.handleEvent(event);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2008 Intel Corporation and others. * Copyright (c) 2007, 2017 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,12 +16,12 @@ import org.eclipse.core.runtime.ListenerList;
public abstract class CExternalSettingContainerFactoryWithListener extends public abstract class CExternalSettingContainerFactoryWithListener extends
CExternalSettingContainerFactory { CExternalSettingContainerFactory {
private ListenerList fListenerList; private ListenerList<ICExternalSettingsListener> fListenerList;
@Override @Override
public void addListener(ICExternalSettingsListener listener){ public void addListener(ICExternalSettingsListener listener){
if(fListenerList == null) if(fListenerList == null)
fListenerList = new ListenerList(); fListenerList = new ListenerList<>();
fListenerList.add(listener); fListenerList.add(listener);
} }
@ -43,9 +43,8 @@ public abstract class CExternalSettingContainerFactoryWithListener extends
CExternalSettingChangeEvent event = new CExternalSettingChangeEvent(infos); CExternalSettingChangeEvent event = new CExternalSettingChangeEvent(infos);
Object[] listeners = fListenerList.getListeners(); for(ICExternalSettingsListener listener : fListenerList){
for(int i = 0; i < listeners.length; i++){ listener.settingsChanged(project, cfgId, event);
((ICExternalSettingsListener)listeners[i]).settingsChanged(project, cfgId, event);
} }
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 Broadcom Corporation and others. * Copyright (c) 2009, 2017 Broadcom Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -74,7 +74,7 @@ public class PrefsStorableEnvironment extends StorableEnvironment {
private boolean fAppendChanged = false; private boolean fAppendChanged = false;
private boolean fAppendContributedChanged = false; private boolean fAppendContributedChanged = false;
private static ListenerList fEnvironmentChangeListeners = new ListenerList(ListenerList.IDENTITY); private static ListenerList<IEnvironmentChangeListener> fEnvironmentChangeListeners = new ListenerList<>(ListenerList.IDENTITY);
/** A listener for changes in the backing store */ /** A listener for changes in the backing store */
private static class PrefListener implements IPreferenceChangeListener, INodeChangeListener { private static class PrefListener implements IPreferenceChangeListener, INodeChangeListener {
@ -573,8 +573,8 @@ public class PrefsStorableEnvironment extends StorableEnvironment {
* @param event - the {@link IEnvironmentChangeEvent} event to be broadcast. * @param event - the {@link IEnvironmentChangeEvent} event to be broadcast.
*/ */
private static void notifyLanguageSettingsChangeListeners(IEnvironmentChangeEvent event) { private static void notifyLanguageSettingsChangeListeners(IEnvironmentChangeEvent event) {
for (Object listener : fEnvironmentChangeListeners.getListeners()) { for (IEnvironmentChangeListener listener : fEnvironmentChangeListeners) {
((IEnvironmentChangeListener) listener).handleEvent(event); listener.handleEvent(event);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2011 QNX Software Systems and others. * Copyright (c) 2002, 2017 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -67,7 +67,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
private static final String BUILD_CONSOLE_NODE = "buildConsole"; //$NON-NLS-1$ private static final String BUILD_CONSOLE_NODE = "buildConsole"; //$NON-NLS-1$
private static final String PROJECT_LOG_EXT = ".build.log"; //$NON-NLS-1$ private static final String PROJECT_LOG_EXT = ".build.log"; //$NON-NLS-1$
private ListenerList listeners = new ListenerList(); private ListenerList<IBuildConsoleListener> listeners = new ListenerList<>();
/** UI console object in which per-project consoles are shown */ /** UI console object in which per-project consoles are shown */
private BuildConsole fConsole; private BuildConsole fConsole;
private Map<IProject, BuildConsolePartitioner> fConsoleMap = new HashMap<IProject, BuildConsolePartitioner>(); private Map<IProject, BuildConsolePartitioner> fConsoleMap = new HashMap<IProject, BuildConsolePartitioner>();
@ -126,10 +126,8 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
* show the console, and notify listeners * show the console, and notify listeners
*/ */
protected void startConsoleActivity(IProject project) { protected void startConsoleActivity(IProject project) {
Object[] list = listeners.getListeners(); if (!listeners.isEmpty()) {
if (list.length > 0) { for (IBuildConsoleListener listener: listeners) {
for (Object element : list) {
IBuildConsoleListener listener = (IBuildConsoleListener)element;
ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, IBuildConsoleEvent.CONSOLE_START); ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, IBuildConsoleEvent.CONSOLE_START);
listener.consoleChange(event); listener.consoleChange(event);
} }
@ -196,10 +194,8 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
IDocumentPartitioner partioner = fConsoleMap.remove(resource); IDocumentPartitioner partioner = fConsoleMap.remove(resource);
if (partioner != null) { if (partioner != null) {
partioner.disconnect(); partioner.disconnect();
Object[] list = listeners.getListeners(); if (!listeners.isEmpty()) {
if (list.length > 0) { for (IBuildConsoleListener listener : listeners) {
for (Object element : list) {
IBuildConsoleListener listener = (IBuildConsoleListener)element;
ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject)resource, IBuildConsoleEvent.CONSOLE_CLOSE); ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject)resource, IBuildConsoleEvent.CONSOLE_CLOSE);
listener.consoleChange(consoleEvent); listener.consoleChange(consoleEvent);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2016 TimeSys Corporation and others. * Copyright (c) 2004, 2017 TimeSys Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -30,11 +30,9 @@ import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
@ -47,8 +45,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableColumn;
@ -112,7 +108,7 @@ public class CFileTypesPreferenceBlock {
} }
private class AssocLabelProvider implements ILabelProvider, ITableLabelProvider { private class AssocLabelProvider implements ILabelProvider, ITableLabelProvider {
private ListenerList listeners = new ListenerList(); private ListenerList<ILabelProviderListener> listeners = new ListenerList<>();
@Override @Override
public Image getColumnImage(Object element, int columnIndex) { public Image getColumnImage(Object element, int columnIndex) {
@ -261,12 +257,7 @@ public class CFileTypesPreferenceBlock {
gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnNew); gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnNew);
fBtnNew.setLayoutData(gridData); fBtnNew.setLayoutData(gridData);
fBtnNew.addListener(SWT.Selection, new Listener() { fBtnNew.addListener(SWT.Selection, e -> handleAdd());
@Override
public void handleEvent(Event e) {
handleAdd();
}
});
// Remove button // Remove button
@ -277,12 +268,7 @@ public class CFileTypesPreferenceBlock {
gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnRemove); gridData.widthHint = SWTUtil.getButtonWidthHint(fBtnRemove);
fBtnRemove.setLayoutData(gridData); fBtnRemove.setLayoutData(gridData);
fBtnRemove.addListener(SWT.Selection, new Listener() { fBtnRemove.addListener(SWT.Selection, e -> handleRemove());
@Override
public void handleEvent(Event e) {
handleRemove();
}
});
// Hook up the viewer // Hook up the viewer
@ -293,12 +279,7 @@ public class CFileTypesPreferenceBlock {
fAssocViewer.setLabelProvider(new AssocLabelProvider()); fAssocViewer.setLabelProvider(new AssocLabelProvider());
fAssocViewer.setInput(getCFileTypeAssociations()); fAssocViewer.setInput(getCFileTypeAssociations());
fAssocViewer.addSelectionChangedListener(new ISelectionChangedListener() { fAssocViewer.addSelectionChangedListener(event -> handleSelectionChanged());
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleSelectionChanged();
}
});
handleSelectionChanged(); handleSelectionChanged();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2012 IBM Corporation and others. * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -95,15 +95,12 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio
} }
} }
ListenerList fListeners; ListenerList<IProblemChangedListener> fListeners;
public ProblemMarkerManager() { public ProblemMarkerManager() {
fListeners = new ListenerList(); fListeners = new ListenerList<>();
} }
/*
* @see IResourceChangeListener#resourceChanged
*/
@Override @Override
public void resourceChanged(IResourceChangeEvent event) { public void resourceChanged(IResourceChangeEvent event) {
HashSet<IResource> changedElements = new HashSet<IResource>(); HashSet<IResource> changedElements = new HashSet<IResource>();
@ -123,21 +120,11 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio
} }
/*
* (non-Javadoc)
*
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
*/
@Override @Override
public void modelChanged(IAnnotationModel model) { public void modelChanged(IAnnotationModel model) {
// no action // no action
} }
/*
* (non-Javadoc)
*
* @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
*/
@Override @Override
public void modelChanged(AnnotationModelEvent event) { public void modelChanged(AnnotationModelEvent event) {
if (event instanceof TranslationUnitAnnotationModelEvent) { if (event instanceof TranslationUnitAnnotationModelEvent) {
@ -178,15 +165,9 @@ public class ProblemMarkerManager implements IResourceChangeListener, IAnnotatio
private void fireChanges(final IResource[] changes, final boolean markerChanged) { private void fireChanges(final IResource[] changes, final boolean markerChanged) {
Display display = SWTUtil.getStandardDisplay(); Display display = SWTUtil.getStandardDisplay();
if (display != null && !display.isDisposed()) { if (display != null && !display.isDisposed()) {
display.asyncExec(new Runnable() { display.asyncExec(() -> {
for (IProblemChangedListener curr : fListeners) {
@Override curr.problemsChanged(changes, markerChanged);
public void run() {
Object[] listeners = fListeners.getListeners();
for (Object listener : listeners) {
IProblemChangedListener curr = (IProblemChangedListener)listener;
curr.problemsChanged(changes, markerChanged);
}
} }
}); });
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2012 Wind River Systems, Inc. and others. * Copyright (c) 2006, 2017 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -31,13 +31,13 @@ import org.eclipse.jface.viewers.StructuredSelection;
public class AdaptingSelectionProvider implements ISelectionProvider, ISelectionChangedListener { public class AdaptingSelectionProvider implements ISelectionProvider, ISelectionChangedListener {
private Class<?> fTargetType; private Class<?> fTargetType;
private ListenerList fListenerList; private ListenerList<ISelectionChangedListener> fListenerList;
private ISelectionProvider fProvider; private ISelectionProvider fProvider;
public AdaptingSelectionProvider(Class<?> targetType, ISelectionProvider provider) { public AdaptingSelectionProvider(Class<?> targetType, ISelectionProvider provider) {
fProvider= provider; fProvider= provider;
fTargetType= targetType; fTargetType= targetType;
fListenerList= new ListenerList(); fListenerList= new ListenerList<>();
} }
private ISelection convertSelection(ISelection selection) { private ISelection convertSelection(ISelection selection) {
@ -96,9 +96,7 @@ public class AdaptingSelectionProvider implements ISelectionProvider, ISelection
@Override @Override
public void selectionChanged(SelectionChangedEvent event) { public void selectionChanged(SelectionChangedEvent event) {
SelectionChangedEvent event2= new SelectionChangedEvent(this, convertSelection(event.getSelection())); SelectionChangedEvent event2= new SelectionChangedEvent(this, convertSelection(event.getSelection()));
Object[] listeners= fListenerList.getListeners(); for (ISelectionChangedListener l : fListenerList) {
for (Object listener : listeners) {
ISelectionChangedListener l= (ISelectionChangedListener) listener;
l.selectionChanged(event2); l.selectionChanged(event2);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2013 IBM Corporation and others. * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -118,7 +118,7 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
private boolean fUseNewRegistry; private boolean fUseNewRegistry;
private IProblemChangedListener fProblemChangedListener; private IProblemChangedListener fProblemChangedListener;
private ListenerList fListeners; private ListenerList<ILabelProviderListener> fListeners;
private Map<MarkersCacheKey, IMarker[]> fMarkersCache = new HashMap<MarkersCacheKey, IMarker[]>(); private Map<MarkersCacheKey, IMarker[]> fMarkersCache = new HashMap<MarkersCacheKey, IMarker[]>();
/** /**
@ -290,16 +290,11 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
@Override @Override
public void addListener(ILabelProviderListener listener) { public void addListener(ILabelProviderListener listener) {
if (fListeners == null) { if (fListeners == null) {
fListeners= new ListenerList(); fListeners= new ListenerList<>();
} }
fListeners.add(listener); fListeners.add(listener);
if (fProblemChangedListener == null) { if (fProblemChangedListener == null) {
fProblemChangedListener= new IProblemChangedListener() { fProblemChangedListener= (changedResources, isMarkerChange) -> fireProblemsChanged(changedResources, isMarkerChange);
@Override
public void problemsChanged(IResource[] changedResources, boolean isMarkerChange) {
fireProblemsChanged(changedResources, isMarkerChange);
}
};
CUIPlugin.getDefault().getProblemMarkerManager().addListener(fProblemChangedListener); CUIPlugin.getDefault().getProblemMarkerManager().addListener(fProblemChangedListener);
} }
} }
@ -319,9 +314,8 @@ public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabe
fMarkersCache.clear(); fMarkersCache.clear();
if (fListeners != null && !fListeners.isEmpty()) { if (fListeners != null && !fListeners.isEmpty()) {
LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange); LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange);
Object[] listeners= fListeners.getListeners(); for (ILabelProviderListener listener : fListeners) {
for (Object listener : listeners) { listener.labelProviderChanged(event);
((ILabelProviderListener) listener).labelProviderChanged(event);
} }
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2012 IBM Corporation and others. * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -25,9 +25,7 @@ import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
@ -60,7 +58,7 @@ public class SelectionListenerWithASTManager {
private ISelectionListener fPostSelectionListener; private ISelectionListener fPostSelectionListener;
private ISelectionChangedListener fSelectionListener; private ISelectionChangedListener fSelectionListener;
private Job fCurrentJob; private Job fCurrentJob;
private ListenerList fAstListeners; private ListenerList<ISelectionListenerWithAST> fAstListeners;
/** Rule to make sure only one job is running at a time */ /** Rule to make sure only one job is running at a time */
private final ILock fJobLock= Job.getJobManager().newLock(); private final ILock fJobLock= Job.getJobManager().newLock();
private ISelectionValidator fValidator; private ISelectionValidator fValidator;
@ -68,24 +66,18 @@ public class SelectionListenerWithASTManager {
public PartListenerGroup(ITextEditor editorPart) { public PartListenerGroup(ITextEditor editorPart) {
fPart= editorPart; fPart= editorPart;
fCurrentJob= null; fCurrentJob= null;
fAstListeners= new ListenerList(ListenerList.IDENTITY); fAstListeners= new ListenerList<>(ListenerList.IDENTITY);
fSelectionListener= new ISelectionChangedListener() { fSelectionListener= event -> {
@Override ISelection selection= event.getSelection();
public void selectionChanged(SelectionChangedEvent event) { if (selection instanceof ITextSelection) {
ISelection selection= event.getSelection(); fireSelectionChanged((ITextSelection) selection);
if (selection instanceof ITextSelection) {
fireSelectionChanged((ITextSelection) selection);
}
} }
}; };
fPostSelectionListener= new ISelectionListener() { fPostSelectionListener= (part, selection) -> {
@Override if (part == fPart && selection instanceof ITextSelection)
public void selectionChanged(IWorkbenchPart part, ISelection selection) { firePostSelectionChanged((ITextSelection) selection);
if (part == fPart && selection instanceof ITextSelection)
firePostSelectionChanged((ITextSelection) selection);
}
}; };
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. * Copyright (c) 2007, 2017 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -31,15 +31,10 @@ public class SelectionProviderMediator implements ISelectionProvider {
private ISelectionChangedListener fSelectionChangedListener; private ISelectionChangedListener fSelectionChangedListener;
private FocusListener fFocusListener; private FocusListener fFocusListener;
private ListenerList fListenerList= new ListenerList(); private ListenerList<ISelectionChangedListener> fListenerList= new ListenerList<>();
public SelectionProviderMediator() { public SelectionProviderMediator() {
fSelectionChangedListener= new ISelectionChangedListener() { fSelectionChangedListener= event -> onSelectionChanged(event);
@Override
public void selectionChanged(SelectionChangedEvent event) {
onSelectionChanged(event);
}
};
fFocusListener = new FocusListener() { fFocusListener = new FocusListener() {
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
@ -62,12 +57,10 @@ public class SelectionProviderMediator implements ISelectionProvider {
} }
final protected void fireSelectionChanged() { final protected void fireSelectionChanged() {
Object[] listeners= fListenerList.getListeners(); if (!fListenerList.isEmpty()) {
if (listeners.length > 0) {
SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection()); SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
for (int i = 0; i < listeners.length; i++) { for (ISelectionChangedListener listener : fListenerList) {
ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
listener.selectionChanged(event); listener.selectionChanged(event);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2016 Wind River Systems and others. * Copyright (c) 2007, 2017 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -251,7 +251,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private MarkerAnnotationPreferences fAnnotationPreferences; private MarkerAnnotationPreferences fAnnotationPreferences;
private IPreferenceStore fPreferenceStore; private IPreferenceStore fPreferenceStore;
private IOverviewRuler fOverviewRuler; private IOverviewRuler fOverviewRuler;
private final ListenerList fRulerContextMenuListeners= new ListenerList(ListenerList.IDENTITY); private final ListenerList<IMenuListener> fRulerContextMenuListeners= new ListenerList<>(ListenerList.IDENTITY);
private SourceViewerDecorationSupport fDecorationSupport; private SourceViewerDecorationSupport fDecorationSupport;
private Font fFont; private Font fFont;
private IVerticalRuler fVerticalRuler; private IVerticalRuler fVerticalRuler;
@ -1234,8 +1234,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
addRulerContributionActions(manager); addRulerContributionActions(manager);
manager.add(new Separator(ITextEditorActionConstants.GROUP_REST)); manager.add(new Separator(ITextEditorActionConstants.GROUP_REST));
for (Object listener : fRulerContextMenuListeners.getListeners()) for (IMenuListener listener : fRulerContextMenuListeners)
((IMenuListener) listener).menuAboutToShow(manager); listener.menuAboutToShow(manager);
manager.add(new Separator(ITextEditorActionConstants.GROUP_EDIT)); manager.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
manager.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.COPY)); manager.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.COPY));

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. * Copyright (c) 2009, 2017 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -32,13 +32,8 @@ import org.eclipse.jface.viewers.StructuredSelection;
*/ */
class DisassemblySelectionProvider implements ISelectionProvider { class DisassemblySelectionProvider 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() { private final ISelectionChangedListener fListener = event -> fireSelectionChanged(event);
@Override
public void selectionChanged(SelectionChangedEvent event) {
fireSelectionChanged(event);
}
};
private final DisassemblyPart fPart; private final DisassemblyPart fPart;
DisassemblySelectionProvider(DisassemblyPart disassemblyPart) { DisassemblySelectionProvider(DisassemblyPart disassemblyPart) {
@ -48,24 +43,16 @@ class DisassemblySelectionProvider implements ISelectionProvider {
private void fireSelectionChanged(SelectionChangedEvent event) { private void fireSelectionChanged(SelectionChangedEvent event) {
SelectionChangedEvent newEvent = new SelectionChangedEvent(this, getSelection()); SelectionChangedEvent newEvent = new SelectionChangedEvent(this, getSelection());
Object[] listeners = fListenerList.getListeners(); for (ISelectionChangedListener listener : fListenerList) {
for (int i = 0; i < listeners.length; i++) {
ISelectionChangedListener listener = (ISelectionChangedListener) listeners[i];
listener.selectionChanged(newEvent); listener.selectionChanged(newEvent);
} }
} }
/*
* @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
@Override @Override
public void addSelectionChangedListener(ISelectionChangedListener listener) { public void addSelectionChangedListener(ISelectionChangedListener listener) {
fListenerList.add(listener); fListenerList.add(listener);
} }
/*
* @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
*/
@Override @Override
public ISelection getSelection() { public ISelection getSelection() {
final ISourceViewer textViewer= fPart.getTextViewer(); final ISourceViewer textViewer= fPart.getTextViewer();
@ -76,17 +63,11 @@ class DisassemblySelectionProvider implements ISelectionProvider {
return StructuredSelection.EMPTY; return StructuredSelection.EMPTY;
} }
/*
* @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
*/
@Override @Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) { public void removeSelectionChangedListener(ISelectionChangedListener listener) {
fListenerList.remove(listener); fListenerList.remove(listener);
} }
/*
* @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
*/
@Override @Override
public void setSelection(ISelection selection) { public void setSelection(ISelection selection) {
ISelectionProvider provider = fPart.getTextViewer().getSelectionProvider(); ISelectionProvider provider = fPart.getTextViewer().getSelectionProvider();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2012 Wind River Systems and others. * Copyright (c) 2007, 2017 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -24,7 +24,7 @@ import org.eclipse.core.runtime.ListenerList;
*/ */
public class CSourceTagProvider implements ISourceTagProvider { public class CSourceTagProvider implements ISourceTagProvider {
private ListenerList fListenerList= new ListenerList(ListenerList.IDENTITY); private ListenerList<ISourceTagListener> fListenerList= new ListenerList<>(ListenerList.IDENTITY);
private ITranslationUnit fUnit; private ITranslationUnit fUnit;
/** /**
@ -89,9 +89,6 @@ public class CSourceTagProvider implements ISourceTagProvider {
} }
} }
/*
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.ISourceTagProvider#removeSourceTagListener(org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.ISourceTagListener)
*/
@Override @Override
public void removeSourceTagListener(ISourceTagListener listener) { public void removeSourceTagListener(ISourceTagListener listener) {
fListenerList.remove(listener); fListenerList.remove(listener);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2012 Wind River Systems and others. * Copyright (c) 2008, 2017 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -58,7 +58,7 @@ public class DsfSuspendTrigger implements ISuspendTrigger {
private final DsfServicesTracker fServicesTracker; private final DsfServicesTracker fServicesTracker;
@ThreadSafe @ThreadSafe
private final ListenerList fListeners = new ListenerList(); private final ListenerList<ISuspendTriggerListener> fListeners = new ListenerList<>();
@ThreadSafe @ThreadSafe
public DsfSuspendTrigger(DsfSession session, ILaunch launch) { public DsfSuspendTrigger(DsfSession session, ILaunch launch) {
@ -192,8 +192,7 @@ public class DsfSuspendTrigger implements ISuspendTrigger {
*/ */
@ThreadSafe @ThreadSafe
protected void fireSuspended(final Object context) { protected void fireSuspended(final Object context) {
final Object[] listeners = fListeners.getListeners(); if (!fListeners.isEmpty()) {
if (listeners.length != 0) {
new Job("DSF Suspend Trigger Notify") { //$NON-NLS-1$ new Job("DSF Suspend Trigger Notify") { //$NON-NLS-1$
{ {
setSystem(true); setSystem(true);
@ -202,8 +201,7 @@ public class DsfSuspendTrigger implements ISuspendTrigger {
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
final MultiStatus status = new MultiStatus(DsfUIPlugin.PLUGIN_ID, 0, "DSF Suspend Trigger Notify Job Status", null); //$NON-NLS-1$ final MultiStatus status = new MultiStatus(DsfUIPlugin.PLUGIN_ID, 0, "DSF Suspend Trigger Notify Job Status", null); //$NON-NLS-1$
for (int i = 0; i < listeners.length; i++) { for (final ISuspendTriggerListener listener : fListeners) {
final ISuspendTriggerListener listener = (ISuspendTriggerListener) listeners[i];
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override @Override
public void run() throws Exception { public void run() throws Exception {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2016 IBM Corporation and others. * Copyright (c) 2005, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -64,7 +64,7 @@ public class DefaultVMModelProxyStrategy implements IVMModelProxy {
private IPresentationContext fContext; private IPresentationContext fContext;
private Viewer fViewer; private Viewer fViewer;
private boolean fDisposed = false; private boolean fDisposed = false;
private ListenerList fListeners = new ListenerList(); private ListenerList<IModelChangedListener> fListeners = new ListenerList<>();
private IDoubleClickListener fDoubleClickListener; private IDoubleClickListener fDoubleClickListener;
private boolean fAllowRecursiveVMNodes = false; private boolean fAllowRecursiveVMNodes = false;