Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 47718 Details for
Bug 103093
spell checking of bugzilla comments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Broken spell check, annotations don't show up.
Clipboard-attachment (text/plain), 12.81 KB, created by
Jeff Pound
on 2006-08-10 15:02:31 EDT
(
hide
)
Description:
Broken spell check, annotations don't show up.
Filename:
MIME Type:
Creator:
Jeff Pound
Created:
2006-08-10 15:02:31 EDT
Size:
12.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.tasks.ui >Index: src/org/eclipse/mylar/internal/tasks/ui/editors/RepositoryTextViewer.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.ui/src/org/eclipse/mylar/internal/tasks/ui/editors/RepositoryTextViewer.java,v >retrieving revision 1.3 >diff -u -r1.3 RepositoryTextViewer.java >--- src/org/eclipse/mylar/internal/tasks/ui/editors/RepositoryTextViewer.java 24 Jul 2006 23:44:37 -0000 1.3 >+++ src/org/eclipse/mylar/internal/tasks/ui/editors/RepositoryTextViewer.java 10 Aug 2006 19:01:42 -0000 >@@ -15,6 +15,7 @@ > import java.util.Arrays; > import java.util.List; > >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.TextAttribute; > import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter; >@@ -22,6 +23,8 @@ > import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter; > import org.eclipse.jface.text.presentation.IPresentationReconciler; > import org.eclipse.jface.text.presentation.PresentationReconciler; >+import org.eclipse.jface.text.reconciler.IReconciler; >+import org.eclipse.jface.text.reconciler.MonoReconciler; > import org.eclipse.jface.text.rules.DefaultDamagerRepairer; > import org.eclipse.jface.text.rules.IRule; > import org.eclipse.jface.text.rules.IToken; >@@ -29,8 +32,11 @@ > import org.eclipse.jface.text.rules.RuleBasedScanner; > import org.eclipse.jface.text.rules.SingleLineRule; > import org.eclipse.jface.text.rules.Token; >+import org.eclipse.jface.text.source.AnnotationModel; >+import org.eclipse.jface.text.source.IAnnotationModel; > import org.eclipse.jface.text.source.ISourceViewer; > import org.eclipse.jface.text.source.SourceViewer; >+import org.eclipse.jface.text.source.VerticalRuler; > import org.eclipse.mylar.tasks.core.TaskRepository; > import org.eclipse.mylar.tasks.ui.TasksUiPlugin; > import org.eclipse.swt.SWT; >@@ -39,20 +45,36 @@ > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; >+import org.eclipse.ui.forms.editor.FormEditor; > > /** > * @author Rob Elves > */ > public class RepositoryTextViewer extends SourceViewer { > >+ private static final int VERTICAL_RULER_WIDTH = 1; // ? > private TaskRepository repository; >+ private AnnotationModel annotationModel; >+ private RepositoryViewerConfig repositoryViewerConfig; > >- public RepositoryTextViewer(TaskRepository repository, Composite composite, int style) { >- super(composite, null, style); >- this.configure(new RepositoryViewerConfig()); >+ public RepositoryTextViewer(TaskRepository repository, FormEditor editor, Composite composite, int style) { >+ super(composite, new VerticalRuler(VERTICAL_RULER_WIDTH), style); >+ >+ annotationModel = new AnnotationModel(); >+ getVerticalRuler().setModel(annotationModel); >+ this.showAnnotations(true); >+ >+ repositoryViewerConfig = new RepositoryViewerConfig(editor); >+ this.configure(repositoryViewerConfig); > this.repository = repository; > } > >+ public void setDocument(IDocument doc) { >+ annotationModel.connect(doc); >+ super.setDocument(doc, annotationModel); >+ repositoryViewerConfig.setAnnotationModel(getAnnotationModel()); >+ } >+ > public TaskRepository getRepository() { > return repository; > } >@@ -60,10 +82,20 @@ > public void setRepository(TaskRepository repository) { > this.repository = repository; > } >- >+ > class RepositoryViewerConfig extends TextSourceViewerConfiguration { > > private RepositoryTextScanner scanner = null; >+ private FormEditor editor; >+ private TaskSpellingReconcileStrategy strategy; >+ >+ public RepositoryViewerConfig(FormEditor editor) { >+ this.editor = editor; >+ } >+ >+ public void setAnnotationModel(IAnnotationModel model) { >+ strategy.setAnnotationModel(model); >+ } > > public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { > PresentationReconciler reconciler = new PresentationReconciler(); >@@ -96,6 +128,19 @@ > public int getHyperlinkStateMask(ISourceViewer sourceViewer) { > return SWT.NONE; > } >+ >+ public IReconciler getReconciler(ISourceViewer sourceViewer) { >+ if (editor != null) { >+ strategy= new TaskSpellingReconcileStrategy(editor); >+ MonoReconciler reconciler= new MonoReconciler(strategy, false); >+ reconciler.setIsIncrementalReconciler(false); >+ reconciler.setProgressMonitor(new NullProgressMonitor()); >+ reconciler.setDelay(500); >+ return reconciler; >+ } >+ return null; >+ } >+ > } > > static class RepositoryTextScanner extends RuleBasedScanner { >Index: src/org/eclipse/mylar/internal/tasks/ui/editors/TaskSpellingReconcileStrategy.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/tasks/ui/editors/TaskSpellingReconcileStrategy.java >diff -N src/org/eclipse/mylar/internal/tasks/ui/editors/TaskSpellingReconcileStrategy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/tasks/ui/editors/TaskSpellingReconcileStrategy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,210 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 Mylar committers and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.tasks.ui.editors; >+ >+import java.util.ArrayList; >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Map; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.content.IContentTypeManager; >+import org.eclipse.jdt.core.compiler.IProblem; >+import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.ProblemAnnotation; >+import org.eclipse.jdt.internal.ui.text.spelling.CoreSpellingProblem; >+import org.eclipse.jdt.internal.ui.text.spelling.JavaSpellingProblem; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.IRegion; >+import org.eclipse.jface.text.Position; >+import org.eclipse.jface.text.Region; >+import org.eclipse.jface.text.reconciler.DirtyRegion; >+import org.eclipse.jface.text.reconciler.IReconcilerExtension; >+import org.eclipse.jface.text.reconciler.IReconcilingStrategy; >+import org.eclipse.jface.text.source.Annotation; >+import org.eclipse.jface.text.source.IAnnotationModel; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.editors.text.EditorsUI; >+import org.eclipse.ui.forms.editor.FormEditor; >+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector; >+import org.eclipse.ui.texteditor.spelling.SpellingContext; >+import org.eclipse.ui.texteditor.spelling.SpellingProblem; >+ >+/** >+ * Adapted from >+ * org.eclipse.jdt.internal.ui.text.spelling.PropertiesSpellingReconcileStrategy >+ * >+ * @author Jeff Pound >+ */ >+public class TaskSpellingReconcileStrategy implements IReconcilerExtension, IReconcilingStrategy { >+ >+ /** >+ * Spelling problem collector that forwards {@link SpellingProblem}s as >+ * {@link IProblem}s to the {@link org.eclipse.jdt.core.IProblemRequestor}. >+ */ >+ private class SpellingProblemCollector implements ISpellingProblemCollector { >+ >+ /** Annotation model */ >+ private IAnnotationModel fAnnotationModel; >+ >+ /** Annotations to add */ >+ private Map<ProblemAnnotation, Position> fAddAnnotations; >+ >+ /** >+ * Initializes this collector with the given annotation model. >+ * >+ * @param annotationModel >+ * the annotation model >+ */ >+ public SpellingProblemCollector(IAnnotationModel annotationModel) { >+ fAnnotationModel = annotationModel; >+ } >+ >+ /* >+ * @see org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#accept(org.eclipse.ui.texteditor.spelling.SpellingProblem) >+ */ >+ public void accept(SpellingProblem problem) { >+ try { >+ int line = fDocument.getLineOfOffset(problem.getOffset()) + 1; >+ String word = fDocument.get(problem.getOffset(), problem.getLength()); >+ boolean dictionaryMatch = false; >+ boolean sentenceStart = false; >+ if (problem instanceof JavaSpellingProblem) { >+ dictionaryMatch = ((JavaSpellingProblem) problem).isDictionaryMatch(); >+ sentenceStart = ((JavaSpellingProblem) problem).isSentenceStart(); >+ } >+ // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514 >+ IEditorInput editorInput = editor.getEditorInput(); >+ if (editorInput != null) { >+ CoreSpellingProblem iProblem = new CoreSpellingProblem(problem.getOffset(), problem.getOffset() >+ + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, >+ sentenceStart, fDocument, editorInput.getName()); >+ System.err.println(word); >+ fAddAnnotations.put(new ProblemAnnotation(iProblem, null), new Position(problem.getOffset(), >+ problem.getLength())); >+ } >+ } catch (BadLocationException x) { >+ // drop this SpellingProblem >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#beginCollecting() >+ */ >+ public void beginCollecting() { >+ fAddAnnotations = new HashMap<ProblemAnnotation, Position>(); >+ } >+ >+ /* >+ * @see org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#endCollecting() >+ */ >+ public void endCollecting() { >+ >+ List<Annotation> removeAnnotations = new ArrayList<Annotation>(); >+ for (Iterator iter = fAnnotationModel.getAnnotationIterator(); iter.hasNext();) { >+ Annotation annotation = (Annotation) iter.next(); >+ if (ProblemAnnotation.SPELLING_ANNOTATION_TYPE.equals(annotation.getType())) >+ removeAnnotations.add(annotation); >+ } >+ >+// if (fAnnotationModel instanceof IAnnotationModelExtension) >+// ((IAnnotationModelExtension) fAnnotationModel).replaceAnnotations((Annotation[]) removeAnnotations >+// .toArray(new Annotation[removeAnnotations.size()]), fAddAnnotations); >+// else { >+ for (Iterator iter = removeAnnotations.iterator(); iter.hasNext();) >+ fAnnotationModel.removeAnnotation((Annotation) iter.next()); >+ for (Iterator iter = fAddAnnotations.keySet().iterator(); iter.hasNext();) { >+ Annotation annotation = (Annotation) iter.next(); >+ fAnnotationModel.addAnnotation(annotation, (Position) fAddAnnotations.get(annotation)); >+ } >+// } >+ >+ fAddAnnotations = null; >+ } >+ } >+ >+ /** The id of the problem */ >+ public static final int SPELLING_PROBLEM_ID = 0x80000000; >+ >+ /** The document to operate on. */ >+ private IDocument fDocument; >+ >+ /** The progress monitor. */ >+ private IProgressMonitor fProgressMonitor; >+ >+ /** >+ * The spelling context containing the Java properties content type. >+ * <p> >+ * Since his reconcile strategy is for the Properties File editor which >+ * normally edits Java properties files we always use the Java properties >+ * file content type for performance reasons. >+ * </p> >+ * >+ * @since 3.2 >+ */ >+ private SpellingContext fSpellingContext; >+ >+ private FormEditor editor; >+ >+ private IAnnotationModel annotationModel; >+ >+ public TaskSpellingReconcileStrategy(FormEditor editor) { >+ this.editor = editor; >+ this.annotationModel = null; >+ fSpellingContext = new SpellingContext(); >+ fSpellingContext.setContentType(Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT)); >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile() >+ */ >+ public void initialReconcile() { >+ reconcile(new Region(0, fDocument.getLength())); >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion,org.eclipse.jface.text.IRegion) >+ */ >+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { >+ reconcile(subRegion); >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion) >+ */ >+ public void reconcile(IRegion region) { >+ TaskSpellingReconcileStrategy.SpellingProblemCollector collector = new SpellingProblemCollector(annotationModel); >+ EditorsUI.getSpellingService().check(fDocument, fSpellingContext, collector, fProgressMonitor); >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument) >+ */ >+ public void setDocument(IDocument document) { >+ fDocument = document; >+ } >+ >+ /* >+ * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public void setProgressMonitor(IProgressMonitor monitor) { >+ fProgressMonitor = monitor; >+ } >+ >+ public String getDocumentPartitioning() { >+ // ignore >+ return null; >+ } >+ >+ public void setAnnotationModel(IAnnotationModel model) { >+ annotationModel = model; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 103093
: 47718 |
47719
|
48766