1 11 package org.eclipse.ui.internal.progress; 12 13 import java.util.Date ; 14 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.jobs.Job; 17 import org.eclipse.jface.resource.JFaceResources; 18 import org.eclipse.osgi.util.NLS; 19 import org.eclipse.swt.graphics.Image; 20 21 import com.ibm.icu.text.DateFormat; 22 23 26 public class ErrorInfo extends JobTreeElement { 27 28 private final IStatus errorStatus; 29 30 private final Job job; 31 32 private final long timestamp; 33 34 41 public ErrorInfo(IStatus status, Job job) { 42 errorStatus = status; 43 this.job = job; 44 timestamp = System.currentTimeMillis(); 45 } 46 47 52 Object getParent() { 53 return null; 54 } 55 56 61 boolean hasChildren() { 62 return false; 63 } 64 65 70 Object [] getChildren() { 71 return ProgressManagerUtil.EMPTY_OBJECT_ARRAY; 72 } 73 74 79 String getDisplayString() { 80 return NLS.bind(ProgressMessages.JobInfo_Error, (new Object [] { 81 job.getName(), 82 DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG).format(new Date (timestamp)) })); 83 } 84 85 90 Image getImage() { 91 return JFaceResources.getImage(ProgressManager.ERROR_JOB_KEY); 92 } 93 94 99 boolean isJobInfo() { 100 return false; 101 } 102 103 108 IStatus getErrorStatus() { 109 return errorStatus; 110 } 111 112 117 boolean isActive() { 118 return true; 119 } 120 121 126 public Job getJob() { 127 return job; 128 } 129 130 135 public long getTimestamp() { 136 return timestamp; 137 } 138 139 144 public int compareTo(Object arg0) { 145 if (arg0 instanceof ErrorInfo) { 146 long otherTimestamp = ((ErrorInfo) arg0).timestamp; 148 if (timestamp < otherTimestamp) { 149 return -1; 150 } else if (timestamp > otherTimestamp) { 151 return 1; 152 } else { 153 return 0; 154 } 155 } 156 return super.compareTo(arg0); 157 } 158 } 159 | Popular Tags |