From 45ca5aca753f93f9b19dc5f1a80f0ae14a914829 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Tue, 26 Apr 2016 10:19:22 +0300 Subject: [PATCH] inspection tool window: do not show huge right panel when fix is applying --- .../codeInspection/ex/QuickFixAction.java | 5 +- .../ui/InspectionResultsView.java | 82 +++++++++++-------- .../ui/InspectionResultsViewUtil.java | 8 ++ 3 files changed, 57 insertions(+), 38 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java index 91a8b406b559..d463e718d57b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java @@ -114,15 +114,14 @@ public class QuickFixAction extends AnAction implements CustomComponentAction { final InspectionTree tree = view.getTree(); final CommonProblemDescriptor[] descriptors; try { - view.setUpdating(true); - view.syncRightPanel(); + view.setApplyingFix(true); if (isProblemDescriptorsAcceptable() && (descriptors = tree.getSelectedDescriptors(true)).length > 0) { doApplyFix(view.getProject(), descriptors, tree.getContext()); } else { doApplyFix(getSelectedElements(e), view); } } finally { - view.setUpdating(false); + view.setApplyingFix(false); } } 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 b45c3689d94a..f42c5a4056f5 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -114,6 +114,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren private boolean myRerun; private volatile boolean myDisposed; private int myUpdatingRequestors; //accessed only in edt + private boolean myApplyingFix = false; //accessed only in edt @NotNull private final InspectionRVContentProvider myProvider; @@ -375,6 +376,11 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren return null; } + public void setApplyingFix(boolean applyingFix) { + myApplyingFix = applyingFix; + syncRightPanel(); + } + public void openRightPanelIfNeed() { if (mySplitter.getSecondComponent() == null) { syncRightPanel(); @@ -387,42 +393,48 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren Disposer.dispose(myLoadingProgressPreview); myLoadingProgressPreview = null; } - if (myTree.getSelectionModel().getSelectionCount() != 1) { - if (myTree.getSelectedToolWrapper() == null) { - mySplitter.setSecondComponent(InspectionResultsViewUtil.getNothingToShowTextLabel()); - } - else { - showInRightPanel(myTree.getCommonSelectedElement()); - } - } - else { - TreePath pathSelected = myTree.getSelectionModel().getLeadSelectionPath(); - if (pathSelected != null) { - final InspectionTreeNode node = (InspectionTreeNode)pathSelected.getLastPathComponent(); - if (node instanceof ProblemDescriptionNode) { - final ProblemDescriptionNode problemNode = (ProblemDescriptionNode)node; - showInRightPanel(problemNode.getElement()); - } - else if (node instanceof InspectionPackageNode || - node instanceof InspectionModuleNode || - node instanceof RefElementNode) { - showInRightPanel(node.getContainingFileLocalEntity()); - } - else if (node instanceof InspectionNode) { - if (myGlobalInspectionContext.getPresentation(((InspectionNode)node).getToolWrapper()).isDummy()) { - mySplitter.setSecondComponent(InspectionResultsViewUtil.getNothingToShowTextLabel()); - } - else { - showInRightPanel(null); - } - } - else if (node instanceof InspectionRootNode || node instanceof InspectionGroupNode || node instanceof InspectionSeverityGroupNode) { - final InspectionViewNavigationPanel panel = new InspectionViewNavigationPanel(node, myTree); - myLoadingProgressPreview = panel; - mySplitter.setSecondComponent(panel); + if (myApplyingFix) { + final InspectionToolWrapper wrapper = myTree.getSelectedToolWrapper(); + LOG.assertTrue(wrapper != null); + mySplitter.setSecondComponent(InspectionResultsViewUtil.getApplyingFixLabel(wrapper)); + } else { + if (myTree.getSelectionModel().getSelectionCount() != 1) { + if (myTree.getSelectedToolWrapper() == null) { + mySplitter.setSecondComponent(InspectionResultsViewUtil.getNothingToShowTextLabel()); } else { - LOG.error("Unexpected node: " + node.getClass()); + showInRightPanel(myTree.getCommonSelectedElement()); + } + } + else { + TreePath pathSelected = myTree.getSelectionModel().getLeadSelectionPath(); + if (pathSelected != null) { + final InspectionTreeNode node = (InspectionTreeNode)pathSelected.getLastPathComponent(); + if (node instanceof ProblemDescriptionNode) { + final ProblemDescriptionNode problemNode = (ProblemDescriptionNode)node; + showInRightPanel(problemNode.getElement()); + } + else if (node instanceof InspectionPackageNode || + node instanceof InspectionModuleNode || + node instanceof RefElementNode) { + showInRightPanel(node.getContainingFileLocalEntity()); + } + else if (node instanceof InspectionNode) { + if (myGlobalInspectionContext.getPresentation(((InspectionNode)node).getToolWrapper()).isDummy()) { + mySplitter.setSecondComponent(InspectionResultsViewUtil.getNothingToShowTextLabel()); + } + else { + showInRightPanel(null); + } + } + else if (node instanceof InspectionRootNode || node instanceof InspectionGroupNode || node instanceof InspectionSeverityGroupNode) { + final InspectionViewNavigationPanel panel = new InspectionViewNavigationPanel(node, myTree); + myLoadingProgressPreview = panel; + mySplitter.setSecondComponent(panel); + } + else { + LOG.error("Unexpected node: " + node.getClass()); + } } } } @@ -506,7 +518,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren }); } else { - myPreviewEditor = (EditorEx)EditorFactory.getInstance().createEditor( document, myProject, file.getVirtualFile(), true); + myPreviewEditor = (EditorEx)EditorFactory.getInstance().createEditor(document, myProject, file.getVirtualFile(), true); DiffUtil.setFoldingModelSupport(myPreviewEditor); final EditorSettings settings = myPreviewEditor.getSettings(); settings.setLineNumbersShown(false); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java index 7e0292711cf5..7ac852d50401 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsViewUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.codeInspection.ui; +import com.intellij.codeInspection.ex.InspectionToolWrapper; import com.intellij.codeInspection.reference.RefElement; import com.intellij.codeInspection.reference.RefEntity; import com.intellij.openapi.editor.Editor; @@ -53,11 +54,18 @@ public class InspectionResultsViewUtil { return createLabelForText(InspectionViewNavigationPanel.getTitleText(false, false)); } + @NotNull static JComponent getInvalidEntityLabel(@NotNull RefEntity entity) { final String name = entity.getName(); return createLabelForText("\'" + name + "\' is no longer valid."); } + @NotNull + static JComponent getApplyingFixLabel(@NotNull InspectionToolWrapper wrapper) { + return createLabelForText("Applying quick fix for \'" + wrapper.getDisplayName() + "\'..."); + } + + @NotNull private static JLabel createLabelForText(String text) { final JLabel multipleSelectionLabel = new JBLabel(text); multipleSelectionLabel.setVerticalAlignment(SwingConstants.TOP);