Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 217774 Details for
Bug 371285
Session comparison between runs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Added label provider and column sorter to the compaison viewer
0001-Added-label-provider-and-column-sorter-for-compariso.patch (text/plain), 7.03 KB, created by
Camilo Bernal
on 2012-06-22 18:38:28 EDT
(
hide
)
Description:
Added label provider and column sorter to the compaison viewer
Filename:
MIME Type:
Creator:
Camilo Bernal
Created:
2012-06-22 18:38:28 EDT
Size:
7.03 KB
patch
obsolete
>From 109a7d237c4ab1bdaca702a8da4882afa61b4095 Mon Sep 17 00:00:00 2001 >From: Camilo Bernal <cabernal@redhat.com> >Date: Fri, 22 Jun 2012 17:59:59 -0400 >Subject: [PATCH] Added label provider and column sorter for comparison > viewer. > >The label provider (PerfDiffLabelProvider.java) displays the corresponding >text of each column, along with color for the "Result" column signifying >overhead gain or loss. The getColumnText method decides what is displayed >in each column based on the what column index is provided. > >The viewer sorter (PerfDiffTableSorter.java) provides sorting functionality >to each column. It compares column elements differently depending on the >column index provided. >--- > .../internal/perf/ui/PerfDiffLabelProvider.java | 115 ++++++++++++++++++++ > .../internal/perf/ui/PerfDiffTableSorter.java | 67 ++++++++++++ > 2 files changed, 182 insertions(+), 0 deletions(-) > create mode 100644 perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffLabelProvider.java > create mode 100644 perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffTableSorter.java > >diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffLabelProvider.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffLabelProvider.java >new file mode 100644 >index 0000000..2b86832 >--- /dev/null >+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffLabelProvider.java >@@ -0,0 +1,115 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 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: >+ * Camilo Bernal <cabernal@redhat.com> - Initial Implementation. >+ *******************************************************************************/ >+package org.eclipse.linuxtools.internal.perf.ui; >+ >+import org.eclipse.jface.resource.StringConverter; >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.jface.viewers.ITableColorProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.linuxtools.internal.perf.model.PMSymbol; >+import org.eclipse.linuxtools.internal.perf.model.PMSymbolMatch; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Display; >+ >+class PerfDiffLabelProvider implements ITableLabelProvider, ITableColorProvider { >+ >+ public static final String COLOR_RED = "75, 200, 75"; >+ public static final String COLOR_GREEN = "200, 75, 75"; >+ >+ @Override >+ public Color getBackground(Object element, int columnIndex) { >+ String result = ((PMSymbolMatch) element).getResult(); >+ switch (columnIndex) { >+ >+ case 3: >+ try { >+ float resFloat = Float.parseFloat(result); >+ if (resFloat < 0) { >+ return new Color(Display.getCurrent(), >+ StringConverter.asRGB(COLOR_RED)); >+ } else if (resFloat == 0) { >+ return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); >+ } else { >+ return new Color(Display.getCurrent(), >+ StringConverter.asRGB(COLOR_GREEN)); >+ } >+ } catch (Exception ex) { >+ // result is a character string >+ return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); >+ } >+ default: >+ return Display.getCurrent().getSystemColor(SWT.COLOR_WHITE); >+ } >+ } >+ >+ @Override >+ public String getColumnText(Object element, int columnIndex) { >+ PMSymbolMatch p = (PMSymbolMatch) element; >+ switch (columnIndex) { >+ // function column >+ case 0: >+ return p.getName(); >+ // new column >+ case 1: >+ PMSymbol fresh = p.getFresh(); >+ return (fresh == null) ? "-" : String.valueOf(fresh.getPercent()); >+ // old column >+ case 2: >+ PMSymbol stale = p.getStale(); >+ return (stale == null) ? "-" : String.valueOf(stale.getPercent()); >+ // result column >+ case 3: >+ String result = p.getResult(); >+ try { >+ Float.parseFloat(result); >+ return result + "%"; >+ } catch (Exception e) { >+ return result; >+ } >+ // event column >+ case 4: >+ return p.getEvent(); >+ case 5: >+ return ""; >+ default: >+ throw new RuntimeException("Something went wrong"); >+ } >+ } >+ >+ @Override >+ public void addListener(ILabelProviderListener listener) { >+ } >+ >+ @Override >+ public void dispose() { >+ } >+ >+ @Override >+ public boolean isLabelProperty(Object element, String property) { >+ return false; >+ } >+ >+ @Override >+ public void removeListener(ILabelProviderListener listener) { >+ } >+ >+ @Override >+ public Color getForeground(Object element, int columnIndex) { >+ return null; >+ } >+ >+ @Override >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+} >\ No newline at end of file >diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffTableSorter.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffTableSorter.java >new file mode 100644 >index 0000000..147a5c2 >--- /dev/null >+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/ui/PerfDiffTableSorter.java >@@ -0,0 +1,67 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 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: >+ * Camilo Bernal <cabernal@redhat.com> - Initial Implementation. >+ *******************************************************************************/ >+package org.eclipse.linuxtools.internal.perf.ui; >+ >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.linuxtools.internal.perf.model.PMSymbolMatch; >+ >+class PerfDiffTableSorter extends ViewerSorter { >+ private int index; >+ private int direction; >+ >+ public void setColumnIndex(int val) { >+ if (index == val) { >+ direction = 1 - direction; >+ } else { >+ direction = 0; >+ index = val; >+ } >+ } >+ >+ @Override >+ public int compare(Viewer viewer, Object e1, Object e2) { >+ PMSymbolMatch s1 = (PMSymbolMatch) e1; >+ PMSymbolMatch s2 = (PMSymbolMatch) e2; >+ int ret = 0; >+ switch (index) { >+ // function column >+ case 0: >+ ret = s1.getName().compareTo(s2.getName()); >+ break; >+ // new column >+ case 1: >+ ret = s1.compareSymbol(s2, /* compare fresh */true); >+ break; >+ // old column >+ case 2: >+ ret = s1.compareSymbol(s2, /* compare stale */false); >+ break; >+ // result column >+ case 3: >+ ret = s1.compareResult(s2); >+ break; >+ // event column >+ case 4: >+ ret = s1.getEvent().compareTo(s2.getEvent()); >+ break; >+ case 5: >+ break; >+ default: >+ ret = 0; >+ } >+ if (direction == 1) { >+ return -ret; >+ } >+ return ret; >+ } >+ >+} >\ No newline at end of file >-- >1.7.7.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
jjohnstn
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 371285
:
217768
|
217769
|
217770
|
217771
|
217772
|
217773
| 217774 |
217775
|
217776
|
217779
|
218026
|
218056