1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Get rid of SharedTextColors

This commit is contained in:
Anton Leherbauer 2008-03-28 15:39:09 +00:00
parent d0e1ee1473
commit dd9db085d7
4 changed files with 6 additions and 171 deletions

View file

@ -1,79 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
/*
* @see org.eclipse.jface.text.source.ISharedTextColors
* @since 2.1
*/
public class SharedTextColors implements ISharedTextColors {
/** The display table. */
private Map fDisplayTable;
/** Creates an returns a shared color manager. */
public SharedTextColors() {
super();
}
/*
* @see ISharedTextColors#getColor(RGB)
*/
public Color getColor(RGB rgb) {
if (rgb == null)
return null;
if (fDisplayTable == null)
fDisplayTable= new HashMap(2);
Display display= Display.getCurrent();
Map colorTable= (Map) fDisplayTable.get(display);
if (colorTable == null) {
colorTable= new HashMap(10);
fDisplayTable.put(display, colorTable);
}
Color color= (Color) colorTable.get(rgb);
if (color == null) {
color= new Color(display, rgb);
colorTable.put(rgb, color);
}
return color;
}
/*
* @see ISharedTextColors#dispose()
*/
public void dispose() {
if (fDisplayTable != null) {
Iterator j= fDisplayTable.values().iterator();
while (j.hasNext()) {
Iterator i= ((Map) j.next()).values().iterator();
while (i.hasNext())
((Color) i.next()).dispose();
}
}
}
}

View file

@ -83,7 +83,6 @@ import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
import org.eclipse.cdt.internal.ui.editor.ASTProvider;
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
import org.eclipse.cdt.internal.ui.editor.CustomBufferFactory;
import org.eclipse.cdt.internal.ui.editor.SharedTextColors;
import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
import org.eclipse.cdt.internal.ui.refactoring.CTextFileChangeFactory;
@ -335,8 +334,6 @@ public class CUIPlugin extends AbstractUIPlugin {
// ------ CUIPlugin
private ISharedTextColors fSharedTextColors;
private ImageDescriptorRegistry fImageDescriptorRegistry;
private CEditorTextHoverDescriptor[] fCEditorTextHoverDescriptors;
@ -599,10 +596,9 @@ public class CUIPlugin extends AbstractUIPlugin {
manager.unregisterAdapters(fCElementAdapterFactory);
}
/** @deprecated Use {@link EditorsUI#getSharedTextColors()} instead. */
public ISharedTextColors getSharedTextColors() {
if (fSharedTextColors == null)
fSharedTextColors= new SharedTextColors();
return fSharedTextColors;
return EditorsUI.getSharedTextColors();
}
public void configurePluginDebugOptions(){

View file

@ -1,76 +0,0 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.editors;
import java.util.Iterator;
import org.eclipse.swt.widgets.Display;
import java.util.Map;
import java.util.HashMap;
import org.eclipse.swt.graphics.Color;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.swt.graphics.RGB;
/*
* @see org.eclipse.jface.text.source.ISharedTextColors
* @since 2.1
*/
class SharedTextColors implements ISharedTextColors {
/** The display table. */
private Map fDisplayTable;
/** Creates an returns a shared color manager. */
public SharedTextColors() {
super();
}
/*
* @see ISharedTextColors#getColor(RGB)
*/
public Color getColor(RGB rgb) {
if (rgb == null)
return null;
if (fDisplayTable == null)
fDisplayTable= new HashMap(2);
Display display= Display.getCurrent();
Map colorTable= (Map) fDisplayTable.get(display);
if (colorTable == null) {
colorTable= new HashMap(10);
fDisplayTable.put(display, colorTable);
}
Color color= (Color) colorTable.get(rgb);
if (color == null) {
color= new Color(display, rgb);
colorTable.put(rgb, color);
}
return color;
}
/*
* @see ISharedTextColors#dispose()
*/
public void dispose() {
if (fDisplayTable != null) {
Iterator j= fDisplayTable.values().iterator();
while (j.hasNext()) {
Iterator i= ((Map) j.next()).values().iterator();
while (i.hasNext())
((Color) i.next()).dispose();
}
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2007 QNX Software Systems and others.
* Copyright (c) 2004, 2008 QNX Software 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
@ -8,6 +8,7 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.debug.ui;
@ -43,6 +44,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@ -66,8 +68,6 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
private CDebugImageDescriptorRegistry fImageDescriptorRegistry;
private ISharedTextColors fSharedTextColors;
/**
* The constructor.
*/
@ -276,10 +276,6 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
*/
public void stop( BundleContext context ) throws Exception {
CDebugCorePlugin.getDefault().removeCBreakpointListener( CBreakpointUpdater.getInstance() );
if ( fSharedTextColors != null ) {
fSharedTextColors.dispose();
fSharedTextColors = null;
}
if ( fImageDescriptorRegistry != null ) {
fImageDescriptorRegistry.dispose();
}
@ -293,8 +289,6 @@ public class CDebugUIPlugin extends AbstractUIPlugin {
* @since 3.1
*/
public ISharedTextColors getSharedTextColors() {
if ( fSharedTextColors == null )
fSharedTextColors = CUIPlugin.getDefault().getSharedTextColors();
return fSharedTextColors;
return EditorsUI.getSharedTextColors();
}
}