1 package winterwell.markdown.commands;
3 import org.eclipse.core.commands.AbstractHandler;
4 import org.eclipse.core.commands.ExecutionEvent;
5 import org.eclipse.core.commands.ExecutionException;
6 import org.eclipse.jface.dialogs.MessageDialog;
7 import org.eclipse.swt.widgets.Display;
8 import org.eclipse.ui.IViewPart;
9 import org.eclipse.ui.IWorkbenchPage;
10 import org.eclipse.ui.PartInitException;
11 import org.eclipse.ui.PlatformUI;
13 import winterwell.markdown.LogUtil;
15 public class OpenGfmView extends AbstractHandler {
18 public Object execute(final ExecutionEvent event) throws ExecutionException {
20 IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
21 String gfmViewId = "code.satyagraha.gfm.viewer.views.GfmView";
22 IViewPart gfmView = activePage.showView(gfmViewId);
23 activePage.activate(gfmView);
24 } catch (PartInitException e) {
26 } catch (Exception e) {
32 private void showError(Exception e) {
33 String title = "Exception while opening GitHub Flavored Markdown View";
34 String message = title+" (code.satyagraha.gfm.viewer.views.GfmView)"
35 +"\nCheck Error Log View and continue at https://github.com/winterstein/Eclipse-Markdown-Editor-Plugin/issues/42"
36 +"\n\nYou can also right-click file in Project Explorer"
37 +"\n and select \"Show in GFM view\".";
38 LogUtil.error(message, e);
39 MessageDialog.openError(Display.getDefault().getActiveShell(), title , message);