11package io .snyk .eclipse .plugin .views .snyktoolview .handlers ;
22
3- import java .util .Map ;
4-
5- import org .eclipse .core .commands .AbstractHandler ;
6- import org .eclipse .core .commands .ExecutionEvent ;
7- import org .eclipse .core .commands .ExecutionException ;
8- import org .eclipse .jface .resource .ImageDescriptor ;
9- import org .eclipse .ui .PlatformUI ;
10- import org .eclipse .ui .commands .ICommandService ;
113import org .eclipse .ui .commands .IElementUpdater ;
12- import org .eclipse .ui .menus .UIElement ;
134
145import io .snyk .eclipse .plugin .Activator ;
156import io .snyk .eclipse .plugin .properties .preferences .Preferences ;
167
17- public class FilterDeltaHandler extends AbstractHandler implements IElementUpdater {
18-
19- // TODO should we replace the filter button with a filter applied button icon?
20- protected static ImageDescriptor FILTER_ENABLE = Activator .getImageDescriptor ("/icons/severity-medium.png" );
21- protected static ImageDescriptor FILTER_DISABLE = Activator .getImageDescriptor ("/icons/oss_disabled.png" );
22- protected static String FILTER = Preferences .FILTER_DELTA ;
23-
24- @ Override
25- public Object execute (ExecutionEvent event ) throws ExecutionException {
26- String commandId = event .getCommand ().getId ();
8+ public class FilterDeltaHandler extends BaseHandler implements IElementUpdater {
279
28- ICommandService commandService = PlatformUI .getWorkbench ().getService (ICommandService .class );
29- if (commandService != null ) {
30- commandService .refreshElements (commandId , null );
31- }
32-
33- return null ;
10+ public FilterDeltaHandler () {
11+ super ();
12+ // TODO should we replace the filter button with a filter applied button icon?
13+ // TODO update to the actual Delta findings icons, if needed.
14+ iconEnabled = Activator .getImageDescriptor ("/icons/code.png" );
15+ iconDisabled = Activator .getImageDescriptor ("/icons/code_disabled.png" );
16+ preferenceKey = Preferences .FILTER_DELTA ;
3417 }
3518
36- @ Override
37- public void updateElement (UIElement element , @ SuppressWarnings ("rawtypes" ) Map map ) {
38-
39- String preference = Preferences .getInstance ().getPref (FILTER );
40-
41- // Toggle the value, if it was true, it should be set to false
42- if (Boolean .parseBoolean (preference )) {
43- // element.setIcon(FILTER_DISABLE);
44- Preferences .getInstance ().store (FILTER , "false" );
45-
46- } else {
47-
48- // element.setIcon(FILTER_ENABLE);
49- Preferences .getInstance ().store (FILTER , "true" );
50-
51- }
52-
53- }
5419}
0 commit comments