-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added handlers for each severity
- Loading branch information
Showing
7 changed files
with
272 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...c/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterCriticalHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.handlers; | ||
|
||
import java.util.Map; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.commands.ICommandService; | ||
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 FilterCriticalHandler extends AbstractHandler implements IElementUpdater { | ||
|
||
//TODO should we replace the filter button with a filter applied button icon? | ||
protected static ImageDescriptor FILTER_ENABLE = Activator.getImageDescriptor("/icons/severity-critical.png"); | ||
protected static ImageDescriptor FILTER_DISABLE = Activator.getImageDescriptor("/icons/oss_disabled.png"); | ||
protected static String FILTER = Preferences.FILTER_CRITICAL; | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
String commandId = event.getCommand().getId(); | ||
|
||
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); | ||
if (commandService != null) { | ||
commandService.refreshElements(commandId, null); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map map) { | ||
|
||
String preference = Preferences.getInstance().getPref(FILTER); | ||
|
||
// Toggle the value, if it was true, it should be set to false | ||
if (Boolean.parseBoolean(preference)) { | ||
// element.setIcon(FILTER_DISABLE); | ||
Preferences.getInstance().store(FILTER, "false"); | ||
|
||
} else { | ||
|
||
// element.setIcon(FILTER_ENABLE); | ||
Preferences.getInstance().store(FILTER, "true"); | ||
|
||
} | ||
|
||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
.../src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterDeltaHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.handlers; | ||
|
||
import java.util.Map; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.commands.ICommandService; | ||
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 FilterDeltaHandler extends AbstractHandler implements IElementUpdater { | ||
|
||
// TODO should we replace the filter button with a filter applied button icon? | ||
protected static ImageDescriptor FILTER_ENABLE = Activator.getImageDescriptor("/icons/severity-medium.png"); | ||
protected static ImageDescriptor FILTER_DISABLE = Activator.getImageDescriptor("/icons/oss_disabled.png"); | ||
protected static String FILTER = Preferences.FILTER_DELTA; | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
String commandId = event.getCommand().getId(); | ||
|
||
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); | ||
if (commandService != null) { | ||
commandService.refreshElements(commandId, null); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map map) { | ||
|
||
String preference = Preferences.getInstance().getPref(FILTER); | ||
|
||
// Toggle the value, if it was true, it should be set to false | ||
if (Boolean.parseBoolean(preference)) { | ||
// element.setIcon(FILTER_DISABLE); | ||
Preferences.getInstance().store(FILTER, "false"); | ||
|
||
} else { | ||
|
||
// element.setIcon(FILTER_ENABLE); | ||
Preferences.getInstance().store(FILTER, "true"); | ||
|
||
} | ||
|
||
} | ||
} |
65 changes: 0 additions & 65 deletions
65
plugin/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterHandler.java
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
...n/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterHighHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.handlers; | ||
|
||
import java.util.Map; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.commands.ICommandService; | ||
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 FilterHighHandler extends AbstractHandler implements IElementUpdater { | ||
|
||
// TODO should we replace the filter button with a filter applied button icon? | ||
protected static ImageDescriptor FILTER_ENABLE = Activator.getImageDescriptor("/icons/severity-high.png"); | ||
protected static ImageDescriptor FILTER_DISABLE = Activator | ||
.getImageDescriptor("platform:/plugin/org.eclipse.ui/icons/full/etool16/delete_edit.png"); | ||
protected static String FILTER = Preferences.FILTER_HIGH; | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
String commandId = event.getCommand().getId(); | ||
|
||
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); | ||
if (commandService != null) { | ||
commandService.refreshElements(commandId, null); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map map) { | ||
|
||
String preference = Preferences.getInstance().getPref(FILTER); | ||
|
||
// Toggle the value, if it was true, it should be set to false | ||
if (Boolean.parseBoolean(preference)) { | ||
element.setIcon(FILTER_DISABLE); | ||
Preferences.getInstance().store(FILTER, "false"); | ||
|
||
} else { | ||
|
||
element.setIcon(FILTER_ENABLE); | ||
Preferences.getInstance().store(FILTER, "true"); | ||
|
||
} | ||
|
||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...in/src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterLowHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.handlers; | ||
|
||
import java.util.Map; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.commands.ICommandService; | ||
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 FilterLowHandler extends AbstractHandler implements IElementUpdater { | ||
|
||
// TODO should we replace the filter button with a filter applied button icon? | ||
protected static ImageDescriptor FILTER_ENABLE = Activator.getImageDescriptor("/icons/severity-low.png"); | ||
protected static ImageDescriptor FILTER_DISABLE = Activator.getImageDescriptor("/icons/oss_disabled.png"); | ||
protected static String FILTER = Preferences.FILTER_LOW; | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
String commandId = event.getCommand().getId(); | ||
|
||
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); | ||
if (commandService != null) { | ||
commandService.refreshElements(commandId, null); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map map) { | ||
|
||
String preference = Preferences.getInstance().getPref(FILTER); | ||
|
||
// Toggle the value, if it was true, it should be set to false | ||
if (Boolean.parseBoolean(preference)) { | ||
// element.setIcon(FILTER_DISABLE); | ||
Preferences.getInstance().store(FILTER, "false"); | ||
|
||
} else { | ||
|
||
// element.setIcon(FILTER_ENABLE); | ||
Preferences.getInstance().store(FILTER, "true"); | ||
|
||
} | ||
|
||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...src/main/java/io/snyk/eclipse/plugin/views/snyktoolview/handlers/FilterMediumHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.snyk.eclipse.plugin.views.snyktoolview.handlers; | ||
|
||
import java.util.Map; | ||
|
||
import org.eclipse.core.commands.AbstractHandler; | ||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.commands.ExecutionException; | ||
import org.eclipse.jface.resource.ImageDescriptor; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.commands.ICommandService; | ||
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 FilterMediumHandler extends AbstractHandler implements IElementUpdater { | ||
|
||
// TODO should we replace the filter button with a filter applied button icon? | ||
protected static ImageDescriptor FILTER_ENABLE = Activator.getImageDescriptor("/icons/severity-medium.png"); | ||
protected static ImageDescriptor FILTER_DISABLE = Activator.getImageDescriptor("/icons/oss_disabled.png"); | ||
protected static String FILTER = Preferences.FILTER_MEDIUM; | ||
|
||
@Override | ||
public Object execute(ExecutionEvent event) throws ExecutionException { | ||
String commandId = event.getCommand().getId(); | ||
|
||
ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class); | ||
if (commandService != null) { | ||
commandService.refreshElements(commandId, null); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map map) { | ||
|
||
String preference = Preferences.getInstance().getPref(FILTER); | ||
|
||
// Toggle the value, if it was true, it should be set to false | ||
if (Boolean.parseBoolean(preference)) { | ||
// element.setIcon(FILTER_DISABLE); | ||
Preferences.getInstance().store(FILTER, "false"); | ||
|
||
} else { | ||
|
||
// element.setIcon(FILTER_ENABLE); | ||
Preferences.getInstance().store(FILTER, "true"); | ||
|
||
} | ||
|
||
} | ||
} |