}
}
}
}
API api = APIFactory.getAPI();
Page category = DataManager.getPage(toWikipedia, "Category:" + title, null, null, null);
api.retrieveContents(toWikipedia, Collections.singletonList(category), false, false);
if (category.isExisting() == null) {
Utilities.displayWarning(
textPane.getParent(),
GT._(
"Unable to find if category {0} exists in \"{1}\".",
new Object[] { title, toWikipedia.toString() }));
return;
}
if (Boolean.TRUE.equals(category.isExisting())) {
String replace = categoryName + ":" + title + ((order != null) ? "|" + order : "");
int answer = Utilities.displayYesNoWarning(
textPane.getParent(),
GT._(
"The category {0} exists in \"{1}\".\n" +
"Do you want to replace the category by [[{2}]] ?",
new Object[] { title, toWikipedia.toString(), replace }));
if (answer == JOptionPane.YES_OPTION) {
int startOffset = element.getStartOffset();
int endOffset = element.getEndOffset();
try {
textPane.getDocument().remove(startOffset, endOffset - startOffset);
textPane.getDocument().insertString(startOffset, "[[" + replace + "]]", element.getAttributes());
textPane.setCaretPosition(startOffset);
textPane.moveCaretPosition(startOffset + replace.length());
} catch (BadLocationException e1) {
// Nothing to be done
}
}
return;
}
String languageLink = api.getLanguageLink(fromWikipedia, toWikipedia, "Category:" + title);
if (languageLink == null) {
Utilities.displayInformationMessage(
textPane.getParent(),
GT._(
"The category {0} in the {1} Wikipedia doesn''t have a language link to the {2} Wikipedia.\n" +