@Override
  protected boolean performLeavingAction(WizardStepDirection direction) {
    if (direction == WizardStepDirection.FINISH) {
      try {
        if (state.getTranslator() != null) {
          state.getTranslator().close();
        }
      } catch (OperatorException e) {
        ImportWizardUtils.showErrorMessage(
            state.getDataResultSetFactory().getResourceName(), e.toString(), e);
      }

      // use settings edited by user even if he never pressed Enter or otherwise confirmed his
      // changes
      for (int i = 0; i < previewTable.getColumnCount(); i++) {
        EditableTableHeaderColumn col =
            (EditableTableHeaderColumn) previewTable.getColumnModel().getColumn(i);
        if (col.getHeaderEditor() instanceof MetaDataTableHeaderCellEditor) {
          MetaDataTableHeaderCellEditor editor =
              (MetaDataTableHeaderCellEditor) col.getHeaderEditor();
          editor.updateColumnMetaData();
        }
      }
    }
    return true;
  }
  @Override
  public DataSet getData() throws DataSetException {
    /*
     * Create a new data set instance in case no data set is available yet or configuration has
     * changed
     */
    boolean configurationChanged =
        dataSetConfiguration != null
            && !dataSetConfiguration.getParameters().equals(getConfiguration().getParameters());
    if (dataSet == null || configurationChanged) {

      // close old preview set in case a new one is created
      if (dataSet != null) {
        dataSet.close();
        dataSet = null;
      }

      try {
        this.dataSet = createDataSet(XlsxReadMode.OPERATOR);
        this.dataSetConfiguration = getConfiguration();
      } catch (OperatorException e) {
        throw new DataSetException(e.getMessage(), e.getCause());
      }
    }
    return dataSet;
  }
  @Override
  public DataSet getPreview(int maxPreviewSize) throws DataSetException {
    /*
     * Create a new preview data set instance in case no preview is available yet or
     * configuration has changed
     */
    boolean configChange =
        previewConfiguration != null
            && !previewConfiguration.getParameters().equals(getConfiguration().getParameters());
    if (previewDataSet == null || configChange) {

      // close old preview set in case a new one is created
      if (previewDataSet != null) {
        previewDataSet.close();
        previewDataSet = null;
      }

      try {
        this.previewDataSet = createDataSet(XlsxReadMode.WIZARD_PREVIEW, maxPreviewSize);
        this.previewConfiguration = getConfiguration();
      } catch (OperatorException e) {
        throw new DataSetException(e.getMessage(), e.getCause());
      }
    }
    return previewDataSet;
  }
  /**
   * Creates a new meta data instance with the results of the {@link ExcelSheetSelectionWizardStep}
   * and assigns it to the {@link #metaData} field of the {@link ExcelDataSource}.
   *
   * <p>The method checks if the header row and the starting row exist and throws an exception
   * otherwise.
   *
   * @throws DataSetException in case the guessing failed (e.g. because of file reading errors,
   *     wrong file path, etc.)
   */
  void createMetaData() throws DataSetException {
    // create a new Excel ResultSet configuration which reads the whole selected sheet
    // we cannot call getData() here as it might already skip the first lines
    try (ExcelResultSetConfiguration configuration = new ExcelResultSetConfiguration()) {

      configuration.setWorkbookFile(getLocation().toFile());
      configuration.setSheet(getResultSetConfiguration().getSheet());
      configuration.setColumnOffset(getResultSetConfiguration().getColumnOffset());
      configuration.setColumnLast(getResultSetConfiguration().getColumnLast());
      configuration.setEncoding(getResultSetConfiguration().getEncoding());

      try (DataResultSet resultSet = configuration.makeDataResultSet(null)) {
        this.metaData =
            ResultSetAdapterUtils.createMetaData(
                resultSet, null, getStartRowIndex(), getHeaderRowIndex());
      } catch (OperatorException e) {
        throw new DataSetException(e.getMessage(), e);
      }
    }
  }
 protected PerformanceVector getPerformance(boolean cloneInput) {
   try {
     inputExtender.passDataThrough();
     executeSubprocess();
     if (isPerformanceRequired()) {
       return getPerformanceInnerSink().getData(PerformanceVector.class);
     } else {
       return getPerformanceInnerSink().getDataOrNull(PerformanceVector.class);
     }
   } catch (OperatorException e) {
     StringBuilder builder = new StringBuilder();
     builder.append(this.getName());
     builder.append(
         ": Cannot evaluate performance for current parameter combination because of an error in one of the inner operators: ");
     builder.append(e.getMessage());
     getLogger().severe(builder.toString());
     //            getLogger().severe("Cannot evaluate performance for current parameter
     // combination: " + e.getMessage());
     if (Boolean.parseBoolean(
         ParameterService.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_GENERAL_DEBUGMODE)))
       e.printStackTrace();
     return null;
   }
 }
 @Override
 protected void createMatrices() {
   List<Attribute> attributes = new ArrayList<Attribute>(exampleSet.getAttributes().size());
   for (Attribute attribute : exampleSet.getAttributes()) {
     attributes.add((Attribute) attribute.clone());
   }
   MemoryExampleTable table = new MemoryExampleTable(attributes);
   for (int x = 0; x < dimensions[0]; x++) {
     for (int y = 0; y < dimensions[1]; y++) {
       DataRow row = new DoubleArrayDataRow(net.getNodeWeights(new int[] {x, y}));
       table.addDataRow(row);
     }
   }
   ExampleSet set = table.createExampleSet();
   this.classificationMatrix = new double[dimensions[0]][dimensions[1]];
   try {
     set = model.apply(set);
     Iterator<Example> exampleIterator = set.iterator();
     for (int x = 0; x < dimensions[0]; x++) {
       for (int y = 0; y < dimensions[1]; y++) {
         Example example = exampleIterator.next();
         classificationMatrix[x][y] =
             example.getValue(example.getAttributes().getPredictedLabel());
       }
     }
   } catch (OperatorException e) {
     // LogService.getGlobal().log("Cannot use Model for prediction of node label: " +
     // e.getMessage(), LogService.WARNING);
     LogService.getRoot()
         .log(
             Level.WARNING,
             "com.rapidminer.operator.visualization.SOMModelPlotter.using_model_for_prediction_error"
                 + e.getMessage());
   }
   super.createMatrices();
 }