diff options
author | Jens Ole Lauridsen <jlauridsen@google.com> | 2022-01-31 13:32:04 -0800 |
---|---|---|
committer | Jens Ole Lauridsen <jlauridsen@google.com> | 2022-02-01 02:59:38 +0000 |
commit | ea1d3538c27e41b8f8053c2676ca9779026721bf (patch) | |
tree | a9b8fa4f47bd8b29cc9d80ed9fee4c312f235735 /layout-inspector/src | |
parent | 580dc6a8be16d6630dd978d4e8dc81476398db0e (diff) | |
download | idea-ea1d3538c27e41b8f8053c2676ca9779026721bf.tar.gz |
Fix draw problem in certain inspector fields
There is a JDK problem (reference: JDK-4194023) where selected text
in a JTextField will be painted wrong if antialiasing is turned on.
The Layout Inspector has antialiasing turned on and if the user
attempts to select text in the value of e.g. an id value of a View
then the painting becomes garbled.
Fix this by turning antialiasing OFF when painting CommonTextField
which is the JTextField used in the property panel.
Also in this change: Allow text to be selected in a CommonTextField
by turning caret.isSelectionVisible ON while painting. Normally
caret.isSelectionVisible is controlled by the field having focus.
The layout inspector we have read only values using this field type.
Allow the property table transfer handler to export just the selected
text to the clipboard. If there are no text selection we continue to
export both the property name and the property value.
Bug: 201553210
Test: Added unit test for the export of a TextField with a selection.
Change-Id: Ie7be1d621367b04a6cac8283b6a0d7ae13709e93
Diffstat (limited to 'layout-inspector/src')
2 files changed, 3 insertions, 5 deletions
diff --git a/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/BannerActions.kt b/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/BannerActions.kt index 2a0c87a4f40..321a28d7fe3 100644 --- a/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/BannerActions.kt +++ b/layout-inspector/src/com/android/tools/idea/layoutinspector/pipeline/appinspection/BannerActions.kt @@ -139,9 +139,7 @@ private fun <T : Component> Component.firstComponentOfClass(cls: Class<T>): T? { return cls.cast(this) } if (this is Container) { - components.asSequence().forEach { component -> - component.firstComponentOfClass(cls)?.let { return it } - } + return components.asSequence().mapNotNull { it.firstComponentOfClass(cls) }.firstOrNull() } return null } diff --git a/layout-inspector/src/com/android/tools/idea/layoutinspector/ui/ResolutionElementEditor.kt b/layout-inspector/src/com/android/tools/idea/layoutinspector/ui/ResolutionElementEditor.kt index 22228f4a4b5..2f419012604 100644 --- a/layout-inspector/src/com/android/tools/idea/layoutinspector/ui/ResolutionElementEditor.kt +++ b/layout-inspector/src/com/android/tools/idea/layoutinspector/ui/ResolutionElementEditor.kt @@ -15,7 +15,6 @@ */ package com.android.tools.idea.layoutinspector.ui -import com.android.tools.adtui.model.stdui.ValueChangedListener import com.android.tools.adtui.stdui.KeyStrokes import com.android.tools.adtui.stdui.registerActionKey import com.android.tools.idea.layoutinspector.model.ResolutionStackModel @@ -61,13 +60,14 @@ class ResolutionElementEditor( private val linkPanel = JPanel() init { + isOpaque = false background = UIUtil.TRANSPARENT_COLOR add(editor, BorderLayout.CENTER) add(linkPanel, BorderLayout.SOUTH) linkPanel.layout = BoxLayout(linkPanel, BoxLayout.Y_AXIS) linkPanel.isVisible = false linkPanel.background = UIUtil.TRANSPARENT_COLOR - editorModel.addListener(ValueChangedListener { updateFromModel() }) + editorModel.addListener { updateFromModel() } editor.addMouseListener(object : MouseAdapter() { override fun mouseClicked(event: MouseEvent) { if (!event.isConsumed && event.clickCount > 1) { |