KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > about > AboutItem


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.about;
12
13 /**
14  * Holds the information for text appearing in the about dialog
15  */

16 public class AboutItem {
17     private String JavaDoc text;
18
19     private int[][] linkRanges;
20
21     private String JavaDoc[] hrefs;
22
23     /**
24      * Creates a new about item
25      */

26     public AboutItem(String JavaDoc text, int[][] linkRanges, String JavaDoc[] hrefs) {
27
28         this.text = text;
29         this.linkRanges = linkRanges;
30         this.hrefs = hrefs;
31     }
32
33     /**
34      * Returns the link ranges (character locations)
35      */

36     public int[][] getLinkRanges() {
37         return linkRanges;
38     }
39
40     /**
41      * Returns the text to display
42      */

43     public String JavaDoc getText() {
44         return text;
45     }
46
47     /**
48      * Returns true if a link is present at the given character location
49      */

50     public boolean isLinkAt(int offset) {
51         // Check if there is a link at the offset
52
for (int i = 0; i < linkRanges.length; i++) {
53             if (offset >= linkRanges[i][0]
54                     && offset < linkRanges[i][0] + linkRanges[i][1]) {
55                 return true;
56             }
57         }
58         return false;
59     }
60
61     /**
62      * Returns the link at the given offset (if there is one),
63      * otherwise returns <code>null</code>.
64      */

65     public String JavaDoc getLinkAt(int offset) {
66         // Check if there is a link at the offset
67
for (int i = 0; i < linkRanges.length; i++) {
68             if (offset >= linkRanges[i][0]
69                     && offset < linkRanges[i][0] + linkRanges[i][1]) {
70                 return hrefs[i];
71             }
72         }
73         return null;
74     }
75 }
76
Popular Tags