| 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 | 0 | public class StatusUtil { |
| 23 | |
|
| 24 | |
public static IStatus create(Plugin plugin, int severity, int code, |
| 25 | |
String message, Throwable throwable) { |
| 26 | 0 | 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 | 0 | String message = throwable.getMessage(); |
| 33 | 0 | if (message == null) { |
| 34 | 0 | message = throwable.getClass().getName(); |
| 35 | |
} |
| 36 | 0 | 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 | 0 | 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 | 0 | 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 | 0 | return create(plugin, IStatus.INFO, code, message, throwable); |
| 52 | |
} |
| 53 | |
|
| 54 | |
public static boolean isError(IStatus status) { |
| 55 | 0 | return status.getSeverity() == IStatus.ERROR |
| 56 | |
|| status.getSeverity() == IStatus.WARNING; |
| 57 | |
} |
| 58 | |
|
| 59 | |
} |