## org.eclipse.datatools.sqltools.common.ui.tableviewer
Class PasteRowActionUtil

    java.lang.Object
      org.eclipse.datatools.sqltools.common.ui.tableviewer.PasteRowActionUtil

    public class PasteRowActionUtil

extends java.lang.Object

A util for PasteRowAction, add postfix for pasted row to avoid duplicate name error for wizard and editor

Author:
  Hao-yue

Constructor Summary
`PasteRowActionUtil()`

Method Summary
`static void` `addPostfix(org.eclipse.datatools.sqltools.common.core.tableviewer.RowData rowData, int col, org.eclipse.datatools.sqltools.common.core.tableviewer.ITableData data)` When the user pastes a row, a new row which is exactly identical with the original row is appended.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PasteRowActionUtil

    public PasteRowActionUtil()

Method Detail

### addPostfix

    public static void addPostfix(org.eclipse.datatools.sqltools.common.core.tableviewer.RowData rowData,
                                  int col,
                                  org.eclipse.datatools.sqltools.common.core.tableviewer.ITableData data)

  When the user pastes a row, a new row which is exactly identical with the original row is appended. In some cases, there will be a "Duplicate name found" error. It will be nice if we automatically append a postfix to the name of pasted row. We use "_number" as the postfix. For example, in Table Schema Editor, if the column "id" is pasted, the name is changed to "id_1"; and if column "id_3" is pasted, the name is changed to "id_4". The rule is, the paste action won't introduce new error into the columns page. Steps to add postfix:
  - Find the name which can not be duplicated
  - Check if the name is duplicate now, if duplicate, add the postfix, else no action is needed.
  - Find the last '_' in the name.
  - If there is '_' in the name and there is an integer after the '_', the integer in the name will be changed to the integer plus 1, else '_1' will be appended to the name.
  - Check if the revised name is duplicate, if duplicate, repeat above step to increase the postfix util the name is not duplicate, then update the row data with the name to get the row to be pasted.