KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > forms > widgets > ImageHyperlinkSegment


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.forms.widgets;
12
13 import java.util.Hashtable JavaDoc;
14
15 import org.eclipse.swt.graphics.*;
16
17 public class ImageHyperlinkSegment extends ImageSegment implements
18         IHyperlinkSegment {
19     private String JavaDoc href;
20     private String JavaDoc text;
21
22     private String JavaDoc tooltipText;
23
24     public ImageHyperlinkSegment() {
25     }
26
27     /*
28      * (non-Javadoc)
29      *
30      * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#setHref(java.lang.String)
31      */

32     public void setHref(String JavaDoc href) {
33         this.href = href;
34     }
35
36     /*
37      * (non-Javadoc)
38      *
39      * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#getHref()
40      */

41     public String JavaDoc getHref() {
42         return href;
43     }
44
45     public void paintFocus(GC gc, Color bg, Color fg, boolean selected,
46             Rectangle repaintRegion) {
47         Rectangle bounds = getBounds();
48         if (bounds == null)
49             return;
50         if (selected) {
51             gc.setBackground(bg);
52             gc.setForeground(fg);
53             gc.drawFocus(bounds.x, bounds.y, bounds.width, bounds.height);
54         } else {
55             gc.setForeground(bg);
56             gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1,
57                     bounds.height - 1);
58         }
59     }
60
61     /*
62      * (non-Javadoc)
63      *
64      * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#isWordWrapAllowed()
65      */

66     public boolean isWordWrapAllowed() {
67         return !isNowrap();
68     }
69
70     /*
71      * (non-Javadoc)
72      *
73      * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#setWordWrapAllowed(boolean)
74      */

75     public void setWordWrapAllowed(boolean value) {
76         setNowrap(!value);
77     }
78
79     /*
80      * (non-Javadoc)
81      *
82      * @see org.eclipse.ui.internal.forms.widgets.IHyperlinkSegment#getText()
83      */

84     public String JavaDoc getText() {
85         return text!=null?text:""; //$NON-NLS-1$
86
}
87     
88     public void setText(String JavaDoc text) {
89         this.text = text;
90     }
91
92     /**
93      * @return Returns the tooltipText.
94      */

95     public String JavaDoc getTooltipText() {
96         return tooltipText;
97     }
98
99     /**
100      * @param tooltipText
101      * The tooltipText to set.
102      */

103     public void setTooltipText(String JavaDoc tooltipText) {
104         this.tooltipText = tooltipText;
105     }
106     
107     public boolean isSelectable() {
108         return true;
109     }
110
111     public boolean isFocusSelectable(Hashtable JavaDoc resourceTable) {
112         return true;
113     }
114
115     public boolean setFocus(Hashtable JavaDoc resourceTable, boolean direction) {
116         return true;
117     }
118 }
119
Popular Tags