diff --git a/.idea/misc.xml b/.idea/misc.xml index f91b516..24fff94 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,3 +1,4 @@ + diff --git a/CHANGELOG.md b/CHANGELOG.md index cd17397..77c4a1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ ## [Unreleased] +## [0.5.7] +### Changed +- Added feature to enable and disable all problems with a keybind (thanks to khopland) +- Added feature to hover and click in a problem to get the fix context window (thanks to khopland) + ## [0.5.6] ### Changed - Added 2 settings options to disable HTML stripping and XML unescaping diff --git a/README.md b/README.md index d2f8704..1c4fad9 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@

InlineProblems

-Plugin to show problems like errors and warnings inside the text editor (inline) for IDEs based on the IntelliJ Platform, inspired by Error Lens and InlineError +Plugin to show problems like errors and warnings inside the text editor (inline) for IDEs based on the IntelliJ Platform, inspired by Error Lens and InlineError. + +You can turn this plugin on and off with the keyboard shortcut `alt+u`, additional shortcuts can be configured in the settings.

diff --git a/gradle.properties b/gradle.properties index 9d215b8..4eddd9b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ pluginGroup = org.OverEngineer pluginName = InlineProblems pluginRepositoryUrl = https://github.com/OverEngineer/InlineProblems # SemVer format -> https://semver.org -pluginVersion = 0.5.6 +pluginVersion = 0.5.7 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 212.5 diff --git a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java index 004cec8..36a3173 100644 --- a/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java +++ b/src/main/java/org/overengineer/inlineproblems/DocumentMarkupModelScanner.java @@ -84,24 +84,24 @@ public void scanForProblemsManually() { if (projectManager != null) { List problems = new ArrayList<>(); + if (settingsState.isEnableInlineProblem()) + for (var project : projectManager.getOpenProjects()) { + if (!project.isInitialized() || project.isDisposed()) + continue; - for (var project : projectManager.getOpenProjects()) { - if (!project.isInitialized() || project.isDisposed()) - continue; + FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); + for (var editor : fileEditorManager.getAllEditors()) { - FileEditorManager fileEditorManager = FileEditorManager.getInstance(project); - for (var editor : fileEditorManager.getAllEditors()) { + if (editor.getFile() == null || FileNameUtil.ignoreFile(editor.getFile().getName())) { + continue; + } - if (editor.getFile() == null || FileNameUtil.ignoreFile(editor.getFile().getName())) { - continue; - } - - if (editor instanceof TextEditor) { - var textEditor = (TextEditor) editor; - problems.addAll(getProblemsInEditor(textEditor)); + if (editor instanceof TextEditor) { + var textEditor = (TextEditor) editor; + problems.addAll(getProblemsInEditor(textEditor)); + } } } - } problemManager.updateFromNewActiveProblems(problems); } @@ -119,7 +119,7 @@ public void scanForProblemsManuallyInTextEditor(TextEditor textEditor) { mergingUpdateQueue.queue(new Update("scan") { @Override public void run() { - List problems = getProblemsInEditor(textEditor); + List problems = settingsState.isEnableInlineProblem() ? List.of() : getProblemsInEditor(textEditor); problemManager.updateFromNewActiveProblemsForProjectAndFile( problems, @@ -158,8 +158,7 @@ private List getProblemsInEditor(TextEditor textEditor) { !highlightInfo.getDescription().isEmpty() && problemTextBeginningFilterList.stream() .noneMatch(f -> highlightInfo.getDescription().stripLeading().toLowerCase().startsWith(f.toLowerCase())) && - fileEndOffset >= highlightInfo.getStartOffset() - ; + fileEndOffset >= highlightInfo.getStartOffset(); } return false; diff --git a/src/main/java/org/overengineer/inlineproblems/InlineDrawer.java b/src/main/java/org/overengineer/inlineproblems/InlineDrawer.java index 5d9f920..b064f36 100644 --- a/src/main/java/org/overengineer/inlineproblems/InlineDrawer.java +++ b/src/main/java/org/overengineer/inlineproblems/InlineDrawer.java @@ -38,6 +38,7 @@ public void drawProblemLabel(InlineProblem problem) { problem, drawDetails.getTextColor(), drawDetails.getBackgroundColor(), + drawDetails.getTextColor().brighter(), settings ); diff --git a/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java b/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java index 6adb7ab..accaa18 100644 --- a/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java +++ b/src/main/java/org/overengineer/inlineproblems/InlineProblemLabel.java @@ -1,15 +1,26 @@ package org.overengineer.inlineproblems; +import com.intellij.codeInsight.hints.presentation.InputHandler; +import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler; import com.intellij.ide.ui.AntialiasingType; import com.intellij.ide.ui.UISettings; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.actionSystem.ex.ActionUtil; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorCustomElementRenderer; import com.intellij.openapi.editor.Inlay; +import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.impl.FontInfo; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiUtilBase; +import com.intellij.ui.paint.EffectPainter; import lombok.Getter; import lombok.Setter; +import org.jdesktop.swingx.action.ActionManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.overengineer.inlineproblems.entities.InlineProblem; @@ -17,18 +28,23 @@ import org.overengineer.inlineproblems.utils.FontUtil; import java.awt.*; +import java.awt.event.MouseEvent; import java.awt.font.FontRenderContext; @Getter -public class InlineProblemLabel implements EditorCustomElementRenderer { - +public class InlineProblemLabel implements EditorCustomElementRenderer, InputHandler { private final String text; private final Color textColor; private final Color backgroundColor; + private final Color hoverColor; private final boolean isDrawBox; private final boolean isRoundedCorners; private final boolean isFillBackground; + private boolean hovered; + private final boolean clickableContext; + private Inlay inlay; + private final int actualStartOffset; @Setter private boolean isBlockElement; @@ -47,10 +63,12 @@ public InlineProblemLabel( final InlineProblem problem, final Color textColor, final Color backgroundColor, + final Color hoverColor, final SettingsState settings ) { this.textColor = textColor; this.backgroundColor = backgroundColor; + this.hoverColor = hoverColor; this.isDrawBox = settings.isDrawBoxesAroundErrorLabels(); this.isRoundedCorners = settings.isRoundedCornerBoxes(); this.text = problem.getText(); @@ -59,6 +77,9 @@ public InlineProblemLabel( this.isUseEditorFont = settings.isUseEditorFont(); this.inlayFontSizeDelta = settings.getInlayFontSizeDelta(); + this.hovered = false; + this.actualStartOffset = problem.getActualStartffset(); + this.clickableContext = settings.isClickableContext(); } @Override @@ -80,7 +101,7 @@ public int calcWidthInPixels(@NotNull Editor editor) { @Override public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rectangle targetRegion, @NotNull TextAttributes textAttributes) { Editor editor = inlay.getEditor(); - + this.inlay = inlay; // These offsets are applied here and not in the calc functions itself because we use it to shrink the drawn stuff a little bit int width = calcWidthInPixels(inlay) + DRAW_BOX_WIDTH_OFFSET; int height = calcHeightInPixels(inlay) + DRAW_BOX_HEIGHT_OFFSET; @@ -92,7 +113,7 @@ public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rec // Apply delta on the boxes if (inlayFontSizeDelta != 0 && editorFontSize > inlayFontSizeDelta) { height -= inlayFontSizeDelta; - targetRegionY += (int)(inlayFontSizeDelta / 1.5); + targetRegionY += (int) (inlayFontSizeDelta / 1.5); } if (isDrawBox) { @@ -118,14 +139,13 @@ public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rec 5 ); } - } - else { - graphics.drawRect( - targetRegion.x, - targetRegionY, - width, - height - ); + } else { + graphics.drawRect( + targetRegion.x, + targetRegionY, + width, + height + ); if (isFillBackground) { graphics.fillRect( @@ -138,7 +158,7 @@ public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rec } } - graphics.setColor(textColor); + graphics.setColor(hovered ? hoverColor : textColor); graphics.setFont(FontUtil.getActiveFont(editor)); @@ -147,10 +167,63 @@ public void paint(@NotNull Inlay inlay, @NotNull Graphics graphics, @NotNull Rec targetRegion.x + DRAW_STRING_LINE_PLACEMENT_OFFSET_X, targetRegion.y + DRAW_STRING_LINE_PLACEMENT_OFFSET_Y + editor.getAscent() ); + if (hovered) + EffectPainter.LINE_UNDERSCORE.paint( + (Graphics2D) graphics, + targetRegion.x - DRAW_BOX_WIDTH_OFFSET, + targetRegion.y + editor.getAscent() , + width + (DRAW_BOX_WIDTH_OFFSET * 2), + editor.getAscent(), + FontUtil.getActiveFont(editor)); + } + + private void setHovered(boolean hovered) { + if (!this.clickableContext || this.hovered == hovered) { + return; + } + this.hovered = hovered; + if (inlay != null) + inlay.repaint(); } @Override public @Nullable GutterIconRenderer calcGutterIconRenderer(@NotNull Inlay inlay) { return EditorCustomElementRenderer.super.calcGutterIconRenderer(inlay); } + + @Override + public void mouseClicked(@NotNull MouseEvent mouseEvent, @NotNull Point point) { + if (!clickableContext) { + return; + } + if (mouseEvent.getButton() == MouseEvent.BUTTON1) { + mouseEvent.consume(); + + var editor = inlay.getEditor(); + editor.getCaretModel().moveToOffset(actualStartOffset); + editor.getScrollingModel().scrollToCaret(ScrollType.CENTER); + + var action = ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS); + if (action == null) { + Project project = editor.getProject(); + if (project == null) return; + PsiFile psiFileInEditor = PsiUtilBase.getPsiFileInEditor(editor, project); + if (psiFileInEditor == null) return; + new ShowIntentionActionsHandler().invoke(project, editor, psiFileInEditor, false); + } else { + ActionUtil.invokeAction((AnAction) action, editor.getComponent(), "EditorInlay", null, null); + } + } + } + + @Override + public void mouseMoved(@NotNull MouseEvent mouseEvent, @NotNull Point point) { + setHovered(true); + } + + @Override + public void mouseExited() { + setHovered(false); + } + } diff --git a/src/main/java/org/overengineer/inlineproblems/actions/EnableInlineProblemsAction.java b/src/main/java/org/overengineer/inlineproblems/actions/EnableInlineProblemsAction.java new file mode 100644 index 0000000..895ed82 --- /dev/null +++ b/src/main/java/org/overengineer/inlineproblems/actions/EnableInlineProblemsAction.java @@ -0,0 +1,30 @@ +package org.overengineer.inlineproblems.actions; + +import com.intellij.notification.NotificationType; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.application.ApplicationManager; +import org.jetbrains.annotations.NotNull; +import org.overengineer.inlineproblems.DocumentMarkupModelScanner; +import org.overengineer.inlineproblems.Notifier; +import org.overengineer.inlineproblems.bundles.SettingsBundle; +import org.overengineer.inlineproblems.settings.SettingsState; + +public class EnableInlineProblemsAction extends AnAction { + + @Override + public void actionPerformed(@NotNull AnActionEvent anActionEvent) { + SettingsState settingsState = SettingsState.getInstance(); + if (settingsState.isEnableInlineProblemsNotifications()) { + Notifier.notify(SettingsBundle.message( + settingsState.isEnableInlineProblem() + ? "settings.enableInlineProblem.disabled" + : "settings.enableInlineProblem.enabled"), + NotificationType.INFORMATION, + anActionEvent.getProject() + ); + } + settingsState.setEnableInlineProblem(!settingsState.isEnableInlineProblem()); + ApplicationManager.getApplication().invokeAndWait(DocumentMarkupModelScanner.getInstance()::scanForProblemsManually); + } +} diff --git a/src/main/java/org/overengineer/inlineproblems/actions/ShowErrorsAction.java b/src/main/java/org/overengineer/inlineproblems/actions/ShowErrorsAction.java new file mode 100644 index 0000000..fa4ecde --- /dev/null +++ b/src/main/java/org/overengineer/inlineproblems/actions/ShowErrorsAction.java @@ -0,0 +1,14 @@ +package org.overengineer.inlineproblems.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import org.jetbrains.annotations.NotNull; +import org.overengineer.inlineproblems.settings.SettingsState; + +public class ShowErrorsAction extends AnAction { + @Override + public void actionPerformed(@NotNull AnActionEvent anActionEvent) { + SettingsState settingsState = SettingsState.getInstance(); + settingsState.setShowErrors(!settingsState.isShowErrors()); + } +} diff --git a/src/main/java/org/overengineer/inlineproblems/actions/ShowInfosAction.java b/src/main/java/org/overengineer/inlineproblems/actions/ShowInfosAction.java new file mode 100644 index 0000000..b7271cb --- /dev/null +++ b/src/main/java/org/overengineer/inlineproblems/actions/ShowInfosAction.java @@ -0,0 +1,14 @@ +package org.overengineer.inlineproblems.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import org.jetbrains.annotations.NotNull; +import org.overengineer.inlineproblems.settings.SettingsState; + +public class ShowInfosAction extends AnAction { + @Override + public void actionPerformed(@NotNull AnActionEvent anActionEvent) { + SettingsState settingsState = SettingsState.getInstance(); + settingsState.setShowInfos(!settingsState.isShowInfos()); + } +} diff --git a/src/main/java/org/overengineer/inlineproblems/actions/ShowWarningsAction.java b/src/main/java/org/overengineer/inlineproblems/actions/ShowWarningsAction.java new file mode 100644 index 0000000..41ccf04 --- /dev/null +++ b/src/main/java/org/overengineer/inlineproblems/actions/ShowWarningsAction.java @@ -0,0 +1,14 @@ +package org.overengineer.inlineproblems.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import org.jetbrains.annotations.NotNull; +import org.overengineer.inlineproblems.settings.SettingsState; + +public class ShowWarningsAction extends AnAction { + @Override + public void actionPerformed(@NotNull AnActionEvent anActionEvent) { + SettingsState settingsState = SettingsState.getInstance(); + settingsState.setShowWarnings(!settingsState.isShowWarnings()); + } +} diff --git a/src/main/java/org/overengineer/inlineproblems/actions/ShowWeakWarningsAction.java b/src/main/java/org/overengineer/inlineproblems/actions/ShowWeakWarningsAction.java new file mode 100644 index 0000000..fa0e0ca --- /dev/null +++ b/src/main/java/org/overengineer/inlineproblems/actions/ShowWeakWarningsAction.java @@ -0,0 +1,14 @@ +package org.overengineer.inlineproblems.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import org.jetbrains.annotations.NotNull; +import org.overengineer.inlineproblems.settings.SettingsState; + +public class ShowWeakWarningsAction extends AnAction { + @Override + public void actionPerformed(@NotNull AnActionEvent anActionEvent) { + SettingsState settingsState = SettingsState.getInstance(); + settingsState.setShowWeakWarnings(!settingsState.isShowWeakWarnings()); + } +} diff --git a/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java b/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java index c377223..b780efd 100644 --- a/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java +++ b/src/main/java/org/overengineer/inlineproblems/entities/InlineProblem.java @@ -30,6 +30,7 @@ public class InlineProblem { private DrawDetails drawDetails; private int actualEndOffset; + private int actualStartffset; private boolean isBlockElement = false; @@ -68,6 +69,7 @@ public InlineProblem( this.project = textEditor.getEditor().getProject(); this.highlightInfoStartOffset = highlightInfo.hashCode(); this.rangeHighlighterHashCode = rangeHighlighter.hashCode(); + this.actualStartffset = highlightInfo.getStartOffset(); if (highlightInfo.getActualEndOffset() == 0) this.actualEndOffset = highlightInfo.getActualEndOffset(); diff --git a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java index 66c2776..cb9611b 100644 --- a/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java +++ b/src/main/java/org/overengineer/inlineproblems/listeners/MarkupModelProblemListener.java @@ -88,6 +88,8 @@ public static void disposeAll() { } private void handleEvent(EventType type, @NotNull RangeHighlighterEx highlighter) { + if (!settingsState.isEnableInlineProblem()) + return; if (settingsState.getEnabledListener() != Listener.MARKUP_MODEL_LISTENER) return; diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java index ca45b5e..28fc66a 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsComponent.java @@ -55,6 +55,9 @@ public class SettingsComponent { private final ColorPanel infoLabelBackgroundColor = new ColorPanel(); private final ColorPanel infoHighlightColor = new ColorPanel(); + private final JBCheckBox enableInlineProblem = new JBCheckBox(SettingsBundle.message("settings.enableInlineProblem")); + private final JBCheckBox enableInlineProblemsNotifications = new JBCheckBox(SettingsBundle.message("settings.enableInlineProblemsNotifications")); + private final JBCheckBox forceErrorsInSameLine = new JBCheckBox(SettingsBundle.message("settings.forceProblemsInOneLine")); private final JBCheckBox drawBoxesAroundProblemLabels = new JBCheckBox(SettingsBundle.message("settings.drawBoxesAroundProblemLabels")); private final JBCheckBox roundedCornerBoxes = new JBCheckBox(SettingsBundle.message("settings.roundedCornerBoxes")); @@ -68,6 +71,8 @@ public class SettingsComponent { private final JBCheckBox fillProblemLabels = new JBCheckBox(SettingsBundle.message("settings.fillProblemLabels")); private final JBCheckBox boldProblemLabels = new JBCheckBox(SettingsBundle.message("settings.boldProblemLabels")); private final JBCheckBox italicProblemLabels = new JBCheckBox(SettingsBundle.message("settings.italicProblemLabels")); + private final JBCheckBox clickableContext = new JBCheckBox(SettingsBundle.message("settings.enableClickableContext")); + private final JBTextField problemFilterList = new JBTextField(); private final JBTextField fileExtensionBlacklist = new JBTextField(); @@ -77,7 +82,7 @@ public class SettingsComponent { private final JBTextField additionalInfoSeverities = new JBTextField(); private final JBTextField additionalWarningSeverities = new JBTextField(); private final JBTextField additionalWeakWarningSeverities = new JBTextField(); - private final JBTextField additionalErrorSeverities = new JBTextField(); + private final JBTextField additionalErrorSeverities = new JBTextField(); @Getter private final JPanel settingsPanel; @@ -113,6 +118,9 @@ public SettingsComponent() { infoLabelBackgroundColor.setSelectedColor(settingsState.getInfoBackgroundColor()); infoHighlightColor.setSelectedColor(settingsState.getInfoHighlightColor()); + enableInlineProblem.setSelected(settingsState.isEnableInlineProblem()); + enableInlineProblemsNotifications.setSelected(settingsState.isEnableInlineProblemsNotifications()); + forceErrorsInSameLine.setSelected(settingsState.isForceProblemsInSameLine()); drawBoxesAroundProblemLabels.setSelected(settingsState.isDrawBoxesAroundErrorLabels()); roundedCornerBoxes.setSelected(settingsState.isRoundedCornerBoxes()); @@ -133,6 +141,7 @@ public SettingsComponent() { fillProblemLabels.setSelected(settingsState.isFillProblemLabels()); boldProblemLabels.setSelected(settingsState.isBoldProblemLabels()); italicProblemLabels.setSelected(settingsState.isItalicProblemLabels()); + clickableContext.setSelected(settingsState.isClickableContext()); additionalInfoSeverities.setText(settingsState.getAdditionalInfoSeveritiesAsString()); additionalWeakWarningSeverities.setText(settingsState.getAdditionalWeakWarningSeveritiesAsString()); @@ -149,11 +158,14 @@ public SettingsComponent() { settingsPanel = FormBuilder.createFormBuilder() .addComponent(new JBLabel(SettingsBundle.message("settings.submenu.label"))) + .addComponent(enableInlineProblem, 0) + .addComponent(enableInlineProblemsNotifications, 0) .addComponent(drawBoxesAroundProblemLabels, 0) .addComponent(roundedCornerBoxes, 0) .addComponent(fillProblemLabels, 0) .addComponent(boldProblemLabels, 0) .addComponent(italicProblemLabels, 0) + .addComponent(clickableContext, 0) .addSeparator() .addComponent(new JBLabel(SettingsBundle.message("settings.submenu.general"))) .addLabeledComponent(new JBLabel(SettingsBundle.message("settings.activeProblemListener")), enabledListener) @@ -227,6 +239,22 @@ public void setForceErrorsInSameLine(final boolean isSelected) { forceErrorsInSameLine.setSelected(isSelected); } + public boolean isEnableInlineProblem() { + return enableInlineProblem.isSelected(); + } + + public void setEnableInlineProblem(final boolean isSelected) { + enableInlineProblem.setSelected(isSelected); + } + + public boolean isEnableInlineProblemsNotifications() { + return enableInlineProblemsNotifications.isSelected(); + } + + public void setEnableInlineProblemsNotifications(final boolean isSelected) { + enableInlineProblemsNotifications.setSelected(isSelected); + } + public boolean getDrawBoxesAroundProblemLabels() { return drawBoxesAroundProblemLabels.isSelected(); } @@ -264,8 +292,8 @@ public int getInlayFontSizeDelta() { // Convert the String try { val = Integer.parseInt(inlayFontSizeDeltaText.getText()); + } catch (NumberFormatException ignored) { } - catch (NumberFormatException ignored) {} if (val < 0) val = 0; @@ -317,6 +345,14 @@ public void setItalicProblemLabels(boolean isSelected) { italicProblemLabels.setSelected(isSelected); } + public boolean isClickableContext() { + return clickableContext.isSelected(); + } + + public void setClickableContext(boolean isSelected) { + clickableContext.setSelected(isSelected); + } + public boolean isShowErrors() { return showErrors.isSelected(); } @@ -600,8 +636,7 @@ private List getSeverityIntegerList(String text) { public int getManualScannerDelay() { try { return Math.max(Integer.parseInt(manualScannerDelay.getText()), 10); - } - catch (NumberFormatException e) { + } catch (NumberFormatException e) { return 100; } } diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java index 276d653..f26c328 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsConfigurable.java @@ -17,7 +17,8 @@ public class SettingsConfigurable implements Configurable { private final ListenerManager listenerManager = ListenerManager.getInstance(); - SettingsConfigurable() {} + SettingsConfigurable() { + } @Override @NlsContexts.ConfigurableName @@ -42,6 +43,7 @@ public boolean isModified() { SettingsState state = SettingsState.getInstance(); boolean oldStateEqualsNewState = state.isForceProblemsInSameLine() == settingsComponent.isForceErrorsInSameLine() && + state.isEnableInlineProblem() == settingsComponent.isEnableInlineProblem() && state.isDrawBoxesAroundErrorLabels() == settingsComponent.getDrawBoxesAroundProblemLabels() && state.isRoundedCornerBoxes() == settingsComponent.isRoundedCornerBoxes() && state.isUseEditorFont() == settingsComponent.isUseEditorFont() && @@ -52,6 +54,7 @@ public boolean isModified() { state.isFillProblemLabels() == settingsComponent.isFillProblemLabels() && state.isBoldProblemLabels() == settingsComponent.isBoldProblemLabels() && state.isItalicProblemLabels() == settingsComponent.isItalicProblemLabels() && + state.isClickableContext() == settingsComponent.isClickableContext() && state.getErrorTextColor().equals(settingsComponent.getErrorTextColor()) && state.getErrorBackgroundColor().equals(settingsComponent.getErrorLabelBackgroundColor()) && @@ -132,6 +135,9 @@ public void apply() { state.setInfoBackgroundColor(settingsComponent.getInfoLabelBackgroundColor()); state.setInfoHighlightColor(settingsComponent.getInfoHighlightColor()); + state.setEnableInlineProblem(settingsComponent.isEnableInlineProblem()); + state.setEnableInlineProblemsNotifications(settingsComponent.isEnableInlineProblemsNotifications()); + state.setForceProblemsInSameLine(settingsComponent.isForceErrorsInSameLine()); state.setDrawBoxesAroundErrorLabels(settingsComponent.getDrawBoxesAroundProblemLabels()); state.setRoundedCornerBoxes(settingsComponent.isRoundedCornerBoxes()); @@ -143,6 +149,7 @@ public void apply() { state.setFillProblemLabels(settingsComponent.isFillProblemLabels()); state.setBoldProblemLabels(settingsComponent.isBoldProblemLabels()); state.setItalicProblemLabels(settingsComponent.isItalicProblemLabels()); + state.setClickableContext(settingsComponent.isClickableContext()); state.setEnabledListener(settingsComponent.getEnabledListener()); state.setManualScannerDelay(settingsComponent.getManualScannerDelay()); @@ -202,6 +209,9 @@ public void reset() { settingsComponent.setInfoLabelBackgroundColor(state.getInfoBackgroundColor()); settingsComponent.setInfoHighlightColor(state.getInfoHighlightColor()); + settingsComponent.setEnableInlineProblem(state.isEnableInlineProblem()); + settingsComponent.setEnableInlineProblemsNotifications(state.isEnableInlineProblemsNotifications()); + settingsComponent.setForceErrorsInSameLine(state.isForceProblemsInSameLine()); settingsComponent.setDrawBoxesAroundProblemLabels(state.isDrawBoxesAroundErrorLabels()); settingsComponent.setRoundedCornerBoxes(state.isRoundedCornerBoxes()); @@ -213,6 +223,7 @@ public void reset() { settingsComponent.setFillProblemLabels(state.isFillProblemLabels()); settingsComponent.setBoldProblemLabels(state.isBoldProblemLabels()); settingsComponent.setItalicProblemLabels(state.isItalicProblemLabels()); + settingsComponent.setClickableContext(state.isClickableContext()); settingsComponent.setEnabledListener(state.getEnabledListener()); settingsComponent.setManualScannerDelay(state.getManualScannerDelay()); diff --git a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java index b8ba8d6..e821f88 100644 --- a/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java +++ b/src/main/java/org/overengineer/inlineproblems/settings/SettingsState.java @@ -40,6 +40,9 @@ public class SettingsState implements PersistentStateComponent { private boolean showInfos = false; private boolean highlightInfos = false; private boolean showInfosInGutter = false; + private boolean clickableContext = false; + private boolean enableInlineProblem = true; + private boolean enableInlineProblemsNotifications = false; /** * Colors renamed from 'Color' to 'Col' to solve diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 236a586..74b967b 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -19,23 +19,48 @@ - + key="application.configurable.InlineProblems"/> - + - - + + + + + + + + + + + + - + - - + + \ No newline at end of file diff --git a/src/main/resources/messages/SettingsBundle_en.properties b/src/main/resources/messages/SettingsBundle_en.properties index f1a04b5..550905a 100644 --- a/src/main/resources/messages/SettingsBundle_en.properties +++ b/src/main/resources/messages/SettingsBundle_en.properties @@ -52,4 +52,21 @@ settings.forceProblemsInOneLine=Force problems in the same line even if they are settings.useEditorFont=Use editor font instead of tooltip font settings.showOnlyHighestPerLine=Show only the problem with the highest severity per line settings.enableHtmlStripping=Enable stripping of HTML in the messages -settings.enableXmlUnescaping=Enable unescaping of XML in the messages \ No newline at end of file +settings.enableXmlUnescaping=Enable unescaping of XML in the messages +settings.enableClickableContext=Enable clickable inline problems for IDE context actions +settings.enableInlineProblem=Enable inlineProblems +settings.enableInlineProblemsNotifications=Enable InlineProblems notifications +settings.enableInlineProblem.enabled=Enabling inlineProblems +settings.enableInlineProblem.disabled=Disabling inlineProblems +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.EnableInlineProblemsAction.text=Enable inline Problems +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowErrorsAction.text=Show Errors +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowWarningsAction.text=Show Warnings +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowWeakWarningsAction.text=Show Weak Warnings +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowInfosAction.text=Show Infos +notification.group.InlineProblems=InlineProblems +application.configurable.InlineProblems=InlineProblems diff --git a/src/main/resources/messages/SettingsBundle_zh_CN.properties b/src/main/resources/messages/SettingsBundle_zh_CN.properties index 0737999..14c6a8d 100644 --- a/src/main/resources/messages/SettingsBundle_zh_CN.properties +++ b/src/main/resources/messages/SettingsBundle_zh_CN.properties @@ -51,3 +51,19 @@ settings.useEditorFont=\u4F7F\u7528\u7F16\u8F91\u5668\u5B57\u4F53\u800C\u4E0D\u6 settings.showOnlyHighestPerLine=\u4ec5\u663e\u793a\u6bcf\u884c\u4e2d\u6700\u4e25\u91cd\u7684\u95ee\u9898 settings.enableHtmlStripping=Enable stripping of HTML in the messages settings.enableXmlUnescaping=Enable unescaping of XML in the messages +settings.enableClickableContext=Enable clickable inline problems for IDE context actions +settings.enableInlineProblem=Enable inlineProblems +settings.enableInlineProblem.enabled=Enabling inlineProblems +settings.enableInlineProblem.disabled=Disabling inlineProblems +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.EnableInlineProblemsAction.text=Enable inline Problems +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowErrorsAction.text=Show Errors +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowWarningsAction.text=Show Warnings +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowWeakWarningsAction.text=Show Weak Warnings +# suppress inspection "UnusedProperty" +action.org.overengineer.inlineproblems.actions.ShowInfosAction.text=Show Infos +notification.group.InlineProblems=InlineProblems +application.configurable.InlineProblems=InlineProblems