added first version of codetemplates (needs to fix some bugs)
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / PHPUIStatus.java
1 /*
2  * (c) Copyright IBM Corp. 2000, 2001.
3  * All Rights Reserved.
4  */
5 package net.sourceforge.phpdt.internal.ui;
6
7 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
8
9 import org.eclipse.core.runtime.IStatus;
10 import org.eclipse.core.runtime.Status;
11
12 /**
13  * Convenience class for error exceptions thrown inside PHPeclipse plugin.
14  */
15 public class PHPUIStatus extends Status {
16
17   public PHPUIStatus(int code) {
18     this(code, ""); //$NON-NLS-1$
19   }
20
21   private PHPUIStatus(int severity, int code, String message, Throwable throwable) {
22     super(severity, PHPeclipsePlugin.getPluginId(), code, message, throwable);
23   }
24
25   public PHPUIStatus(int code, String message) {
26     this(code, message, null);
27   }
28
29   public PHPUIStatus(int code, String message, Throwable throwable) {
30     super(IStatus.ERROR, PHPeclipsePlugin.getPluginId(), code, message, throwable);
31   }
32   
33   public static IStatus createError(int code, Throwable throwable) {
34         String message= throwable.getMessage();
35         if (message == null) {
36                 message= throwable.getClass().getName();
37         }
38         return new PHPUIStatus(IStatus.ERROR, code, message, throwable);
39   }
40   
41   public static IStatus createError(int code, String message, Throwable throwable) {
42     return new PHPUIStatus(IStatus.ERROR, code, message, throwable);
43   }
44
45   public static IStatus createInfo(int code, String message, Throwable throwable) {
46     return new PHPUIStatus(IStatus.INFO, code, message, throwable);
47   }
48
49   public static IStatus createWarning(int code, String message, Throwable throwable) {
50     return new PHPUIStatus(IStatus.WARNING, code, message, throwable);
51   }
52 }