Skip to content

Commit 7ed56b2

Browse files
committed
fix: update Ignores Preferences and some tidying
1 parent 6bc37fa commit 7ed56b2

8 files changed

Lines changed: 29 additions & 61 deletions

File tree

plugin/plugin.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,14 @@
125125
name="Collapse Tree"
126126
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.CollapseTreeHandler">
127127
</command>
128-
<command
129-
id="io.snyk.eclipse.plugin.commands.snykFilterAllIssues"
130-
name="All Issues"
131-
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaAllIssuesHandler">
132-
</command>
133128
<command
134129
id="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues"
135130
name="Net New Issues"
136131
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaNewIssuesHandler">
137132
</command>
138133
<command
139134
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresOpenIssuesHandler"
140-
id="io.snyk.eclipse.plugin.commands.snykHideIgnored"
135+
id="io.snyk.eclipse.plugin.commands.snykShowOpenIgnored"
141136
name="Open Issues">
142137
</command>
143138
<command
@@ -315,7 +310,7 @@
315310
id="io.snyk.eclipse.plugin.views.snyktoolview.filterIgnoreMenu"
316311
label="Issues Status">
317312
<command
318-
commandId="io.snyk.eclipse.plugin.commands.snykHideIgnored"
313+
commandId="io.snyk.eclipse.plugin.commands.snykShowOpenIgnored"
319314
icon="icons/enabled.png"
320315
style="push"
321316
tooltip="Hide Ignored">
@@ -326,11 +321,6 @@
326321
style="push"
327322
tooltip="Show Ignored">
328323
</command>
329-
<command
330-
commandId="io.snyk.eclipse.plugin.commands.snykFilterAllIssues"
331-
style="push"
332-
tooltip="Show All Issues">
333-
</command>
334324
<command
335325
commandId="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues"
336326
icon="icons/enabled.png"

plugin/src/main/java/io/snyk/eclipse/plugin/SnykStartup.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
public class SnykStartup implements IStartup {
4040
private static LsRuntimeEnvironment runtimeEnvironment;
4141
private SnykView snykView = null;
42+
private static SnykToolView snykToolView = null;
4243
private static boolean downloading = true;
4344
private static ILog logger;
4445

@@ -118,17 +119,18 @@ public static SnykView getSnykView() {
118119
}
119120

120121
public static ISnykToolView getView() {
122+
IWorkbench workbench = PlatformUI.getWorkbench();
121123

122-
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
123-
ISnykToolView toolView;
124-
try {
125-
toolView = (ISnykToolView) activePage.showView(SnykToolView.ID);
126-
} catch (PartInitException e) {
127-
SnykLogger.logError(e);
128-
return null;
129-
}
130-
return toolView;
124+
workbench.getDisplay().syncExec(() -> {
125+
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
131126

127+
try {
128+
snykToolView = (SnykToolView) activePage.showView(SnykToolView.ID);
129+
} catch (PartInitException e) {
130+
SnykLogger.logError(e);
131+
}
132+
});
133+
return snykToolView;
132134
}
133135

134136
private boolean downloadLS() {

plugin/src/main/java/io/snyk/eclipse/plugin/properties/preferences/Preferences.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
5151
public static final String FILTER_MEDIUM = "FILTER_SNYK_MEDIUM";
5252
public static final String FILTER_LOW = "FILTER_SNYK_LOW";
5353
public static final String FILTER_DELTA_NEW_ISSUES = "FILTER_SNYK_NEW_ISSUES";
54-
public static final String FILTER_DELTA_ALL_ISSUES = "FILTER_SNYK_ALL_ISSUES";
55-
public static final String FILTER_IGNORES_OPEN_ISSUES = "FILTER_IGNORES_OPEN_ISSUES";
56-
public static final String FILTER_IGNORES_IGNORED_ISSUES = "FILTER_IGNORES_IGNORED_ISSUES";
54+
public static final String FILTER_IGNORES_SHOW_OPEN_ISSUES = "FILTER_IGNORES_OPEN_ISSUES";
55+
public static final String FILTER_IGNORES_SHOW_IGNORED_ISSUES = "FILTER_IGNORES_IGNORED_ISSUES";
5756
public static final String FILTER_FIXABLE_ISSUES = "FILTER_FIXABLE_ISSUES";
5857

5958
// This is a bit confusing - CLI takes DISABLE as env variable, but we ask for
@@ -101,14 +100,11 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
101100
if (getPref(FILTER_DELTA_NEW_ISSUES) == null) {
102101
store(FILTER_DELTA_NEW_ISSUES, "false");
103102
}
104-
if (getPref(FILTER_DELTA_ALL_ISSUES) == null) {
105-
store(FILTER_DELTA_ALL_ISSUES, "true");
103+
if (getPref(FILTER_IGNORES_SHOW_OPEN_ISSUES) == null) {
104+
store(FILTER_IGNORES_SHOW_OPEN_ISSUES, "true");
106105
}
107-
if (getPref(FILTER_IGNORES_OPEN_ISSUES) == null) {
108-
store(FILTER_IGNORES_OPEN_ISSUES, "true");
109-
}
110-
if (getPref(FILTER_IGNORES_IGNORED_ISSUES) == null) {
111-
store(FILTER_IGNORES_IGNORED_ISSUES, "false");
106+
if (getPref(FILTER_IGNORES_SHOW_IGNORED_ISSUES) == null) {
107+
store(FILTER_IGNORES_SHOW_IGNORED_ISSUES, "true");
112108
}
113109
if (getPref(FILTER_FIXABLE_ISSUES) == null) {
114110
store(FILTER_FIXABLE_ISSUES, "false");

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaAllIssuesHandler.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresIgnoredIssuesHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public FilterIgnoresIgnoredIssuesHandler() {
1212

1313
iconEnabled = SnykIcons.ENABLED;
1414
iconDisabled = SnykIcons.DISABLED;
15-
preferenceKey = Preferences.FILTER_IGNORES_IGNORED_ISSUES;
15+
preferenceKey = Preferences.FILTER_IGNORES_SHOW_IGNORED_ISSUES;
1616
}
1717
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresOpenIssuesHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public FilterIgnoresOpenIssuesHandler() {
1212

1313
iconEnabled = SnykIcons.ENABLED;
1414
iconDisabled = SnykIcons.DISABLED;
15-
preferenceKey = Preferences.FILTER_IGNORES_OPEN_ISSUES;
15+
preferenceKey = Preferences.FILTER_IGNORES_SHOW_OPEN_ISSUES;
1616
}
1717

1818
}

plugin/src/main/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import static io.snyk.eclipse.plugin.domain.ProductConstants.SCAN_STATE_ERROR;
1111
import static io.snyk.eclipse.plugin.domain.ProductConstants.SCAN_STATE_IN_PROGRESS;
1212
import static io.snyk.eclipse.plugin.domain.ProductConstants.SCAN_STATE_SUCCESS;
13-
import static io.snyk.eclipse.plugin.properties.preferences.Preferences.FILTER_IGNORES_IGNORED_ISSUES;
14-
import static io.snyk.eclipse.plugin.properties.preferences.Preferences.FILTER_IGNORES_OPEN_ISSUES;
13+
import static io.snyk.eclipse.plugin.properties.preferences.Preferences.FILTER_IGNORES_SHOW_IGNORED_ISSUES;
14+
import static io.snyk.eclipse.plugin.properties.preferences.Preferences.FILTER_IGNORES_SHOW_OPEN_ISSUES;
1515
import static io.snyk.eclipse.plugin.views.snyktoolview.ISnykToolView.CONGRATS_NO_ISSUES_FOUND;
1616
import static io.snyk.eclipse.plugin.views.snyktoolview.ISnykToolView.NODE_TEXT_SCANNING;
1717
import static io.snyk.eclipse.plugin.views.snyktoolview.ISnykToolView.NO_FIXABLE_ISSUES;
@@ -352,13 +352,13 @@ private void addInfoNodes(String displayProduct) {
352352
}
353353

354354
if (totalCount > 0 && ignoredCount == totalCount
355-
&& Preferences.getInstance().getBooleanPref(FILTER_IGNORES_OPEN_ISSUES)) {
355+
&& Preferences.getInstance().getBooleanPref(FILTER_IGNORES_SHOW_OPEN_ISSUES)) {
356356
toolView.addInfoNode(productNode,
357357
new BaseTreeNode("Adjust your Issue View Options to see ignored issues."));
358358
}
359359

360360
if (totalCount > 0 && ignoredCount == 0
361-
&& Preferences.getInstance().getBooleanPref(FILTER_IGNORES_IGNORED_ISSUES)) {
361+
&& Preferences.getInstance().getBooleanPref(FILTER_IGNORES_SHOW_IGNORED_ISSUES)) {
362362
toolView.addInfoNode(productNode, new BaseTreeNode("Adjust your Issue View Options to see open issues."));
363363
}
364364
}

tests/src/test/java/io/snyk/languageserver/protocolextension/SnykExtendedLanguageClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ void testSnykScanSuccessAddsInfoNodes_IssuesFound_onlyIgnoredDisplayed() {
331331
param.setProduct(SCAN_PARAMS_CODE);
332332
param.setFolderPath("a/b/c");
333333

334-
pref.store(Preferences.FILTER_IGNORES_OPEN_ISSUES, "true");
335-
pref.store(Preferences.FILTER_IGNORES_IGNORED_ISSUES, "false");
334+
pref.store(Preferences.FILTER_IGNORES_SHOW_OPEN_ISSUES, "true");
335+
pref.store(Preferences.FILTER_IGNORES_SHOW_IGNORED_ISSUES, "false");
336336

337337
String expectedFirstInfoNode = "✋ 4 issues found by Snyk, 4 ignored";
338338
String expectedSecondInfoNode = "⚡️ 2 issues can be fixed automatically";
@@ -348,8 +348,8 @@ void testSnykScanSuccessAddsInfoNodes_IssuesFound_onlyOpenDisplayed() {
348348
param.setProduct(SCAN_PARAMS_CODE);
349349
param.setFolderPath("a/b/c");
350350

351-
pref.store(Preferences.FILTER_IGNORES_OPEN_ISSUES, "false");
352-
pref.store(Preferences.FILTER_IGNORES_IGNORED_ISSUES, "true");
351+
pref.store(Preferences.FILTER_IGNORES_SHOW_OPEN_ISSUES, "false");
352+
pref.store(Preferences.FILTER_IGNORES_SHOW_IGNORED_ISSUES, "true");
353353

354354
String expectedFirstInfoNode = "✋ 4 issues found by Snyk";
355355
String expectedSecondInfoNode = "⚡️ 2 issues can be fixed automatically";

0 commit comments

Comments
 (0)