JMenu submenu = new JMenu(GT._("Mark as needing help"));
if (templates != null) {
for (String template : templates) {
addItem(
submenu, null, GT._("Using {0}", "{{" + template + "}}"), true,
new MarkLinkAction(
element,
createTextForTemplate(template, page.getTitle(), text),
textPane, checkBox));
}
}
if (templatesAfter != null) {
for (List<String> template : templatesAfter) {
String templateName = template.get(0);
addItem(
submenu, null, GT._("Using {0}", "[[…]]{{" + templateName + "}}"), true,
new MarkLinkAction(
element,
createTextForTemplateAfterLink(template, page.getTitle(), text),
textPane, checkBox));
}
}
popup.add(submenu);
} else {
String newText = null;
if ((templates != null) && (templates.size() > 0)) {
newText = createTextForTemplate(templates.get(0), page.getTitle(), text);
} else if ((templatesAfter != null) && (templatesAfter.size() > 0)) {
newText = createTextForTemplateAfterLink(templatesAfter.get(0), page.getTitle(), text);
}
if (newText != null) {
addItem(
popup, null, GT._("Mark as needing help"), true,
new MarkLinkAction(element, newText.toString(), textPane, checkBox));
}
}
}
}