Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to use SpellingService
How to use SpellingService [message #723144] Wed, 07 September 2011 15:56 Go to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Hello,

how can i use the ui.texteditor SpellingService in a SourceViewer? If i write a wrong word nothing is underlined. What's missing?

My try:
SourceViewer viewer =new SourceViewer(currentVersionTextsComposite,null,SWT.BORDER | SWT.WRAP | SWT.MULTI | SWT.V_SCROLL  );
            IPreferenceStore iPreferenceStore = new PreferenceStore();
            iPreferenceStore.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, true);
            TextSourceViewerConfiguration configuration = new TextSourceViewerConfiguration(iPreferenceStore);
            viewer.configure(configuration);
Re: How to use SpellingService [message #723847 is a reply to message #723144] Fri, 09 September 2011 12:36 Go to previous messageGo to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
So my new version: It will show a popup but the wrong word isn't underlined? What do i have to do?
 final SourceViewer sourceViewer = new SourceViewer(parent, null, null,
                true, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
        // grab the text widget from the source viewer
        StyledText fTextField = sourceViewer.getTextWidget();
        // this is where the magic happens for spellchecking
        // see TextSourceViewerConfiguration#getReconciler
        Document document = new Document("dfg");
        SourceViewerConfiguration config = new TextSourceViewerConfiguration(
                EditorsUI.getPreferenceStore());
        sourceViewer.configure(config);
        sourceViewer.setDocument(document, new AnnotationModel());
Re: How to use SpellingService [message #724793 is a reply to message #723847] Tue, 13 September 2011 03:33 Go to previous messageGo to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
Nobody any idea?
Re: How to use SpellingService [message #724954 is a reply to message #723847] Tue, 13 September 2011 11:13 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
On 09.09.2011 18:36, SirWayne wrote:
> So my new version: It will show a popup but the wrong word isn't
> underlined? What do i have to do?
If you don't have JDT installed then you won't have a spelling engine.
Maybe that's your problem? See https://bugs.eclipse.org/185695.

Dani
>
> final SourceViewer sourceViewer = new SourceViewer(parent, null, null,
> true, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
> // grab the text widget from the source viewer
> StyledText fTextField = sourceViewer.getTextWidget();
> // this is where the magic happens for spellchecking
> // see TextSourceViewerConfiguration#getReconciler
> Document document = new Document("dfg");
> SourceViewerConfiguration config = new
> TextSourceViewerConfiguration(
> EditorsUI.getPreferenceStore());
> sourceViewer.configure(config);
> sourceViewer.setDocument(document, new AnnotationModel());
>
Re: How to use SpellingService [message #726146 is a reply to message #724954] Fri, 16 September 2011 12:40 Go to previous messageGo to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
no i have jdt installed

here my new version with underlined words =), but now i miss the quick assistant =(. and how can i choose a dictanory?

		private void createSourceViewer(Composite parent) {
			final IAnnotationAccess access = new DefaultMarkerAnnotationAccess();
			final SourceViewer sourceViewer = new SourceViewer(parent, null,
					null, true, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
			Document document = new Document("dfg");
			SourceViewerConfiguration config = new TextSourceViewerConfiguration(
					EditorsUI.getPreferenceStore());
			sourceViewer.configure(config);
			sourceViewer.setDocument(document, new AnnotationModel());
			SourceViewerDecorationSupport decorationSupport = new SourceViewerDecorationSupport(
					sourceViewer, null, access, EditorsPlugin.getDefault()
							.getSharedTextColors());
			configureSourceViewerDecorationSupport(decorationSupport);
			if (sourceViewer instanceof ISourceViewerExtension3)
				((IAnnotationAccessExtension2) access)
						.setQuickAssistAssistant(((ISourceViewerExtension3) sourceViewer)
								.getQuickAssistAssistant());

			GridDataFactory.fillDefaults().grab(true, true)
					.applyTo(sourceViewer.getTextWidget());

		}

		private void configureSourceViewerDecorationSupport(
				SourceViewerDecorationSupport support) {

			for(Object o :new MarkerAnnotationPreferences()
			.getAnnotationPreferences())
				support.setAnnotationPreference((AnnotationPreference)o);

			support.setCursorLinePainterPreferenceKeys(
					AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
					AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
			support.install(EditorsUI.getPreferenceStore());
		}

Re: How to use SpellingService [message #727886 is a reply to message #726146] Thu, 22 September 2011 02:45 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
On 16.09.2011 18:40, SirWayne wrote:
> no i have jdt installed
>
> here my new version with underlined words =), but now i miss the quick
> assistant =(. and how can i choose a dictanory?
Take a look at TextSourceViewerConfiguration.

Dani
>
>
> private void createSourceViewer(Composite parent) {
> final IAnnotationAccess access = new
> DefaultMarkerAnnotationAccess();
> final SourceViewer sourceViewer = new SourceViewer(parent,
> null,
> null, true, SWT.MULTI | SWT.V_SCROLL | SWT.WRAP);
> Document document = new Document("dfg");
> SourceViewerConfiguration config = new
> TextSourceViewerConfiguration(
> EditorsUI.getPreferenceStore());
> sourceViewer.configure(config);
> sourceViewer.setDocument(document, new AnnotationModel());
> SourceViewerDecorationSupport decorationSupport = new
> SourceViewerDecorationSupport(
> sourceViewer, null, access,
> EditorsPlugin.getDefault()
> .getSharedTextColors());
> configureSourceViewerDecorationSupport(decorationSupport);
> if (sourceViewer instanceof ISourceViewerExtension3)
> ((IAnnotationAccessExtension2) access)
>
> .setQuickAssistAssistant(((ISourceViewerExtension3) sourceViewer)
> .getQuickAssistAssistant());
>
> GridDataFactory.fillDefaults().grab(true, true)
> .applyTo(sourceViewer.getTextWidget());
>
> }
>
> private void configureSourceViewerDecorationSupport(
> SourceViewerDecorationSupport support) {
>
> for(Object o :new MarkerAnnotationPreferences()
> .getAnnotationPreferences())
> support.setAnnotationPreference((AnnotationPreference)o);
>
> support.setCursorLinePainterPreferenceKeys(
>
> AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
>
> AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
> support.install(EditorsUI.getPreferenceStore());
> }
>
>
Re: How to use SpellingService [message #728378 is a reply to message #727886] Fri, 23 September 2011 03:02 Go to previous messageGo to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
ok which line,section or methode =).

i set the textviewerconfiguration in my sourceviewer

		if (sourceViewer instanceof ISourceViewerExtension3)
			((IAnnotationAccessExtension2)access).setQuickAssistAssistant(((ISourceViewerExtension3)sourceViewer).getQuickAssistAssistant());


the QuickAssistAssistant is the SpellingCorrectionProcessor

[Updated on: Fri, 23 September 2011 03:33]

Report message to a moderator

Re: How to use SpellingService [message #730871 is a reply to message #728378] Thu, 29 September 2011 08:27 Go to previous messageGo to next message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
*push* Razz

Has anybody an information for me ?
Re: How to use SpellingService [message #732281 is a reply to message #730871] Tue, 04 October 2011 08:13 Go to previous message
Sir Wayne is currently offline Sir Wayne
Messages: 206
Registered: July 2009
Senior Member
The SpellingEngine works fine, but the quick assistant not.
Do i need the extension point quickDiffReferenceProvider from ui.workbench.texteditor?
Previous Topic:eclipse.ini for Windows built on Linux is unix format
Next Topic:RetargetAction behavior with command/handler/menu extension points
Goto Forum:
  


Current Time: Wed Jul 23 01:52:22 EDT 2014

Powered by FUDForum. Page generated in 0.01819 seconds