krysalis-version/src/java/org/krysalis/version/eclipse/plugin/error PluginErrorHandler.java,1.1,1.2
[email protected] Thu, 27 Mar 2003 15:17:51 -0800
| Newsgroups | gmane.comp.krysalis.sandbox |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/eclipse/plugin/error
In directory sc8-pr-cvs1:/tmp/cvs-serv31680/src/java/org/krysalis/version/eclipse/plugin/error
Modified Files:
PluginErrorHandler.java
Log Message:
Tryign to log into the Eclipse plugin log -- when inside Eclipse...
Index: PluginErrorHandler.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/eclipse/plugin/error/PluginErrorHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PluginErrorHandler.java 17 Mar 2003 16:07:01 -0000 1.1
--- PluginErrorHandler.java 27 Mar 2003 23:17:49 -0000 1.2
***************
*** 13,17 ****
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
! import org.krysalis.version.eclipse.plugin.log.PluginLogger;
/**
--- 13,18 ----
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
! import org.krysalis.version.util.logging.LogHandle;
! import org.krysalis.version.util.logging.LogHandleFactory;
/**
***************
*** 19,163 ****
*
*/
! public class PluginErrorHandler implements ErrorHandler
! {
! private Plugin m_plugin = null;
! private PluginLogger m_logger = null;
!
! private static final String ERROR_TITLE = "Error";
! private static final String CORE_ERROR_TITLE = "CoreError";
! /**
! * Constructor for PluginErrorHandler.
! */
! public PluginErrorHandler(Plugin plugin)
! {
! super();
!
! m_plugin = plugin;
! m_logger = new PluginLogger(m_plugin);
! }
! /**
! * Reports an exception to the user by displaying and logging
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void handleExceptionMessage(Throwable e, String msg)
! {
! m_logger.log(e, msg);
! displayException(e, msg);
! }
! /**
! * Reports an exception to the user by displaying and logging
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void handleErrorMessage(String msg)
! {
! m_logger.error(msg);
! displayError(msg);
! }
! /**
! * Displays an error to the user
! *
! * @param msg The message to display
! */
! public void displayError(String msg)
! {
! Shell shell = new Shell();
! // Create an error message
! String title = ERROR_TITLE;
! MessageDialog.openError(shell, title, msg);
! }
! /**
! * Displays an exception to the user
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void displayException(Throwable e, String msg)
! {
! if (e instanceof CoreException)
! {
! displayCoreExceptionMessage((CoreException) e, msg);
! }
! else
! {
! displayExceptionMessage(e, msg);
! }
! }
! /**
! * Displays an exception to the user
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void displayExceptionMessage(Throwable e, String msg)
! {
! Shell shell = new Shell();
! // Create an error message
! String title = ERROR_TITLE;
! MessageDialog.openError(shell, title, msg);
! }
! /**
! * Displays a <code>CoreException</code> to the user
! *
! * @param e The exception
! */
! static public void displayCoreExceptionMessage(CoreException e, String msg)
! {
! Shell shell = new Shell();
! // Create an error message
! String title = CORE_ERROR_TITLE;
! String dispMsg = msg + "\n\n" + e.getMessage();
! // If there was a CoreException, show the appropriate dialog
! IStatus status = e.getStatus();
! if (status != null)
! {
! switch (status.getSeverity())
! {
! case IStatus.INFO :
! MessageDialog.openInformation(shell, title, dispMsg);
! break;
! case IStatus.WARNING :
! MessageDialog.openWarning(shell, title, dispMsg);
! break;
! default :
! MessageDialog.openError(shell, title, dispMsg);
! }
! }
! else
! {
! // Everything else is an error
! MessageDialog.openError(shell, title, dispMsg);
! }
! }
! public static void main(String[] args)
! {
! }
}
/*
--- 20,155 ----
*
*/
! public class PluginErrorHandler implements ErrorHandler {
! private Plugin m_plugin = null;
! private LogHandle m_logger = null;
! private static final String ERROR_TITLE = "Error";
! private static final String CORE_ERROR_TITLE = "CoreError";
! /**
! * Constructor for PluginErrorHandler.
! */
! public PluginErrorHandler(Plugin plugin) {
! super();
! m_plugin = plugin;
! m_logger =
! LogHandleFactory.getLogHandle(
! m_plugin.getDescriptor().getUniqueIdentifier(),
! m_plugin);
! }
! /**
! * Reports an exception to the user by displaying and logging
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void handleExceptionMessage(Throwable e, String msg) {
! m_logger.error(msg, e);
! displayException(e, msg);
! }
! /**
! * Reports an exception to the user by displaying and logging
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void handleErrorMessage(String msg) {
! m_logger.error(msg);
! displayError(msg);
! }
! /**
! * Displays an error to the user
! *
! * @param msg The message to display
! */
! public void displayError(String msg) {
! Shell shell = new Shell();
! // Create an error message
! String title = ERROR_TITLE;
! MessageDialog.openError(shell, title, msg);
! }
! /**
! * Displays an exception to the user
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void displayException(Throwable e, String msg) {
! if (e instanceof CoreException) {
! displayCoreExceptionMessage((CoreException) e, msg);
! }
! else {
! displayExceptionMessage(e, msg);
! }
! }
! /**
! * Displays an exception to the user
! *
! * @param e The exception
! * @param msg The message to display
! */
! public void displayExceptionMessage(Throwable e, String msg) {
! Shell shell = new Shell();
! // Create an error message
! String title = ERROR_TITLE;
! MessageDialog.openError(shell, title, msg);
! }
! /**
! * Displays a <code>CoreException</code> to the user
! *
! * @param e The exception
! */
! static public void displayCoreExceptionMessage(
! CoreException e,
! String msg) {
! Shell shell = new Shell();
! // Create an error message
! String title = CORE_ERROR_TITLE;
! String dispMsg = msg + "\n\n" + e.getMessage();
! // If there was a CoreException, show the appropriate dialog
! IStatus status = e.getStatus();
! if (status != null) {
! switch (status.getSeverity()) {
! case IStatus.INFO :
! MessageDialog.openInformation(shell, title, dispMsg);
! break;
! case IStatus.WARNING :
! MessageDialog.openWarning(shell, title, dispMsg);
! break;
!
! default :
! MessageDialog.openError(shell, title, dispMsg);
! }
! }
! else {
! // Everything else is an error
! MessageDialog.openError(shell, title, dispMsg);
! }
! }
!
! public static void main(String[] args) {
! }
}
/*
-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en