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 |
} |