1 11 package org.eclipse.ui.internal.forms.widgets; 12 13 import java.util.Hashtable ; 14 15 import org.eclipse.swt.graphics.*; 16 import org.eclipse.ui.forms.HyperlinkSettings; 17 18 22 public class TextHyperlinkSegment extends TextSegment implements 23 IHyperlinkSegment { 24 private String href; 25 26 private String tooltipText; 27 28 30 private HyperlinkSettings settings; 31 32 public TextHyperlinkSegment(String text, HyperlinkSettings settings, 33 String fontId) { 34 super(text, fontId); 35 this.settings = settings; 36 underline = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_ALWAYS; 37 } 38 39 42 public String getHref() { 43 return href; 44 } 45 46 public void setHref(String href) { 47 this.href = href; 48 } 49 50 57 58 public void paint(GC gc, boolean hover, Hashtable resourceTable, 59 boolean selected, SelectionData selData, Rectangle repaintRegion) { 60 boolean rolloverMode = settings.getHyperlinkUnderlineMode() == HyperlinkSettings.UNDERLINE_HOVER; 61 Color savedFg = gc.getForeground(); 62 Color newFg = hover ? settings.getActiveForeground() : settings 63 .getForeground(); 64 if (newFg!=null) 65 gc.setForeground(newFg); 66 super.paint(gc, hover, resourceTable, selected, rolloverMode, selData, 67 repaintRegion); 68 gc.setForeground(savedFg); 69 } 70 71 public String getTooltipText() { 72 return tooltipText; 73 } 74 75 public void setTooltipText(String tooltip) { 76 this.tooltipText = tooltip; 77 } 78 79 public boolean isSelectable() { 80 return true; 81 } 82 83 public boolean isFocusSelectable(Hashtable resourceTable) { 84 return true; 85 } 86 87 public boolean setFocus(Hashtable resourceTable, boolean direction) { 88 return true; 89 } 90 } | Popular Tags |