From 796d8d7b320d57026278a52904f9f175d507892e Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Tue, 3 Sep 2024 09:34:25 +0300 Subject: [PATCH 1/2] check --- .../settings/global/GlobalSettingsComponent.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/checkmarx/intellij/settings/global/GlobalSettingsComponent.java b/src/main/java/com/checkmarx/intellij/settings/global/GlobalSettingsComponent.java index f9da8675..25921fe6 100644 --- a/src/main/java/com/checkmarx/intellij/settings/global/GlobalSettingsComponent.java +++ b/src/main/java/com/checkmarx/intellij/settings/global/GlobalSettingsComponent.java @@ -35,9 +35,8 @@ public class GlobalSettingsComponent implements SettingsComponent { private static final Logger LOGGER = Utils.getLogger(GlobalSettingsComponent.class); - private final static GlobalSettingsState SETTINGS_STATE = GlobalSettingsState.getInstance(); - private final static GlobalSettingsSensitiveState SENSITIVE_SETTINGS_STATE - = GlobalSettingsSensitiveState.getInstance(); + private static GlobalSettingsState SETTINGS_STATE; + private static GlobalSettingsSensitiveState SENSITIVE_SETTINGS_STATE; private final MessageBus messageBus = ApplicationManager.getApplication().getMessageBus(); @@ -52,6 +51,12 @@ public class GlobalSettingsComponent implements SettingsComponent { private final JBLabel validateResult = new JBLabel(); public GlobalSettingsComponent() { + if (SETTINGS_STATE == null) { + SETTINGS_STATE = GlobalSettingsState.getInstance(); + } + if (SENSITIVE_SETTINGS_STATE == null) { + SENSITIVE_SETTINGS_STATE = GlobalSettingsSensitiveState.getInstance(); + } addValidateConnectionListener(); setupFields(); From ade15b1144d1d06b9791bedb7bc7b265dbddc388 Mon Sep 17 00:00:00 2001 From: AlvoBen Date: Wed, 4 Sep 2024 17:09:08 +0300 Subject: [PATCH 2/2] fix intellij plugin --- .../tool/window/actions/CancelScanAction.java | 9 +++++++-- .../tool/window/actions/CollapseAllAction.java | 6 ++++++ .../intellij/tool/window/actions/ExpandAllAction.java | 6 ++++++ .../tool/window/actions/OpenSettingsAction.java | 6 ++++++ .../intellij/tool/window/actions/StartScanAction.java | 8 ++++++-- .../tool/window/actions/filter/FilterBaseAction.java | 6 ++++++ .../window/actions/group/by/GroupByActionGroup.java | 6 ++++++ .../window/actions/group/by/GroupByBaseAction.java | 6 ++++++ .../window/actions/selection/BaseSelectionGroup.java | 7 +++++++ .../actions/selection/BranchSelectionGroup.java | 1 + .../actions/selection/ResetSelectionAction.java | 6 ++++++ .../tool/window/actions/selection/RootGroup.java | 11 ++++++++++- 12 files changed, 73 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/CancelScanAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/CancelScanAction.java index d9ce0dcc..ba90cbf4 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/CancelScanAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/CancelScanAction.java @@ -8,6 +8,7 @@ import com.intellij.ide.ActivityTracker; import com.intellij.ide.util.PropertiesComponent; import com.intellij.notification.NotificationType; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.diagnostic.Logger; @@ -62,8 +63,12 @@ public void update(@NotNull AnActionEvent e) { e.getPresentation().setEnabled(isScanRunning); } catch (Exception ex) { - ex.printStackTrace(); - e.getPresentation().setEnabled(false); + e.getPresentation().setEnabled(true); } } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/CollapseAllAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/CollapseAllAction.java index ab0dc5f6..b55a4d09 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/CollapseAllAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/CollapseAllAction.java @@ -3,6 +3,7 @@ import com.checkmarx.intellij.Bundle; import com.checkmarx.intellij.Resource; import com.checkmarx.intellij.tool.window.CxToolWindowPanel; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import org.jetbrains.annotations.NotNull; @@ -28,4 +29,9 @@ public CollapseAllAction() { public void actionPerformed(@NotNull AnActionEvent e) { Optional.ofNullable(getCxToolWindowPanel(e)).ifPresent(CxToolWindowPanel::collapseAll); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/ExpandAllAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/ExpandAllAction.java index 0496e3c8..c944e6b7 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/ExpandAllAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/ExpandAllAction.java @@ -3,6 +3,7 @@ import com.checkmarx.intellij.Bundle; import com.checkmarx.intellij.Resource; import com.checkmarx.intellij.tool.window.CxToolWindowPanel; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import org.jetbrains.annotations.NotNull; @@ -28,4 +29,9 @@ public ExpandAllAction() { public void actionPerformed(@NotNull AnActionEvent e) { Optional.ofNullable(getCxToolWindowPanel(e)).ifPresent(CxToolWindowPanel::expandAll); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/OpenSettingsAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/OpenSettingsAction.java index ebf8e342..fe7bbece 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/OpenSettingsAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/OpenSettingsAction.java @@ -3,6 +3,7 @@ import com.checkmarx.intellij.Bundle; import com.checkmarx.intellij.Resource; import com.checkmarx.intellij.settings.global.GlobalSettingsConfigurable; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.options.ShowSettingsUtil; @@ -27,4 +28,9 @@ public void actionPerformed(@NotNull AnActionEvent e) { ShowSettingsUtil.getInstance() .showSettingsDialog(e.getProject(), GlobalSettingsConfigurable.class); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/StartScanAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/StartScanAction.java index 4e5296b5..9e3dca43 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/StartScanAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/StartScanAction.java @@ -15,6 +15,7 @@ import com.intellij.ide.ActivityTracker; import com.intellij.ide.util.PropertiesComponent; import com.intellij.notification.*; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.diagnostic.Logger; @@ -71,7 +72,6 @@ public static Boolean getUserHasPermissionsToScan() { userHasPermissionsToScan = TenantSetting.isScanAllowed(); } catch (Exception ex) { userHasPermissionsToScan = false; - LOGGER.error(ex); } } return userHasPermissionsToScan; @@ -289,7 +289,6 @@ public void update(@NotNull AnActionEvent e) { e.getPresentation().setEnabled(!isScanRunning && !isPollingScan && !scanTriggered && projectAndBranchSelected); } catch (Exception ex) { - LOGGER.error(ex); e.getPresentation().setEnabled(false); } } @@ -311,4 +310,9 @@ public static void cancelRunningScan() { private static String msg(Resource resource, Object... params) { return Bundle.message(resource, params); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/filter/FilterBaseAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/filter/FilterBaseAction.java index c77e5738..e54dc137 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/filter/FilterBaseAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/filter/FilterBaseAction.java @@ -4,6 +4,7 @@ import com.checkmarx.intellij.tool.window.ResultState; import com.checkmarx.intellij.tool.window.Severity; import com.checkmarx.intellij.tool.window.actions.CxToolWindowAction; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.application.ApplicationManager; @@ -211,4 +212,9 @@ public interface FilterChanged { */ void filterChanged(); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByActionGroup.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByActionGroup.java index 1dd5b130..79bd4097 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByActionGroup.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByActionGroup.java @@ -1,5 +1,6 @@ package com.checkmarx.intellij.tool.window.actions.group.by; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.project.DumbAware; @@ -12,4 +13,9 @@ public void update(@NotNull AnActionEvent e) { super.update(e); e.getPresentation().setEnabled(true); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByBaseAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByBaseAction.java index e4a2d68d..0b1faeab 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByBaseAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/group/by/GroupByBaseAction.java @@ -2,6 +2,7 @@ import com.checkmarx.intellij.tool.window.actions.CxToolWindowAction; import com.checkmarx.intellij.tool.window.GroupBy; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.util.NlsActions; @@ -32,4 +33,9 @@ public void setSelected(@NotNull AnActionEvent e, boolean state) { } protected abstract GroupBy getGroupBy(); + + @Override + public ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BaseSelectionGroup.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BaseSelectionGroup.java index c13d2b39..551f7635 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BaseSelectionGroup.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BaseSelectionGroup.java @@ -6,6 +6,7 @@ import com.checkmarx.intellij.tool.window.actions.CxToolWindowAction; import com.intellij.icons.AllIcons; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.project.DumbAware; @@ -83,4 +84,10 @@ public void update(@NotNull AnActionEvent e) { * @param scan overriding scan */ abstract void override(Scan scan); + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } + } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BranchSelectionGroup.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BranchSelectionGroup.java index 857ee056..c0db0a6d 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BranchSelectionGroup.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/BranchSelectionGroup.java @@ -5,6 +5,7 @@ import com.checkmarx.intellij.Constants; import com.checkmarx.intellij.Resource; import com.checkmarx.intellij.Utils; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/ResetSelectionAction.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/ResetSelectionAction.java index 228f948d..1c28045f 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/ResetSelectionAction.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/ResetSelectionAction.java @@ -4,6 +4,7 @@ import com.checkmarx.intellij.Resource; import com.checkmarx.intellij.tool.window.actions.CxToolWindowAction; import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import lombok.Getter; @@ -45,4 +46,9 @@ public void actionPerformed(@NotNull AnActionEvent e) { cxToolWindowPanel.resetPanel(); }); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } } diff --git a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/RootGroup.java b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/RootGroup.java index 80122e2a..04fc524e 100644 --- a/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/RootGroup.java +++ b/src/main/java/com/checkmarx/intellij/tool/window/actions/selection/RootGroup.java @@ -2,6 +2,7 @@ import com.checkmarx.intellij.commands.Scan; import com.checkmarx.intellij.tool.window.actions.CxToolWindowAction; +import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.DumbAware; @@ -64,10 +65,13 @@ public void setEnabled(boolean enabled) { projectSelectionGroup.setEnabled(enabled); branchSelectionGroup.setEnabled(enabled); scanSelectionGroup.setEnabled(enabled); - resetSelectionAction.setEnabled(enabled); + if (resetSelectionAction != null) { + resetSelectionAction.setEnabled(enabled); + } refreshPanel(project); } + public void reset() { projectSelectionGroup.clear(); branchSelectionGroup.clear(); @@ -75,4 +79,9 @@ public void reset() { refreshPanel(project); projectSelectionGroup.refresh(); } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.EDT; + } }