Skip to content

Commit

Permalink
feat: updated viewmenu and added handlers for stop scan and clear cac…
Browse files Browse the repository at this point in the history
…he commands
  • Loading branch information
acke committed Nov 14, 2024
1 parent 6c3c487 commit e17fecf
Show file tree
Hide file tree
Showing 18 changed files with 196 additions and 155 deletions.
Binary file added plugin/icons/enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
165 changes: 73 additions & 92 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@
defaultHandler="io.snyk.eclipse.plugin.views.ScanWorkspaceMenuHandler"
id="io.snyk.eclipse.plugin.commands.snykWorkspaceScan"
name="%scanWorkspace.name">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.StopScanHandler"
id="io.snyk.eclipse.plugin.commands.snykStopScan"
name="Stop Scan">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.ClearCacheHandler"
id="io.snyk.eclipse.plugin.commands.snykEmptyScanResults"
name="Clear Cache">
</command>
<command
id="io.snyk.eclipse.plugin.properties.preferencespage"
Expand Down Expand Up @@ -97,9 +107,14 @@
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableOssProductHandler">
</command>
<command
id="io.snyk.eclipse.plugin.commands.enableCode"
id="io.snyk.eclipse.plugin.commands.enableCodeSecurity"
name="Code Security"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableCodeProductHandler">
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableCodeSecurityProductHandler">
</command>
<command
id="io.snyk.eclipse.plugin.commands.enableCodeQuality"
name="Code Quality"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableCodeQualityProductHandler">
</command>
<command
id="io.snyk.eclipse.plugin.commands.enableIAC"
Expand All @@ -117,22 +132,24 @@
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.CollapseTreeHandler">
</command>
<command
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.providers.ViewMenuHandler"
id="io.snyk.eclipse.plugin.commands.viewmenu"
name="Show View Menu">
id="io.snyk.eclipse.plugin.commands.snykFilterAllIssues"
name="All Issues"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaAllIssuesHandler">
</command>
<command
id="io.snyk.eclipse.plugin.commands.snykFilterDelta"
name="Delta findings"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaHandler">
id="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues"
name="Net New Issues"
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresOpenIssuesHandler">
</command>
<command
id="io.snyk.eclipse.plugin.commands.snykHideIgnored"
name="Hide Ignored">
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaOpenIssuesHandler"
id="io.snyk.eclipse.plugin.commands.snykHideIgnored"
name="Open Issues">
</command>
<command
id="io.snyk.eclipse.plugin.commands.snykShowIgnored"
name="Show Ignored">
defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresIgnoredIssuesHandler"
id="io.snyk.eclipse.plugin.commands.snykShowIgnored"
name="Ignored Issues">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
Expand Down Expand Up @@ -214,7 +231,7 @@
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.snykEmptyScanResults"
icon="platform:/plugin/org.eclipse.ui/icons/full/elcl16/trash.png"
icon="platform:/plugin/org.eclipse.ui.console/icons/full/clcl16/clear_co.png"
style="push"
tooltip="Empty Scan Results Cache">
</command>
Expand Down Expand Up @@ -247,73 +264,49 @@
style="push"
tooltip="Low Severity">
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterDelta"
icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/elcl16/exclusion_filter_attrib.png"
style="push"
tooltip="Delta findings">
</command>
<!-- Add a separator -->
<separator
name="FilterSeparator"
name="io.snyk.eclipse.plugin.filter"
visible="true">
</separator>
<!-- Add a separator -->
</menuContribution>
<menuContribution
allPopups="false"
locationURI="menu:io.snyk.eclipse.plugin.views.snyktoolview">
<command
commandId="io.snyk.eclipse.plugin.properties.preferencespage"
icon="platform:/plugin/org.eclipse.jdt.debug.ui/icons/full/elcl16/thread_view.gif"
style="push"
tooltip="Open Snyk Preferences">
</command>
<separator
name="io.snyk.eclipse.plugin.filter"
visible="true">
</separator>
<!-- Add a separator -->
<separator
name="RunScanSeparator"
visible="true">
</separator>
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterCritical"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-critical.png"
style="push"
tooltip="Critical Severity">
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterHigh"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-high.png"
style="push"
tooltip="High Severity">
</menuContribution>
<menuContribution
allPopups="false"
locationURI="menu:io.snyk.eclipse.plugin.views.snyktoolview">
<menu id="io.snyk.eclipse.plugin.views.snyktoolview.filterProductTypeMenu"
label="Filter Product Type">
<command
commandId="io.snyk.eclipse.plugin.commands.enableOSS"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/oss.png"
style="push"
tooltip="Enable/disable OSS scans">
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterMedium"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-medium.png"
style="push"
tooltip="Medium Severity">
commandId="io.snyk.eclipse.plugin.commands.enableCodeSecurity"
icon="icons/code.png"
style="push"
tooltip="Enable/disable Code scans">
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterLow"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/severity-low.png"
style="push"
tooltip="Low Severity">
<command
commandId="io.snyk.eclipse.plugin.commands.enableCodeQuality"
icon="icons/code.png"
style="push"
tooltip="Enable/disable Code scans">
</command>
<!-- Add a separator -->
<separator
name="FilterSeparator"
visible="true">
</separator>
<!-- Add a separator -->
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterDelta"
icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/elcl16/exclusion_filter_attrib.png"
commandId="io.snyk.eclipse.plugin.commands.enableIAC"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/iac.png"
style="push"
tooltip="Delta findings">
tooltip="Enable/disable IAC scans">
</command>
</menu>
<menu id="io.snyk.eclipse.plugin.views.snyktoolview.filterIgnoreMenu"
label="Filter Ignores">
<command
commandId="io.snyk.eclipse.plugin.commands.snykHideIgnored"
icon="platform:/plugin/org.eclipse.jdt.ui/icons/full/elcl16/hide_ignored.png"
Expand All @@ -326,28 +319,20 @@
style="push"
tooltip="Show Ignored">
</command>
<separator
name="ProductChooserSeparator"
visible="true">
</separator>
<command
commandId="io.snyk.eclipse.plugin.commands.enableOSS"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/oss.png"
style="push"
tooltip="Enable/disable OSS scans">
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.enableCode"
icon="icons/code.png"
style="push"
tooltip="Enable/disable Code scans">
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.enableIAC"
icon="platform:/plugin/io.snyk.eclipse.plugin/icons/iac.png"
style="push"
tooltip="Enable/disable IAC scans">
</command>
</menu>
<menu id="io.snyk.eclipse.plugin.views.snyktoolview.filterDeltaMenu"
label="Filter Net New Issues">
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterAllIssues"
style="push"
tooltip="Show All Issues">
</command>
<command
commandId="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues"
style="push"
tooltip="Show Only Net New Issues">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="popup:io.snyk.eclipse.plugin.views.snyktoolview#PopupTreeMenu">
Expand Down Expand Up @@ -513,15 +498,11 @@
</extension>
<extension point="org.eclipse.ui.handlers">
<handler
class="io.snyk.eclipse.plugin.views.snyktoolview.providers.ViewMenuHandler"
commandId="io.snyk.eclipse.plugin.commands.viewmenu">
</handler>
<handler
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.ShowIgnoredHandler"
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresIgnoredIssuesHandler"
commandId="io.snyk.eclipse.plugin.commands.snykShowIgnored">
</handler>
<handler
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.HideIgnoredHandler"
class="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaOpenIssuesHandler"
commandId="io.snyk.eclipse.plugin.commands.snykHideIgnored">
</handler>
</extension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public static synchronized Preferences getInstance(PreferenceStore store) {
public static final String FILTER_HIGH = "FILTER_SNYK_HIGH";
public static final String FILTER_MEDIUM = "FILTER_SNYK_MEDIUM";
public static final String FILTER_LOW = "FILTER_SNYK_LOW";
public static final String FILTER_DELTA = "FILTER_SNYK_DELTA";
public static final String FILTER_DELTA_OPEN_ISSUES = "FILTER_SNYK_OPEN_ISSUES";
public static final String FILTER_DELTA_ALL_ISSUES = "FILTER_SNYK_ALL_ISSUES";
public static final String FILTER_IGNORES_OPEN_ISSUES = "FILTER_IGNORES_OPEN_ISSUES";
public static final String FILTER_IGNORES_IGNORED_ISSUES = "FILTER_IGNORES_IGNORED_ISSUES";

// This is a bit confusing - CLI takes DISABLE as env variable, but we ask for
// ENABLE, so we need to revert it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

public interface ISnykToolView {
abstract void setNodeText(TreeNode node, String text);

abstract void setNodeIcon(ImageDescriptor icon);

abstract void addIssueNode(TreeNode parent, TreeNode toBeAdded);

abstract void addFileNode(TreeNode parent, TreeNode toBeAdded);

abstract void addInfoNode(TreeNode parent, TreeNode toBeAdded);

abstract TreeNode getProductNode(String product);

abstract TreeNode getRoot();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@ public class RootNode extends TreeNode {

public RootNode() {
super("");

ossRootNode = new TreeNode(OPEN_SOURCE);
codeSecurityRootNode = new TreeNode(CODE_SECURITY);
codeQualityRootNode = new TreeNode(CODE_QUALITY);
iacRootNode = new TreeNode(CONFIGURATION);

TreeNode[] children = new TreeNode[] {
ossRootNode,
codeSecurityRootNode,
codeQualityRootNode,
iacRootNode,
};

TreeNode[] children = new TreeNode[] { ossRootNode, codeSecurityRootNode, codeQualityRootNode, iacRootNode, };
setChildren(children);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.menus.UIElement;

import io.snyk.eclipse.plugin.Activator;
import io.snyk.eclipse.plugin.properties.preferences.Preferences;

public class BaseHandler extends AbstractHandler implements IElementUpdater {

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

String preference = Preferences.getInstance().getPref(preferenceKey);
boolean bool = Boolean.parseBoolean(preference);

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

} else {

element.setIcon(iconEnabled);
Preferences.getInstance().store(preferenceKey, "true");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

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

public class ShowIgnoredHandler extends AbstractHandler {
public class ClearCacheHandler extends AbstractHandler {

public ClearCacheHandler() {
super();

}

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Expand All @@ -20,4 +25,4 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
return null;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.snyk.eclipse.plugin.views.snyktoolview.handlers;

import org.eclipse.ui.commands.IElementUpdater;

import io.snyk.eclipse.plugin.Activator;
import io.snyk.eclipse.plugin.properties.preferences.Preferences;

public class EnableCodeQualityProductHandler extends BaseHandler implements IElementUpdater {

public EnableCodeQualityProductHandler() {
super();
// TODO should we replace the filter button with a filter applied button icon?
iconEnabled = Activator.getImageDescriptor("/icons/oss.png");
iconDisabled = Activator.getImageDescriptor("/icons/oss_disabled.png");
preferenceKey = Preferences.ACTIVATE_SNYK_OPEN_SOURCE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import io.snyk.eclipse.plugin.Activator;
import io.snyk.eclipse.plugin.properties.preferences.Preferences;

public class EnableCodeProductHandler extends BaseHandler implements IElementUpdater {
public class EnableCodeSecurityProductHandler extends BaseHandler implements IElementUpdater {

public EnableCodeProductHandler() {
public EnableCodeSecurityProductHandler() {
super();
// TODO should we replace the filter button with a filter applied button icon?
iconEnabled = Activator.getImageDescriptor("/icons/code.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.snyk.eclipse.plugin.properties.preferences.Preferences;

public class FilterCriticalHandler extends BaseHandler implements IElementUpdater {

public FilterCriticalHandler() {
super();
// TODO should we replace the filter button with a filter applied button icon?
Expand Down
Loading

0 comments on commit e17fecf

Please sign in to comment.