private ScrolledPageBook createMainPageBook(FormToolkit toolkit, Form form) {
// get body and create page book in it. Body has GridLayout.
Composite body = form.getBody();
body.setLayout(new GridLayout());
// make sure page book expands h and v.
ScrolledPageBook pageBook = toolkit.createPageBook(body, SWT.V_SCROLL
| SWT.H_SCROLL);
pageBook.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create root page in root page layout form, only if needed.
if (sharedStyleManager.useCustomHomePagelayout()) {
// if we do not have a root page form, create one
RootPageForm rootPageForm = new RootPageForm(toolkit, model, form);
rootPageForm.createPartControl(pageBook, sharedStyleManager);
rootPageForm.setContentProviderSite(this);
}
// Create the two Page forms .
pageForm = new PageForm(toolkit, model, form);
pageForm.setContentProviderSite(this);
pageForm.createPartControl(pageBook, sharedStyleManager);
pageFormWithNav = new PageFormWithNavigation(toolkit, model, form);
pageFormWithNav.setContentProviderSite(this);
pageFormWithNav.createPartControl(pageBook, sharedStyleManager);
// now determine which page to show. Show it and add it to history.
// if the cached page is a URL ignore it. We do not want to launch a
// browser on startup.
String cachedPage = getCachedCurrentPage();
if (cachedPage != null & !History.isURL(cachedPage))
// this will create the page in the page form.
model.setCurrentPageId(cachedPage);
AbstractIntroPage pageToShow = getModel().getCurrentPage();
// load style manager here to test for navigation.
PageStyleManager styleManager = new PageStyleManager(pageToShow,
sharedStyleManager.getProperties());
boolean pageHasNavigation = styleManager.showHomePageNavigation();
if (pageToShow != null) {
if (pageBook.hasPage(pageToShow.getId()))
// we are showing Home Page.
pageBook.showPage(pageToShow.getId());
else {
if (pageHasNavigation) {
// page or Home Page with a page layout and navigation, set
// the page id to the static PageFormWithNavigation id.
// first create the correct content.
pageFormWithNav.showPage(pageToShow, sharedStyleManager);
// then show the page
pageBook
.showPage(PageFormWithNavigation.PAGE_FORM_WITH_NAVIGATION_ID);
} else {
// page or Home Page with a regular page layout, set the
// page id to the static PageForm id. first create the
// correct content.
pageForm.showPage(pageToShow, sharedStyleManager);
// then show the page
pageBook.showPage(PageForm.PAGE_FORM_ID);
}
}
updateHistory(pageToShow);
}