Package org.wikipediacleaner.utils

Examples of org.wikipediacleaner.utils.ConfigurationValueStyle


    if ((doc == null) || (error == null)) {
      return;
    }

    // Format error
    ConfigurationValueStyle styleConfig = ConfigurationValueStyle.CHECK_WIKI_ERROR;
    if (error.getErrorLevel() == CheckErrorResult.ErrorLevel.CORRECT) {
      styleConfig = ConfigurationValueStyle.CHECK_WIKI_OK;
    } else if (error.getErrorLevel() == CheckErrorResult.ErrorLevel.WARNING) {
      styleConfig = ConfigurationValueStyle.CHECK_WIKI_WARNING;
    }
    doc.setCharacterAttributes(
        error.getStartPosition(),
        error.getLength(),
        doc.getStyle(styleConfig.getName()),
        true);
    SimpleAttributeSet attributes = new SimpleAttributeSet();
    attributes.addAttribute(MWPaneFormatter.ATTRIBUTE_INFO, error);
    attributes.addAttribute(MWPaneFormatter.ATTRIBUTE_UUID, UUID.randomUUID());
    doc.setCharacterAttributes(
View Full Code Here


      end++;
    }
    if (end > internalLink.getEndIndex()) {
      text = text + contents.substring(internalLink.getEndIndex(), end);
    }
    ConfigurationValueStyle styleType = null;
    if (disambiguation) {
      styleType = ConfigurationValueStyle.INTERNAL_LINK_DAB;

      // Check if a template is after the link to ask for help
      List<String> templatesAfter = wikipedia.getConfiguration().getStringList(
          WPCConfigurationStringList.TEMPLATES_AFTER_HELP_ASKED);
      if ((templatesAfter != null) && !templatesAfter.isEmpty()) {
        int maxSize = contents.length();
        int currentPos = end;
        while ((currentPos < maxSize) && (contents.charAt(currentPos) == ' ')) {
          currentPos++;
        }
        if ((currentPos < maxSize) && (contents.charAt(currentPos) == '{')) {
          PageElementTemplate nextTemplate = pageAnalysis.isInTemplate(currentPos);
          if (nextTemplate != null) {
            for (String templateAfter : templatesAfter) {
              if (Page.areSameTitle(templateAfter, nextTemplate.getTemplateName())) {
                styleType = ConfigurationValueStyle.HELP_REQUESTED;
                end = nextTemplate.getEndIndex();
              }
            }
          }
        }
      }

      List<String> commentsAfter = wikipedia.getConfiguration().getStringList(
          WPCConfigurationStringList.COMMENTS_FOR_DAB_LINK);
      if ((commentsAfter != null) && !commentsAfter.isEmpty()) {
        int maxSize = contents.length();
        int currentPos = end;
        while ((currentPos < maxSize) && (contents.charAt(currentPos) == ' ')) {
          currentPos++;
        }
        if ((currentPos < maxSize) && (contents.charAt(currentPos) == '<')) {
          PageElementComment comment = pageAnalysis.isInComment(currentPos);
          if (comment != null) {
            for (String commentAfter : commentsAfter) {
              String comment2 = comment.getComment();
              if ((comment2 != null) && (comment2.length() >= commentAfter.length())) {
                comment2 = comment2.substring(0, commentAfter.length());
                if (comment2.equalsIgnoreCase(commentAfter)) {
                  styleType = ConfigurationValueStyle.INTERNAL_LINK_NORMAL;
                  end = comment.getEndIndex();
                }
              }
            }
          }
        }
      }
    } else if (link.isRedirect()) {
      styleType = ConfigurationValueStyle.INTERNAL_LINK_REDIRECT;
    } else if (Boolean.TRUE.equals(link.isExisting())) {
      styleType = ConfigurationValueStyle.INTERNAL_LINK_NORMAL;
    } else {
      styleType = ConfigurationValueStyle.INTERNAL_LINK_MISSING;
    }
    Style attr = doc.getStyle(styleType.getName());
    if (attr == null) {
      return;
    }
    attr = (Style) attr.copyAttributes();
    attr.addAttribute(ATTRIBUTE_PAGE, link);
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.utils.ConfigurationValueStyle

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.