public void spellingError(SpellCheckEvent event) {
    List<String> suggestions = new ArrayList<String>();

    Iterator<Word> itr = event.getSuggestions().iterator();

    while (itr.hasNext()) {
      Word word = itr.next();

      suggestions.add(word.getWord());
    }

    int pos = event.getWordContextPosition();

    if (pos >= 0) {
      if ((pos == 0)
          || ((pos > 0)
              &&
              // (_text.charAt(pos - 1) != '<') &&
              (!_isInsideHtmlTag(pos))
              && (_text.charAt(pos - 1) != '&')
              && (event.getInvalidWord().length() > 1))) {

        _invalidWords.add(
            new InvalidWord(
                event.getInvalidWord(), suggestions,
                event.getWordContext(), pos));
      }
    }
  }
  @Override
  public void spellingError(SpellCheckEvent event) {
    List<String> suggestions = new ArrayList<String>();

    for (Word word : (List<Word>) event.getSuggestions()) {
      suggestions.add(word.getWord());
    }

    int pos = event.getWordContextPosition();

    if (pos >= 0) {
      if ((pos == 0)
          || ((pos > 0)
              &&
              // (_text.charAt(pos - 1) != '<') &&
              (!_isInsideHtmlTag(pos))
              && (_text.charAt(pos - 1) != '&')
              && (event.getInvalidWord().length() > 1))) {

        _invalidWords.add(
            new InvalidWord(
                event.getInvalidWord(), suggestions,
                event.getWordContext(), pos));
      }
    }
  }
示例#3
0
  /** @param gc */
  private void paintSpellError(GC gc) {
    if (ranges.isEmpty()) return;

    int lineStyle = gc.getLineStyle();
    int lineWidth = gc.getLineWidth();
    Color lineColor = gc.getForeground();
    gc.setLineWidth(2);
    gc.setLineStyle(SWT.LINE_DOT);
    gc.setForeground(gc.getDevice().getSystemColor(SWT.COLOR_RED));
    int charCount = contentAdapter.getControlContents(control).length();
    Rectangle clipping = gc.getClipping();
    lineCache.clear();
    for (Object obj : ranges.values().toArray()) {
      SpellCheckEvent range = (SpellCheckEvent) obj;
      int start = range.getWordContextPosition();
      if (start < 0 || start >= charCount) continue;

      int length = Math.min(range.getInvalidWord().length(), charCount - start);
      if (length <= 0) continue;

      drawLines(gc, start, start + length - 1, clipping);
    }
    gc.setLineWidth(lineWidth);
    gc.setLineStyle(lineStyle);
    gc.setForeground(lineColor);
  }
示例#4
0
 public void run() {
   if (!isActive()) return;
   String old = contentAdapter.getControlContents(control);
   int oldLength = old.length();
   int start = range.getWordContextPosition();
   String invalidWord = range.getInvalidWord();
   int invalidLength = invalidWord.length();
   if (start < oldLength && start + invalidLength <= oldLength) {
     contentAdapter.replaceControlContents(control, start, invalidLength, suggestion);
     check(Display.getCurrent());
   }
 }
示例#5
0
 private SpellCheckEvent getCurrentRange() {
   int pos = contentAdapter.getCursorPosition(control);
   for (Entry<Integer, SpellCheckEvent> en : ranges.entrySet()) {
     SpellCheckEvent range = en.getValue();
     int start = en.getKey().intValue();
     int length = range.getInvalidWord().length();
     if (start <= pos && pos <= start + length) {
       return range;
     }
   }
   return null;
 }
示例#6
0
 public SuggestionAction(SpellCheckEvent range, String suggestion) {
   super(range.getInvalidWord() + " -> " + suggestion); // $NON-NLS-1$
   this.range = range;
   this.suggestion = suggestion;
 }