KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > MemoryViewTabLabelProvider


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

11 package org.eclipse.debug.internal.ui.views.memory;
12
13 import java.math.BigInteger JavaDoc;
14
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
17 import org.eclipse.debug.ui.IDebugModelPresentation;
18 import org.eclipse.jface.viewers.IColorProvider;
19 import org.eclipse.swt.graphics.Color;
20
21 /**
22  * @since 3.0
23  */

24 public class MemoryViewTabLabelProvider
25     extends AbstractTableViewTabLabelProvider implements IColorProvider{
26     
27     /**
28      * Constructor for MemoryViewLabelProvider
29      */

30     public MemoryViewTabLabelProvider() {
31         super();
32     }
33     
34     public MemoryViewTabLabelProvider(ITableMemoryViewTab viewTab, AbstractMemoryRenderer renderer){
35         super(viewTab, renderer);
36     }
37     
38     /* (non-Javadoc)
39      * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
40      */

41     public String JavaDoc getColumnText(Object JavaDoc element, int columnIndex) {
42         
43         String JavaDoc label = super.getColumnText(element, columnIndex);
44         
45         // consult model presentation for address presentation
46
if (columnIndex == 0)
47         {
48             if (fViewTab instanceof MemoryViewTab)
49             {
50                 // get model presentation
51
IDebugModelPresentation presentation = ((MemoryViewTab)fViewTab).getMemoryBlockPresentation();
52                 
53                 if (presentation instanceof IMemoryBlockModelPresentation)
54                 {
55                     IMemoryBlockModelPresentation memPresentation = (IMemoryBlockModelPresentation)presentation;
56                     String JavaDoc address = ((MemoryViewLine)element).getAddress();
57                     
58                     // get address presentation
59
String JavaDoc tempLabel = memPresentation.getAddressPresentation(fViewTab.getMemoryBlock(), new BigInteger JavaDoc(address, 16));
60                     
61                     if (tempLabel != null)
62                         return tempLabel;
63                 }
64             }
65             return label;
66         }
67         return label;
68     }
69
70     /* (non-Javadoc)
71      * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
72      */

73     public Color getForeground(Object JavaDoc element) {
74         if (element instanceof MemoryViewLine)
75         {
76             MemoryViewLine line = (MemoryViewLine)element;
77             
78             if (line.isMonitored) {
79                 return null;
80             }
81             return DebugUIPlugin.getPreferenceColor(IDebugPreferenceConstants.MEMORY_VIEW_UNBUFFERED_LINE_COLOR);
82         }
83         return null;
84     }
85
86     /* (non-Javadoc)
87      * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
88      */

89     public Color getBackground(Object JavaDoc element) {
90         
91         return null;
92     }
93 }
94
Popular Tags