mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 04:55:22 +02:00
[238288] use ImageRegistry to store/retrieve images for RSE label providers
This commit is contained in:
parent
0379d2300e
commit
bfa9911a84
3 changed files with 11 additions and 59 deletions
|
@ -1,49 +0,0 @@
|
||||||
/********************************************************************************
|
|
||||||
* Copyright (c) 2008 IBM Corporation. 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
|
|
||||||
*
|
|
||||||
* Initial Contributors:
|
|
||||||
* The following IBM employees contributed to the Remote System Explorer
|
|
||||||
* component that contains this file: David McKnight.
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* David McKnight (IBM) - [236505] Remote systems dialog not working
|
|
||||||
********************************************************************************/
|
|
||||||
package org.eclipse.rse.internal.ui;
|
|
||||||
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.eclipse.swt.graphics.Image;
|
|
||||||
|
|
||||||
public class RSEImageMap {
|
|
||||||
|
|
||||||
private static Map _imageTable = new Hashtable(100);
|
|
||||||
|
|
||||||
public static Image get(Object key) {
|
|
||||||
if (_imageTable != null){
|
|
||||||
return (Image)_imageTable.get(key);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void put(Object key, Image image) {
|
|
||||||
if (_imageTable == null){
|
|
||||||
_imageTable = new Hashtable(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
_imageTable.put(key, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final void shutdown() {
|
|
||||||
if (_imageTable != null) {
|
|
||||||
for (Iterator i = _imageTable.values().iterator(); i.hasNext();) {
|
|
||||||
((Image) i.next()).dispose();
|
|
||||||
}
|
|
||||||
_imageTable = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,6 +17,7 @@
|
||||||
* Martin Oberhuber (Wind River) - [197550] Fix NPE when refreshing Pending items
|
* Martin Oberhuber (Wind River) - [197550] Fix NPE when refreshing Pending items
|
||||||
* David McKnight (IBM) - [236505] Remote systems dialog not working
|
* David McKnight (IBM) - [236505] Remote systems dialog not working
|
||||||
* Martin Oberhuber (Wind River) - [238519][api] Support styled label decorations
|
* Martin Oberhuber (Wind River) - [238519][api] Support styled label decorations
|
||||||
|
* David McKnight (IBM) - [238288] use ImageRegistry to store/retrieve images for RSE label providers
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.ui.view;
|
package org.eclipse.rse.internal.ui.view;
|
||||||
|
@ -30,6 +31,7 @@ import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.resource.ImageRegistry;
|
||||||
import org.eclipse.jface.viewers.AbstractTreeViewer;
|
import org.eclipse.jface.viewers.AbstractTreeViewer;
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
@ -41,7 +43,7 @@ import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelP
|
||||||
import org.eclipse.rse.core.model.ISystemViewInputProvider;
|
import org.eclipse.rse.core.model.ISystemViewInputProvider;
|
||||||
import org.eclipse.rse.core.model.SystemMessageObject;
|
import org.eclipse.rse.core.model.SystemMessageObject;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
import org.eclipse.rse.internal.ui.RSEImageMap;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
import org.eclipse.rse.ui.SystemBasePlugin;
|
import org.eclipse.rse.ui.SystemBasePlugin;
|
||||||
import org.eclipse.rse.ui.model.ISystemShellProvider;
|
import org.eclipse.rse.ui.model.ISystemShellProvider;
|
||||||
import org.eclipse.rse.ui.operations.SystemDeferredTreeContentManager;
|
import org.eclipse.rse.ui.operations.SystemDeferredTreeContentManager;
|
||||||
|
@ -431,7 +433,6 @@ public class SystemViewLabelAndContentProvider extends LabelProvider
|
||||||
public Image getImage(Object element)
|
public Image getImage(Object element)
|
||||||
{
|
{
|
||||||
ISystemViewElementAdapter adapter = getViewAdapter(element);
|
ISystemViewElementAdapter adapter = getViewAdapter(element);
|
||||||
//System.out.println("Inside getImage. element = " + element + ", adapter = " + adapter);
|
|
||||||
if (adapter == null)
|
if (adapter == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -442,12 +443,14 @@ public class SystemViewLabelAndContentProvider extends LabelProvider
|
||||||
|
|
||||||
//add any annotations to the image descriptor
|
//add any annotations to the image descriptor
|
||||||
descriptor = decorateImage(descriptor, element);
|
descriptor = decorateImage(descriptor, element);
|
||||||
|
|
||||||
|
ImageRegistry imageRegistry = RSEUIPlugin.getDefault().getImageRegistry();
|
||||||
|
Image image = imageRegistry.get(descriptor.toString());
|
||||||
|
|
||||||
//obtain the cached image corresponding to the descriptor
|
//obtain the cached image corresponding to the descriptor
|
||||||
Image image = RSEImageMap.get(descriptor);
|
if (image == null){
|
||||||
if (image == null)
|
image = descriptor.createImage();
|
||||||
{
|
imageRegistry.put(descriptor.toString(), image);
|
||||||
image = descriptor.createImage();
|
|
||||||
RSEImageMap.put(descriptor, image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
* David Dykstal (IBM) - [197167] adding notification and waiting for RSE model
|
* David Dykstal (IBM) - [197167] adding notification and waiting for RSE model
|
||||||
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
|
* David McKnight (IBM) - [225506] [api][breaking] RSE UI leaks non-API types
|
||||||
* David McKnight (IBM) - [236505] Remote systems dialog not working
|
* David McKnight (IBM) - [236505] Remote systems dialog not working
|
||||||
|
* David McKnight (IBM) - [238288] use ImageRegistry to store/retrieve images for RSE label providers
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.ui;
|
package org.eclipse.rse.ui;
|
||||||
|
@ -54,7 +55,6 @@ import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||||
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
|
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
|
||||||
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
||||||
import org.eclipse.rse.internal.core.model.SystemRegistry;
|
import org.eclipse.rse.internal.core.model.SystemRegistry;
|
||||||
import org.eclipse.rse.internal.ui.RSEImageMap;
|
|
||||||
import org.eclipse.rse.internal.ui.RSESystemTypeAdapterFactory;
|
import org.eclipse.rse.internal.ui.RSESystemTypeAdapterFactory;
|
||||||
import org.eclipse.rse.internal.ui.RSEUIInitJob;
|
import org.eclipse.rse.internal.ui.RSEUIInitJob;
|
||||||
import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapterFactory;
|
import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapterFactory;
|
||||||
|
@ -502,8 +502,6 @@ public class RSEUIPlugin extends SystemBasePlugin
|
||||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||||
*/
|
*/
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
RSEImageMap.shutdown();
|
|
||||||
|
|
||||||
// disconnect all active connections
|
// disconnect all active connections
|
||||||
disconnectAll(true);
|
disconnectAll(true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue