diff --git a/src/main/java/org/infernus/idea/checkstyle/actions/ScanModule.java b/src/main/java/org/infernus/idea/checkstyle/actions/ScanModule.java index 80f32cca..7682a8e3 100644 --- a/src/main/java/org/infernus/idea/checkstyle/actions/ScanModule.java +++ b/src/main/java/org/infernus/idea/checkstyle/actions/ScanModule.java @@ -12,6 +12,7 @@ import com.intellij.openapi.wm.ToolWindow; import com.intellij.util.ThrowableRunnable; import org.infernus.idea.checkstyle.model.ScanScope; +import org.infernus.idea.checkstyle.toolwindow.CheckStyleToolWindowPanel; import org.jetbrains.annotations.NotNull; import static org.infernus.idea.checkstyle.actions.ToolWindowAccess.toolWindow; @@ -27,6 +28,7 @@ public final void actionPerformed(final @NotNull AnActionEvent event) { project(event).ifPresent(project -> { try { final ToolWindow toolWindow = toolWindow(project); + CheckStyleToolWindowPanel checkStyleToolWindowPanel = CheckStyleToolWindowPanel.panelFor(project); final VirtualFile[] selectedFiles = FileEditorManager.getInstance(project).getSelectedFiles(); @@ -38,7 +40,9 @@ public final void actionPerformed(final @NotNull AnActionEvent event) { final Module module = ModuleUtil.findModuleForFile( selectedFiles[0], project); if (module == null) { - setProgressText(toolWindow, "plugin.status.in-progress.no-module"); + if (checkStyleToolWindowPanel != null) { + checkStyleToolWindowPanel.displayWarningResult("plugin.status.in-progress.no-module"); + } return; } @@ -46,8 +50,6 @@ public final void actionPerformed(final @NotNull AnActionEvent event) { toolWindow.activate(() -> { try { - setProgressText(toolWindow, "plugin.status.in-progress.module"); - ThrowableRunnable scanAction = null; if (scope == ScanScope.Everything) { scanAction = new ScanAllFilesInModuleTask(module, getSelectedOverride(toolWindow)); @@ -57,9 +59,12 @@ public final void actionPerformed(final @NotNull AnActionEvent event) { if (moduleSourceRoots.length > 0) { scanAction = new ScanAllGivenFilesTask(project, moduleSourceRoots, getSelectedOverride(toolWindow)); + } else if (checkStyleToolWindowPanel != null) { + checkStyleToolWindowPanel.displayWarningResult("plugin.status.in-progress.no-module-source-roots"); } } if (scanAction != null) { + setProgressText(toolWindow, "plugin.status.in-progress.module"); ReadAction.run(scanAction); } } catch (Throwable e) { diff --git a/src/main/resources/org/infernus/idea/checkstyle/CheckStyleBundle.properties b/src/main/resources/org/infernus/idea/checkstyle/CheckStyleBundle.properties index c033fb8b..8bbd41bf 100644 --- a/src/main/resources/org/infernus/idea/checkstyle/CheckStyleBundle.properties +++ b/src/main/resources/org/infernus/idea/checkstyle/CheckStyleBundle.properties @@ -27,6 +27,7 @@ plugin.status.in-progress.module=Scanning current module... plugin.status.in-progress.no-file=No file is open for editing plugin.status.in-progress.no-modified-files=There are no modified files in the current changelist plugin.status.in-progress.no-module=The current file being edited does not belong to a module +plugin.status.in-progress.no-module-source-roots=The current module has no source roots plugin.status.in-progress.project=Scanning current project... plugin.status.in-progress.out-of-scope=Scan was skipped as file is out of scope plugin.status.aborted=Check was aborted