View | Details | Raw Unified | Return to bug 88293 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-1 / +2 lines)
Lines 4-10 Link Here
4
4
5
    <extension-point id="quickDiffReferenceProvider" name="%ExtPoint.referenceProvider" schema="schema/quickDiffReferenceProvider.exsd"/>
5
    <extension-point id="quickDiffReferenceProvider" name="%ExtPoint.referenceProvider" schema="schema/quickDiffReferenceProvider.exsd"/>
6
	<extension-point id="spellingEngine" name="%SpellingEngine" schema="schema/spellingEngine.exsd"/>
6
	<extension-point id="spellingEngine" name="%SpellingEngine" schema="schema/spellingEngine.exsd"/>
7
	   
7
	<extension-point id="hyperlinkDetectors" name="%HyperlinkDetectors" schema="schema/hyperlinkDetectors.exsd"/>
8
	
8
	   
9
	   
9
	<extension
10
	<extension
10
	     point="org.eclipse.ui.commands">
11
	     point="org.eclipse.ui.commands">
(-)plugin.properties (+1 lines)
Lines 160-162 Link Here
160
command.windowStart.name = Window Start
160
command.windowStart.name = Window Start
161
161
162
SpellingEngine= Spelling Engine
162
SpellingEngine= Spelling Engine
163
HyperlinkDetectors= Hyperlink Detectors
(-)src/org/eclipse/ui/texteditor/AbstractTextEditor.java (-1 / +65 lines)
Lines 17-22 Link Here
17
import java.lang.reflect.InvocationTargetException;
17
import java.lang.reflect.InvocationTargetException;
18
import java.text.MessageFormat;
18
import java.text.MessageFormat;
19
import java.util.ArrayList;
19
import java.util.ArrayList;
20
import java.util.Arrays;
20
import java.util.HashMap;
21
import java.util.HashMap;
21
import java.util.Iterator;
22
import java.util.Iterator;
22
import java.util.List;
23
import java.util.List;
Lines 61-66 Link Here
61
62
62
import org.eclipse.core.runtime.CoreException;
63
import org.eclipse.core.runtime.CoreException;
63
import org.eclipse.core.runtime.IConfigurationElement;
64
import org.eclipse.core.runtime.IConfigurationElement;
65
import org.eclipse.core.runtime.IExtension;
66
import org.eclipse.core.runtime.IExtensionPoint;
67
import org.eclipse.core.runtime.IExtensionRegistry;
64
import org.eclipse.core.runtime.ILog;
68
import org.eclipse.core.runtime.ILog;
65
import org.eclipse.core.runtime.IProgressMonitor;
69
import org.eclipse.core.runtime.IProgressMonitor;
66
import org.eclipse.core.runtime.IStatus;
70
import org.eclipse.core.runtime.IStatus;
Lines 162-168 Link Here
162
import org.eclipse.ui.part.EditorActionBarContributor;
166
import org.eclipse.ui.part.EditorActionBarContributor;
163
import org.eclipse.ui.part.EditorPart;
167
import org.eclipse.ui.part.EditorPart;
164
168
165
166
/**
169
/**
167
 * Abstract base implementation of a text editor.
170
 * Abstract base implementation of a text editor.
168
 * <p>
171
 * <p>
Lines 2559-2564 Link Here
2559
		fSourceViewer.addTextInputListener(fTextListener);
2562
		fSourceViewer.addTextInputListener(fTextListener);
2560
		getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
2563
		getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
2561
2564
2565
		initializeViewerHyperlinkDetectors(fSourceViewer);
2562
		initializeViewerFont(fSourceViewer);
2566
		initializeViewerFont(fSourceViewer);
2563
		initializeViewerColors(fSourceViewer);
2567
		initializeViewerColors(fSourceViewer);
2564
		initializeFindScopeColor(fSourceViewer);
2568
		initializeFindScopeColor(fSourceViewer);
Lines 5672-5675 Link Here
5672
		return true;
5676
		return true;
5673
	}
5677
	}
5674
5678
5679
	private HyperlinkDetectorExtensionReader fDetectorExtensionReader = new HyperlinkDetectorExtensionReader();
5680
	
5681
	private IHyperlinkDetector[] fContributedHyperlinkDectors = null;
5682
	
5683
	private void initializeViewerHyperlinkDetectors(ISourceViewer sourceViewer) {
5684
		fDetectorExtensionReader.readHyperlinkDetectorsExtension(this);
5685
		if (fContributedHyperlinkDectors != null && fPreferenceStore.getBoolean(PREFERENCE_HYPERLINKS_ENABLED)
5686
				&& fSourceViewer instanceof ITextViewerExtension6) {
5687
			
5688
			IHyperlinkDetector[] sourceViewerDetectors = getSourceViewerConfiguration().getHyperlinkDetectors(fSourceViewer);
5689
			int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(fSourceViewer);
5690
			ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) fSourceViewer;
5691
			
5692
			List allDectors = new ArrayList();
5693
			allDectors.addAll(Arrays.asList(sourceViewerDetectors));
5694
			allDectors.addAll(Arrays.asList(fContributedHyperlinkDectors));
5695
			textViewer6.setHyperlinkDetectors((IHyperlinkDetector[])allDectors.toArray(new IHyperlinkDetector[allDectors.size()]), stateMask);
5696
		}
5697
	} 
5698
	
5699
	private final class HyperlinkDetectorExtensionReader {
5700
5701
		private List contributedDetectors = new ArrayList();
5702
5703
		private boolean extensionsRead = false;
5704
5705
		public static final String EXTENSION_POINT_HYPERLINK_DETECTOR = "org.eclipse.ui.workbench.texteditor.hyperlinkDetectors";
5706
5707
		public static final String ELEMENT_HYPERLINK_DETECTOR = "hyperlinkDetector";
5708
5709
		public static final String ELEMENT_CLASS = "class";
5710
5711
		private void readHyperlinkDetectorsExtension(ITextEditor textEditor) {
5712
			if (!extensionsRead) {
5713
				List contributedDectors = new ArrayList();
5714
				IExtensionRegistry registry = Platform.getExtensionRegistry();
5715
				IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_HYPERLINK_DETECTOR);
5716
				IExtension[] extensions = extensionPoint.getExtensions();
5717
				for (int i = 0; i < extensions.length; i++) {
5718
					IConfigurationElement[] elements = extensions[i].getConfigurationElements();
5719
					for (int j = 0; j < elements.length; j++) {
5720
						if (elements[j].getName().compareTo(ELEMENT_HYPERLINK_DETECTOR) == 0) {
5721
							try {
5722
								Object detector = elements[j].createExecutableExtension(ELEMENT_CLASS);
5723
								if (detector instanceof AbstractHyperlinkDetector) {
5724
									((AbstractHyperlinkDetector) detector).setEditor(textEditor);
5725
									contributedDectors.add(detector);
5726
								}
5727
							} catch (CoreException e) {
5728
								// TODO: handle once this goes where it belongs
5729
								throw new RuntimeException(e);
5730
							}
5731
						}
5732
					}
5733
				}
5734
				AbstractTextEditor.this.fContributedHyperlinkDectors = (IHyperlinkDetector[]) contributedDectors.toArray(new IHyperlinkDetector[contributedDectors.size()]);
5735
				extensionsRead = true;
5736
			}
5737
		}
5738
	}
5675
}
5739
}
(-)src/org/eclipse/ui/texteditor/AbstractHyperlinkDetector.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 - 2006 University Of British Columbia 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
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ui.texteditor;
13
14
import org.eclipse.jface.text.IRegion;
15
import org.eclipse.jface.text.ITextViewer;
16
import org.eclipse.jface.text.hyperlink.IHyperlink;
17
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
18
19
/**
20
 * @author Mik Kersten
21
 */
22
public abstract class AbstractHyperlinkDetector implements IHyperlinkDetector {
23
24
	private ITextEditor fEditor;
25
26
	public abstract IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region,
27
			boolean canShowMultipleHyperlinks);
28
29
	public ITextEditor getEditor() {
30
		return fEditor;
31
	}
32
33
	public void setEditor(ITextEditor editor) {
34
		this.fEditor = editor;
35
	}
36
}
(-)schema/hyperlinkDetectors.exsd (+122 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.ui.workbench.texteditor">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.ui.workbench.texteditor" id="hyperlinkDetectors" name="Hyperlink Detectors"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point is used to plug-in hyperlink detectors to a Java editor.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="hyperlinkDetector" minOccurs="0" maxOccurs="unbounded"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="hyperlinkDetector">
46
      <complexType>
47
         <attribute name="class" type="string" use="required">
48
            <annotation>
49
               <documentation>
50
                  
51
               </documentation>
52
               <appInfo>
53
                  <meta.attribute kind="java" basedOn="org.eclipse.ui.texteditor.AbstractHyperlinkDetector"/>
54
               </appInfo>
55
            </annotation>
56
         </attribute>
57
         <attribute name="id" type="string">
58
            <annotation>
59
               <documentation>
60
                  
61
               </documentation>
62
            </annotation>
63
         </attribute>
64
         <attribute name="name" type="string">
65
            <annotation>
66
               <documentation>
67
                  
68
               </documentation>
69
               <appInfo>
70
                  <meta.attribute translatable="true"/>
71
               </appInfo>
72
            </annotation>
73
         </attribute>
74
      </complexType>
75
   </element>
76
77
   <annotation>
78
      <appInfo>
79
         <meta.section type="since"/>
80
      </appInfo>
81
      <documentation>
82
         [Enter the first release in which this extension point appears.]
83
      </documentation>
84
   </annotation>
85
86
   <annotation>
87
      <appInfo>
88
         <meta.section type="examples"/>
89
      </appInfo>
90
      <documentation>
91
         [Enter extension point usage example here.]
92
      </documentation>
93
   </annotation>
94
95
   <annotation>
96
      <appInfo>
97
         <meta.section type="apiInfo"/>
98
      </appInfo>
99
      <documentation>
100
         [Enter API information here.]
101
      </documentation>
102
   </annotation>
103
104
   <annotation>
105
      <appInfo>
106
         <meta.section type="implementation"/>
107
      </appInfo>
108
      <documentation>
109
         [Enter information about supplied implementation of this extension point.]
110
      </documentation>
111
   </annotation>
112
113
   <annotation>
114
      <appInfo>
115
         <meta.section type="copyright"/>
116
      </appInfo>
117
      <documentation>
118
         
119
      </documentation>
120
   </annotation>
121
122
</schema>

Return to bug 88293