1 12 package org.eclipse.jface.viewers; 13 14 import org.eclipse.swt.graphics.Color; 15 import org.eclipse.swt.graphics.Font; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.swt.graphics.Point; 18 19 26 public class ViewerLabel { 27 28 private String newText = null; 30 31 private Image newImage = null; 32 33 private boolean imageUpdated = false; 34 35 private boolean textUpdated = false; 36 37 private Color background = null; 38 39 private Color foreground = null; 40 41 private Font font = null; 42 43 private String startText; 45 46 private Image startImage; 47 48 private boolean hasPendingDecorations; 49 50 private String tooltipText; 51 52 private Color tooltipForegroundColor; 53 54 private Color tooltipBackgroundColor; 55 56 private Point tooltipShift; 57 58 65 public ViewerLabel(String initialText, Image initialImage) { 66 startText = initialText; 67 startImage = initialImage; 68 } 69 70 76 public final Image getImage() { 77 if (imageUpdated) { 78 return newImage; 79 } 80 return startImage; 81 } 82 83 89 public final void setImage(Image image) { 90 imageUpdated = true; 91 newImage = image; 92 } 93 94 101 public final String getText() { 102 if (textUpdated) { 103 return newText; 104 } 105 return startText; 106 } 107 108 116 public final void setText(String text) { 117 newText = text; 118 textUpdated = true; 119 } 120 121 129 public boolean hasNewImage() { 130 131 if (startImage == null) { 133 return newImage != null; 134 } 135 136 if (imageUpdated) { 137 return !(startImage.equals(newImage)); 138 } 139 return false; 140 } 141 142 148 public boolean hasNewText() { 149 150 if (startText == null) { 152 return newText != null; 153 } 154 155 if (textUpdated) { 156 return !(startText.equals(newText)); 157 } 158 159 return false; 160 } 161 162 167 public boolean hasNewBackground() { 168 return background != null; 169 } 170 171 178 public boolean hasNewForeground() { 179 return foreground != null; 180 } 181 182 189 public boolean hasNewFont() { 190 return font != null; 191 } 192 193 200 public Color getBackground() { 201 return background; 202 } 203 204 212 public void setBackground(Color background) { 213 this.background = background; 214 } 215 216 223 public Font getFont() { 224 return font; 225 } 226 227 235 public void setFont(Font font) { 236 this.font = font; 237 } 238 239 246 public Color getForeground() { 247 return foreground; 248 } 249 250 258 public void setForeground(Color foreground) { 259 this.foreground = foreground; 260 } 261 262 267 void setHasPendingDecorations(boolean hasPendingDecorations) { 268 this.hasPendingDecorations = hasPendingDecorations; 269 } 270 271 275 boolean hasPendingDecorations() { 276 return hasPendingDecorations; 277 } 278 279 287 public String getTooltipText() { 288 return tooltipText; 289 } 290 291 300 public void setTooltipText(String tooltipText) { 301 this.tooltipText = tooltipText; 302 } 303 304 312 public boolean hasNewTooltipText() { 313 return this.tooltipText != null; 314 } 315 316 324 public Color getTooltipBackgroundColor() { 325 return tooltipBackgroundColor; 326 } 327 328 337 public void setTooltipBackgroundColor(Color tooltipBackgroundColor) { 338 this.tooltipBackgroundColor = tooltipBackgroundColor; 339 } 340 341 349 public boolean hasNewTooltipBackgroundColor() { 350 return tooltipBackgroundColor != null; 351 } 352 353 361 public Color getTooltipForegroundColor() { 362 return tooltipForegroundColor; 363 } 364 365 373 public void setTooltipForegroundColor(Color tooltipForegroundColor) { 374 this.tooltipForegroundColor = tooltipForegroundColor; 375 } 376 377 386 public boolean hasNewTooltipForegroundColor() { 387 return tooltipForegroundColor != null; 388 } 389 390 394 public Point getTooltipShift() { 395 return tooltipShift; 396 } 397 398 403 public void setTooltipShift(Point tooltipShift) { 404 this.tooltipShift = tooltipShift; 405 } 406 407 411 public boolean hasTooltipShift() { 412 return this.tooltipShift != null; 413 } 414 } 415 | Popular Tags |