1 11 package org.eclipse.ui.texteditor.templates; 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 24 29 class MessageLine extends CLabel { 30 31 private Color fNormalMsgAreaBackground; 32 33 38 public MessageLine(Composite parent) { 39 this(parent, SWT.LEFT); 40 } 41 42 48 public MessageLine(Composite parent, int style) { 49 super(parent, style); 50 fNormalMsgAreaBackground= getBackground(); 51 } 52 53 54 private Image findImage(IStatus status) { 55 if (status.isOK()) { 56 return null; 57 } 58 return null; 59 } 60 61 67 public void setErrorStatus(IStatus status) { 68 if (status != null && !status.isOK()) { 69 String message= status.getMessage(); 70 if (message != null && message.length() > 0) { 71 setText(message); 72 setImage(findImage(status)); 73 setBackground(JFaceColors.getErrorBackground(getDisplay())); 74 return; 75 } 76 } 77 setText(""); setImage(null); 79 setBackground(fNormalMsgAreaBackground); 80 } 81 } 82 83 | Popular Tags |