01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.about;
11:
12: /**
13: * Holds the information for text appearing in the about dialog
14: */
15: public class AboutItem {
16: private String text;
17:
18: private int[][] linkRanges;
19:
20: private String[] hrefs;
21:
22: /**
23: * Creates a new about item
24: */
25: public AboutItem(String text, int[][] linkRanges, String[] hrefs) {
26:
27: this .text = text;
28: this .linkRanges = linkRanges;
29: this .hrefs = hrefs;
30: }
31:
32: /**
33: * Returns the link ranges (character locations)
34: */
35: public int[][] getLinkRanges() {
36: return linkRanges;
37: }
38:
39: /**
40: * Returns the text to display
41: */
42: public String getText() {
43: return text;
44: }
45:
46: /**
47: * Returns true if a link is present at the given character location
48: */
49: public boolean isLinkAt(int offset) {
50: // Check if there is a link at the offset
51: for (int i = 0; i < linkRanges.length; i++) {
52: if (offset >= linkRanges[i][0]
53: && offset < linkRanges[i][0] + linkRanges[i][1]) {
54: return true;
55: }
56: }
57: return false;
58: }
59:
60: /**
61: * Returns the link at the given offset (if there is one),
62: * otherwise returns <code>null</code>.
63: */
64: public String getLinkAt(int offset) {
65: // Check if there is a link at the offset
66: for (int i = 0; i < linkRanges.length; i++) {
67: if (offset >= linkRanges[i][0]
68: && offset < linkRanges[i][0] + linkRanges[i][1]) {
69: return hrefs[i];
70: }
71: }
72: return null;
73: }
74: }
|