/**
   * DOC zli Comment method "guessSchema".
   *
   * @param processDescription
   */
  public void guessSchema(ProcessDescription processDescription) {
    informationLabel.setText(
        "   " + Messages.getString("FileStep3.guessIsDone")); // $NON-NLS-1$ //$NON-NLS-2$
    // clear all items
    tableEditorView.getMetadataEditor().removeAll();
    List<MetadataColumn> columns = new ArrayList<MetadataColumn>();

    List<IMetadataColumn> listColumns = processDescription.getSchema().get(0).getListColumns();
    int size = listColumns.size();
    if (size > 0) {
      for (int i = 0; i < size; i++) {
        MetadataColumn metadataColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
        metadataColumn.setNullable(listColumns.get(i).isNullable());
        metadataColumn.setLength(listColumns.get(i).getLength());
        metadataColumn.setPattern(listColumns.get(i).getPattern());
        metadataColumn.setTalendType(listColumns.get(i).getTalendType());
        metadataColumn.setPrecision(listColumns.get(i).getPrecision());
        metadataColumn.setLabel(listColumns.get(i).getLabel());
        columns.add(i, metadataColumn);
      }
    }
    tableEditorView.getMetadataEditor().addAll(columns);
    tableEditorView.getTableViewerCreator().layout();
    informationLabel.setText(Messages.getString("FileStep3.guessTip")); // $NON-NLS-1$
  }
  public void refreshMetaDataTable(final CsvArray csvArray, ProcessDescription processDescription) {
    informationLabel.setText(
        "   " + Messages.getString("FileStep3.guessIsDone")); // $NON-NLS-1$ //$NON-NLS-2$
    // clear all items
    tableEditorView.getMetadataEditor().removeAll();

    List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
    if (csvArray == null || csvArray.getRows().isEmpty()) {
      return;
    } else {

      List<String[]> csvRows = csvArray.getRows();
      Integer numberOfCol = getRightFirstRow(csvRows);

      // define the label to the metadata width the content of the first row
      int firstRowToExtractMetadata = 0;
      List<IMetadataColumn> listColumns = processDescription.getSchema().get(0).getListColumns();
      // the first rows is used to define the label of any metadata
      String[] label = new String[numberOfCol.intValue()];
      for (int i = 0; i < numberOfCol; i++) {
        label[i] = DEFAULT_LABEL + i;
        if (firstRowToExtractMetadata == 0) {

          label[i] = "" + listColumns.get(i); // $NON-NLS-1$
        }
      }

      for (int i = 0; i < numberOfCol.intValue(); i++) {
        // define the first currentType and assimile it to globalType
        String globalType = null;
        int lengthValue = 0;
        int precisionValue = 0;
        boolean nullAble = true;

        int current = firstRowToExtractMetadata;
        while (globalType == null) {
          String value = csvRows.get(current)[i];
          if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
            if (i >= csvRows.get(current).length) {
              globalType = "id_String"; // $NON-NLS-1$
            } else {
              if (value != null && !"".equals(value)) { // $NON-NLS-1$
                globalType = JavaDataTypeHelper.getTalendTypeOfValue(value);
              } else {
                globalType = listColumns.get(i).getTalendType();
              }
              current++;
            }
          } else {
            if (i >= csvRows.get(current).length) {
              globalType = "String"; // $NON-NLS-1$
            } else {
              globalType = PerlDataTypeHelper.getTalendTypeOfValue(value);
              current++;
            }
          }
        }
        nullAble = listColumns.get(i).isNullable();
        lengthValue = listColumns.get(i).getLength();
        precisionValue = listColumns.get(i).getPrecision();

        // define the metadataColumn to field i
        MetadataColumn metadataColumn = ConnectionFactory.eINSTANCE.createMetadataColumn();
        // Convert javaType to TalendType
        String talendType = null;
        if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
          talendType = globalType;
          if (globalType.equals(JavaTypesManager.FLOAT.getId())
              || globalType.equals(JavaTypesManager.DOUBLE.getId())) {
            metadataColumn.setPrecision(precisionValue);
          } else {
            metadataColumn.setPrecision(0);
          }
        } else {
          talendType =
              PerlTypesManager.getNewTypeName(
                  MetadataTalendType.loadTalendType(
                      globalType, "TALENDDEFAULT", false)); // $NON-NLS-1$
          if (globalType.equals("FLOAT")
              || globalType.equals("DOUBLE")) { // $NON-NLS-1$ //$NON-NLS-2$
            metadataColumn.setPrecision(precisionValue);
          } else {
            metadataColumn.setPrecision(0);
          }
        }

        metadataColumn.setNullable(nullAble);
        metadataColumn.setTalendType(talendType);
        metadataColumn.setLength(lengthValue);
        // bug 6758
        if (talendType.equals("id_Date")) { // $NON-NLS-1$
          String pattern = listColumns.get(i).getPattern();
          metadataColumn.setPattern(pattern);
        }
        // Check the label and add it to the table
        metadataColumn.setLabel(
            tableEditorView.getMetadataEditor().getNextGeneratedColumnName(label[i]));
        columns.add(i, metadataColumn);
      }
    }
    // tableEditorView.getMetadataEditor().registerDataList(columns);
    tableEditorView.getMetadataEditor().addAll(columns);

    checkFieldsValue();
    tableEditorView.getTableViewerCreator().layout();
    informationLabel.setText(Messages.getString("FileStep3.guessTip")); // $NON-NLS-1$
  }