Package org.wikipediacleaner.api.check

Examples of org.wikipediacleaner.api.check.CheckErrorResult


        if ((alt == null) || (alt.trim().length() == 0)) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, image.getBeginIndex(), image.getEndIndex());

          // Action: add a description
          StringBuilder prefixFull = new StringBuilder();
          prefixFull.append("[[");
          prefixFull.append(image.getNamespace());
          prefixFull.append(":");
          prefixFull.append(image.getImage());
          StringBuilder prefixShort = new StringBuilder(prefixFull);
          if (image.getParameters() != null) {
            for (PageElementImage.Parameter param : image.getParameters()) {
              prefixFull.append("|");
              prefixFull.append(param.getContents());
              if (!magicWordImgAlt.isPossibleAlias(param.getContents())) {
                prefixShort.append("|");
                prefixShort.append(param.getContents());
              }
            }
          }
          prefixFull.append("|");
          prefixShort.append("|alt=");
          errorResult.addPossibleAction(
              GT._("Add a description..."),
              new AddTextActionProvider(
                  prefixFull.toString(), "]]",
                  new TextProviderImageDescription(image),
                  GT._("What description would you like to use for the image ?"),
                  descriptionChecker));
          errorResult.addPossibleAction(
              GT._("Add an alternate description..."),
              new AddTextActionProvider(
                  prefixShort.toString(), "]]",
                  new TextProviderImageDescription(image),
                  GT._("What alternate description would you like to use for the image ?"),
                  descriptionChecker));

          // Action: view image
          errorResult.addPossibleAction(new SimpleAction(
              GT._("View image"),
              new ActionExternalViewer(
                  wiki,
                  image.getNamespace() + ":" + image.getImage(),
                  true)));
View Full Code Here


        startIndex = link.getEndIndex();
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, link.getBeginIndex(), link.getEndIndex());
        if (link.getText() != null) {
          errorResult.addReplacement(link.getText());
        } else {
          errorResult.addReplacement(link.getLink());
        }
        errors.add(errorResult);
      } else {
        startIndex = contents.length();
      }
View Full Code Here

        if ((check != computedCheck) && Character.isDigit(computedCheck)) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(analysis, isbn, true);
          errorResult.addPossibleAction(
              GT._(
                  "The checksum is {0} instead of {1}",
                  new Object[] { check, computedCheck } ),
              new NullActionProvider());
          addHelpNeededTemplates(analysis, errorResult, isbn);
View Full Code Here

      if (link.getFullLink().trim().length() == 0) {
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, link.getBeginIndex(), link.getEndIndex());
        String text = link.getText();
        if ((text != null) && (text.length() > 0)) {
          errorResult.addReplacement("[[" + link.getText() + "]]");
        }
        errors.add(errorResult);
      }
    }
View Full Code Here

          if (punctuationFoundAfter) {
            endIndex = tmpIndex;
          }
 
          // Create error
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, beginIndex, endIndex);
          boolean automatic = false;
          if (allPunctuations.equals(".") && !punctuationFoundAfter) {
            tmpIndex = endIndex;
            while ((tmpIndex < contents.length()) && (contents.charAt(tmpIndex) == ' ')) {
              tmpIndex++;
            }
            if (contents.startsWith("\n\n", tmpIndex) ||
                contents.startsWith("\n*", tmpIndex)) {
              automatic = true;
            }
          }
          for (String[] generalAbbreviation : generalAbbreviationFound) {
            if ((generalAbbreviation.length > 2)) {
              String abbreviation = generalAbbreviation[2];
              String meaning = "";
              if (generalAbbreviation[1].length() > 0) {
                meaning = " (" + generalAbbreviation[1] + ")";
              }
              errorResult.addReplacement(
                  abbreviation + replace + punctuationAfter,
                  abbreviation + textReplace + punctuationAfter + meaning);
            }
          }
          errorResult.addReplacement(
              prefix + replace + moveablePrefix + allPunctuations,
              prefix + textReplace + moveablePrefix + allPunctuations, automatic);
          if (punctuationFoundAfter &&
              !allPunctuations.equals(punctuationAfter)) {
            errorResult.addReplacement(
                prefix + replace + moveablePrefix + punctuationAfter,
                prefix + textReplace + moveablePrefix + punctuationAfter);
          }
          errors.add(errorResult);

        } else {

          // Create error
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, firstTag.getBeginIndex(), lastTag.getEndIndex());
          errorResult.addReplacement(replace, textReplace);
          errors.add(errorResult);
        }
      }
    }
    return result;
View Full Code Here

          if (errors == null) {
            return true;
          }
          result = true;

          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, galleryTag.getBeginIndex(), galleryTag.getEndIndex());
          errors.add(errorResult);
        }
      }
    }
View Full Code Here

          if (attrInfo instanceof CheckErrorResult) {
            int startOffset = MWPaneFormatter.getUUIDStartOffset(textPane, run);
            int endOffset = MWPaneFormatter.getUUIDEndOffet(textPane, run);
            if (originalText.equals(textPane.getText(startOffset, endOffset - startOffset))) {
              boolean possible = false;
              CheckErrorResult info = (CheckErrorResult) attrInfo;
              List<Actionnable> actionnables = info.getPossibleActions();
              if (actionnables != null) {
                for (Actionnable actionnable : actionnables) {
                  possible |= actionnable.isPossibleReplacement(newText);
                }
              }
View Full Code Here

      if (category.getBeginIndex() < title.getBeginIndex()) {
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis,
            category.getBeginIndex(),
            category.getEndIndex());
        String categoryName = category.getName();
        if ((categoryName == null) || ("".equals(categoryName))) {
          errorResult.addReplacement("", true);
        }
        errors.add(errorResult);
      }
    }
View Full Code Here

            PageElementTag.TAG_WIKI_IMAGEMAP, link.getBeginIndex());
        if (tagImagemap != null) {
          int previousCR = getPreviousCR(contents, link.getBeginIndex());
          int nextCR = getNextCR(contents, link.getEndIndex());
          nextCR = Math.min(nextCR, tagImagemap.getMatchingTag().getBeginIndex());
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, previousCR, nextCR);
          if ((previousCR > tagImagemap.getEndIndex()) &&
              (contents.charAt(nextCR) == '\n')) {
            errorResult.addReplacement("", GT._("Delete"));
          }
          errors.add(errorResult);
        } else {
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis,
              link.getBeginIndex(), link.getEndIndex());
          errorResult.addReplacement(link.getDisplayedText());
          errorResult.addReplacement("'''" + link.getDisplayedText() + "'''");
          errors.add(errorResult);
        }
      }
    }
    return result;
View Full Code Here

      if (!tag.isComplete()) {
        if (errors == null) {
          return true;
        }
        result = true;
        CheckErrorResult errorResult = createCheckErrorResult(
            analysis, tag.getBeginIndex(), tag.getEndIndex());
        errors.add(errorResult);
      }
    }
    return result;
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.check.CheckErrorResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.