debugger: scroll for images popup
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Fri, 5 Dec 2014 13:31:40 +0000 (16:31 +0300)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Sat, 6 Dec 2014 12:26:04 +0000 (15:26 +0300)
utility method for UI debugging

java/debugger/impl/src/com/intellij/debugger/settings/ImageObjectRenderer.java
platform/util/src/com/intellij/util/ui/UIUtil.java

index fa332a34779446140bfcba73ad4ea52ae175f84b..bb43a98f8e793494db12426a4565f787a9303789 100644 (file)
@@ -26,6 +26,7 @@ import com.intellij.debugger.ui.tree.render.CompoundReferenceRenderer;
 import com.intellij.debugger.ui.tree.render.DescriptorLabelListener;
 import com.intellij.rt.debugger.ImageSerializer;
 import com.intellij.ui.components.JBLabel;
+import com.intellij.ui.components.JBScrollPane;
 import com.intellij.xdebugger.frame.XFullValueEvaluator;
 import com.sun.jdi.*;
 import org.jetbrains.annotations.NotNull;
@@ -59,7 +60,7 @@ class ImageObjectRenderer extends CompoundReferenceRenderer implements FullValue
     return new CustomPopupFullValueEvaluator(" (Show image)", evaluationContext) {
       @Override
       protected JComponent createComponent() {
-        return new JBLabel(getIcon(myEvaluationContext, valueDescriptor.getValue(), "imageToBytes"));
+        return new JBScrollPane(new JBLabel(getIcon(myEvaluationContext, valueDescriptor.getValue(), "imageToBytes")));
       }
     };
   }
index b971116fa1bf98f7c432a573402a8faf15dda797..a7ce99ab1c5fa514de78921c2dd20ae7087180e1 100644 (file)
@@ -3236,4 +3236,13 @@ public class UIUtil {
   public static Window getWindow(Component component) {
     return component instanceof Window ? (Window)component : SwingUtilities.getWindowAncestor(component);
   }
+
+  public static Image getDebugImage(Component component) {
+    BufferedImage image = createImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_ARGB);
+    Graphics2D graphics = image.createGraphics();
+    graphics.setColor(Color.RED);
+    graphics.fillRect(0, 0, component.getWidth() + 1, component.getHeight() + 1);
+    component.paint(graphics);
+    return image;
+  }
 }