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));
      }
    }
  }
Example #2
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);
  }
  @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));
      }
    }
  }
Example #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());
   }
 }
Example #5
0
 public void spellingError(SpellCheckEvent event) {
   int start = event.getWordContextPosition();
   ranges.put(Integer.valueOf(start), event);
 }