}
}
};
Activator.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
final SourceViewerDecorationSupport support = configureAnnotationPreferences();
if (isEditable(sourceViewer)) {
quickFixActionHandler = createQuickFixActionHandler(sourceViewer);
}
Document document = new Document(initialText);
configuration = new TextSourceViewerConfiguration(
EditorsUI
.getPreferenceStore()) {
public int getHyperlinkStateMask(ISourceViewer targetViewer) {
return SWT.NONE;
}
protected Map getHyperlinkDetectorTargets(ISourceViewer targetViewer) {
return getHyperlinkTargets();
}
@Override
public IHyperlinkPresenter getHyperlinkPresenter(
ISourceViewer targetViewer) {
return new MultipleHyperlinkPresenter(PlatformUI.getWorkbench()
.getDisplay().getSystemColor(SWT.COLOR_BLUE).getRGB()) {
@Override
public void hideHyperlinks() {
// We want links to always show.
}
};
}
public IHyperlinkDetector[] getHyperlinkDetectors(
ISourceViewer targetViewer) {
return getRegisteredHyperlinkDetectors(sourceViewer);
}
@Override
public IReconciler getReconciler(ISourceViewer viewer) {
if (!isEditable(viewer))
return null;
return super.getReconciler(sourceViewer);
}
public IContentAssistant getContentAssistant(ISourceViewer viewer) {
if (!viewer.isEditable())
return null;
IContentAssistant assistant = createContentAssistant(viewer);
// Add content assist proposal handler if assistant exists
if (assistant != null)
contentAssistActionHandler = createContentAssistActionHandler(sourceViewer);
return assistant;
}
};
sourceViewer.configure(configuration);
sourceViewer.setDocument(document, annotationModel);
StyleRange[] styleRanges = UIUtils
.getHyperlinkDetectorStyleRanges(sourceViewer,
configuration.getHyperlinkDetectors(sourceViewer));
sourceViewer.getTextWidget().setStyleRanges(styleRanges);
configureContextMenu();
getTextWidget().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent disposeEvent) {
support.uninstall();
Activator.getDefault().getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
}
});
}