for (int i = 0; i < n; ++i)
{
GeneratorPageDescriptor pd = (GeneratorPageDescriptor) customPages.get(i);
String pageName = pd.getName();
WizardPage page = (WizardPage) getPage(pageName);
if (page == null)
{
// If the page does not yet exist, create it
String pageClassName = pd.getPageClassName();
String objectClassName = pd.getObjectClassName();
if (objectClassName != null)
{
// Object page, get/create the object
Object o = context.getProperty(pageName);
if (o == null)
{
o = ReflectUtil.instantiate(objectClassName, null,
"generator settings object class");
context.setProperty(pageName, o);
}
// Create property browser page and set the object
page = new WizardObjectPage(this, pd);
}
else if (pageClassName != null)
{
try
{
Class pageClass = Class.forName(pageClassName);
// We retrieve the Constructor of the page that uses one single parameter
// of the type Wizard.
Constructor[] ctrs = pageClass.getDeclaredConstructors();
for (int ic = 0; ic < ctrs.length; ++ic)
{
Class[] params = ctrs[ic].getParameterTypes();
if (params.length == 1 && params[0] == GeneratorWizard.class)
{
page = (WizardPage) ctrs[ic].newInstance(new Object[]
{
this
});
break;
}
}
if (page == null)
throw new GeneratorException("Class '" + pageClassName
+ "' does not have a (GeneratorWizard) constructor.");
}
catch (Exception e)
{
String msg = LogUtil.error(getClass(), "Cannot instantiate page class $0.",
pageClassName, e);
String exMsg = ExceptionUtil.getNestedMessage(e);
throw new GeneratorException(exMsg != null ? exMsg : msg);
}
}
if (page != null)
{
// Get the description of the page from the page descriptor
String pageDescription = pd.getDescription();
page.setDescription(pageDescription);
// Add it to the wizard
addPage(pageName, page);
}
}
if (page != null)
{
// Get the title of the page from the page descriptor
String pageTitle = pd.getDisplayName();
if (pageTitle == null)
pageTitle = generator.getDisplayName();
page.setTitle(pageTitle);
if (pd.isFinish())
{
page.canFinish = true;
}