diff --git a/plugin/icons/enabled.png b/plugin/icons/enabled.png new file mode 100644 index 0000000..34235bd Binary files /dev/null and b/plugin/icons/enabled.png differ diff --git a/plugin/plugin.xml b/plugin/plugin.xml index bb57aeb..44f0ee2 100644 --- a/plugin/plugin.xml +++ b/plugin/plugin.xml @@ -65,6 +65,16 @@ defaultHandler="io.snyk.eclipse.plugin.views.ScanWorkspaceMenuHandler" id="io.snyk.eclipse.plugin.commands.snykWorkspaceScan" name="%scanWorkspace.name"> + + + + + defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.EnableCodeSecurityProductHandler"> + + + id="io.snyk.eclipse.plugin.commands.snykFilterAllIssues" + name="All Issues" + defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaAllIssuesHandler"> + id="io.snyk.eclipse.plugin.commands.snykFilterNetNewIssues" + name="Net New Issues" + defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresOpenIssuesHandler"> + defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterDeltaOpenIssuesHandler" + id="io.snyk.eclipse.plugin.commands.snykHideIgnored" + name="Open Issues"> + defaultHandler="io.snyk.eclipse.plugin.views.snyktoolview.handlers.FilterIgnoresIgnoredIssuesHandler" + id="io.snyk.eclipse.plugin.commands.snykShowIgnored" + name="Ignored Issues"> @@ -214,7 +231,7 @@ @@ -247,73 +264,49 @@ style="push" tooltip="Low Severity"> - - - - - - - - - - - - - - + + + + + commandId="io.snyk.eclipse.plugin.commands.enableCodeSecurity" + icon="icons/code.png" + style="push" + tooltip="Enable/disable Code scans"> - + - - - - + tooltip="Enable/disable IAC scans"> + + - - - - - - - - + + + + + + + @@ -513,15 +498,11 @@ - - diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/properties/preferences/Preferences.java b/plugin/src/main/java/io/snyk/eclipse/plugin/properties/preferences/Preferences.java index 3773427..f2ff75b 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/properties/preferences/Preferences.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/properties/preferences/Preferences.java @@ -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 diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/ISnykToolView.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/ISnykToolView.java index 656315e..65b2726 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/ISnykToolView.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/ISnykToolView.java @@ -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(); } diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/RootNode.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/RootNode.java index bc72f61..0656bae 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/RootNode.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/RootNode.java @@ -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); } } \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/BaseHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/BaseHandler.java index 32b8908..4606eb8 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/BaseHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/BaseHandler.java @@ -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; @@ -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"); diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ShowIgnoredHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ClearCacheHandler.java similarity index 85% rename from plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ShowIgnoredHandler.java rename to plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ClearCacheHandler.java index 37c315d..4d1dd2a 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ShowIgnoredHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/ClearCacheHandler.java @@ -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 { @@ -20,4 +25,4 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return null; } -} +} \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeQualityProductHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeQualityProductHandler.java new file mode 100644 index 0000000..4cbad78 --- /dev/null +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeQualityProductHandler.java @@ -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; + } + +} \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeProductHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeSecurityProductHandler.java similarity index 78% rename from plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeProductHandler.java rename to plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeSecurityProductHandler.java index 745ab79..a14cbe3 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeProductHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/EnableCodeSecurityProductHandler.java @@ -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"); diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterCriticalHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterCriticalHandler.java index dbaf207..02f14a9 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterCriticalHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterCriticalHandler.java @@ -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? diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaAllIssuesHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaAllIssuesHandler.java new file mode 100644 index 0000000..efa236a --- /dev/null +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaAllIssuesHandler.java @@ -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 FilterDeltaAllIssuesHandler extends BaseHandler implements IElementUpdater { + + public FilterDeltaAllIssuesHandler() { + super(); + + iconEnabled = Activator.getImageDescriptor("/icons/enabled.png"); + // iconDisabled = Activator.getImageDescriptor("/icons/severity-medium.png"); + preferenceKey = Preferences.FILTER_DELTA_ALL_ISSUES; + } + +} \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaHandler.java deleted file mode 100644 index 4b98922..0000000 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -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 FilterDeltaHandler extends BaseHandler implements IElementUpdater { - - public FilterDeltaHandler() { - super(); - // TODO should we replace the filter button with a filter applied button icon? - // TODO update to the actual Delta findings icons, if needed. - iconEnabled = Activator.getImageDescriptor("/icons/code.png"); - iconDisabled = Activator.getImageDescriptor("/icons/code_disabled.png"); - preferenceKey = Preferences.FILTER_DELTA; - } - -} \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaOpenIssuesHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaOpenIssuesHandler.java new file mode 100644 index 0000000..a192367 --- /dev/null +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaOpenIssuesHandler.java @@ -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 FilterDeltaOpenIssuesHandler extends BaseHandler implements IElementUpdater { + + public FilterDeltaOpenIssuesHandler() { + super(); + + iconEnabled = Activator.getImageDescriptor("/icons/enabled.png"); + // iconDisabled = Activator.getImageDescriptor("/icons/severity-medium.png"); + preferenceKey = Preferences.FILTER_DELTA_OPEN_ISSUES; + } + +} diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresIgnoredIssuesHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresIgnoredIssuesHandler.java new file mode 100644 index 0000000..1a99e4a --- /dev/null +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresIgnoredIssuesHandler.java @@ -0,0 +1,17 @@ +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 FilterIgnoresIgnoredIssuesHandler extends BaseHandler implements IElementUpdater { + + public FilterIgnoresIgnoredIssuesHandler() { + super(); + + iconEnabled = Activator.getImageDescriptor("/icons/enabled.png"); + // iconDisabled = Activator.getImageDescriptor("/icons/severity-medium.png"); + preferenceKey = Preferences.FILTER_IGNORES_IGNORED_ISSUES; + } +} \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresOpenIssuesHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresOpenIssuesHandler.java new file mode 100644 index 0000000..9572f64 --- /dev/null +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterIgnoresOpenIssuesHandler.java @@ -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 FilterIgnoresOpenIssuesHandler extends BaseHandler implements IElementUpdater { + + public FilterIgnoresOpenIssuesHandler() { + super(); + + iconEnabled = Activator.getImageDescriptor("/icons/enabled.png"); + // iconDisabled = Activator.getImageDescriptor("/icons/severity-medium.png"); + preferenceKey = Preferences.FILTER_IGNORES_OPEN_ISSUES; + } + +} \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/HideIgnoredHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/StopScanHandler.java similarity index 86% rename from plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/HideIgnoredHandler.java rename to plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/StopScanHandler.java index a29ade6..af658ae 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/HideIgnoredHandler.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/StopScanHandler.java @@ -8,11 +8,15 @@ import io.snyk.eclipse.plugin.utils.SnykMessageDialog; -public class HideIgnoredHandler extends AbstractHandler { +public class StopScanHandler extends AbstractHandler { + + public StopScanHandler() { + super(); + + } @Override public Object execute(ExecutionEvent event) throws ExecutionException { - // TODO Auto-generated method stub String commandId = event.getCommand().getId(); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); @@ -21,4 +25,4 @@ public Object execute(ExecutionEvent event) throws ExecutionException { return null; } -} +} \ No newline at end of file diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/providers/TreeContentProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/providers/TreeContentProvider.java index aa6bb51..901ecca 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/providers/TreeContentProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/providers/TreeContentProvider.java @@ -12,7 +12,7 @@ public Object[] getElements(Object inputElement) { // Return the root elements of your tree // This method is called to get the top-level items if (inputElement instanceof RootNode) { - return ((RootNode) inputElement).getChildren().toArray(); + return ((RootNode) inputElement).getChildren(); } return new Object[0]; } diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/providers/ViewMenuHandler.java b/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/providers/ViewMenuHandler.java deleted file mode 100644 index d9e9566..0000000 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/providers/ViewMenuHandler.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.snyk.eclipse.plugin.views.snyktoolview.providers; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; - -import io.snyk.eclipse.plugin.utils.SnykMessageDialog; - -public class ViewMenuHandler extends AbstractHandler { - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - // TODO Auto-generated method stub - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - SnykMessageDialog.showOkDialog(shell, "Show ViewMenu"); - - return null; - } - -}