本文整理汇总了Java中com.swabunga.spell.event.SpellCheckEvent类的典型用法代码示例。如果您正苦于以下问题:Java SpellCheckEvent类的具体用法?Java SpellCheckEvent怎么用?Java SpellCheckEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpellCheckEvent类属于com.swabunga.spell.event包,在下文中一共展示了SpellCheckEvent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: spellingError
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public void spellingError(SpellCheckEvent event) {
String invalidWord = event.getInvalidWord();
List suggestionsList = event.getSuggestions();
//System.out.println("Invalid Word: " + event.getInvalidWord());
if (mSuggestions.containsKey(invalidWord)) // if we already recorded this misspell previously, exit
return;
mMisspelledWords.add(event.getInvalidWord());
ArrayList suggestionsForWord = new ArrayList<String>();
for (Iterator suggestedWord = suggestionsList.iterator(); suggestedWord.hasNext();) {
Word currentSuggestion = (Word) suggestedWord.next();
suggestionsForWord.add(currentSuggestion.getWord());
//System.out.println("\tSuggested Word: " + currentSuggestion);
}
mSuggestions.put(invalidWord, suggestionsForWord);
}
示例2: spellingError
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
/**
* @param event Description of the Parameter
*/
public void spellingError(SpellCheckEvent event) {
// java.util.List suggestions = event.getSuggestions();
event.getSuggestions();
int start = event.getWordContextPosition();
int end = start + event.getInvalidWord().length();
// Mark the invalid word in TextComponent
// added by Saruta
CaretListener cl[] = textComp.getCaretListeners();
for (int i = 0; i < cl.length; i++)
textComp.removeCaretListener(cl[i]);
textComp.requestFocus();
textComp.setCaretPosition(0);
textComp.setCaretPosition(start);
textComp.moveCaretPosition(end);
for (int i = 0; i < cl.length; i++)
textComp.addCaretListener(cl[i]);
try {
Rectangle r = textComp.modelToView(start);
r.add(textComp.modelToView(end));
textComp.scrollRectToVisible(r);
}
catch (Exception ex) {}
dlg.show(event);
}
示例3: spellingError
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public void spellingError(SpellCheckEvent event) {
@SuppressWarnings("unchecked")
List<Word> suggestions = (List<Word>) event.getSuggestions();
if (suggestions.size() > 0) {
Iterator<Word> suggestedWord = suggestions.iterator();
if (suggestedWord.hasNext()) {
String orig = event.getInvalidWord();
String sugg = suggestedWord.next().getWord();
if (_correctionType == SpellCorrectionType.Add)
event.replaceWord(sugg + " ( " + orig + " ) ", false);
else if (_correctionType == SpellCorrectionType.Replace)
event.replaceWord(sugg, false);
}
}
}
示例4: check
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public void check(IDocument document, IRegion[] regions, SpellingContext context,
ISpellingProblemCollector collector, IProgressMonitor monitor) {
if (ignore == null) {
ignore = new HashSet<String>();
}
IProject project = getProject(document);
String lang = DEFAULT_LANG;
if (project != null) {
lang = TexlipseProperties.getProjectProperty(project, TexlipseProperties.LANGUAGE_PROPERTY);
}
//Get spellchecker for the correct language
SpellChecker spellCheck = getSpellChecker(lang);
if (spellCheck == null) return;
if (collector instanceof TeXSpellingProblemCollector) {
((TeXSpellingProblemCollector) collector).setRegions(regions);
}
try {
spellCheck.addSpellCheckListener(this);
for (final IRegion r : regions) {
errors = new LinkedList<SpellCheckEvent>();
int roffset = r.getOffset();
//Create a new wordfinder and initialize it
TexlipseWordFinder wf = new TexlipseWordFinder();
wf.setIgnoreComments(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.SPELLCHECKER_IGNORE_COMMENTS));
wf.setIgnoreMath(TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.SPELLCHECKER_IGNORE_MATH));
spellCheck.checkSpelling(new StringWordTokenizer(
document.get(roffset, r.getLength()), wf));
for (SpellCheckEvent error : errors) {
SpellingProblem p = new TexSpellingProblem(error, roffset, lang);
collector.accept(p);
}
}
spellCheck.removeSpellCheckListener(this);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
示例5: spellingError
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public void spellingError(SpellCheckEvent event) {
String invWord = event.getInvalidWord();
if (invWord.length() < 3) return;
if (invWord.indexOf('_') > -1) return;
if (invWord.indexOf('^') > -1) return;
if (ignore.contains(invWord)) return;
if (TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.SPELLCHECKER_IGNORE_MIXED_CASE)) {
if (isMixedCase(invWord)) return;
}
errors.add(event);
}
示例6: SpellCheckError
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public SpellCheckError(SpellCheckEvent event, SpellChecker spellChecker) {
this.error = event.getInvalidWord();
this.position = event.getWordContextPosition();
// List<String> suggestions = event.getSuggestions();
List<Word> suggestions = spellChecker.getSuggestions(error, 1);
if (suggestions != null && suggestions.size() > 0) {
String firstSuggestion = suggestions.get(0).getWord();
if (!firstSuggestion.equals(this.error)) {
this.suggestion = firstSuggestion;
}
}
}
示例7: spellingError
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
@Override
public void spellingError(SpellCheckEvent event) {
event.ignoreWord(true);
misspelledWords.add(event.getInvalidWord());
}
示例8: AddToDictProposal
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public AddToDictProposal(SpellCheckEvent error, String lang,
ISourceViewer viewer) {
ferror = error;
fLang = lang;
fviewer = viewer;
}
示例9: TexSpellingProblem
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public TexSpellingProblem(SpellCheckEvent error, int roffset, String lang) {
this.fError = error;
this.fOffset = roffset + fError.getWordContextPosition();
fLang = lang;
}
示例10: spellingError
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
public void spellingError(SpellCheckEvent event) {
spellCheckErrors.add(new SpellCheckError(event, spellChecker));
}
示例11: iterator
import com.swabunga.spell.event.SpellCheckEvent; //导入依赖的package包/类
@Override
public Iterator<SpellCheckEvent> iterator() {
return ImmutableList.copyOf(errors).iterator();
}