int fixedEndLink = 0;
String title = LinkReplacement.getLastReplacement(page.getTitle());
if (title != null) {
fixedBeginLink += addItem(
submenuLink, null, title, true,
new ReplaceAllLinksAction(textPane, page, title, null));
fixedBeginLink += addSeparator(submenuLink);
}
for (Page p : links) {
if (p.isRedirect()) {
JMenu submenu1 = new JMenu(p.getTitle());
Iterator<Page> iter = p.getRedirectIteratorWithPage();
while (iter.hasNext()) {
Page pageTmp = iter.next();
addItem(
submenu1, pageTmp, null, true,
new ReplaceAllLinksAction(textPane, page, pageTmp.getTitle(), null));
}
submenuLink.add(submenu1);
} else {
addItem(
submenuLink, p, null, true,
new ReplaceAllLinksAction(textPane, page, p.getTitle(), null));
}
}
title = LinkReplacement.getLastReplacement(page.getTitle());
if (title != null) {
fixedEndLink += addSeparator(submenuLink);
fixedEndLink += addItem(
submenuLink, null, title, true,
new ReplaceAllLinksAction(textPane, page, title, null));
}
addSubmenu(popup, submenuLink, fixedBeginLink, fixedEndLink);
}
}