inspection tool window: select&expand first node + register shortcuts in swing thread

This commit is contained in:
Dmitry Batkovich
2016-03-18 10:07:18 +03:00
parent 43a8528736
commit 43b634904b
2 changed files with 12 additions and 8 deletions
@@ -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
@@ -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);
}
}
}