Skip to content

Commit a460b03

Browse files
committed
feat: updated viewmenu and added handlers for stop scan and clear cache commands
1 parent 6c3c487 commit a460b03

18 files changed

Lines changed: 196 additions & 157 deletions

plugin/icons/enabled.png

217 Bytes
Loading

plugin/plugin.xml

Lines changed: 73 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
<!--
3838
<view
3939
id="io.snyk.eclipse.plugin.views.snyktoolview"
40-
relative="org.eclipse.ui.views.ProblemView"
41-
relationship="right"
4240
ratio="0.5">
4341
</view>
4442
-->
@@ -65,6 +63,16 @@
6563
defaultHandler="io.snyk.eclipse.plugin.views.ScanWorkspaceMenuHandler"
6664
id="io.snyk.eclipse.plugin.commands.snykWorkspaceScan"
6765
name="%scanWorkspace.name">
66+
</command>
67+
<command
68+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.StopScanHandler"
69+
id="io.snyk.eclipse.plugin.commands.snykStopScan"
70+
name="Stop Scan">
71+
</command>
72+
<command
73+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.ClearCacheHandler"
74+
id="io.snyk.eclipse.plugin.commands.snykEmptyScanResults"
75+
name="Clear Cache">
6876
</command>
6977
<command
7078
id="io.snyk.eclipse.plugin.properties.preferencespage"
@@ -97,9 +105,14 @@
97105
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableOssProductHandler">
98106
</command>
99107
<command
100-
id="io.snyk.eclipse.plugin.commands.enableCode"
108+
id="io.snyk.eclipse.plugin.commands.enableCodeSecurity"
101109
name="Code Security"
102-
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableCodeProductHandler">
110+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableCodeSecurityProductHandler">
111+
</command>
112+
<command
113+
id="io.snyk.eclipse.plugin.commands.enableCodeQuality"
114+
name="Code Quality"
115+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableCodeQualityProductHandler">
103116
</command>
104117
<command
105118
id="io.snyk.eclipse.plugin.commands.enableIAC"
@@ -117,22 +130,24 @@
117130
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.CollapseTreeHandler">
118131
</command>
119132
<command
120-
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.providers.ViewMenuHandler"
121-
id="io.snyk.eclipse.plugin.commands.viewmenu"
122-
name="Show View Menu">
133+
id="io.snyk.eclipse.plugin.commands.snykFilterAllIssues"
134+
name="All Issues"
135+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaAllIssuesHandler">
123136
</command>
124137
<command
125-
id="io.snyk.eclipse.plugin.commands.snykFilterDelta"
126-
name="Delta findings"
127-
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaHandler">
138+
id="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues"
139+
name="Net New Issues"
140+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresOpenIssuesHandler">
128141
</command>
129142
<command
130-
id="io.snyk.eclipse.plugin.commands.snykHideIgnored"
131-
name="Hide Ignored">
143+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaOpenIssuesHandler"
144+
id="io.snyk.eclipse.plugin.commands.snykHideIgnored"
145+
name="Open Issues">
132146
</command>
133147
<command
134-
id="io.snyk.eclipse.plugin.commands.snykShowIgnored"
135-
name="Show Ignored">
148+
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresIgnoredIssuesHandler"
149+
id="io.snyk.eclipse.plugin.commands.snykShowIgnored"
150+
name="Ignored Issues">
136151
</command>
137152
</extension>
138153
<extension point="org.eclipse.ui.menus">
@@ -214,7 +229,7 @@
214229
</command>
215230
<command
216231
commandId="io.snyk.eclipse.plugin.commands.snykEmptyScanResults"
217-
icon="platform:/plugin/org.eclipse.ui/icons/full/elcl16/trash.png"
232+
icon="platform:/plugin/org.eclipse.ui.console/icons/full/clcl16/clear_co.png"
218233
style="push"
219234
tooltip="Empty Scan Results Cache">
220235
</command>
@@ -247,73 +262,49 @@
247262
style="push"
248263
tooltip="Low Severity">
249264
</command>
250-
<command
251-
commandId="io.snyk.eclipse.plugin.commands.snykFilterDelta"
252-
icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/elcl16/exclusion_filter_attrib.png"
253-
style="push"
254-
tooltip="Delta findings">
255-
</command>
256-
<!-- Add a separator -->
257265
<separator
258-
name="FilterSeparator"
266+
name="io.snyk.eclipse.plugin.filter"
259267
visible="true">
260268
</separator>
261-
<!-- Add a separator -->
262-
</menuContribution>
263-
<menuContribution
264-
allPopups="false"
265-
locationURI="menu:io.snyk.eclipse.plugin.views.snyktoolview">
266269
<command
267270
commandId="io.snyk.eclipse.plugin.properties.preferencespage"
268271
icon="platform:/plugin/org.eclipse.jdt.debug.ui/icons/full/elcl16/thread_view.gif"
269272
style="push"
270273
tooltip="Open Snyk Preferences">
271274
</command>
272-
<separator
273-
name="io.snyk.eclipse.plugin.filter"
274-
visible="true">
275-
</separator>
276-
<!-- Add a separator -->
277-
<separator
278-
name="RunScanSeparator"
279-
visible="true">
280-
</separator>
281-
<command
282-
commandId="io.snyk.eclipse.plugin.commands.snykFilterCritical"
283-
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-critical.png"
284-
style="push"
285-
tooltip="Critical Severity">
286-
</command>
287-
<command
288-
commandId="io.snyk.eclipse.plugin.commands.snykFilterHigh"
289-
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-high.png"
290-
style="push"
291-
tooltip="High Severity">
275+
</menuContribution>
276+
<menuContribution
277+
allPopups="false"
278+
locationURI="menu:io.snyk.eclipse.plugin.views.snyktoolview">
279+
<menu id="io.snyk.eclipse.plugin.views.snyktoolview.filterProductTypeMenu"
280+
label="Filter Product Type">
281+
<command
282+
commandId="io.snyk.eclipse.plugin.commands.enableOSS"
283+
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/oss.png"
284+
style="push"
285+
tooltip="Enable/disable OSS scans">
292286
</command>
293287
<command
294-
commandId="io.snyk.eclipse.plugin.commands.snykFilterMedium"
295-
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-medium.png"
296-
style="push"
297-
tooltip="Medium Severity">
288+
commandId="io.snyk.eclipse.plugin.commands.enableCodeSecurity"
289+
icon="icons/code.png"
290+
style="push"
291+
tooltip="Enable/disable Code scans">
298292
</command>
299-
<command
300-
commandId="io.snyk.eclipse.plugin.commands.snykFilterLow"
301-
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-low.png"
302-
style="push"
303-
tooltip="Low Severity">
293+
<command
294+
commandId="io.snyk.eclipse.plugin.commands.enableCodeQuality"
295+
icon="icons/code.png"
296+
style="push"
297+
tooltip="Enable/disable Code scans">
304298
</command>
305-
<!-- Add a separator -->
306-
<separator
307-
name="FilterSeparator"
308-
visible="true">
309-
</separator>
310-
<!-- Add a separator -->
311299
<command
312-
commandId="io.snyk.eclipse.plugin.commands.snykFilterDelta"
313-
icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/elcl16/exclusion_filter_attrib.png"
300+
commandId="io.snyk.eclipse.plugin.commands.enableIAC"
301+
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/iac.png"
314302
style="push"
315-
tooltip="Delta findings">
303+
tooltip="Enable/disable IAC scans">
316304
</command>
305+
</menu>
306+
<menu id="io.snyk.eclipse.plugin.views.snyktoolview.filterIgnoreMenu"
307+
label="Filter Ignores">
317308
<command
318309
commandId="io.snyk.eclipse.plugin.commands.snykHideIgnored"
319310
icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/elcl16/hide_ignored.png"
@@ -326,28 +317,20 @@
326317
style="push"
327318
tooltip="Show Ignored">
328319
</command>
329-
<separator
330-
name="ProductChooserSeparator"
331-
visible="true">
332-
</separator>
333-
<command
334-
commandId="io.snyk.eclipse.plugin.commands.enableOSS"
335-
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/oss.png"
336-
style="push"
337-
tooltip="Enable/disable OSS scans">
338-
</command>
339-
<command
340-
commandId="io.snyk.eclipse.plugin.commands.enableCode"
341-
icon="icons/code.png"
342-
style="push"
343-
tooltip="Enable/disable Code scans">
344-
</command>
345-
<command
346-
commandId="io.snyk.eclipse.plugin.commands.enableIAC"
347-
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/iac.png"
348-
style="push"
349-
tooltip="Enable/disable IAC scans">
350-
</command>
320+
</menu>
321+
<menu id="io.snyk.eclipse.plugin.views.snyktoolview.filterDeltaMenu"
322+
label="Filter Net New Issues">
323+
<command
324+
commandId="io.snyk.eclipse.plugin.commands.snykFilterAllIssues"
325+
style="push"
326+
tooltip="Show All Issues">
327+
</command>
328+
<command
329+
commandId="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues"
330+
style="push"
331+
tooltip="Show Only Net New Issues">
332+
</command>
333+
</menu>
351334
</menuContribution>
352335
<menuContribution
353336
locationURI="popup:io.snyk.eclipse.plugin.views.snyktoolview#PopupTreeMenu">
@@ -513,15 +496,11 @@
513496
</extension>
514497
<extension point="org.eclipse.ui.handlers">
515498
<handler
516-
class="io.snyk.eclipse.plugin.views.snyktoolview.providers.ViewMenuHandler"
517-
commandId="io.snyk.eclipse.plugin.commands.viewmenu">
518-
</handler>
519-
<handler
520-
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.ShowIgnoredHandler"
499+
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresIgnoredIssuesHandler"
521500
commandId="io.snyk.eclipse.plugin.commands.snykShowIgnored">
522501
</handler>
523502
<handler
524-
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.HideIgnoredHandler"
503+
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaOpenIssuesHandler"
525504
commandId="io.snyk.eclipse.plugin.commands.snykHideIgnored">
526505
</handler>
527506
</extension>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
5050
public static final String FILTER_HIGH = "FILTER_SNYK_HIGH";
5151
public static final String FILTER_MEDIUM = "FILTER_SNYK_MEDIUM";
5252
public static final String FILTER_LOW = "FILTER_SNYK_LOW";
53-
public static final String FILTER_DELTA = "FILTER_SNYK_DELTA";
53+
public static final String FILTER_DELTA_OPEN_ISSUES = "FILTER_SNYK_OPEN_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";
5457

5558
// This is a bit confusing - CLI takes DISABLE as env variable, but we ask for
5659
// ENABLE, so we need to revert it

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/ISnykToolView.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55

66
public interface ISnykToolView {
77
abstract void setNodeText(TreeNode node, String text);
8+
89
abstract void setNodeIcon(ImageDescriptor icon);
10+
911
abstract void addIssueNode(TreeNode parent, TreeNode toBeAdded);
12+
1013
abstract void addFileNode(TreeNode parent, TreeNode toBeAdded);
14+
1115
abstract void addInfoNode(TreeNode parent, TreeNode toBeAdded);
16+
1217
abstract TreeNode getProductNode(String product);
18+
1319
abstract TreeNode getRoot();
1420
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/RootNode.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ public class RootNode extends TreeNode {
1414

1515
public RootNode() {
1616
super("");
17-
17+
1818
ossRootNode = new TreeNode(OPEN_SOURCE);
1919
codeSecurityRootNode = new TreeNode(CODE_SECURITY);
2020
codeQualityRootNode = new TreeNode(CODE_QUALITY);
2121
iacRootNode = new TreeNode(CONFIGURATION);
22-
23-
TreeNode[] children = new TreeNode[] {
24-
ossRootNode,
25-
codeSecurityRootNode,
26-
codeQualityRootNode,
27-
iacRootNode,
28-
};
22+
23+
TreeNode[] children = new TreeNode[] { ossRootNode, codeSecurityRootNode, codeQualityRootNode, iacRootNode, };
2924
setChildren(children);
3025
}
3126
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
import org.eclipse.ui.commands.IElementUpdater;
1212
import org.eclipse.ui.menus.UIElement;
1313

14-
import io.snyk.eclipse.plugin.Activator;
1514
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
1615

1716
public class BaseHandler extends AbstractHandler implements IElementUpdater {
1817

19-
//TODO should we replace the filter button with a filter applied button icon?
18+
// TODO should we replace the filter button with a filter applied button icon?
2019
protected ImageDescriptor iconEnabled = null;
2120
protected ImageDescriptor iconDisabled = null;
2221
protected String preferenceKey = null;
@@ -37,14 +36,14 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
3736
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map map) {
3837

3938
String preference = Preferences.getInstance().getPref(preferenceKey);
39+
boolean bool = Boolean.parseBoolean(preference);
4040

4141
// Toggle the value, if it was true, it should be set to false
42-
if (Boolean.parseBoolean(preference)) {
42+
if (bool) {
4343
element.setIcon(iconDisabled);
4444
Preferences.getInstance().store(preferenceKey, "false");
4545

4646
} else {
47-
4847
element.setIcon(iconEnabled);
4948
Preferences.getInstance().store(preferenceKey, "true");
5049

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ShowIgnoredHandler.java renamed to plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ClearCacheHandler.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
import io.snyk.eclipse.plugin.utils.SnykMessageDialog;
1010

11-
public class ShowIgnoredHandler extends AbstractHandler {
11+
public class ClearCacheHandler extends AbstractHandler {
12+
13+
public ClearCacheHandler() {
14+
super();
15+
16+
}
1217

1318
@Override
1419
public Object execute(ExecutionEvent event) throws ExecutionException {
@@ -20,4 +25,4 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2025
return null;
2126
}
2227

23-
}
28+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.snyk.eclipse.plugin.views.snyktoolview.handlers;
2+
3+
import org.eclipse.ui.commands.IElementUpdater;
4+
5+
import io.snyk.eclipse.plugin.Activator;
6+
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
7+
8+
public class EnableCodeQualityProductHandler extends BaseHandler implements IElementUpdater {
9+
10+
public EnableCodeQualityProductHandler() {
11+
super();
12+
// TODO should we replace the filter button with a filter applied button icon?
13+
iconEnabled = Activator.getImageDescriptor("/icons/oss.png");
14+
iconDisabled = Activator.getImageDescriptor("/icons/oss_disabled.png");
15+
preferenceKey = Preferences.ACTIVATE_SNYK_OPEN_SOURCE;
16+
}
17+
18+
}

plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeProductHandler.java renamed to plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeSecurityProductHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import io.snyk.eclipse.plugin.Activator;
66
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
77

8-
public class EnableCodeProductHandler extends BaseHandler implements IElementUpdater {
8+
public class EnableCodeSecurityProductHandler extends BaseHandler implements IElementUpdater {
99

10-
public EnableCodeProductHandler() {
10+
public EnableCodeSecurityProductHandler() {
1111
super();
1212
// TODO should we replace the filter button with a filter applied button icon?
1313
iconEnabled = Activator.getImageDescriptor("/icons/code.png");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import io.snyk.eclipse.plugin.properties.preferences.Preferences;
77

88
public class FilterCriticalHandler extends BaseHandler implements IElementUpdater {
9-
9+
1010
public FilterCriticalHandler() {
1111
super();
1212
// TODO should we replace the filter button with a filter applied button icon?

0 commit comments

Comments
 (0)