1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.eclipse.common.util;
17
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.core.runtime.Plugin;
20 import org.eclipse.core.runtime.Status;
21
22 public class StatusUtil {
23
24 public static IStatus create(Plugin plugin, int severity, int code,
25 String message, Throwable throwable) {
26 return new Status(severity, plugin.getBundle().getSymbolicName(), code,
27 message, throwable);
28 }
29
30 public static IStatus createError(Plugin plugin, int code,
31 Throwable throwable) {
32 String message = throwable.getMessage();
33 if (message == null) {
34 message = throwable.getClass().getName();
35 }
36 return create(plugin, IStatus.ERROR, code, message, throwable);
37 }
38
39 public static IStatus createError(Plugin plugin, int code, String message,
40 Throwable throwable) {
41 return create(plugin, IStatus.ERROR, code, message, throwable);
42 }
43
44 public static IStatus createWarning(Plugin plugin, int code,
45 String message, Throwable throwable) {
46 return create(plugin, IStatus.WARNING, code, message, throwable);
47 }
48
49 public static IStatus createInfo(Plugin plugin, int code, String message,
50 Throwable throwable) {
51 return create(plugin, IStatus.INFO, code, message, throwable);
52 }
53
54 public static boolean isError(IStatus status) {
55 return status.getSeverity() == IStatus.ERROR
56 || status.getSeverity() == IStatus.WARNING;
57 }
58
59 }