blob: 6d2bef07105255b52319bf36ad8c2d75006be340 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jface.text.hyperlink;
import org.eclipse.swt.SWT;
import org.eclipse.swt.program.Program;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.IRegion;
/**
* URL hyperlink.
*
* @since 3.1
*/
public class URLHyperlink implements IHyperlink {
private String fURLString;
private IRegion fRegion;
/**
* Creates a new URL hyperlink.
*
* @param region
* @param urlString
*/
public URLHyperlink(IRegion region, String urlString) {
Assert.isNotNull(urlString);
Assert.isNotNull(region);
fRegion= region;
fURLString= urlString;
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion()
*/
public IRegion getHyperlinkRegion() {
return fRegion;
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#open()
*/
public void open() {
if (fURLString != null) {
String platform= SWT.getPlatform();
if ("motif".equals(platform) || "gtk".equals(platform)) { //$NON-NLS-1$ //$NON-NLS-2$
Program program= Program.findProgram("html"); //$NON-NLS-1$
if (program == null)
program= Program.findProgram("htm"); //$NON-NLS-1$
if (program != null)
program.execute(fURLString);
} else
Program.launch(fURLString);
fURLString= null;
return;
}
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getTypeLabel()
*/
public String getTypeLabel() {
return null;
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
return null;
}
}
|