changeset 1579:783d3874f9ff

Fix profile data table sorting Reviewed-by: neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-November/011817.html
author Omair Majid <omajid@redhat.com>
date Fri, 28 Nov 2014 16:39:08 -0500
parents 43864ae00dbf
children 3c0f219f340a
files vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileView.java
diffstat 1 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileView.java	Fri Nov 28 16:37:02 2014 -0500
+++ b/vm-profiler/client-swing/src/main/java/com/redhat/thermostat/vm/profiler/client/swing/internal/SwingVmProfileView.java	Fri Nov 28 16:39:08 2014 -0500
@@ -40,6 +40,7 @@
 import java.awt.Component;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Vector;
@@ -184,7 +185,21 @@
         columnNames.add(translator.localize(LocaleResources.PROFILER_RESULTS_METHOD).getContents());
         columnNames.add(translator.localize(LocaleResources.PROFILER_RESULTS_PERCENTAGE_TIME).getContents());
         columnNames.add(translator.localize(LocaleResources.PROFILER_RESULTS_TIME, "ms").getContents());
-        tableModel = new DefaultTableModel(columnNames, 0);
+        tableModel = new DefaultTableModel(columnNames, 0) {
+            @Override
+            public java.lang.Class<?> getColumnClass(int columnIndex) {
+                switch (columnIndex) {
+                case 0:
+                    return String.class;
+                case 1:
+                    return Double.class;
+                case 2:
+                    return Long.class;
+                default:
+                    throw new AssertionError("Unknown column index");
+                }
+            }
+        };
 
         JTable profileTable = new ThermostatTable(tableModel);
         profileTable.setAutoCreateRowSorter(true);
@@ -306,6 +321,15 @@
                 window.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                 window.pack();
                 window.setVisible(true);
+
+                List<MethodInfo> data = new ArrayList<>();
+                data.add(new MethodInfo("foo", 1000, 1.0));
+                data.add(new MethodInfo("foo2", 10001, 100001));
+                data.add(new MethodInfo("bar", 200, 3.5));
+                data.add(new MethodInfo("baz", 100000, 9.8));
+                data.add(new MethodInfo("spam", 5000, 0.99999));
+                ProfilingResult results = new ProfilingResult(data);
+                view.setProfilingDetailData(results);
             }
         });
     }