1 11 package org.eclipse.jdt.internal.debug.ui; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.jface.resource.JFaceColors; 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.custom.CLabel; 17 import org.eclipse.swt.graphics.Color; 18 import org.eclipse.swt.graphics.Image; 19 import org.eclipse.swt.widgets.Composite; 20 import org.eclipse.ui.ISharedImages; 21 import org.eclipse.ui.PlatformUI; 22 23 26 public class MessageLine extends CLabel { 27 28 private Color fNormalMsgAreaBackground; 29 30 33 public MessageLine(Composite parent) { 34 this(parent, SWT.LEFT); 35 } 36 37 40 public MessageLine(Composite parent, int style) { 41 super(parent, style); 42 fNormalMsgAreaBackground= getBackground(); 43 } 44 45 46 private Image findImage(IStatus status) { 47 if (status.isOK()) { 48 return null; 49 } else if (status.matches(IStatus.ERROR)) { 50 return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); 51 } else if (status.matches(IStatus.WARNING)) { 52 return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK); 53 } else if (status.matches(IStatus.INFO)) { 54 return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK); 55 } 56 return null; 57 } 58 59 63 public void setErrorStatus(IStatus status) { 64 if (status != null && !status.isOK()) { 65 String message= status.getMessage(); 66 if (message != null && message.length() > 0) { 67 setText(message); 68 setImage(findImage(status)); 69 setBackground(JFaceColors.getErrorBackground(getDisplay())); 70 return; 71 } 72 } 73 setText(""); setImage(null); 75 setBackground(fNormalMsgAreaBackground); 76 } 77 } 78 79 | Popular Tags |