changeset 1731:a3e53d1737f9

Show deadlock raw text and visualization side-by-side Display them side by side to avoid confusion when the visualization is empty but the text claims that there is no deadlock information. It also allows user to see more information at once. PR 2590 Reviewed-by: jerboaa, neugens Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2015-August/015059.html Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2015-August/015409.html
author Omair Majid <omajid@redhat.com>
date Tue, 11 Aug 2015 17:42:58 -0400
parents 208f06d630d4
children 28d1691c7203
files thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/locale/LocaleResources.java thread/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingVmDeadLockView.java
diffstat 3 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/locale/LocaleResources.java	Tue Aug 11 17:41:16 2015 -0400
+++ b/thread/client-common/src/main/java/com/redhat/thermostat/thread/client/common/locale/LocaleResources.java	Tue Aug 11 17:42:58 2015 -0400
@@ -72,8 +72,6 @@
     THREAD_DETAILS_EMTPY,
 
     CHECK_FOR_DEADLOCKS,
-    DEADLOCK_GRAPHICAL_TAB_TITLE,
-    DEADLOCK_RAW_TAB_TITLE,
     DEADLOCK_WAITING_ON,
     DEADLOCK_THREAD_NAME,
     DEADLOCK_THREAD_TOOLTIP,
--- a/thread/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties	Tue Aug 11 17:41:16 2015 -0400
+++ b/thread/client-common/src/main/resources/com/redhat/thermostat/thread/client/common/locale/strings.properties	Tue Aug 11 17:42:58 2015 -0400
@@ -31,8 +31,6 @@
 THREAD_DETAILS_EMTPY = Please double-click on a thread in the thread table
 
 CHECK_FOR_DEADLOCKS = Check
-DEADLOCK_GRAPHICAL_TAB_TITLE = Visualization
-DEADLOCK_RAW_TAB_TITLE = Raw Data
 DEADLOCK_WAITING_ON = Waiting on
 DEADLOCK_THREAD_NAME = Thread {0} ({1})
 DEADLOCK_THREAD_TOOLTIP = <html> Waiting on lock {0} at <br/>{1}</html>
--- a/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingVmDeadLockView.java	Tue Aug 11 17:41:16 2015 -0400
+++ b/thread/client-swing/src/main/java/com/redhat/thermostat/thread/client/swing/impl/SwingVmDeadLockView.java	Tue Aug 11 17:42:58 2015 -0400
@@ -52,7 +52,7 @@
 import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
-import javax.swing.JTabbedPane;
+import javax.swing.JSplitPane;
 import javax.swing.JTextArea;
 import javax.swing.SwingUtilities;
 
@@ -77,15 +77,20 @@
 
     private static final Translate<LocaleResources> translate = LocaleResources.createLocalizer();
 
-    private static final int TAB_VISUALIZATION_INDEX = 0;
-    private static final int TAB_RAW_INDEX = 1;
-
     private final JPanel actualComponent = new JPanel();
 
-    private final JTabbedPane tabbedPane = new JTabbedPane();
+    private final JSplitPane deadlockTextAndVisualization = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+
     private final JPanel graphical = new JPanel();
     private final JTextArea description = new JTextArea();
 
+    /**
+     * Whether to set the divider's location. Do this only once to set a sane
+     * initial value but don't change anything after and allow the user to tweak
+     * this as appropriate.
+     */
+    private boolean dividerLocationSet = false;
+
     public SwingVmDeadLockView() {
         actualComponent.setLayout(new GridBagLayout());
 
@@ -108,18 +113,16 @@
         c.weightx = 1;
         c.weighty = 1;
 
-        actualComponent.add(tabbedPane, c);
-
         description.setEditable(false);
 
         JScrollPane scrollPane = new ThermostatScrollPane(description);
 
         graphical.setLayout(new BorderLayout());
 
-        final String GRAPHICAL_TAB_TITLE = translate.localize(LocaleResources.DEADLOCK_GRAPHICAL_TAB_TITLE).getContents();
-        tabbedPane.insertTab(GRAPHICAL_TAB_TITLE, null, graphical, null, TAB_VISUALIZATION_INDEX);
-        final String RAW_TAB_TITLE = translate.localize(LocaleResources.DEADLOCK_RAW_TAB_TITLE).getContents();
-        tabbedPane.insertTab(RAW_TAB_TITLE, null, scrollPane, null, TAB_RAW_INDEX);
+        deadlockTextAndVisualization.setLeftComponent(scrollPane);
+        deadlockTextAndVisualization.setRightComponent(graphical);
+
+        actualComponent.add(deadlockTextAndVisualization, c);
 
         new ComponentVisibilityNotifier().initialize(actualComponent, notifier);
     }
@@ -132,11 +135,21 @@
 
                 graphical.removeAll();
 
+                if (!dividerLocationSet) {
+                    // 0.7 is chosen empirically to show a bit more of the text than the gui
+                    deadlockTextAndVisualization.setDividerLocation(0.7);
+                    deadlockTextAndVisualization.revalidate();
+                    dividerLocationSet = true;
+                }
+
                 if (parsed != null) {
                     FontMetrics metrics = graphical.getGraphics().getFontMetrics();
                     graphical.add(createGraph(parsed, metrics), BorderLayout.CENTER);
                 }
 
+                graphical.revalidate();
+                graphical.repaint();
+
                 description.setText(rawText);
             }
         });