KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > spelling > TextSpellingEngine


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.text.spelling;
13
14 import org.eclipse.core.runtime.IProgressMonitor;
15
16 import org.eclipse.jface.text.IDocument;
17 import org.eclipse.jface.text.IRegion;
18
19 import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
20
21 import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker;
22
23 /**
24  * Text spelling engine
25  *
26  * @since 3.1
27  */

28 public class TextSpellingEngine extends SpellingEngine {
29
30     /*
31      * @see org.eclipse.jdt.internal.ui.text.spelling.SpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
32      */

33     protected void check(IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor) {
34         SpellEventListener listener= new SpellEventListener(collector, document);
35         try {
36             checker.addListener(listener);
37             for (int i= 0; i < regions.length; i++) {
38                 if (monitor != null && monitor.isCanceled())
39                     return;
40                 if (listener.isProblemsThresholdReached())
41                     return;
42                 checker.execute(new SpellCheckIterator(document, regions[i], checker.getLocale()));
43             }
44         } finally {
45             checker.removeListener(listener);
46         }
47     }
48 }
49
Popular Tags