diff options
author | Elliott Baron | 2009-03-16 14:59:49 +0000 |
---|---|---|
committer | Elliott Baron | 2009-03-16 14:59:49 +0000 |
commit | 64aeaed3d39e400488a59e5aeacd739af0a5cd6d (patch) | |
tree | 1f5d88703fd0088b12351e60eec70ccd84812837 /valgrind | |
parent | b7e20b2cb8122f5c27e9f8ab47a131c56e8d5297 (diff) | |
download | org.eclipse.linuxtools-64aeaed3d39e400488a59e5aeacd739af0a5cd6d.tar.gz org.eclipse.linuxtools-64aeaed3d39e400488a59e5aeacd739af0a5cd6d.tar.xz org.eclipse.linuxtools-64aeaed3d39e400488a59e5aeacd739af0a5cd6d.zip |
Extracted CachegrindLabelProvider
Diffstat (limited to 'valgrind')
8 files changed, 281 insertions, 98 deletions
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog index a8c4256414..f83d91a9a4 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog @@ -1,3 +1,9 @@ +2009-03-16 Elliott Baron <ebaron@redhat.com> + + * META-INF/MANIFEST.MF: Added cdt.ui to deps. + * AbstractCachegrindTest.java (getFileByName): Extracted method. + * BasicCachegrindTest.java: Likewise. + 2009-03-13 Andrew Overholt <overholt@redhat.com> * about.html: Initial checkin. diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF index d491aa7b6b..b9dafc4122 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF @@ -12,6 +12,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin Import-Package: org.eclipse.cdt.core.model, + org.eclipse.cdt.ui, org.eclipse.debug.core, org.eclipse.debug.ui, org.eclipse.linuxtools.profiling.tests, diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java index 77bcb01e2b..eec7ca1460 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java @@ -11,6 +11,8 @@ package org.eclipse.linuxtools.valgrind.cachegrind.tests; import org.eclipse.linuxtools.valgrind.cachegrind.CachegrindPlugin; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindFile; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindOutput; import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage; import org.eclipse.linuxtools.valgrind.tests.AbstractValgrindTest; import org.osgi.framework.Bundle; @@ -32,4 +34,14 @@ public abstract class AbstractCachegrindTest extends AbstractValgrindTest { return new CachegrindTestToolPage(); } + protected CachegrindFile getFileByName(CachegrindOutput output, String name) { + CachegrindFile file = null; + for (CachegrindFile f : output.getFiles()) { + if (f.getName().equals(name)) { + file = f; + } + } + return file; + } + } diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java index 715186088a..3830671f7a 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java @@ -64,14 +64,4 @@ public class BasicCachegrindTest extends AbstractCachegrindTest { assertNotNull(file); assertEquals(8, file.getFunctions().length); } - - private CachegrindFile getFileByName(CachegrindOutput output, String name) { - CachegrindFile file = null; - for (CachegrindFile f : output.getFiles()) { - if (f.getName().equals(name)) { - file = f; - } - } - return file; - } } diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/TableTest.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/TableTest.java new file mode 100644 index 0000000000..671be45b48 --- /dev/null +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/TableTest.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2009 Red Hat, Inc. + * 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: + * Elliott Baron <ebaron@redhat.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.valgrind.cachegrind.tests; + +import org.eclipse.cdt.core.model.IBinary; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.ui.CElementLabelProvider; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.jface.viewers.TreePath; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.linuxtools.valgrind.cachegrind.CachegrindLabelProvider; +import org.eclipse.linuxtools.valgrind.cachegrind.CachegrindViewPart; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindFile; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindOutput; +import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin; +import org.eclipse.swt.widgets.TreeItem; + +public class TableTest extends AbstractCachegrindTest { + + @Override + protected void setUp() throws Exception { + super.setUp(); + proj = createProject("cpptest"); //$NON-NLS-1$ + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + deleteProject(proj); + } + + public void testFileLabelsCPP() throws Exception { + IBinary bin = proj.getBinaryContainer().getBinaries()[0]; + ILaunchConfiguration config = createConfiguration(bin); + doLaunch(config, "testFileLabelsCPP"); //$NON-NLS-1$ + + CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView(); + CachegrindOutput output = view.getOutputs()[0]; + CachegrindFile file = getFileByName(output, "cpptest.cpp"); //$NON-NLS-1$ + + assertTrue(file.getModel() instanceof ITranslationUnit); + + checkLabelProvider(file); + } + + public void testFileLabelsH() throws Exception { + IBinary bin = proj.getBinaryContainer().getBinaries()[0]; + ILaunchConfiguration config = createConfiguration(bin); + doLaunch(config, "testFileLabelsH"); //$NON-NLS-1$ + + CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView(); + CachegrindOutput output = view.getOutputs()[0]; + CachegrindFile file = getFileByName(output, "cpptest.h"); //$NON-NLS-1$ + + assertTrue(file.getModel() instanceof ITranslationUnit); + assertTrue(((ITranslationUnit) file.getModel()).isHeaderUnit()); + + checkLabelProvider(file); + } + + private void checkLabelProvider(CachegrindFile file) { + CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView(); + TreeViewer viewer = view.getViewer(); + + // collapse the tree, then expand only the interesting item + viewer.expandToLevel(file, TreeViewer.ALL_LEVELS); + TreePath path = new TreePath(new Object[] { view.getOutputs()[0], file }); + TreeSelection selection = new TreeSelection(path); + viewer.setSelection(selection); + TreeItem item = viewer.getTree().getSelection()[0]; + + // ensure the CElementLabelProvider is called correctly + CElementLabelProvider provider = ((CachegrindLabelProvider) viewer.getLabelProvider(0)).getCLabelProvider(); + assertEquals(provider.getText(file.getModel()), item.getText()); + assertEquals(provider.getImage(file.getModel()), item.getImage()); + } + +} diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/ChangeLog b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/ChangeLog index 8e973c998d..3b437a1826 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/ChangeLog +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/ChangeLog @@ -1,3 +1,9 @@ +2009-03-16 Elliott Baron <ebaron@redhat.com> + + * CachegrindLabelProvider.java: New file. + * CachegrindViewPart.java (getViewer): Getter for TreeViewer. + (CachegrindTreeContentProvider): Extracted. + 2009-03-13 Andrew Overholt <overholt@redhat.com> * build.properties: Add icons to binary build. diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/valgrind/cachegrind/CachegrindLabelProvider.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/valgrind/cachegrind/CachegrindLabelProvider.java new file mode 100644 index 0000000000..f8438df872 --- /dev/null +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/valgrind/cachegrind/CachegrindLabelProvider.java @@ -0,0 +1,91 @@ +package org.eclipse.linuxtools.valgrind.cachegrind; + +import java.text.DecimalFormat; + +import org.eclipse.cdt.core.model.util.CElementBaseLabels; +import org.eclipse.cdt.ui.CElementLabelProvider; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.viewers.CellLabelProvider; +import org.eclipse.jface.viewers.ViewerCell; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindFile; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindFunction; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindLine; +import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindOutput; +import org.eclipse.linuxtools.valgrind.cachegrind.model.ICachegrindElement; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class CachegrindLabelProvider extends CellLabelProvider { + + protected CElementLabelProvider cLabelProvider = new CElementLabelProvider(CElementLabelProvider.SHOW_SMALL_ICONS | CElementLabelProvider.SHOW_PARAMETERS | CElementLabelProvider.SHOW_RETURN_TYPE) { + @Override + public int getTextFlags() { + int flags = super.getTextFlags(); + return flags |= CElementBaseLabels.M_FULLY_QUALIFIED; + } + }; + + protected DecimalFormat df = new DecimalFormat("#,##0"); //$NON-NLS-1$ + + protected static final Image FUNC_IMG = CachegrindPlugin.imageDescriptorFromPlugin(CachegrindPlugin.PLUGIN_ID, "icons/function_obj.gif").createImage(); //$NON-NLS-1$ + + @Override + public void update(ViewerCell cell) { + ICachegrindElement element = ((ICachegrindElement) cell.getElement()); + int index = cell.getColumnIndex(); + + if (index == 0) { + if (element instanceof CachegrindFile) { + // Try to use the CElementLabelProvider + IAdaptable model = ((CachegrindFile) element).getModel(); + if (model != null) { + cell.setText(cLabelProvider.getText(model)); + cell.setImage(cLabelProvider.getImage(model)); + } + else { // Fall back + String name = ((CachegrindFile) element).getName(); + cell.setText(name); + cell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE)); + } + } + else if (element instanceof CachegrindFunction) { + // Try to use the CElementLabelProvider + IAdaptable model = ((CachegrindFunction) element).getModel(); + if (model != null) { + cell.setText(cLabelProvider.getText(model)); + cell.setImage(cLabelProvider.getImage(model)); + } + else { // Fall back + String name = ((CachegrindFunction) element).getName(); + cell.setText(name); + cell.setImage(FUNC_IMG); + } + } + else if (element instanceof CachegrindLine) { + cell.setText(NLS.bind(Messages.getString("CachegrindViewPart.line"), ((CachegrindLine) element).getLine())); //$NON-NLS-1$ + cell.setImage(DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_INSTRUCTION_POINTER_TOP)); + } + else if (element instanceof CachegrindOutput) { + cell.setText(NLS.bind(Messages.getString("CachegrindViewPart.Total_PID"), ((CachegrindOutput) element).getPid())); //$NON-NLS-1$ + cell.setImage(DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_REGISTER)); + } + } + else if (element instanceof CachegrindFunction) { + cell.setText(df.format(((CachegrindFunction) element).getTotals()[index - 1])); + } + else if (element instanceof CachegrindLine) { + cell.setText(df.format(((CachegrindLine) element).getValues()[index - 1])); + } + else if (element instanceof CachegrindOutput) { + cell.setText(df.format(((CachegrindOutput) element).getSummary()[index - 1])); + } + } + + public CElementLabelProvider getCLabelProvider() { + return cLabelProvider; + } +}
\ No newline at end of file diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/valgrind/cachegrind/CachegrindViewPart.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/valgrind/cachegrind/CachegrindViewPart.java index 8992a71916..95f88e2462 100644 --- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/valgrind/cachegrind/CachegrindViewPart.java +++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind/src/org/eclipse/linuxtools/valgrind/cachegrind/CachegrindViewPart.java @@ -10,20 +10,13 @@ *******************************************************************************/ package org.eclipse.linuxtools.valgrind.cachegrind; -import java.text.DecimalFormat; import java.util.Arrays; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; -import org.eclipse.cdt.core.model.util.CElementBaseLabels; -import org.eclipse.cdt.ui.CElementLabelProvider; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.viewers.CellLabelProvider; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ITreeContentProvider; @@ -31,7 +24,6 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewerColumn; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerCell; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.linuxtools.profiling.ui.ProfileUIUtils; import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindFile; @@ -40,20 +32,16 @@ import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindLine; import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindOutput; import org.eclipse.linuxtools.valgrind.cachegrind.model.ICachegrindElement; import org.eclipse.linuxtools.valgrind.ui.IValgrindToolView; -import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; public class CachegrindViewPart extends ViewPart implements IValgrindToolView { @@ -62,7 +50,7 @@ public class CachegrindViewPart extends ViewPart implements IValgrindToolView { protected TreeViewer viewer; protected static final int COLUMN_SIZE = 75; - protected CellLabelProvider labelProvider; + protected CachegrindLabelProvider labelProvider; // Events - Cache protected static final String IR = "Ir"; //$NON-NLS-1$ @@ -81,8 +69,6 @@ public class CachegrindViewPart extends ViewPart implements IValgrindToolView { protected static final String BI = "Bi"; //$NON-NLS-1$ protected static final String BIM = "Bim"; //$NON-NLS-1$ - protected static final Image FUNC_IMG = CachegrindPlugin.imageDescriptorFromPlugin(CachegrindPlugin.PLUGIN_ID, "icons/function_obj.gif").createImage(); //$NON-NLS-1$ - @Override public void createPartControl(Composite parent) { Composite top = new Composite(parent, SWT.NONE); @@ -179,6 +165,82 @@ public class CachegrindViewPart extends ViewPart implements IValgrindToolView { } } + // private String getShortEventName(String event) { + // String result = event; + // if (event.equals(IR)) { + // result = Messages.getString("CachegrindViewPart.Ir_short"); //$NON-NLS-1$ + // } + // else if (event.equals(I1MR)) { + // result = Messages.getString("CachegrindViewPart.I1mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(I2MR)) { + // result = Messages.getString("CachegrindViewPart.I2mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(DR)) { + // result = Messages.getString("CachegrindViewPart.Dr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D1MR)) { + // result = Messages.getString("CachegrindViewPart.D1mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D2MR)) { + // result = Messages.getString("CachegrindViewPart.D2mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(DW)) { + // result = Messages.getString("CachegrindViewPart.Dw_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D1MW)) { + // result = Messages.getString("CachegrindViewPart.D1mw_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D2MW)) { + // result = Messages.getString("CachegrindViewPart.D2mw_short"); //$NON-NLS-1$ + // } + // return result; + // } + + public void setOutputs(CachegrindOutput[] outputs) { + this.outputs = outputs; + } + + // private String getShortEventName(String event) { + // String result = event; + // if (event.equals(IR)) { + // result = Messages.getString("CachegrindViewPart.Ir_short"); //$NON-NLS-1$ + // } + // else if (event.equals(I1MR)) { + // result = Messages.getString("CachegrindViewPart.I1mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(I2MR)) { + // result = Messages.getString("CachegrindViewPart.I2mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(DR)) { + // result = Messages.getString("CachegrindViewPart.Dr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D1MR)) { + // result = Messages.getString("CachegrindViewPart.D1mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D2MR)) { + // result = Messages.getString("CachegrindViewPart.D2mr_short"); //$NON-NLS-1$ + // } + // else if (event.equals(DW)) { + // result = Messages.getString("CachegrindViewPart.Dw_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D1MW)) { + // result = Messages.getString("CachegrindViewPart.D1mw_short"); //$NON-NLS-1$ + // } + // else if (event.equals(D2MW)) { + // result = Messages.getString("CachegrindViewPart.D2mw_short"); //$NON-NLS-1$ + // } + // return result; + // } + + public CachegrindOutput[] getOutputs() { + return outputs; + } + + public TreeViewer getViewer() { + return viewer; + } + private SelectionListener getHeaderListener() { return new SelectionAdapter() { @Override @@ -320,14 +382,6 @@ public class CachegrindViewPart extends ViewPart implements IValgrindToolView { // return result; // } - public void setOutputs(CachegrindOutput[] outputs) { - this.outputs = outputs; - } - - public CachegrindOutput[] getOutputs() { - return outputs; - } - protected class CachegrindTreeContentProvider implements ITreeContentProvider { public Object[] getChildren(Object parentElement) { @@ -362,70 +416,6 @@ public class CachegrindViewPart extends ViewPart implements IValgrindToolView { } - protected class CachegrindLabelProvider extends CellLabelProvider { - - protected CElementLabelProvider cLabelProvider = new CElementLabelProvider(CElementLabelProvider.SHOW_SMALL_ICONS | CElementLabelProvider.SHOW_PARAMETERS | CElementLabelProvider.SHOW_RETURN_TYPE) { - @Override - public int getTextFlags() { - int flags = super.getTextFlags(); - return flags |= CElementBaseLabels.M_FULLY_QUALIFIED; - } - }; - - protected DecimalFormat df = new DecimalFormat("#,##0"); //$NON-NLS-1$ - - @Override - public void update(ViewerCell cell) { - ICachegrindElement element = ((ICachegrindElement) cell.getElement()); - int index = cell.getColumnIndex(); - - if (index == 0) { - if (element instanceof CachegrindFile) { - // Try to use the CElementLabelProvider - IAdaptable model = ((CachegrindFile) element).getModel(); - if (model != null) { - cell.setText(cLabelProvider.getText(model)); - cell.setImage(cLabelProvider.getImage(model)); - } - else { // Fall back - String name = ((CachegrindFile) element).getName(); - cell.setText(name); - cell.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE)); - } - } - else if (element instanceof CachegrindFunction) { - // Try to use the CElementLabelProvider - IAdaptable model = ((CachegrindFunction) element).getModel(); - if (model != null) { - cell.setText(cLabelProvider.getText(model)); - cell.setImage(cLabelProvider.getImage(model)); - } - else { // Fall back - String name = ((CachegrindFunction) element).getName(); - cell.setText(name); - cell.setImage(FUNC_IMG); - } - } - else if (element instanceof CachegrindLine) { - cell.setText(NLS.bind(Messages.getString("CachegrindViewPart.line"), ((CachegrindLine) element).getLine())); //$NON-NLS-1$ - cell.setImage(DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_INSTRUCTION_POINTER_TOP)); - } - else if (element instanceof CachegrindOutput) { - cell.setText(NLS.bind(Messages.getString("CachegrindViewPart.Total_PID"), ((CachegrindOutput) element).getPid())); //$NON-NLS-1$ - cell.setImage(DebugUITools.getImage(IDebugUIConstants.IMG_OBJS_REGISTER)); - } - } - else if (element instanceof CachegrindFunction) { - cell.setText(df.format(((CachegrindFunction) element).getTotals()[index - 1])); - } - else if (element instanceof CachegrindLine) { - cell.setText(df.format(((CachegrindLine) element).getValues()[index - 1])); - } - else if (element instanceof CachegrindOutput) { - cell.setText(df.format(((CachegrindOutput) element).getSummary()[index - 1])); - } - } - - } + } |