private void populateMappingComboAndFamilyStuff() {
    String tableName = "";
    if (!Const.isEmpty(m_existingTableNamesCombo.getText().trim())) {
      tableName = m_existingTableNamesCombo.getText().trim();

      if (tableName.indexOf('@') > 0) {
        tableName = tableName.substring(0, tableName.indexOf('@'));
      }
    }

    // defaults if we fail to connect, table doesn't exist etc..
    m_familyCI.setComboValues(new String[] {""});
    m_existingMappingNamesCombo.removeAll();

    if (m_admin != null && !Const.isEmpty(tableName)) {
      try {

        // first get the existing mapping names (if any)
        List<String> mappingNames = m_admin.getMappingNames(tableName);
        for (String m : mappingNames) {
          m_existingMappingNamesCombo.add(m);
        }

        // now get family information for this table
        Configuration conf = m_admin.getConnection();
        HBaseAdmin admin = new HBaseAdmin(conf);

        if (admin.tableExists(tableName)) {
          HTableDescriptor descriptor = admin.getTableDescriptor(Bytes.toBytes(tableName));

          Collection<HColumnDescriptor> families = descriptor.getFamilies();
          String[] familyNames = new String[families.size()];
          int i = 0;
          for (HColumnDescriptor d : families) {
            familyNames[i++] = d.getNameAsString();
          }

          m_familyCI.setComboValues(familyNames);
        } else {
          m_familyCI.setComboValues(new String[] {""});
        }

        m_familiesInvalidated = false;
        return;

      } catch (Exception e) {
        // TODO popup error dialog
        e.printStackTrace();
      }
    }
  }
  private void populateTableWithIncomingFields() {
    if (m_incomingFieldsProducer != null) {
      RowMetaInterface incomingRowMeta = m_incomingFieldsProducer.getIncomingFields();

      Table table = m_fieldsView.table;
      if (incomingRowMeta != null) {
        Set<String> existingRowAliases = new HashSet<String>();
        for (int i = 0; i < table.getItemCount(); i++) {
          TableItem tableItem = table.getItem(i);
          String alias = tableItem.getText(1);
          if (!Const.isEmpty(alias)) {
            existingRowAliases.add(alias);
          }
        }

        int choice = 0;
        if (existingRowAliases.size() > 0) {
          // Ask what we should do with existing mapping data
          MessageDialog md =
              new MessageDialog(
                  m_shell,
                  Messages.getString("MappingDialog.GetFieldsChoice.Title"),
                  null,
                  Messages.getString(
                      "MappingDialog.GetFieldsChoice.Message",
                      "" + existingRowAliases.size(),
                      "" + incomingRowMeta.size()),
                  MessageDialog.WARNING,
                  new String[] {
                    Messages.getString("MappingDialog.AddNew"),
                    Messages.getString("MappingOutputDialog.Add"),
                    Messages.getString("MappingOutputDialog.ClearAndAdd"),
                    Messages.getString("MappingOutputDialog.Cancel"),
                  },
                  0);
          MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
          int idx = md.open();
          choice = idx & 0xFF;
        }

        if (choice == 3 || choice == 255 /* 255 = escape pressed */) {
          return; // Cancel
        }

        if (choice == 2) {
          m_fieldsView.clearAll();
        }

        for (int i = 0; i < incomingRowMeta.size(); i++) {
          ValueMetaInterface vm = incomingRowMeta.getValueMeta(i);
          boolean addIt = true;

          if (choice == 0) {
            // only add if its not already in the table
            if (existingRowAliases.contains(vm.getName())) {
              addIt = false;
            }
          }

          if (addIt) {
            TableItem item = new TableItem(m_fieldsView.table, SWT.NONE);
            item.setText(1, vm.getName());
            item.setText(2, "N");

            if (m_familyCI.getComboValues()[0].length() > 0) {
              // use existing first column family name as the default
              item.setText(3, m_familyCI.getComboValues()[0]);
            } else {
              // default
              item.setText(3, DEFAULT_FAMILY);
            }

            item.setText(4, vm.getName());
            item.setText(5, vm.getTypeDesc());
            if (vm.getType() == ValueMetaInterface.TYPE_INTEGER) {
              item.setText(5, "Long");
            }
            if (vm.getType() == ValueMetaInterface.TYPE_NUMBER) {
              item.setText(5, "Double");
            }
            if (vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_INDEXED) {
              Object[] indexValus = vm.getIndex();
              String indexValsS = HBaseValueMeta.objectIndexValuesToString(indexValus);
              item.setText(6, indexValsS);
            }
          }
        }

        m_fieldsView.removeEmptyRows();
        m_fieldsView.setRowNums();
        m_fieldsView.optWidth(true);
      }
    }
  }
  public MappingEditor(
      Shell shell,
      Composite parent,
      ConfigurationProducer configProducer,
      FieldProducer fieldProducer,
      int tableViewStyle,
      boolean allowTableCreate,
      PropsUI props,
      TransMeta transMeta) {
    //    super(parent, SWT.NO_BACKGROUND | SWT.NO_FOCUS | SWT.NO_MERGE_PAINTS);
    super(parent, SWT.NONE);

    m_shell = shell;
    m_parent = parent;
    m_transMeta = transMeta;
    boolean showConnectWidgets = false;
    m_configProducer = configProducer;
    if (m_configProducer != null) {
      m_currentConfiguration = m_configProducer.getCurrentConfiguration();
    } else {
      showConnectWidgets = true;
      m_configProducer = this;
    }

    m_incomingFieldsProducer = fieldProducer;

    m_allowTableCreate = allowTableCreate;
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    FormLayout controlLayout = new FormLayout();
    /*controlLayout.marginLeft = 0;
    controlLayout.marginRight = 0;
    controlLayout.marginTop = 0;
    controlLayout.marginBottom = 0; */
    controlLayout.marginWidth = 3;
    controlLayout.marginHeight = 3;

    setLayout(controlLayout);
    props.setLook(this);

    if (showConnectWidgets) {
      Label zooHostLab = new Label(this, SWT.RIGHT);
      zooHostLab.setText("Zookeeper host");
      props.setLook(zooHostLab);
      FormData fd = new FormData();
      fd.left = new FormAttachment(0, 0);
      fd.top = new FormAttachment(0, margin);
      fd.right = new FormAttachment(middle, -margin);
      zooHostLab.setLayoutData(fd);

      m_zookeeperHostText = new TextVar(transMeta, this, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
      props.setLook(m_zookeeperHostText);
      fd = new FormData();
      fd.left = new FormAttachment(middle, 0);
      fd.top = new FormAttachment(0, margin);
      fd.right = new FormAttachment(100, 0);
      m_zookeeperHostText.setLayoutData(fd);

      Label zooPortLab = new Label(this, SWT.RIGHT);
      zooPortLab.setText("Zookeeper port");
      props.setLook(zooPortLab);
      fd = new FormData();
      fd.left = new FormAttachment(0, 0);
      fd.top = new FormAttachment(m_zookeeperHostText, margin);
      fd.right = new FormAttachment(middle, -margin);
      zooPortLab.setLayoutData(fd);

      m_zookeeperPortText = new TextVar(transMeta, this, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
      props.setLook(m_zookeeperPortText);
      fd = new FormData();
      fd.left = new FormAttachment(middle, 0);
      fd.top = new FormAttachment(m_zookeeperHostText, margin);
      fd.right = new FormAttachment(100, 0);
      m_zookeeperPortText.setLayoutData(fd);

      m_currentConfiguration = m_configProducer.getCurrentConfiguration();
    }

    // table names
    Label tableNameLab = new Label(this, SWT.RIGHT);
    tableNameLab.setText(Messages.getString("MappingDialog.TableName.Label"));
    props.setLook(tableNameLab);
    FormData fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    if (showConnectWidgets) {
      fd.top = new FormAttachment(m_zookeeperPortText, margin);
    } else {
      fd.top = new FormAttachment(0, margin);
    }
    fd.right = new FormAttachment(middle, -margin);
    tableNameLab.setLayoutData(fd);

    /*    m_existingTableNamesBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_existingTableNamesBut);
    m_existingTableNamesBut.setText("Get existing table names");
    fd = new FormData();
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(0, 0);
    m_existingTableNamesBut.setLayoutData(fd); */

    m_existingTableNamesCombo = new CCombo(this, SWT.BORDER);
    props.setLook(m_existingTableNamesCombo);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    if (showConnectWidgets) {
      fd.top = new FormAttachment(m_zookeeperPortText, margin);
    } else {
      fd.top = new FormAttachment(0, margin);
    }
    fd.right = new FormAttachment(100, 0);
    m_existingTableNamesCombo.setLayoutData(fd);

    // allow or disallow table creation by enabling/disabling the ability
    // to type into this combo
    m_existingTableNamesCombo.setEditable(m_allowTableCreate);

    // mapping names
    Label mappingNameLab = new Label(this, SWT.RIGHT);
    mappingNameLab.setText(Messages.getString("MappingDialog.MappingName.Label"));
    props.setLook(tableNameLab);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.top = new FormAttachment(m_existingTableNamesCombo, margin);
    fd.right = new FormAttachment(middle, -margin);
    mappingNameLab.setLayoutData(fd);

    /*m_existingMappingNamesBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_existingMappingNamesBut);
    m_existingMappingNamesBut.setText("Get mapping names");
    fd = new FormData();
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(m_existingTableNamesCombo, 0);
    m_existingMappingNamesBut.setLayoutData(fd); */

    m_existingMappingNamesCombo = new CCombo(this, SWT.BORDER);
    props.setLook(m_existingMappingNamesCombo);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.top = new FormAttachment(m_existingTableNamesCombo, margin);
    // fd.right = new FormAttachment(m_existingMappingNamesBut, -margin);
    fd.right = new FormAttachment(100, 0);
    m_existingMappingNamesCombo.setLayoutData(fd);

    m_existingTableNamesCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            m_familiesInvalidated = true;
            populateMappingComboAndFamilyStuff();
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            m_familiesInvalidated = true;
            populateMappingComboAndFamilyStuff();
          }
        });

    m_existingTableNamesCombo.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            m_familiesInvalidated = true;
          }
        });

    m_existingTableNamesCombo.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            populateTableCombo(false);
          }

          public void focusLost(FocusEvent e) {
            m_familiesInvalidated = true;
            populateMappingComboAndFamilyStuff();
          }
        });

    m_existingMappingNamesCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            loadTableViewFromMapping();
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            loadTableViewFromMapping();
          }
        });

    // fields
    ColumnInfo[] colinf =
        new ColumnInfo[] {
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_ALIAS"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_KEY"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              true),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_FAMILY"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              true),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_NAME"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_TYPE"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              true),
          new ColumnInfo(
              Messages.getString("HBaseInputDialog.Fields.FIELD_INDEXED"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
        };

    m_keyCI = colinf[1];
    m_keyCI.setComboValues(new String[] {"N", "Y"});
    m_familyCI = colinf[2];
    m_familyCI.setComboValues(new String[] {""});
    m_typeCI = colinf[4];
    // default types for non-key fields
    m_typeCI.setComboValues(
        new String[] {
          "String",
          "Integer",
          "Long",
          "Float",
          "Double",
          "Date",
          "BigNumber",
          "Serializable",
          "Binary"
        });

    m_keyCI.setComboValuesSelectionListener(
        new ComboValuesSelectionListener() {
          public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {

            tableItem.setText(5, "");
            return m_keyCI.getComboValues();
          }
        });

    m_typeCI.setComboValuesSelectionListener(
        new ComboValuesSelectionListener() {
          public String[] getComboValues(TableItem tableItem, int rowNr, int colNr) {
            String[] comboValues = null;

            String keyOrNot = tableItem.getText(2);
            if (Const.isEmpty(keyOrNot) || keyOrNot.equalsIgnoreCase("N")) {
              comboValues =
                  new String[] {
                    "String",
                    "Integer",
                    "Long",
                    "Float",
                    "Double",
                    "Boolean",
                    "Date",
                    "BigNumber",
                    "Serializable",
                    "Binary"
                  };
            } else {
              comboValues =
                  new String[] {
                    "String",
                    "Integer",
                    "UnsignedInteger",
                    "Long",
                    "UnsignedLong",
                    "Date",
                    "UnsignedDate",
                    "Binary"
                  };
            }

            return comboValues;
          }
        });

    m_saveBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_saveBut);
    m_saveBut.setText(Messages.getString("MappingDialog.SaveMapping"));
    fd = new FormData();
    fd.left = new FormAttachment(0, margin);
    fd.bottom = new FormAttachment(100, -margin * 2);
    m_saveBut.setLayoutData(fd);

    m_saveBut.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            saveMapping();
          }
        });

    m_deleteBut = new Button(this, SWT.PUSH | SWT.CENTER);
    props.setLook(m_deleteBut);
    m_deleteBut.setText(Messages.getString("MappingDialog.DeleteMapping"));
    fd = new FormData();
    fd.left = new FormAttachment(m_saveBut, margin);
    fd.bottom = new FormAttachment(100, -margin * 2);
    m_deleteBut.setLayoutData(fd);
    m_deleteBut.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            deleteMapping();
          }
        });

    if (m_allowTableCreate) {
      m_getFieldsBut = new Button(this, SWT.PUSH | SWT.CENTER);
      props.setLook(m_getFieldsBut);
      m_getFieldsBut.setText(Messages.getString("MappingDialog.GetIncomingFields"));
      fd = new FormData();
      // fd.left = new FormAttachment(0, margin);
      fd.right = new FormAttachment(100, 0);
      fd.bottom = new FormAttachment(100, -margin * 2);
      m_getFieldsBut.setLayoutData(fd);

      m_getFieldsBut.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              populateTableWithIncomingFields();
            }
          });
    } else {

      m_keyValueTupleBut = new Button(this, SWT.PUSH | SWT.CENTER);
      props.setLook(m_keyValueTupleBut);
      m_keyValueTupleBut.setText(Messages.getString("MappingDialog.KeyValueTemplate"));
      m_keyValueTupleBut.setToolTipText(
          Messages.getString("MappingDialog.KeyValueTemplate.TipText"));
      fd = new FormData();
      // fd.left = new FormAttachment(0, margin);
      fd.right = new FormAttachment(100, 0);
      fd.bottom = new FormAttachment(100, -margin * 2);
      m_keyValueTupleBut.setLayoutData(fd);

      m_keyValueTupleBut.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              populateTableWithTupleTemplate();
            }
          });

      /*      colinf[0].setReadOnly(true);
      colinf[1].setReadOnly(true);
      colinf[2].setReadOnly(true);
      colinf[4].setReadOnly(true); */
    }

    m_fieldsView = new TableView(transMeta, this, tableViewStyle, colinf, 1, null, props);

    fd = new FormData();
    fd.top = new FormAttachment(m_existingMappingNamesCombo, margin * 2);
    fd.bottom = new FormAttachment(m_saveBut, -margin * 2);
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(100, 0);
    m_fieldsView.setLayoutData(fd);

    // --
    // layout();
    // pack();
  }
  private ColumnInfo[] getParamsColumnInfo() {

    // Nom
    ColumnInfo nameColumnInfo =
        new ColumnInfo(
            BaseMessages.getString(PKG, "GisFileInput.Params.Columns.PARAM_KEY.Label"),
            ColumnInfo.COLUMN_TYPE_TEXT);
    nameColumnInfo.setReadOnly(true);

    // Requis
    ColumnInfo requiredColumnInfo =
        new ColumnInfo(
            BaseMessages.getString(PKG, "GisFileInput.Params.Columns.PARAM_REQUIRED.Label"),
            ColumnInfo.COLUMN_TYPE_TEXT);
    requiredColumnInfo.setReadOnly(true);

    // Valeur fixe ou prédéfinie
    ColumnInfo fixedValueColumnInfo =
        new ColumnInfo(
            BaseMessages.getString(PKG, "GisFileInput.Params.Columns.PARAM_VALUE.Label"),
            ColumnInfo.COLUMN_TYPE_TEXT);
    fixedValueColumnInfo.setReadOnly(false);
    fixedValueColumnInfo.setSelectionAdapter(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {

            Integer tableIndex = wParams.getSelectionIndex();
            TableItem tableItem = wParams.table.getItem(tableIndex);

            // Récupération du type de donnée attendu pour le paramètre
            // sélectionné
            // et des valeurs prédéfinies
            String formatKey = getFormatKey(wInputFormat.getText());
            String paramKey = getParamKey(formatKey, tableItem.getText(1));
            int paramValueMetaType = input.getParameterValueMetaType(formatKey, paramKey);

            // List<String>values =
            // input.getParameterPredefinedValues(formatKey,paramKey);
            List<String> values = new ArrayList<String>();
            for (String value : input.getParameterPredefinedValues(formatKey, paramKey)) {
              values.add(getParamValueLabel(value));
            }

            // Si valeurs prédéfinies, ajout des paramètres de la
            // transformation
            if (values.size() > 0) {
              for (String parameter : transMeta.listParameters()) {
                values.add("${" + parameter + "}");
              }
            }

            // Paramétrage de la boîte de dialogue (commun)
            String dialogTitle =
                BaseMessages.getString(PKG, "GisFileInput.Params.Dialog.PARAM_VALUE.Title");
            String dialogParamComment =
                BaseMessages.getString(PKG, "GisFileInput.Params." + paramKey + ".Description")
                    + " ("
                    + ValueMeta.getTypeDesc(paramValueMetaType)
                    + ")";

            if (values.isEmpty()) {

              // Saisie directe de la valeur du paramètre
              EnterStringDialog dialog =
                  new EnterStringDialog(
                      shell,
                      tableItem.getText(3),
                      dialogTitle,
                      dialogParamComment,
                      true,
                      transMeta);

              // Ouverture de la boîte de dialogue
              String selectedValue = dialog.open();
              if (selectedValue != null) {
                tableItem.setText(3, selectedValue);
              }

            } else {

              // Choix dans une liste
              EnterSelectionDialog dialog =
                  new EnterSelectionDialog(
                      shell,
                      values.toArray(new String[values.size()]),
                      dialogTitle,
                      dialogParamComment);
              dialog.setMulti(false);
              dialog.setViewOnly();
              dialog.setAvoidQuickSearch();

              // Ouverture de la boîte de dialogue
              int index = dialog.getSelectionNr(tableItem.getText(3));
              if (index >= 0) {
                dialog.setSelectedNrs(new int[] {index});
              }

              String selectedValue = dialog.open();
              if (selectedValue != null) {
                tableItem.setText(3, selectedValue);
              }
            }
          }
        });

    return new ColumnInfo[] {nameColumnInfo, requiredColumnInfo, fixedValueColumnInfo};
  }