KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > model > elements > DebugElementLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.model.elements;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
15 import org.eclipse.debug.internal.ui.views.DebugModelPresentationContext;
16 import org.eclipse.debug.internal.ui.views.launch.DebugElementHelper;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.jface.viewers.TreePath;
19 import org.eclipse.swt.graphics.FontData;
20 import org.eclipse.swt.graphics.RGB;
21
22 /**
23  * @since 3.3
24  */

25 public class DebugElementLabelProvider extends ElementLabelProvider {
26
27     protected String JavaDoc getLabel(TreePath elementPath, IPresentationContext presentationContext, String JavaDoc columnId) throws CoreException {
28         Object JavaDoc element = elementPath.getLastSegment();
29         if (presentationContext instanceof DebugModelPresentationContext) {
30             DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
31             return debugContext.getModelPresentation().getText(element);
32         }
33         return DebugElementHelper.getLabel(element);
34     }
35
36     protected RGB getBackground(TreePath elementPath, IPresentationContext presentationContext, String JavaDoc columnId) throws CoreException {
37         Object JavaDoc element = elementPath.getLastSegment();
38         if (presentationContext instanceof DebugModelPresentationContext) {
39             DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
40             return DebugElementHelper.getBackground(element, debugContext.getModelPresentation());
41         }
42         return DebugElementHelper.getBackground(element);
43     }
44
45     protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String JavaDoc columnId) throws CoreException {
46         Object JavaDoc element = elementPath.getLastSegment();
47         if (presentationContext instanceof DebugModelPresentationContext) {
48             DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
49             return DebugElementHelper.getFont(element, debugContext.getModelPresentation());
50             
51         }
52         return DebugElementHelper.getFont(element);
53     }
54
55     protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String JavaDoc columnId) throws CoreException {
56         Object JavaDoc element = elementPath.getLastSegment();
57         if (presentationContext instanceof DebugModelPresentationContext) {
58             DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
59             return DebugElementHelper.getForeground(element, debugContext.getModelPresentation());
60         }
61         return DebugElementHelper.getForeground(element);
62     }
63
64     protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String JavaDoc columnId) throws CoreException {
65         Object JavaDoc element = elementPath.getLastSegment();
66         if (presentationContext instanceof DebugModelPresentationContext) {
67             DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext;
68             return DebugElementHelper.getImageDescriptor(element, debugContext.getModelPresentation());
69         }
70         return DebugElementHelper.getImageDescriptor(element);
71     }
72     
73
74
75 }
76
Popular Tags