1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Generics.

This commit is contained in:
Sergey Prigogin 2010-12-04 22:10:25 +00:00
parent f76e087cfa
commit 3f93fe42c4
3 changed files with 71 additions and 89 deletions

View file

@ -19,13 +19,11 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
/** /**
*
* Color manager for C/C++ Debug UI. * Color manager for C/C++ Debug UI.
* *
* @since Jul 23, 2002 * @since Jul 23, 2002
*/ */
public class ColorManager { public class ColorManager {
private static ColorManager gfColorManager; private static ColorManager gfColorManager;
private ColorManager() { private ColorManager() {
@ -38,24 +36,20 @@ public class ColorManager {
return gfColorManager; return gfColorManager;
} }
protected Map fColorTable = new HashMap( 10 ); protected Map<RGB, Color> fColorTable = new HashMap<RGB, Color>(10);
public Color getColor(RGB rgb) { public Color getColor(RGB rgb) {
Color color = (Color)getColorTable().get(rgb); Color color = fColorTable.get(rgb);
if (color == null) { if (color == null) {
color = new Color(Display.getCurrent(), rgb); color = new Color(Display.getCurrent(), rgb);
getColorTable().put( rgb, color ); fColorTable.put(rgb, color);
} }
return color; return color;
} }
public void dispose() { public void dispose() {
Iterator e = getColorTable().values().iterator(); Iterator<Color> e = fColorTable.values().iterator();
while (e.hasNext()) while (e.hasNext())
((Color)e.next()).dispose(); e.next().dispose();
}
private Map getColorTable() {
return this.fColorTable;
} }
} }

View file

@ -37,19 +37,15 @@ import org.eclipse.ui.PlatformUI;
* visible in editors only if there is a running debug session. * visible in editors only if there is a running debug session.
*/ */
public class EvaluationContextManager implements IWindowListener, IPageListener, ISelectionListener, IPartListener2 { public class EvaluationContextManager implements IWindowListener, IPageListener, ISelectionListener, IPartListener2 {
private final static String DEBUGGER_ACTIVE = CDebugUIPlugin.getUniqueIdentifier() + ".debuggerActive"; //$NON-NLS-1$ private final static String DEBUGGER_ACTIVE = CDebugUIPlugin.getUniqueIdentifier() + ".debuggerActive"; //$NON-NLS-1$
protected static EvaluationContextManager fgManager; protected static EvaluationContextManager fgManager;
private Map<IWorkbenchPage, ICDebugTarget> fContextsByPage = null;
private Map fContextsByPage = null;
protected EvaluationContextManager() { protected EvaluationContextManager() {
} }
public static void startup() { public static void startup() {
Runnable r = new Runnable() { Runnable r = new Runnable() {
public void run() { public void run() {
if (fgManager == null) { if (fgManager == null) {
fgManager = new EvaluationContextManager(); fgManager = new EvaluationContextManager();
@ -205,7 +201,7 @@ public class EvaluationContextManager implements IWindowListener, IPageListener,
*/ */
private void setContext(IWorkbenchPage page, ICDebugTarget target) { private void setContext(IWorkbenchPage page, ICDebugTarget target) {
if (fContextsByPage == null) { if (fContextsByPage == null) {
fContextsByPage = new HashMap(); fContextsByPage = new HashMap<IWorkbenchPage, ICDebugTarget>();
} }
fContextsByPage.put(page, target); fContextsByPage.put(page, target);
System.setProperty(DEBUGGER_ACTIVE, Boolean.TRUE.toString()); System.setProperty(DEBUGGER_ACTIVE, Boolean.TRUE.toString());

View file

@ -8,11 +8,9 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui; package org.eclipse.cdt.debug.internal.ui;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
@ -23,8 +21,7 @@ import org.eclipse.swt.graphics.Image;
* @since May 30, 2003 * @since May 30, 2003
*/ */
public class OverlayImageCache { public class OverlayImageCache {
private Map<OverlayImageDescriptor, Image> fCache = new HashMap<OverlayImageDescriptor, Image>();
private Map fCache = new HashMap();
/** /**
* Returns and caches an image corresponding to the specified image * Returns and caches an image corresponding to the specified image
@ -35,10 +32,10 @@ public class OverlayImageCache {
* @return the image * @return the image
*/ */
public Image getImageFor(OverlayImageDescriptor imageDescriptor) { public Image getImageFor(OverlayImageDescriptor imageDescriptor) {
Image image = (Image)getCache().get( imageDescriptor ); Image image = fCache.get(imageDescriptor);
if (image == null) { if (image == null) {
image = imageDescriptor.createImage(); image = imageDescriptor.createImage();
getCache().put( imageDescriptor, image ); fCache.put(imageDescriptor, image);
} }
return image; return image;
} }
@ -47,14 +44,9 @@ public class OverlayImageCache {
* Disposes of all images in the cache. * Disposes of all images in the cache.
*/ */
public void disposeAll() { public void disposeAll() {
for ( Iterator it = getCache().values().iterator(); it.hasNext(); ) { for (Image image : fCache.values()) {
Image image = (Image)it.next();
image.dispose(); image.dispose();
} }
getCache().clear(); fCache.clear();
}
private Map getCache() {
return this.fCache;
} }
} }