diff --git a/com.github.culmat.eexplorer.plugin/plugin.xml b/com.github.culmat.eexplorer.plugin/plugin.xml index 7646cd5..7ddaa07 100644 --- a/com.github.culmat.eexplorer.plugin/plugin.xml +++ b/com.github.culmat.eexplorer.plugin/plugin.xml @@ -1,118 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.github.culmat.eexplorer.plugin/src/com/github/culmat/eexplorer/LogUtil.java b/com.github.culmat.eexplorer.plugin/src/com/github/culmat/eexplorer/LogUtil.java new file mode 100644 index 0000000..29d72fc --- /dev/null +++ b/com.github.culmat.eexplorer.plugin/src/com/github/culmat/eexplorer/LogUtil.java @@ -0,0 +1,41 @@ +package com.github.culmat.eexplorer; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +/** + * Nodeclipse Log Util + * @author Lamb Gao, Paul Verest + */ +public class LogUtil { + + public static void info(String message) { + log(IStatus.INFO, IStatus.OK, message, null); + } + + public static void error(Throwable exception) { + error("Unexpected Exception", exception); + } + + public static void error(String message) { + error(message, null); + } + + public static void error(String message, Throwable exception) { + log(IStatus.ERROR, IStatus.ERROR, message, exception); + } + + public static void log(int severity, int code, String message, Throwable exception) { + log(createStatus(severity, code, message, exception)); + } + + public static IStatus createStatus(int severity, int code, String message, Throwable exception) { + return new Status(severity, Activator.PLUGIN_ID, code, message, exception); + } + + public static void log(IStatus status) { + ILog log = Activator.getDefault().getLog(); + log.log(status); + } +} diff --git a/com.github.culmat.eexplorer.plugin/src/com/github/culmat/eexplorer/commands/OpenExplorerView.java b/com.github.culmat.eexplorer.plugin/src/com/github/culmat/eexplorer/commands/OpenExplorerView.java new file mode 100644 index 0000000..ab8bd39 --- /dev/null +++ b/com.github.culmat.eexplorer.plugin/src/com/github/culmat/eexplorer/commands/OpenExplorerView.java @@ -0,0 +1,40 @@ +package com.github.culmat.eexplorer.commands; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +import com.github.culmat.eexplorer.LogUtil; + + +public class OpenExplorerView extends AbstractHandler { + + @Override + public Object execute(final ExecutionEvent event) throws ExecutionException { + try { + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + String viewId = "com.github.culmat.eexplore.views.ExplorerView"; + IViewPart view = activePage.showView(viewId); + activePage.activate(view); + } catch (PartInitException e) { + showError(e); + } catch (Exception e) { + showError(e); + } + return null; + } + + private void showError(Exception e) { + String title = "Exception while opening GitHub Flavored Markdown View"; + String message = title+" (com.github.culmat.eexplore.views.ExplorerView)" + +"\nCheck Error Log View and continue at https://github.com/culmat/eExplorer"; + LogUtil.error(message, e); + MessageDialog.openError(Display.getDefault().getActiveShell(), title , message); + } +}