X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.common%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fcommon%2FErrorLogger.java;h=48dc926430cdd7255e4ff1b10f4bc08d93797fe6;hb=6062acdd3d35054d260b1c9c4abcf00700ea01e8;hp=b398feebb41bd954ada862e9dc8a929d4c0b279f;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/ErrorLogger.java b/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/ErrorLogger.java
index b398feebb..48dc92643 100644
--- a/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/ErrorLogger.java
+++ b/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/ErrorLogger.java
@@ -1,166 +1,166 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
- * in Industry THTH ry.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * VTT Technical Research Centre of Finland - initial API and implementation
- *******************************************************************************/
-package org.simantics.browsing.ui.common;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.simantics.db.layer0.exception.InvalidVariableException;
-
-
-/**
- * ErrorLogger sends error messages to "Error log" view.
- *
- * @author Toni Kalajainen
- */
-public class ErrorLogger {
-
- public static final boolean ECHO = true;
-
- private final Plugin plugin;
- private String pluginID;
-
- public ErrorLogger(Plugin plugin) {
- this.plugin = plugin;
- }
-
- private String getPluginID() {
- if (pluginID==null)
- pluginID = plugin.getBundle().getSymbolicName();
- return pluginID;
- }
-
- /**
- * Log a warning event.
- *
- * @param message message of the error
- * @param exception the exception, or null
- */
- public void logWarning(String message, Throwable exception) {
- log(IStatus.WARNING, IStatus.OK, message, exception);
- }
-
- /**
- * Log a message.
- *
- * @param message message of the error
- * @param exception the exception, or null
- */
- public void logMessage(String message, Throwable exception) {
- log(IStatus.INFO, IStatus.OK, message, exception);
- }
-
- /**
- * Log an error event.
- *
- * @param message message of the error
- * @param exception the exception, or null
- */
- public void logError(String message, Throwable exception) {
- // Errors are much more useful with a stack trace!
- if (exception == null) {
- exception = new RuntimeException();
- }
- log(IStatus.ERROR, IStatus.OK, message, exception);
- }
-
- public void log(int severity, int code, String message, Throwable exception) {
- IStatus status = new Status(severity, getPluginID(), code, message, exception);
- log(status);
- }
-
- public void log(IStatus status) {
- plugin.getLog().log(status);
- }
-
- public static ErrorLogger getDefault() {
- return Activator.getDefault().getErrorLogger();
- }
-
- public static void defaultLogError(String message, Throwable exception) {
- if (filterException(exception))
- return;
- getDefault().logError(message, exception);
- if(ECHO && exception != null) exception.printStackTrace();
- }
-
- public static void defaultLogError(Throwable exception) {
- if (filterException(exception))
- return;
- getDefault().logError(getUIFriendErrorMessage(exception), exception);
- if(ECHO && exception != null) exception.printStackTrace();
- }
-
- public static void defaultLogWarning(String message, Throwable exception) {
- if (filterException(exception))
- return;
- getDefault().logWarning(message, exception);
- if(ECHO && exception != null) exception.printStackTrace();
- }
-
- public static void defaultLogWarning(Throwable exception) {
- if (filterException(exception))
- return;
- getDefault().logWarning(getUIFriendErrorMessage(exception), exception);
- if(ECHO && exception != null) exception.printStackTrace();
- }
-
- public static void defaultLog(IStatus status) {
- getDefault().log(status);
- if(ECHO) System.out.println(status);
- }
-
- /**
- * This call makes verbose error message that is suitable for
- * UI Dialgos. The full cause hierarchy is shown with the tree.
- * In this case verbose includes class names.
- *
- * @param e exception
- * @return message
- */
- public static String getUIFriendErrorMessageVerbose(Throwable e) {
- String result = "";
- Throwable pe = null;
- while (e!=null && pe!=e) {
- result += e.getClass().getName()+": "+e.getMessage()+"\n";
- pe = e;
- e = e.getCause();
- }
- return result;
- }
-
- /**
- * This call makes error message that is suitable for
- * UI Dialogs. The full cause hierarchy is shown with the tree.
- * In this case verbose includes class names.
- *
- * @param e exception
- * @return message
- */
- public static String getUIFriendErrorMessage(Throwable e) {
- String result = "";
- Throwable pe = null;
- while (e!=null && pe!=e) {
- result += e.getMessage()+"\n";
- pe = e;
- e = e.getCause();
- }
- return result;
- }
-
- public static boolean filterException(Throwable t) {
- if (t instanceof InvalidVariableException)
- return true;
- return false;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui.common;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.simantics.db.layer0.exception.InvalidVariableException;
+
+
+/**
+ * ErrorLogger sends error messages to "Error log" view.
+ *
+ * @author Toni Kalajainen
+ */
+public class ErrorLogger {
+
+ public static final boolean ECHO = true;
+
+ private final Plugin plugin;
+ private String pluginID;
+
+ public ErrorLogger(Plugin plugin) {
+ this.plugin = plugin;
+ }
+
+ private String getPluginID() {
+ if (pluginID==null)
+ pluginID = plugin.getBundle().getSymbolicName();
+ return pluginID;
+ }
+
+ /**
+ * Log a warning event.
+ *
+ * @param message message of the error
+ * @param exception the exception, or null
+ */
+ public void logWarning(String message, Throwable exception) {
+ log(IStatus.WARNING, IStatus.OK, message, exception);
+ }
+
+ /**
+ * Log a message.
+ *
+ * @param message message of the error
+ * @param exception the exception, or null
+ */
+ public void logMessage(String message, Throwable exception) {
+ log(IStatus.INFO, IStatus.OK, message, exception);
+ }
+
+ /**
+ * Log an error event.
+ *
+ * @param message message of the error
+ * @param exception the exception, or null
+ */
+ public void logError(String message, Throwable exception) {
+ // Errors are much more useful with a stack trace!
+ if (exception == null) {
+ exception = new RuntimeException();
+ }
+ log(IStatus.ERROR, IStatus.OK, message, exception);
+ }
+
+ public void log(int severity, int code, String message, Throwable exception) {
+ IStatus status = new Status(severity, getPluginID(), code, message, exception);
+ log(status);
+ }
+
+ public void log(IStatus status) {
+ plugin.getLog().log(status);
+ }
+
+ public static ErrorLogger getDefault() {
+ return Activator.getDefault().getErrorLogger();
+ }
+
+ public static void defaultLogError(String message, Throwable exception) {
+ if (filterException(exception))
+ return;
+ getDefault().logError(message, exception);
+ if(ECHO && exception != null) exception.printStackTrace();
+ }
+
+ public static void defaultLogError(Throwable exception) {
+ if (filterException(exception))
+ return;
+ getDefault().logError(getUIFriendErrorMessage(exception), exception);
+ if(ECHO && exception != null) exception.printStackTrace();
+ }
+
+ public static void defaultLogWarning(String message, Throwable exception) {
+ if (filterException(exception))
+ return;
+ getDefault().logWarning(message, exception);
+ if(ECHO && exception != null) exception.printStackTrace();
+ }
+
+ public static void defaultLogWarning(Throwable exception) {
+ if (filterException(exception))
+ return;
+ getDefault().logWarning(getUIFriendErrorMessage(exception), exception);
+ if(ECHO && exception != null) exception.printStackTrace();
+ }
+
+ public static void defaultLog(IStatus status) {
+ getDefault().log(status);
+ if(ECHO) System.out.println(status);
+ }
+
+ /**
+ * This call makes verbose error message that is suitable for
+ * UI Dialgos. The full cause hierarchy is shown with the tree.
+ * In this case verbose includes class names.
+ *
+ * @param e exception
+ * @return message
+ */
+ public static String getUIFriendErrorMessageVerbose(Throwable e) {
+ String result = "";
+ Throwable pe = null;
+ while (e!=null && pe!=e) {
+ result += e.getClass().getName()+": "+e.getMessage()+"\n";
+ pe = e;
+ e = e.getCause();
+ }
+ return result;
+ }
+
+ /**
+ * This call makes error message that is suitable for
+ * UI Dialogs. The full cause hierarchy is shown with the tree.
+ * In this case verbose includes class names.
+ *
+ * @param e exception
+ * @return message
+ */
+ public static String getUIFriendErrorMessage(Throwable e) {
+ String result = "";
+ Throwable pe = null;
+ while (e!=null && pe!=e) {
+ result += e.getMessage()+"\n";
+ pe = e;
+ e = e.getCause();
+ }
+ return result;
+ }
+
+ public static boolean filterException(Throwable t) {
+ if (t instanceof InvalidVariableException)
+ return true;
+ return false;
+ }
+
+}