listLinks.clearSelection();
listErrors.clearSelection();
// Update links information
Page page = getPage();
PageAnalysis analysis = page.getAnalysis(page.getContents(), true);
mapLinksTotalCount = new HashMap<String, Integer>();
mapLinksHelpNeededCount = new HashMap<String, Integer>();
if (page.getLinks() != null) {
List<Page> links = page.getLinks();
modelLinks.setElements(links);
countOccurrences(analysis, true);
for (Page p : links) {
if ((p != null) &&
(Boolean.TRUE.equals(p.isDisambiguationPage()))) {
InternalLinkCount count = analysis.getLinkCount(p);
if ((count != null) && (count.getTotalLinkCount() > 0)) {
mapLinksTotalCount.put(p.getTitle(), Integer.valueOf(count.getTotalLinkCount()));
mapLinksHelpNeededCount.put(p.getTitle(), Integer.valueOf(count.getHelpNeededCount()));
}
}
}
}
selectLinks(0);
modelLinks.updateLinkCount();
// Update fix redirects menu
createFixRedirectsMenu();
// Check Wiki
modelErrors.clear();
initializeInitialErrors(allAlgorithms);
if (getInitialErrors() != null) {
for (CheckErrorPage error : getInitialErrors()) {
modelErrors.addElement(error);
}
}
listErrors.clearSelection();
if (firstReload) {
firstReload = false;
// Check page contents
Page pageLoaded = getPage();
if ((pageLoaded != null) &&
(Boolean.FALSE.equals(pageLoaded.isExisting()))) {
List<Page> similarPages = pageLoaded.getRelatedPages(Page.RelatedPages.SIMILAR_PAGES);
if ((similarPages != null) && (similarPages.size() > 0)) {
String answer = Utilities.askForValue(
getParentComponent(),
GT._(
"Page {0} doesn''t exist, do you want to load a similar page ?",
pageLoaded.getTitle()),
similarPages.toArray(), true,
similarPages.get(0).toString(), null);
if ((answer != null) && (answer.trim().length() > 0)) {
Controller.runFullAnalysis(answer, null, getWikipedia());
}
dispose();
return;
}
int answer = Utilities.displayYesNoWarning(
getParentComponent(),
GT._(
"Page {0} doesn''t exist, do you still want to analyze it ?",
pageLoaded.getTitle()));
if (answer != JOptionPane.YES_OPTION) {
dispose();
return;
}
}
// Configuration depending on the type of page
boolean isArticle = (getPage() != null) && (getPage().isArticle());
if (isArticle) {
WPCConfiguration wpcConfig = getConfiguration();
boolean isbnErrors = Page.areSameTitle(
getPage().getTitle(),
wpcConfig.getString(WPCConfigurationString.ISBN_ERRORS_PAGE));
Integer namespace = getPage().getNamespace();
Configuration config = Configuration.getConfiguration();
if (getPage().isInMainNamespace()) {
chkUpdateDabWarning.setSelected(config.getBoolean(
null,
ConfigurationValueBoolean.UPDATE_DAB_WARNING));
chkCreateDabWarning.setSelected(!isbnErrors && config.getBoolean(
null,
ConfigurationValueBoolean.CREATE_DAB_WARNING));
} else if ((namespace != null) &&
(wpcConfig.isEncyclopedicNamespace(namespace))) {
chkUpdateDabWarning.setSelected(config.getBoolean(
null,
ConfigurationValueBoolean.UPDATE_DAB_WARNING_ENCY));
chkCreateDabWarning.setSelected(!isbnErrors && config.getBoolean(
null,
ConfigurationValueBoolean.CREATE_DAB_WARNING_ENCY));
} else {
chkUpdateDabWarning.setSelected(config.getBoolean(
null,
ConfigurationValueBoolean.UPDATE_DAB_WARNING_ALL));
chkCreateDabWarning.setSelected(!isbnErrors && config.getBoolean(
null,
ConfigurationValueBoolean.CREATE_DAB_WARNING_ALL));
}
}
}
updateComponentState();
// Edit warning if needed
boolean automaticFix = true;
WPCConfiguration wpcConfig = getWikipedia().getConfiguration();
List<String[]> warningTemplates = wpcConfig.getStringArrayList(
WPCConfigurationStringList.EDIT_WARNING_TEMPLATES);
if ((warningTemplates != null) && (!warningTemplates.isEmpty())) {
StringBuilder tmp = new StringBuilder(GT._(
"\"{0}\" has been tagged with the following templates, be careful when editing:",
getPage().getTitle()));
boolean found = false;
for (String[] warningTemplate : warningTemplates) {
if ((warningTemplate.length > 0) && (warningTemplate[0] != null)) {
List<PageElementTemplate> templates = analysis.getTemplates(warningTemplate[0]);
for (PageElementTemplate template : templates) {
tmp.append("\n* ");
tmp.append(template.getTemplateName());
if ((warningTemplate.length > 1) && (warningTemplate[1] != null)) {
String message = template.getParameterValue(warningTemplate[1]);