diff options
3 files changed, 56 insertions, 47 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/ImageCache.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/ImageCache.java index 397d33a66..d488ea49b 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/ImageCache.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/ImageCache.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2014 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2016 Wind River Systems, Inc. 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 @@ -18,6 +18,8 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.resource.CompositeImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; @@ -28,6 +30,9 @@ import org.osgi.framework.Bundle; public class ImageCache { + /* Image ID prefix to indicate common Debug UI images */ + private static final String DebugUI = "DebugUI:"; + public static final String IMG_TCF = "icons/tcf", IMG_TARGET_TAB = "icons/target_tab", @@ -77,7 +82,10 @@ public class ImageCache { IMG_BREAKPOINT_OVERLAY = "icons/brkp_ovr", IMG_FOLDER = "icons/full/obj16/fldr_obj", - IMG_FILE = "icons/full/obj16/file_obj"; + IMG_FILE = "icons/full/obj16/file_obj", + + IMG_INSTRUCTION_POINTER_TOP = DebugUI + IDebugUIConstants.IMG_OBJS_INSTRUCTION_POINTER_TOP, + IMG_INSTRUCTION_POINTER = DebugUI + IDebugUIConstants.IMG_OBJS_INSTRUCTION_POINTER; private static final Map<String,ImageDescriptor> desc_cache = new HashMap<String,ImageDescriptor>(); private static final Map<ImageDescriptor,Image> image_cache = new HashMap<ImageDescriptor,Image>(); @@ -88,36 +96,41 @@ public class ImageCache { if (name == null) return null; ImageDescriptor descriptor = desc_cache.get(name); if (descriptor == null) { - String[] ext = { "png", "gif" }; - for (String e : ext) { - IPath path = new Path(name).removeFileExtension().addFileExtension(e); - Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); - if (bundle != null) { - URL url = FileLocator.find(bundle, path, null); - if (url != null) { - descriptor = ImageDescriptor.createFromURL(url); - if (descriptor != null) break; + if (name.startsWith(DebugUI)) { + descriptor = DebugUITools.getImageDescriptor(name.substring(DebugUI.length())); + } + else { + String[] ext = { "png", "gif" }; + for (String e : ext) { + IPath path = new Path(name).removeFileExtension().addFileExtension(e); + Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); + if (bundle != null) { + URL url = FileLocator.find(bundle, path, null); + if (url != null) { + descriptor = ImageDescriptor.createFromURL(url); + if (descriptor != null) break; + } } - } - bundle = Platform.getBundle("org.eclipse.debug.ui"); - if (bundle != null) { - URL url = FileLocator.find(bundle, path, null); - if (url != null) { - descriptor = ImageDescriptor.createFromURL(url); - if (descriptor != null) break; + bundle = Platform.getBundle("org.eclipse.debug.ui"); + if (bundle != null) { + URL url = FileLocator.find(bundle, path, null); + if (url != null) { + descriptor = ImageDescriptor.createFromURL(url); + if (descriptor != null) break; + } } - } - bundle = Platform.getBundle("org.eclipse.cdt.debug.ui"); - if (bundle != null) { - URL url = FileLocator.find(bundle, path, null); - if (url != null) { - descriptor = ImageDescriptor.createFromURL(url); - if (descriptor != null) break; + bundle = Platform.getBundle("org.eclipse.cdt.debug.ui"); + if (bundle != null) { + URL url = FileLocator.find(bundle, path, null); + if (url != null) { + descriptor = ImageDescriptor.createFromURL(url); + if (descriptor != null) break; + } } } - } - if (descriptor == null) { - descriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(name); + if (descriptor == null) { + descriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(name); + } } if (descriptor == null) { descriptor = ImageDescriptor.getMissingImageDescriptor(); diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationImageProvider.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationImageProvider.java index ebf3b3140..17ca37a81 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationImageProvider.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationImageProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2016 Wind River Systems, Inc. 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 @@ -13,19 +13,20 @@ package org.eclipse.tcf.internal.debug.ui.model; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.source.Annotation; import org.eclipse.swt.graphics.Image; +import org.eclipse.tcf.internal.debug.ui.ImageCache; import org.eclipse.ui.texteditor.IAnnotationImageProvider; public class TCFAnnotationImageProvider implements IAnnotationImageProvider { public Image getManagedImage(Annotation annotation) { - return ((TCFAnnotationManager.TCFAnnotation)annotation).image; + return ImageCache.getImage(((TCFAnnotationManager.TCFAnnotation)annotation).image); } public String getImageDescriptorId(Annotation annotation) { return null; } - public ImageDescriptor getImageDescriptor(String imageDescritporId) { + public ImageDescriptor getImageDescriptor(String id) { return null; } } diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java index adbdcdfe0..9f63ee479 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFAnnotationManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2016 Wind River Systems, Inc. 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 @@ -43,7 +43,6 @@ import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.graphics.Device; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; import org.eclipse.tcf.debug.ui.ITCFAnnotationProvider; import org.eclipse.tcf.internal.debug.launch.TCFSourceLookupDirector; @@ -91,7 +90,7 @@ public class TCFAnnotationManager { final String bp_id; final BigInteger addr; final ILineNumbers.CodeArea area; - final Image image; + final String image; final String text; final String type; final int hash_code; @@ -101,7 +100,7 @@ public class TCFAnnotationManager { IBreakpoint breakpoint; TCFAnnotation(String ctx, String bp_id, BigInteger addr, - ILineNumbers.CodeArea area, Image image, String text, String type) { + ILineNumbers.CodeArea area, String image, String text, String type) { super(type, false, text); this.ctx = ctx; this.bp_id = bp_id; @@ -113,10 +112,6 @@ public class TCFAnnotationManager { hash_code = image.hashCode() + text.hashCode() + type.hashCode(); } - protected Image getImage() { - return image; - } - void dispose() { for (IAnnotationModel model : models) { model.removeAnnotation(this); @@ -468,7 +463,7 @@ public class TCFAnnotationManager { ILineNumbers.CodeArea area = getBreakpointCodeArea(launch, id); if (area != null) { TCFAnnotation a = new TCFAnnotation(ctx, id, null, area, - ImageCache.getImage(ImageCache.IMG_BREAKPOINT_ERROR), + ImageCache.IMG_BREAKPOINT_ERROR, "Cannot plant breakpoint: " + error, TYPE_BP_INSTANCE); set.add(a); @@ -719,7 +714,7 @@ public class TCFAnnotationManager { if (addr != null) location = " at 0x" + addr.toString(16); if (org_area == null) org_area = area; TCFAnnotation a = new TCFAnnotation(memory.id, id, addr, org_area, - ImageCache.getImage(ImageCache.IMG_BREAKPOINT_ERROR), + ImageCache.IMG_BREAKPOINT_ERROR, bp_name + " failed to plant" + location + ": " + error, TYPE_BP_INSTANCE); set.add(a); @@ -727,14 +722,14 @@ public class TCFAnnotationManager { else if (area != null && addr != null) { String location = " planted at 0x" + addr.toString(16) + ", line " + area.start_line; TCFAnnotation a = new TCFAnnotation(memory.id, id, addr, area, - ImageCache.getImage(ImageCache.IMG_BREAKPOINT_INSTALLED), + ImageCache.IMG_BREAKPOINT_INSTALLED, bp_name + location, TYPE_BP_INSTANCE); a.breakpoint = bp; set.add(a); if (isLineAdjusted(area, org_area)) { TCFAnnotation b = new TCFAnnotation(memory.id, id, null, org_area, - ImageCache.getImage(ImageCache.IMG_BREAKPOINT_WARNING), + ImageCache.IMG_BREAKPOINT_WARNING, "Breakpoint location is adjusted: " + location, TYPE_BP_INSTANCE); set.add(b); @@ -743,7 +738,7 @@ public class TCFAnnotationManager { error = (String)m.get(IBreakpoints.INSTANCE_CONDITION_ERROR); if (error != null) { TCFAnnotation a = new TCFAnnotation(memory.id, id, addr, org_area, - ImageCache.getImage(ImageCache.IMG_BREAKPOINT_ERROR), + ImageCache.IMG_BREAKPOINT_ERROR, bp_name + " failed to evaluate condition: " + error, TYPE_BP_INSTANCE); set.add(a); @@ -773,13 +768,13 @@ public class TCFAnnotationManager { addr_str += ", line: " + line_data.area.start_line; if (frame.getFrameNo() == 0) { a = new TCFAnnotation(line_data.context_id, null, null, line_data.area, - DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_INSTRUCTION_POINTER_TOP), + ImageCache.IMG_INSTRUCTION_POINTER_TOP, "Current Instruction Pointer" + addr_str, TYPE_TOP_FRAME); } else { a = new TCFAnnotation(line_data.context_id, null, null, line_data.area, - DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_INSTRUCTION_POINTER), + ImageCache.IMG_INSTRUCTION_POINTER, "Call Stack Frame" + addr_str, TYPE_STACK_FRAME); } @@ -792,7 +787,7 @@ public class TCFAnnotationManager { TCFSourceRef line_data = line_cache.getData(); if (line_data != null && line_data.area != null) { TCFAnnotation a = new TCFAnnotation(line_data.context_id, null, null, line_data.area, - DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_INSTRUCTION_POINTER), + ImageCache.IMG_INSTRUCTION_POINTER, "Last Instruction Pointer position", TYPE_STACK_FRAME); set.add(a); |