@Override
  public IWizardPage getNextPage(IWizardPage page) {
    if (page == importToolSelectionPage) {

      // The user has chosen an import tool and cannot change his/her selection; go get the
      // data entry pages from the import tool extension element and add all import wizard
      // pages.  Make sure we build and add the wizard pages only once.

      addDataEntryPages(importToolSelectionPage.getExtensionElement());

      // get a hold of the import tool and the parameters configured for it in the defining
      // extension and create the import tool proxy
      IRecordElementsImportTool importTool =
          activeRecordElementsImportToolExtensionElement.getRecordElementsImportTool();
      Properties importToolParms = activeRecordElementsImportToolExtensionElement.getParameters();
      proxy = new RecordElementsImportToolProxy(importTool, importToolParms);

      // return the first import tool data entry page or null if no data entry pages are
      // defined
      if (!dataEntryWizardPages.isEmpty()) {
        dataEntryWizardPages.get(0).aboutToShow();
        return dataEntryWizardPages.get(0);
      } else {
        return null;
      }
    } else if (dataEntryWizardPages != null && dataEntryWizardPages.contains(page)) {
      // we need the next data entry page
      int i = dataEntryWizardPages.indexOf(page);
      if (i < 0) {
        throw new RuntimeException("logic error");
      } else {
        // get the next relevant data entry page, if any
        ImportWizardPage nextPage = getNextRelevantPageIndex(i);
        if (nextPage != null) {
          // there is a next relevant data entry page, so return it
          nextPage.aboutToShow();
          return nextPage;
        } else {
          // no next data entry page, prepare the preview page and return it
          SchemaRecord record = new RecordModelBuilder().build("DUMMY");
          record.getRootElements().clear();
          record.getRootElements().addAll(proxy.invokeImportTool(context));
          String recordElementsDSL = Tools.generateRecordElementsDSL(record);
          previewPage.setRecordElementsDSL(recordElementsDSL);
          return previewPage;
        }
      }
    }
    return null;
  }
  private void createAndInjectController(final ImportWizardPage wizardPage) {
    // create a controller and inject it in the data entry page's @Controller annotated field
    IDataEntryPageController controller =
        new IDataEntryPageController() {
          @Override
          public void setErrorMessage(String message) {
            wizardPage.setErrorMessage(message);
          }

          @Override
          public void setPageComplete(boolean pageComplete) {
            wizardPage.setPageComplete(pageComplete);
          }
        };
    inject(
        AbstractDataEntryPage.class, wizardPage.getDataEntryPage(), Controller.class, controller);
  }