예제 #1
0
  /**
   * Handles the correct ordering of wizard pages
   *
   * <p>This method makes sure that the correct page is shown once the user hits the "next" button.
   * The page flow depends <code>currentPage</code> and the selected {@link
   * ImportWizardModel#getSourceType() sourceType}.
   *
   * @param currentPage The page that is currently being shown
   * @return The page that will be shown next
   */
  @Override
  public IWizardPage getNextPage(IWizardPage currentPage) {

    this.currentPage = currentPage;
    if (currentPage == sourcePage) {
      SourceType src = data.getSourceType();
      if (src == SourceType.CSV) {
        return csvPage;
      } else if (src == SourceType.JDBC) {
        return jdbcPage;
      } else if (src == SourceType.EXCEL) {
        return xlsPage;
      }
    } else if (currentPage == csvPage) {
      return columnPage;
    } else if (currentPage == columnPage) {
      return previewPage;
    } else if (currentPage == jdbcPage) {
      return tablePage;
    } else if (currentPage == tablePage) {
      return columnPage;
    } else if (currentPage == xlsPage) {
      return columnPage;
    }

    return null;
  }
예제 #2
0
  /**
   * Gets executed once the wizard is about to finish
   *
   * <p>This will build an appropriate {@link ImportConfiguration} object, depending upon the {@link
   * ImportWizardModel#getSourceType() source type} and the choices the user made during the process
   * of the wizard.
   *
   * <p>{@link #configuration} will hold a reference of the object. This can be retrieved later on
   * by {@link #getResultingConfiguration()}.
   *
   * @return
   * @see {@link #getResultingConfiguration()}
   */
  @Override
  public boolean performFinish() {

    if (data.getSourceType() == SourceType.CSV) {

      configuration =
          new ImportConfigurationCSV(
              data.getFileLocation(),
              data.getCharset(),
              data.getCsvDelimiter(),
              data.getCsvQuote(),
              data.getCsvEscape(),
              data.getCsvLinebreak(),
              data.getFirstRowContainsHeader());

    } else if (data.getSourceType() == SourceType.EXCEL) {

      configuration =
          new ImportConfigurationExcel(
              data.getFileLocation(), data.getExcelSheetIndex(), data.getFirstRowContainsHeader());

    } else if (data.getSourceType() == SourceType.JDBC) {

      configuration =
          new ImportConfigurationJDBC(data.getJdbcConnection(), data.getSelectedJdbcTable());

    } else {
      throw new RuntimeException("Configuration type not supported"); // $NON-NLS-1$
    }

    for (ImportColumn c : data.getEnabledColumns()) {
      c.setCleansing(data.isPerformCleansing());
      configuration.addColumn(c);
    }

    if (data.getSourceType() != SourceType.JDBC) {
      try {
        if (data.getJdbcConnection() != null && !data.getJdbcConnection().isClosed()) {
          data.getJdbcConnection().close();
        }
      } catch (Exception e) {
        /* Die silently */
      }
    }

    return true;
  }