changeset 1133:265c548475e7

Add control to take heap dumps from toolbar reviewed-by: vanaltj review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-June/006943.html
author Mario Torre <neugens.limasoftware@gmail.com>
date Wed, 05 Jun 2013 21:32:09 +0200
parents 50b5ae6a4a81
children 3d102042f1df
files vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapIconResources.java vm-heap-analysis/client-core/src/main/resources/com/redhat/thermostat/vm/heap/analysis/client/core/list_dumps.png vm-heap-analysis/client-core/src/main/resources/com/redhat/thermostat/vm/heap/analysis/client/core/take_dump.png vm-heap-analysis/client-swing/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapSwingView.java vm-heap-analysis/client-swing/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapSwingViewTest.java
diffstat 5 files changed, 41 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapIconResources.java	Wed Jun 05 20:26:45 2013 +0200
+++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapIconResources.java	Wed Jun 05 21:32:09 2013 +0200
@@ -47,7 +47,7 @@
 public class HeapIconResources {
 
     public static final String PIN_MASK = "com/redhat/thermostat/vm/heap/analysis/client/core/pin_mask.png";
-    public static final String LIST_DUMPS = "com/redhat/thermostat/vm/heap/analysis/client/core/list_dumps.png";
+    public static final String TRIGGER_HEAP_DUMP = "com/redhat/thermostat/vm/heap/analysis/client/core/take_dump.png";
 
     private static Map<String, IconDescriptor> icons = new HashMap<>();
     
Binary file vm-heap-analysis/client-core/src/main/resources/com/redhat/thermostat/vm/heap/analysis/client/core/list_dumps.png has changed
Binary file vm-heap-analysis/client-core/src/main/resources/com/redhat/thermostat/vm/heap/analysis/client/core/take_dump.png has changed
--- a/vm-heap-analysis/client-swing/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapSwingView.java	Wed Jun 05 20:26:45 2013 +0200
+++ b/vm-heap-analysis/client-swing/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapSwingView.java	Wed Jun 05 21:32:09 2013 +0200
@@ -52,6 +52,7 @@
 import com.redhat.thermostat.client.swing.ComponentVisibleListener;
 import com.redhat.thermostat.client.swing.IconResource;
 import com.redhat.thermostat.client.swing.SwingComponent;
+import com.redhat.thermostat.client.swing.components.ActionButton;
 import com.redhat.thermostat.client.swing.components.ActionToggleButton;
 import com.redhat.thermostat.client.swing.components.HeaderPanel;
 import com.redhat.thermostat.client.swing.components.Icon;
@@ -60,6 +61,7 @@
 import com.redhat.thermostat.shared.locale.Translate;
 import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumpListView;
 import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumpListView.ListAction;
+import com.redhat.thermostat.vm.heap.analysis.client.core.HeapIconResources;
 import com.redhat.thermostat.vm.heap.analysis.client.core.HeapView;
 import com.redhat.thermostat.vm.heap.analysis.client.core.chart.OverviewChart;
 import com.redhat.thermostat.vm.heap.analysis.client.locale.LocaleResources;
@@ -82,6 +84,7 @@
     private OverlayPanel overlay;
     
     private ActionToggleButton showHeapListButton;
+    private ActionButton takeDumpIconButton;
     
     private JPanel stack;
     
@@ -123,8 +126,17 @@
         overview.setContent(stack);
         overview.addHierarchyListener(new ViewVisibleListener());
 
-        // TODO
-        //Icon takeDumpIcon = new Icon(HeapIconResources.getIcon(HeapIconResources.LIST_DUMPS));
+        Icon takeDumpIcon = new Icon(HeapIconResources.getIcon(HeapIconResources.TRIGGER_HEAP_DUMP));
+        takeDumpIconButton = new ActionButton(takeDumpIcon, translator.localize(LocaleResources.TRIGGER_HEAP_DUMP));
+        takeDumpIconButton.setToolTipText(translator.localize(LocaleResources.TRIGGER_HEAP_DUMP).getContents());
+        takeDumpIconButton.setName("TRIGGER_HEAP_DUMP");
+        takeDumpIconButton.getToolbarButton().addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                heapDumperNotifier.fireAction(HeapDumperAction.DUMP_REQUESTED);
+            }
+        });
+        overview.addToolBarButton(takeDumpIconButton);
         
         Icon listDumpIcon = IconResource.HISTORY.getIcon();
         showHeapListButton = new ActionToggleButton(listDumpIcon, translator.localize(LocaleResources.LIST_DUMPS_ACTION).getContents());
--- a/vm-heap-analysis/client-swing/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapSwingViewTest.java	Wed Jun 05 20:26:45 2013 +0200
+++ b/vm-heap-analysis/client-swing/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/swing/internal/HeapSwingViewTest.java	Wed Jun 05 21:32:09 2013 +0200
@@ -51,6 +51,7 @@
 import org.fest.swing.edt.GuiTask;
 import org.fest.swing.fixture.Containers;
 import org.fest.swing.fixture.FrameFixture;
+import org.fest.swing.fixture.JButtonFixture;
 import org.fest.swing.fixture.JLabelFixture;
 import org.fest.swing.fixture.JPanelFixture;
 import org.fest.swing.fixture.JPopupMenuFixture;
@@ -234,7 +235,9 @@
         view.addDumperListener(new ActionListener<HeapView.HeapDumperAction>() {
             @Override
             public void actionPerformed(ActionEvent<HeapDumperAction> actionEvent) {
-                result[0] = true;
+                if (actionEvent.getActionId() == HeapDumperAction.REQUEST_DISPLAY_DUMP_LIST) {
+                    result[0] = true;
+                }
             }
         });
         
@@ -245,5 +248,27 @@
 
         assertTrue(result[0]);
     }
+    
+    @GUITest
+    @Test
+    public void testHeapDumperActionFired2() {
+        
+        final boolean [] result = new boolean[1];
+        view.addDumperListener(new ActionListener<HeapView.HeapDumperAction>() {
+            @Override
+            public void actionPerformed(ActionEvent<HeapDumperAction> actionEvent) {
+                if (actionEvent.getActionId() == HeapDumperAction.DUMP_REQUESTED) {
+                    result[0] = true;
+                }
+            }
+        });
+        
+        frame.show();
+        
+        JButtonFixture listDupms = frame.button("TRIGGER_HEAP_DUMP");
+        listDupms.click();
+
+        assertTrue(result[0]);
+    }
 }