Mercurial > projects > dwt2
comparison org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/URLHyperlink.d @ 12:bc29606a740c
Added dwt-addons in original directory structure of eclipse.org
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 14 Mar 2009 18:23:29 +0100 |
parents | |
children | dbfb303e8fb0 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2008 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.jface.text.hyperlink.URLHyperlink; | |
14 | |
15 import org.eclipse.jface.text.hyperlink.IHyperlinkPresenterExtension; // packageimport | |
16 import org.eclipse.jface.text.hyperlink.MultipleHyperlinkPresenter; // packageimport | |
17 import org.eclipse.jface.text.hyperlink.HyperlinkManager; // packageimport | |
18 import org.eclipse.jface.text.hyperlink.IHyperlinkDetectorExtension2; // packageimport | |
19 import org.eclipse.jface.text.hyperlink.IHyperlinkDetector; // packageimport | |
20 import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter; // packageimport | |
21 import org.eclipse.jface.text.hyperlink.URLHyperlinkDetector; // packageimport | |
22 import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter; // packageimport | |
23 import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector; // packageimport | |
24 import org.eclipse.jface.text.hyperlink.IHyperlinkDetectorExtension; // packageimport | |
25 import org.eclipse.jface.text.hyperlink.HyperlinkMessages; // packageimport | |
26 import org.eclipse.jface.text.hyperlink.IHyperlink; // packageimport | |
27 | |
28 | |
29 import java.lang.all; | |
30 import org.eclipse.dwtxhelper.MessageFormat; | |
31 | |
32 import org.eclipse.swt.program.Program; | |
33 import org.eclipse.core.runtime.Assert; | |
34 import org.eclipse.jface.text.IRegion; | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 /** | |
41 * URL hyperlink. | |
42 * | |
43 * @since 3.1 | |
44 */ | |
45 public class URLHyperlink : IHyperlink { | |
46 | |
47 private String fURLString; | |
48 private IRegion fRegion; | |
49 | |
50 /** | |
51 * Creates a new URL hyperlink. | |
52 * | |
53 * @param region | |
54 * @param urlString | |
55 */ | |
56 public this(IRegion region, String urlString) { | |
57 Assert.isNotNull(urlString); | |
58 Assert.isNotNull(cast(Object)region); | |
59 | |
60 fRegion= region; | |
61 fURLString= urlString; | |
62 } | |
63 | |
64 /* | |
65 * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion() | |
66 */ | |
67 public IRegion getHyperlinkRegion() { | |
68 return fRegion; | |
69 } | |
70 | |
71 /* | |
72 * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#open() | |
73 */ | |
74 public void open() { | |
75 if (fURLString !is null) { | |
76 Program.launch(fURLString); | |
77 fURLString= null; | |
78 return; | |
79 } | |
80 } | |
81 | |
82 /* | |
83 * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getTypeLabel() | |
84 */ | |
85 public String getTypeLabel() { | |
86 return null; | |
87 } | |
88 | |
89 /* | |
90 * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText() | |
91 */ | |
92 public String getHyperlinkText() { | |
93 return MessageFormat.format(HyperlinkMessages.getString("URLHyperlink.hyperlinkText"), stringcast(fURLString) ); //$NON-NLS-1$ | |
94 } | |
95 | |
96 /** | |
97 * Returns the URL string of this hyperlink. | |
98 * | |
99 * @return the URL string | |
100 * @since 3.2 | |
101 */ | |
102 public String getURLString() { | |
103 return fURLString; | |
104 } | |
105 | |
106 } |