*
* @param pageId
* @return
*/
private boolean includePageToShow(IntroModelRoot model, String pageId) {
AbstractIntroPage page = findPageToShow(pageId);
if (page == null) {
Log.warning("Could not find an Intro page with id=" + pageId); //$NON-NLS-1$
return false;
}
// now clone the target page because original model should be kept
// intact. Resolve target page first to resolve its includes
// properly. Insert presentation shared style at the top of the shared
// styles list because once reparented, the shared style is lost.
// Finally, add clone page to current model.
page.getChildren();
// current kind.
String currentPresentationKind = model.getPresentation()
.getImplementationKind();
// load shared style corresponding to same presentation kind from target
// model.
IntroPartPresentation targetPresentation = ((IntroModelRoot) page
.getParent()).getPresentation();
String targetSharedStyle = targetPresentation
.getSharedStyle(currentPresentationKind);
// clone.
AbstractIntroPage clonedPage = null;
try {
clonedPage = (AbstractIntroPage) page.clone();
} catch (CloneNotSupportedException ex) {
// should never be here.
Log.error("Failed to clone Intro model node.", ex); //$NON-NLS-1$
return false;
}
// reparent cloned target to current model.
clonedPage.setParent(model);
// REVISIT: SWT presentation does not support multiple shared
// styles.
if (targetSharedStyle != null)
// add target model shared style.
clonedPage.insertStyle(targetSharedStyle, 0);
model.addChild(clonedPage);
return model.setCurrentPageId(clonedPage.getId());
}