From 43b634904b129e823de4d4331156a201cea0ddca Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Fri, 18 Mar 2016 10:07:18 +0300 Subject: [PATCH] inspection tool window: select&expand first node + register shortcuts in swing thread --- .../codeInspection/ui/InspectionResultsView.java | 15 +++++++-------- .../codeInspection/ui/InspectionTreeUpdater.java | 5 +++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 99ae26f5d7ef..7dce42438570 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -145,12 +145,9 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } }); add(mySplitter, BorderLayout.CENTER); - createActionsToolbar(); - TreeUtil.selectFirstNode(myTree); } - private void initTreeListeners() { myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override @@ -571,12 +568,14 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } private void registerActionShortcuts(@NotNull InspectionToolPresentation presentation) { - final QuickFixAction[] fixes = presentation.getQuickFixes(RefEntity.EMPTY_ELEMENTS_ARRAY, null); - if (fixes != null) { - for (QuickFixAction fix : fixes) { - fix.registerCustomShortcutSet(fix.getShortcutSet(), this); + ApplicationManager.getApplication().invokeLater(() -> { + final QuickFixAction[] fixes = presentation.getQuickFixes(RefEntity.EMPTY_ELEMENTS_ARRAY, null); + if (fixes != null) { + for (QuickFixAction fix : fixes) { + fix.registerCustomShortcutSet(fix.getShortcutSet(), this); + } } - } + }); } @Nullable diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeUpdater.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeUpdater.java index 3eaac402798a..233a5b5e5d14 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeUpdater.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeUpdater.java @@ -16,6 +16,7 @@ package com.intellij.codeInspection.ui; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.update.MergingUpdateQueue; import com.intellij.util.ui.update.Update; @@ -60,6 +61,10 @@ public class InspectionTreeUpdater { } } finally { tree.setQueueUpdate(false); + if (tree.getSelectionModel().getMinSelectionRow() == -1) { + TreeUtil.selectFirstNode(tree); + tree.expandRow(0); + } } }