1 11 package org.eclipse.jdt.internal.ui.dialogs; 12 13 import org.eclipse.core.runtime.IStatus; 14 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 21 import org.eclipse.jface.resource.JFaceColors; 22 23 import org.eclipse.jdt.internal.ui.JavaPluginImages; 24 25 28 public class MessageLine extends CLabel { 29 30 private Color fNormalMsgAreaBackground; 31 32 35 public MessageLine(Composite parent) { 36 this(parent, SWT.LEFT); 37 } 38 39 42 public MessageLine(Composite parent, int style) { 43 super(parent, style); 44 fNormalMsgAreaBackground= getBackground(); 45 } 46 47 48 private Image findImage(IStatus status) { 49 if (status.isOK()) { 50 return null; 51 } else if (status.matches(IStatus.ERROR)) { 52 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_ERROR); 53 } else if (status.matches(IStatus.WARNING)) { 54 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING); 55 } else if (status.matches(IStatus.INFO)) { 56 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO); 57 } 58 return null; 59 } 60 61 65 public void setErrorStatus(IStatus status) { 66 if (status != null && !status.isOK()) { 67 String message= status.getMessage(); 68 if (message != null && message.length() > 0) { 69 setText(message); 70 setImage(findImage(status)); 71 setBackground(JFaceColors.getErrorBackground(getDisplay())); 72 return; 73 } 74 } 75 setText(""); setImage(null); 77 setBackground(fNormalMsgAreaBackground); 78 } 79 } 80 81 | Popular Tags |