Skip to content

Commit a13b160

Browse files
committed
fix: refactor collapse tree handler
1 parent 1029446 commit a13b160

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

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

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@
33
import org.eclipse.core.commands.AbstractHandler;
44
import org.eclipse.core.commands.ExecutionEvent;
55
import org.eclipse.core.commands.ExecutionException;
6-
import org.eclipse.swt.widgets.Shell;
7-
import org.eclipse.ui.IWorkbenchPage;
8-
import org.eclipse.ui.PartInitException;
9-
import org.eclipse.ui.PlatformUI;
106

11-
import io.snyk.eclipse.plugin.utils.SnykLogger;
12-
import io.snyk.eclipse.plugin.utils.SnykMessageDialog;
13-
import io.snyk.eclipse.plugin.views.snyktoolview.ISnykToolView;
14-
import io.snyk.eclipse.plugin.views.snyktoolview.SnykToolView;
7+
import io.snyk.eclipse.plugin.SnykStartup;
158

169
public class CollapseTreeHandler extends AbstractHandler {
1710

@@ -22,27 +15,13 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
2215

2316
switch (commandId) {
2417
case "io.snyk.eclipse.plugin.commands.TreeCollapse":
25-
getView().getTreeViewer().collapseAll();
18+
SnykStartup.getView().getTreeViewer().collapseAll();
2619
break;
2720
case "io.snyk.eclipse.plugin.commands.TreeExpand":
28-
getView().getTreeViewer().expandAll();
21+
SnykStartup.getView().getTreeViewer().expandAll();
2922
break;
3023
}
3124

3225
return null;
3326
}
34-
35-
public ISnykToolView getView() {
36-
37-
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
38-
ISnykToolView toolView;
39-
try {
40-
toolView = (ISnykToolView) activePage.showView(SnykToolView.ID);
41-
} catch (PartInitException e) {
42-
SnykLogger.logError(e);
43-
return null;
44-
}
45-
return toolView;
46-
47-
}
4827
}

0 commit comments

Comments
 (0)