private boolean handleEmbedURLInDiv(String href, String embedTarget,
AbstractIntroPage currentPage) {
// re-use a runtime generated page, if found. Create the mangled id for
// the page and check if page exists first. If not, create one.
IntroModelRoot model = (IntroModelRoot) currentPage.getParentPage()
.getParent();
String currentPageId = null;
if (currentPage.isIFramePage())
currentPageId = currentPage.getUnmangledId();
else
currentPageId = currentPage.getId();
String mangledPageId = currentPageId + "_" + "WITH_IFRAME"; //$NON-NLS-1$ //$NON-NLS-2$
// get current standby state.
boolean standby = IntroPlugin.isIntroStandby();
String standbyAsString = standby ? IntroURL.VALUE_TRUE : "false"; //$NON-NLS-1$
AbstractIntroPage pageWithIFrame = (AbstractIntroPage) model.findChild(
mangledPageId, AbstractIntroElement.ABSTRACT_PAGE);
if (pageWithIFrame != null) {
pageWithIFrame.setIFrameURL(href);
return introURL.showPage(mangledPageId, standbyAsString);
}
// Page never generated, clone and create.
AbstractIntroPage clonedPage = null;
try {
clonedPage = (AbstractIntroPage) currentPage.clone();
} catch (CloneNotSupportedException ex) {
// should never be here.
Log.error("Failed to clone Intro page: " + currentPage.getId(), ex); //$NON-NLS-1$
return false;
}
// embed url as IFrame in target div. We need to find target div in
// cloned page not in the original page.
boolean canInjectFrame = clonedPage.injectIFrame(href, embedTarget);
if (!canInjectFrame)
// Called method handles error.
return false;
clonedPage.setId(mangledPageId);
model.addChild(clonedPage);
return introURL.showPage(clonedPage.getId(), standbyAsString);
}