/* LanguageTool, a natural language style checker 
 * Copyright (C) 2005 Daniel Naber (http://www.danielnaber.de)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package de.danielnaber.languagetool.openoffice;

//import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import de.danielnaber.languagetool.JLanguageTool;
import de.danielnaber.languagetool.Language;
import de.danielnaber.languagetool.gui.Configuration;
import de.danielnaber.languagetool.rules.RuleMatch;

class CheckerThread extends Thread {

  private List<String> paragraphs;
  private Language docLanguage;
  private Configuration config;
  //private File baseDir;
  
  private ProgressInformation progressInfo;
  
  private JLanguageTool langTool; 
  private List<CheckedParagraph> checkedParagraphs = new ArrayList<CheckedParagraph>();
  private boolean done = false;
  
  CheckerThread(final List<String> paragraphs, final Language docLanguage, final Configuration config,
      final ProgressInformation progressInfo) {
    this.paragraphs = paragraphs;
    this.docLanguage = docLanguage;
    this.config = config;
    //this.baseDir = baseDir;
    this.progressInfo = progressInfo;
    progressInfo.setMaxProgress(paragraphs.size());
  }
  
  public boolean done() {
    return done;
  }

  List<CheckedParagraph> getRuleMatches() {
    return checkedParagraphs;
  }

  JLanguageTool getLanguageTool() {
    return langTool;
  }

  public void run() {
    try {
      langTool = new JLanguageTool(docLanguage, config.getMotherTongue());
      langTool.activateDefaultPatternRules();
      langTool.activateDefaultFalseFriendRules();
      if (config.getDisabledRuleIds() != null) {
        for (String id : config.getDisabledRuleIds()) {
          langTool.disableRule(id);
        }
      }
      Set<String> disabledCategories = config.getDisabledCategoryNames();
      if (disabledCategories != null) {
        for (String categoryName : disabledCategories) {
          langTool.disableCategory(categoryName);
        }
      }
      int paraCount = 0;
      for (String para : paragraphs) {
        List<RuleMatch> ruleMatches = langTool.check(para);
        if (ruleMatches.size() > 0) {
          checkedParagraphs.add(new CheckedParagraph(paraCount, ruleMatches));
        }
        paraCount++;
        progressInfo.setProgress(paraCount);
      }
      done = true;
    } catch (Exception e) {
      done = true;
      Main.showError(e);
    }
  }
  
}

@@ -907,31 +907,8 @@
 e;%0A%0A
-//import java.io.File;%0A
 impo
@@ -1320,37 +1320,9 @@
 ig;%0A
-  //private File baseDir;%0A  
 %0A
+
   pr
@@ -1361,19 +1361,17 @@
 ssInfo;%0A
-  
 %0A
+
   privat
@@ -1517,19 +1517,17 @@
  false;%0A
-  
 %0A
+
   Checke
@@ -1769,38 +1769,8 @@
 ig;%0A
-    //this.baseDir = baseDir;%0A
     
@@ -1859,18 +1859,16 @@
 ));%0A  %7D%0A
-  
 %0A  publi
@@ -3076,13 +3076,11 @@
   %7D%0A  %7D%0A
-  
 %0A%7D%0A

remove unused comments - no functional change