Mercurial > projects > dwt-addons
annotate dwtx/jface/text/hyperlink/AbstractHyperlinkDetector.d @ 140:26688fec6d23
Following dsss compile errors
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 03:23:46 +0200 |
parents | c4fb132a086c |
children | 25f1f92fa3df |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2007 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 dwtx.jface.text.hyperlink.AbstractHyperlinkDetector; | |
14 | |
131 | 15 import dwtx.jface.text.hyperlink.IHyperlinkPresenterExtension; // packageimport |
16 import dwtx.jface.text.hyperlink.MultipleHyperlinkPresenter; // packageimport | |
17 import dwtx.jface.text.hyperlink.HyperlinkManager; // packageimport | |
18 import dwtx.jface.text.hyperlink.URLHyperlink; // packageimport | |
19 import dwtx.jface.text.hyperlink.IHyperlinkDetectorExtension2; // packageimport | |
20 import dwtx.jface.text.hyperlink.IHyperlinkDetector; // packageimport | |
21 import dwtx.jface.text.hyperlink.IHyperlinkPresenter; // packageimport | |
22 import dwtx.jface.text.hyperlink.URLHyperlinkDetector; // packageimport | |
23 import dwtx.jface.text.hyperlink.DefaultHyperlinkPresenter; // packageimport | |
24 import dwtx.jface.text.hyperlink.IHyperlinkDetectorExtension; // packageimport | |
25 import dwtx.jface.text.hyperlink.HyperlinkMessages; // packageimport | |
26 import dwtx.jface.text.hyperlink.IHyperlink; // packageimport | |
27 | |
28 | |
129 | 29 import dwt.dwthelper.utils; |
30 | |
31 import dwtx.core.runtime.Assert; | |
32 import dwtx.core.runtime.IAdaptable; | |
33 | |
34 | |
35 /** | |
36 * A hyperlink detector that can provide adapters through | |
37 * a context that can be set by the creator of this hyperlink | |
38 * detector. | |
39 * <p> | |
40 * Clients may subclass. | |
41 * </p> | |
42 * | |
43 * @since 3.3 | |
44 */ | |
45 public abstract class AbstractHyperlinkDetector : IHyperlinkDetector, IHyperlinkDetectorExtension { | |
46 | |
47 /** | |
48 * The context of this hyperlink detector. | |
49 */ | |
50 private IAdaptable fContext; | |
51 | |
52 /** | |
53 * Sets this hyperlink detector's context which | |
54 * is responsible to provide the adapters. | |
55 * | |
56 * @param context the context for this hyperlink detector | |
57 * @throws IllegalArgumentException if the context is <code>null</code> | |
58 * @throws IllegalStateException if this method is called more than once | |
59 */ | |
140
26688fec6d23
Following dsss compile errors
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
60 public final void setContext(IAdaptable context) { |
129 | 61 Assert.isLegal(context !is null); |
62 if (fContext !is null) | |
63 throw new IllegalStateException(); | |
64 fContext= context; | |
65 } | |
66 | |
67 /* | |
68 * @see dwtx.jface.text.hyperlink.IHyperlinkDetectorExtension#dispose() | |
69 */ | |
70 public void dispose() { | |
71 fContext= null; | |
72 } | |
73 | |
74 /** | |
75 * Returns an object which is an instance of the given class | |
76 * and provides additional context for this hyperlink detector. | |
77 * | |
78 * @param adapterClass the adapter class to look up | |
79 * @return an instance that can be cast to the given class, | |
80 * or <code>null</code> if this object does not | |
81 * have an adapter for the given class | |
82 */ | |
83 protected final Object getAdapter(Class adapterClass) { | |
84 Assert.isLegal(adapterClass !is null); | |
85 if (fContext !is null) | |
86 return fContext.getAdapter(adapterClass); | |
87 return null; | |
88 } | |
89 | |
90 } |