protected void getParamsData() {
    wParams.clearAll(false);
    ArrayList<String> paramNames = new ArrayList<String>(configuration.getParams().keySet());
    Collections.sort(paramNames);

    for (int i = 0; i < paramNames.size(); i++) {
      String paramName = paramNames.get(i);
      String paramValue = configuration.getParams().get(paramName);
      String defaultValue;
      try {
        defaultValue = abstractMeta.getParameterDefault(paramName);
      } catch (UnknownParamException e) {
        defaultValue = "";
      }

      String description;
      try {
        description = abstractMeta.getParameterDescription(paramName);
      } catch (UnknownParamException e) {
        description = "";
      }

      TableItem tableItem = new TableItem(wParams.table, SWT.NONE);
      tableItem.setText(1, paramName);
      tableItem.setText(2, Const.NVL(defaultValue, ""));
      tableItem.setText(3, Const.NVL(paramValue, ""));
      tableItem.setText(4, Const.NVL(description, ""));
    }
    wParams.removeEmptyRows();
    wParams.setRowNums();
    wParams.optWidth(true);
  }
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    wAccField.setText(Const.NVL(input.getAcceptingField(), ""));

    for (int i = 0; i < input.getOutputFields().size(); i++) {
      SasInputField field = input.getOutputFields().get(i);

      TableItem item = new TableItem(wFields.table, SWT.NONE);
      int colnr = 1;
      item.setText(colnr++, Const.NVL(field.getName(), ""));
      item.setText(colnr++, Const.NVL(field.getRename(), ""));
      item.setText(colnr++, ValueMeta.getTypeDesc(field.getType()));
      item.setText(colnr++, Const.NVL(field.getConversionMask(), ""));
      item.setText(colnr++, field.getLength() >= 0 ? Integer.toString(field.getLength()) : "");
      item.setText(
          colnr++, field.getPrecision() >= 0 ? Integer.toString(field.getPrecision()) : "");
      item.setText(colnr++, Const.NVL(field.getDecimalSymbol(), ""));
      item.setText(colnr++, Const.NVL(field.getGroupingSymbol(), ""));
      item.setText(colnr++, Const.NVL(field.getTrimTypeDesc(), ""));
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);

    wStepname.selectAll();
    wStepname.setFocus();
  }
  private void populateTableWithTupleTemplate() {
    Table table = m_fieldsView.table;

    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(), "" + 5),
              MessageDialog.WARNING,
              new String[] {
                Messages.getString("MappingOutputDialog.ClearAndAdd"),
                Messages.getString("MappingOutputDialog.Cancel"),
              },
              0);
      MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon());
      int idx = md.open();
      choice = idx & 0xFF;
    }

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

    m_fieldsView.clearAll();
    TableItem item = new TableItem(table, SWT.NONE);
    item.setText(1, "KEY");
    item.setText(2, "Y");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Family");
    item.setText(2, "N");
    item.setText(5, "String");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Column");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Value");
    item.setText(2, "N");
    item = new TableItem(table, SWT.NONE);
    item.setText(1, "Timestamp");
    item.setText(2, "N");
    item.setText(5, "Long");

    m_fieldsView.removeEmptyRows();
    m_fieldsView.setRowNums();
    m_fieldsView.optWidth(true);
  }
  public void getInfo(SasInputMeta meta) throws KettleStepException {
    // copy info to Meta class (input)
    meta.setAcceptingField(wAccField.getText());

    int nrNonEmptyFields = wFields.nrNonEmpty();
    meta.getOutputFields().clear();

    for (int i = 0; i < nrNonEmptyFields; i++) {
      TableItem item = wFields.getNonEmpty(i);

      int colnr = 1;
      SasInputField field = new SasInputField();
      field.setName(item.getText(colnr++));
      field.setRename(item.getText(colnr++));
      if (Const.isEmpty(field.getRename())) {
        field.setRename(field.getName());
      }
      field.setType(ValueMeta.getType(item.getText(colnr++)));
      field.setConversionMask(item.getText(colnr++));
      field.setLength(Const.toInt(item.getText(colnr++), -1));
      field.setPrecision(Const.toInt(item.getText(colnr++), -1));
      field.setDecimalSymbol(item.getText(colnr++));
      field.setGroupingSymbol(item.getText(colnr++));
      field.setTrimType(ValueMeta.getTrimTypeByDesc(item.getText(colnr++)));

      meta.getOutputFields().add(field);
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);
  }
 public void getDatabases() {
   wFields.removeAll();
   for (int i = 0; i < jobMeta.nrDatabases(); i++) {
     DatabaseMeta ci = jobMeta.getDatabase(i);
     if (ci != null) {
       wFields.add(new String[] {ci.getName(), "0", JobEntryCheckDbConnections.unitTimeDesc[0]});
     }
   }
   wFields.removeEmptyRows();
   wFields.setRowNums();
   wFields.optWidth(true);
 }
  public void setMapping(Mapping mapping) {
    if (mapping == null) {
      return;
    }

    m_fieldsView.clearAll();

    // do the key first
    TableItem keyItem = new TableItem(m_fieldsView.table, SWT.NONE);
    keyItem.setText(1, mapping.getKeyName());
    keyItem.setText(2, "Y");
    keyItem.setText(5, mapping.getKeyType().toString());
    if (mapping.isTupleMapping() && !Const.isEmpty(mapping.getTupleFamilies())) {
      keyItem.setText(3, mapping.getTupleFamilies());
    }

    // the rest of the fields in the mapping
    Map<String, HBaseValueMeta> mappedFields = mapping.getMappedColumns();
    for (String alias : mappedFields.keySet()) {
      HBaseValueMeta vm = mappedFields.get(alias);
      TableItem item = new TableItem(m_fieldsView.table, SWT.NONE);
      item.setText(1, alias);
      item.setText(2, "N");
      item.setText(3, vm.getColumnFamily());
      item.setText(4, vm.getColumnName());

      if (vm.isInteger()) {
        if (vm.getIsLongOrDouble()) {
          item.setText(5, "Long");
        } else {
          item.setText(5, "Integer");
        }
      } else if (vm.isNumber()) {
        if (vm.getIsLongOrDouble()) {
          item.setText(5, "Double");
        } else {
          item.setText(5, "Float");
        }
      } else {
        item.setText(5, vm.getTypeDesc());
      }

      if (vm.getStorageType() == ValueMetaInterface.STORAGE_TYPE_INDEXED) {
        item.setText(6, HBaseValueMeta.objectIndexValuesToString(vm.getIndex()));
      }
    }

    m_fieldsView.removeEmptyRows();
    m_fieldsView.setRowNums();
    m_fieldsView.optWidth(true);
  }
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    Table table = wFields.table;
    if (input.getStepName().length > 0) {
      table.removeAll();
    }
    for (int i = 0; i < input.getStepName().length; i++) {
      TableItem ti = new TableItem(table, SWT.NONE);
      ti.setText(0, "" + (i + 1));
      if (input.getStepName()[i] != null) {
        ti.setText(1, input.getStepName()[i]);
        ti.setText(2, String.valueOf(Const.toInt(input.getStepCopyNr()[i], 0)));
        ti.setText(3, input.getRequiredStepsDesc(input.getStepRequired()[i]));
      }
    }

    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);

    if (input.getStepNameFieldName() != null) {
      wStepnameField.setText(input.getStepNameFieldName());
    }
    if (input.getStepIdFieldName() != null) {
      wStepidField.setText(input.getStepIdFieldName());
    }
    if (input.getStepLinesInputFieldName() != null) {
      wLinesinputField.setText(input.getStepLinesInputFieldName());
    }
    if (input.getStepLinesOutputFieldName() != null) {
      wLinesoutputField.setText(input.getStepLinesOutputFieldName());
    }
    if (input.getStepLinesReadFieldName() != null) {
      wLinesreadField.setText(input.getStepLinesReadFieldName());
    }
    if (input.getStepLinesWrittenFieldName() != null) {
      wLineswrittenField.setText(input.getStepLinesWrittenFieldName());
    }
    if (input.getStepLinesUpdatedFieldName() != null) {
      wLinesupdatedField.setText(input.getStepLinesUpdatedFieldName());
    }
    if (input.getStepLinesErrorsFieldName() != null) {
      wLineserrorsField.setText(input.getStepLinesErrorsFieldName());
    }
    if (input.getStepSecondsFieldName() != null) {
      wSecondsField.setText(input.getStepSecondsFieldName());
    }

    wStepname.selectAll();
    wStepname.setFocus();
  }
Example #8
0
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    if (input.getReplaceAllByValue() != null) wReplaceByValue.setText(input.getReplaceAllByValue());
    if (input.getReplaceAllMask() != null) wMask.setText(input.getReplaceAllMask());

    wSelectFields.setSelection(input.isSelectFields());
    wSelectValuesType.setSelection(input.isSelectValuesType());

    Table table = wValueTypes.table;
    if (input.getTypeName().length > 0) table.removeAll();
    for (int i = 0; i < input.getTypeName().length; i++) {
      TableItem ti = new TableItem(table, SWT.NONE);
      ti.setText(0, "" + (i + 1));
      if (input.getTypeName()[i] != null) ti.setText(1, input.getTypeName()[i]);
      if (input.getTypeReplaceValue()[i] != null) ti.setText(2, input.getTypeReplaceValue()[i]);
      if (input.getTypeReplaceMask()[i] != null) ti.setText(3, input.getTypeReplaceMask()[i]);
    }

    wValueTypes.setRowNums();
    wValueTypes.removeEmptyRows();
    wValueTypes.optWidth(true);

    table = wFields.table;
    if (input.getFieldName().length > 0) table.removeAll();
    for (int i = 0; i < input.getFieldName().length; i++) {
      TableItem ti = new TableItem(table, SWT.NONE);
      ti.setText(0, "" + (i + 1));
      if (input.getFieldName()[i] != null) ti.setText(1, input.getFieldName()[i]);
      if (input.getReplaceValue()[i] != null) ti.setText(2, input.getReplaceValue()[i]);
      if (input.getReplaceMask()[i] != null) ti.setText(3, input.getReplaceMask()[i]);
    }

    wFields.setRowNums();
    wValueTypes.removeEmptyRows();
    wFields.optWidth(true);

    wStepname.selectAll();
  }
  private void doGetFields() {
    try {
      List<String> cubeDimensions = null;
      if (comboCube.getText() != null && comboCube.getText() != "") {
        if (addConnectionLine.getText() != null) {
          DatabaseMeta dbMeta = transMeta.findDatabase(addConnectionLine.getText());
          if (dbMeta != null) {
            PaloCellOutputData data = new PaloCellOutputData(dbMeta);
            data.helper.connect();
            cubeDimensions = data.helper.getCubeDimensions(comboCube.getText());
            data.helper.disconnect();
          }
        }
        tableViewFields.table.removeAll();

        for (int i = 0; i < cubeDimensions.size(); i++) {
          final TableItem item = new TableItem(tableViewFields.table, SWT.NONE);
          item.setText(1, cubeDimensions.get(i));
          // item.setText(3, "String");

        }
        final TableItem item = new TableItem(tableViewFields.table, SWT.NONE);
        item.setText(1, "Cube Measure");
        item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));

        tableViewFields.removeEmptyRows();
        tableViewFields.setRowNums();
        tableViewFields.optWidth(true);
        tableViewFields.setReadonly(true);

      } else {
        new ErrorDialog(
            shell,
            BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"),
            BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"),
            new Exception(
                BaseMessages.getString(PKG, "PaloCellOutputDialog.SelectCubeFirstError")));
      }

      this.fillPreviousFieldTableViewColumn();

    } catch (KettleException ke) {
      new ErrorDialog(
          shell,
          BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"),
          BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"),
          ke);
    }
  }
  private void get() {
    wFields.removeAll();
    Table table = wFields.table;

    for (int i = 0; i < previousSteps.length; i++) {
      TableItem ti = new TableItem(table, SWT.NONE);
      ti.setText(0, "" + (i + 1));
      ti.setText(1, previousSteps[i]);
      ti.setText(2, "0");
      ti.setText(3, BaseMessages.getString(PKG, "System.Combo.No"));
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);
  }
  private void getArgumentsData() {
    wArguments.clearAll(false);

    List<String> argumentNames = new ArrayList<String>(configuration.getArguments().keySet());
    Collections.sort(argumentNames);

    for (int i = 0; i < argumentNames.size(); i++) {
      String argumentName = argumentNames.get(i);
      String argumentValue = configuration.getArguments().get(argumentName);

      TableItem tableItem = new TableItem(wArguments.table, SWT.NONE);
      tableItem.setText(1, Const.NVL(argumentName, ""));
      tableItem.setText(2, Const.NVL(argumentValue, ""));
    }
    wArguments.removeEmptyRows();
    wArguments.setRowNums();
    wArguments.optWidth(true);
  }
  private void getInfo(FixedInputMeta fixedInputMeta) {

    fixedInputMeta.setFilename(wFilename.getText());
    fixedInputMeta.setLineWidth(wLineWidth.getText());
    fixedInputMeta.setBufferSize(wBufferSize.getText());
    fixedInputMeta.setLazyConversionActive(wLazyConversion.getSelection());
    fixedInputMeta.setHeaderPresent(wHeaderPresent.getSelection());
    fixedInputMeta.setLineFeedPresent(wLineFeedPresent.getSelection());
    fixedInputMeta.setRunningInParallel(wRunningInParallel.getSelection());
    fixedInputMeta.setFileType(FixedInputMeta.getFileType(wFileType.getText()));
    fixedInputMeta.setEncoding(wEncoding.getText());
    fixedInputMeta.setAddResultFile(wAddResult.getSelection());

    int nrNonEmptyFields = wFields.nrNonEmpty();
    fixedInputMeta.allocate(nrNonEmptyFields);

    for (int i = 0; i < nrNonEmptyFields; i++) {
      TableItem item = wFields.getNonEmpty(i);
      int colnr = 1;

      FixedFileInputField field = new FixedFileInputField();

      field.setName(item.getText(colnr++));
      field.setType(ValueMetaFactory.getIdForValueMeta(item.getText(colnr++)));
      field.setFormat(item.getText(colnr++));
      field.setWidth(Const.toInt(item.getText(colnr++), -1));
      field.setLength(Const.toInt(item.getText(colnr++), -1));
      field.setPrecision(Const.toInt(item.getText(colnr++), -1));
      field.setCurrency(item.getText(colnr++));
      field.setDecimal(item.getText(colnr++));
      field.setGrouping(item.getText(colnr++));
      field.setTrimType(ValueMetaString.getTrimTypeByDesc(item.getText(colnr++)));

      // CHECKSTYLE:Indentation:OFF
      fixedInputMeta.getFieldDefinition()[i] = field;
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);

    fixedInputMeta.setChanged();
  }
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    wStepname.setText(stepname);
    wFilename.setText(Const.NVL(inputMeta.getFilename(), ""));
    wLineWidth.setText(Const.NVL(inputMeta.getLineWidth(), ""));
    wLineFeedPresent.setSelection(inputMeta.isLineFeedPresent());
    wBufferSize.setText(Const.NVL(inputMeta.getBufferSize(), ""));
    wLazyConversion.setSelection(inputMeta.isLazyConversionActive());
    wHeaderPresent.setSelection(inputMeta.isHeaderPresent());
    wRunningInParallel.setSelection(inputMeta.isRunningInParallel());
    wFileType.setText(inputMeta.getFileTypeDesc());
    wEncoding.setText(Const.NVL(inputMeta.getEncoding(), ""));
    wAddResult.setSelection(inputMeta.isAddResultFile());

    for (int i = 0; i < inputMeta.getFieldDefinition().length; i++) {
      TableItem item = new TableItem(wFields.table, SWT.NONE);
      int colnr = 1;
      FixedFileInputField field = inputMeta.getFieldDefinition()[i];

      item.setText(colnr++, Const.NVL(field.getName(), ""));
      item.setText(colnr++, ValueMetaFactory.getValueMetaName(field.getType()));
      item.setText(colnr++, Const.NVL(field.getFormat(), ""));
      item.setText(colnr++, field.getWidth() >= 0 ? Integer.toString(field.getWidth()) : "");
      item.setText(colnr++, field.getLength() >= 0 ? Integer.toString(field.getLength()) : "");
      item.setText(
          colnr++, field.getPrecision() >= 0 ? Integer.toString(field.getPrecision()) : "");
      item.setText(colnr++, Const.NVL(field.getCurrency(), ""));
      item.setText(colnr++, Const.NVL(field.getDecimal(), ""));
      item.setText(colnr++, Const.NVL(field.getGrouping(), ""));
      item.setText(colnr++, ValueMetaString.getTrimTypeCode(field.getTrimType()));
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);

    enableFields();

    wStepname.selectAll();
    wStepname.setFocus();
  }
  private void addMappingDefinitionTab(
      final MappingIODefinition definition,
      int index,
      final String tabTitle,
      final String tabTooltip,
      String inputStepLabel,
      String outputStepLabel,
      String descriptionLabel,
      String sourceColumnLabel,
      String targetColumnLabel,
      final boolean input) {

    final CTabItem wTab;
    if (index >= wTabFolder.getItemCount()) {
      wTab = new CTabItem(wTabFolder, SWT.CLOSE);
    } else {
      wTab = new CTabItem(wTabFolder, SWT.CLOSE, index);
    }
    setMappingDefinitionTabNameAndToolTip(wTab, tabTitle, tabTooltip, definition, input);

    Composite wInputComposite = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wInputComposite);

    FormLayout tabLayout = new FormLayout();
    tabLayout.marginWidth = Const.FORM_MARGIN;
    tabLayout.marginHeight = Const.FORM_MARGIN;
    wInputComposite.setLayout(tabLayout);

    // What's the stepname to read from? (empty is OK too)
    //
    Button wbInputStep = new Button(wInputComposite, SWT.PUSH);
    props.setLook(wbInputStep);
    wbInputStep.setText(Messages.getString("MappingFieldRunnerDialog.button.SourceStepName"));
    FormData fdbInputStep = new FormData();
    fdbInputStep.top = new FormAttachment(0, 0);
    fdbInputStep.right = new FormAttachment(100, 0); // First one in the
    // left top corner
    wbInputStep.setLayoutData(fdbInputStep);

    Label wlInputStep = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlInputStep);
    wlInputStep.setText(inputStepLabel); // $NON-NLS-1$
    FormData fdlInputStep = new FormData();
    fdlInputStep.top = new FormAttachment(wbInputStep, 0, SWT.CENTER);
    fdlInputStep.left = new FormAttachment(0, 0); // First one in the left
    // top corner
    fdlInputStep.right = new FormAttachment(middle, -margin);
    wlInputStep.setLayoutData(fdlInputStep);

    final Text wInputStep = new Text(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wInputStep);
    wInputStep.setText(Const.NVL(definition.getInputStepname(), ""));
    wInputStep.addModifyListener(lsMod);
    FormData fdInputStep = new FormData();
    fdInputStep.top = new FormAttachment(wbInputStep, 0, SWT.CENTER);
    fdInputStep.left = new FormAttachment(middle, 0); // To the right of
    // the label
    fdInputStep.right = new FormAttachment(wbInputStep, -margin);
    wInputStep.setLayoutData(fdInputStep);
    wInputStep.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent event) {
            definition.setInputStepname(wInputStep.getText());
            setMappingDefinitionTabNameAndToolTip(wTab, tabTitle, tabTooltip, definition, input);
          }
        });
    wbInputStep.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            String stepName = selectTransformationStepname(input, input);
            if (stepName != null) {
              wInputStep.setText(stepName);
              definition.setInputStepname(stepName);
              setMappingDefinitionTabNameAndToolTip(wTab, tabTitle, tabTooltip, definition, input);
            }
          }
        });

    // What's the step name to read from? (empty is OK too)
    //
    Button wbOutputStep = new Button(wInputComposite, SWT.PUSH);
    props.setLook(wbOutputStep);
    wbOutputStep.setText(Messages.getString("MappingFieldRunnerDialog.button.SourceStepName"));
    FormData fdbOutputStep = new FormData();
    fdbOutputStep.top = new FormAttachment(wbInputStep, margin);
    fdbOutputStep.right = new FormAttachment(100, 0);
    wbOutputStep.setLayoutData(fdbOutputStep);

    Label wlOutputStep = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlOutputStep);
    wlOutputStep.setText(outputStepLabel); // $NON-NLS-1$
    FormData fdlOutputStep = new FormData();
    fdlOutputStep.top = new FormAttachment(wbOutputStep, 0, SWT.CENTER);
    fdlOutputStep.left = new FormAttachment(0, 0);
    fdlOutputStep.right = new FormAttachment(middle, -margin);
    wlOutputStep.setLayoutData(fdlOutputStep);

    final Text wOutputStep = new Text(wInputComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wOutputStep);
    wOutputStep.setText(Const.NVL(definition.getOutputStepname(), ""));
    wOutputStep.addModifyListener(lsMod);
    FormData fdOutputStep = new FormData();
    fdOutputStep.top = new FormAttachment(wbOutputStep, 0, SWT.CENTER);
    fdOutputStep.left = new FormAttachment(middle, 0); // To the right of
    // the label
    fdOutputStep.right = new FormAttachment(wbOutputStep, -margin);
    wOutputStep.setLayoutData(fdOutputStep);

    // Add a checkbox to indicate the main step to read from, the main data
    // path...
    //
    Label wlMainPath = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlMainPath);
    wlMainPath.setText(
        Messages.getString("MappingFieldRunnerDialog.input.MainDataPath")); // $NON-NLS-1$
    FormData fdlMainPath = new FormData();
    fdlMainPath.top = new FormAttachment(wbOutputStep, margin);
    fdlMainPath.left = new FormAttachment(0, 0);
    fdlMainPath.right = new FormAttachment(middle, -margin);
    wlMainPath.setLayoutData(fdlMainPath);

    Button wMainPath = new Button(wInputComposite, SWT.CHECK);
    props.setLook(wMainPath);
    FormData fdMainPath = new FormData();
    fdMainPath.top = new FormAttachment(wbOutputStep, margin);
    fdMainPath.left = new FormAttachment(middle, 0);
    // fdMainPath.right = new FormAttachment(100, 0); // who cares, it's a
    // checkbox
    wMainPath.setLayoutData(fdMainPath);

    wMainPath.setSelection(definition.isMainDataPath());
    wMainPath.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent event) {
            definition.setMainDataPath(!definition.isMainDataPath()); // flip
            // the
            // switch
          }
        });

    // Add a checkbox to indicate that all output mappings need to rename
    // the values back...
    //
    Label wlRenameOutput = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlRenameOutput);
    wlRenameOutput.setText(
        Messages.getString("MappingFieldRunnerDialog.input.RenamingOnOutput")); // $NON-NLS-1$
    FormData fdlRenameOutput = new FormData();
    fdlRenameOutput.top = new FormAttachment(wMainPath, margin);
    fdlRenameOutput.left = new FormAttachment(0, 0);
    fdlRenameOutput.right = new FormAttachment(middle, -margin);
    wlRenameOutput.setLayoutData(fdlRenameOutput);

    Button wRenameOutput = new Button(wInputComposite, SWT.CHECK);
    props.setLook(wRenameOutput);
    FormData fdRenameOutput = new FormData();
    fdRenameOutput.top = new FormAttachment(wMainPath, margin);
    fdRenameOutput.left = new FormAttachment(middle, 0);
    // fdRenameOutput.right = new FormAttachment(100, 0); // who cares, it's
    // a check box
    wRenameOutput.setLayoutData(fdRenameOutput);

    wRenameOutput.setSelection(definition.isRenamingOnOutput());
    wRenameOutput.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent event) {
            definition.setRenamingOnOutput(!definition.isRenamingOnOutput()); // flip
            // the
            // switch
          }
        });

    // Allow for a small description
    //
    Label wlDescription = new Label(wInputComposite, SWT.RIGHT);
    props.setLook(wlDescription);
    wlDescription.setText(descriptionLabel); // $NON-NLS-1$
    FormData fdlDescription = new FormData();
    fdlDescription.top = new FormAttachment(wRenameOutput, margin);
    fdlDescription.left = new FormAttachment(0, 0); // First one in the left
    // top corner
    fdlDescription.right = new FormAttachment(middle, -margin);
    wlDescription.setLayoutData(fdlDescription);

    final Text wDescription =
        new Text(wInputComposite, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wDescription);
    wDescription.setText(Const.NVL(definition.getDescription(), ""));
    wDescription.addModifyListener(lsMod);
    FormData fdDescription = new FormData();
    fdDescription.top = new FormAttachment(wRenameOutput, margin);
    fdDescription.bottom = new FormAttachment(wRenameOutput, 100 + margin);
    fdDescription.left = new FormAttachment(middle, 0); // To the right of
    // the label
    fdDescription.right = new FormAttachment(wbOutputStep, -margin);
    wDescription.setLayoutData(fdDescription);
    wDescription.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent event) {
            definition.setDescription(wDescription.getText());
          }
        });

    // Now add a table view with the 2 columns to specify: input and output
    // fields for the source and target steps.
    //
    final Button wbEnterMapping = new Button(wInputComposite, SWT.PUSH);
    props.setLook(wbEnterMapping);
    wbEnterMapping.setText(Messages.getString("MappingFieldRunnerDialog.button.EnterMapping"));
    FormData fdbEnterMapping = new FormData();
    fdbEnterMapping.top = new FormAttachment(wDescription, margin * 2);
    fdbEnterMapping.right = new FormAttachment(100, 0); // First one in the
    // left top corner
    wbEnterMapping.setLayoutData(fdbEnterMapping);

    ColumnInfo[] colinfo =
        new ColumnInfo[] {
          new ColumnInfo(
              sourceColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false), // $NON-NLS-1$
          new ColumnInfo(
              targetColumnLabel, ColumnInfo.COLUMN_TYPE_TEXT, false, false), // $NON-NLS-1$
        };
    final TableView wFieldMappings =
        new TableView(
            transMeta,
            wInputComposite,
            SWT.FULL_SELECTION | SWT.SINGLE | SWT.BORDER,
            colinfo,
            1,
            lsMod,
            props);
    props.setLook(wFieldMappings);
    FormData fdMappings = new FormData();
    fdMappings.left = new FormAttachment(0, 0);
    fdMappings.right = new FormAttachment(wbEnterMapping, -margin);
    fdMappings.top = new FormAttachment(wDescription, margin * 2);
    fdMappings.bottom = new FormAttachment(100, -20);
    wFieldMappings.setLayoutData(fdMappings);

    for (MappingValueRename valueRename : definition.getValueRenames()) {
      TableItem tableItem = new TableItem(wFieldMappings.table, SWT.NONE);
      tableItem.setText(1, valueRename.getSourceValueName());
      tableItem.setText(2, valueRename.getTargetValueName());
    }
    wFieldMappings.removeEmptyRows();
    wFieldMappings.setRowNums();
    wFieldMappings.optWidth(true);

    wbEnterMapping.addSelectionListener(
        new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            try {
              RowMetaInterface sourceRowMeta = getFieldsFromStep(wInputStep.getText(), true, input);
              RowMetaInterface targetRowMeta =
                  getFieldsFromStep(wOutputStep.getText(), false, input);
              String sourceFields[] = sourceRowMeta.getFieldNames();
              String targetFields[] = targetRowMeta.getFieldNames();

              EnterMappingDialog dialog = new EnterMappingDialog(shell, sourceFields, targetFields);
              List<SourceToTargetMapping> mappings = dialog.open();
              if (mappings != null) {
                // first clear the dialog...
                wFieldMappings.clearAll(false);

                //
                definition.getValueRenames().clear();

                // Now add the new values...
                for (int i = 0; i < mappings.size(); i++) {
                  SourceToTargetMapping mapping = mappings.get(i);
                  TableItem item = new TableItem(wFieldMappings.table, SWT.NONE);
                  item.setText(1, mapping.getSourceString(sourceFields));
                  item.setText(2, mapping.getTargetString(targetFields));

                  String source = input ? item.getText(1) : item.getText(2);
                  String target = input ? item.getText(2) : item.getText(1);
                  definition.getValueRenames().add(new MappingValueRename(source, target));
                }
                wFieldMappings.removeEmptyRows();
                wFieldMappings.setRowNums();
                wFieldMappings.optWidth(true);
              }
            } catch (KettleException e) {
              new ErrorDialog(
                  shell,
                  Messages.getString("System.Dialog.Error.Title"),
                  Messages.getString(
                      "MappingFieldRunnerDialog.Exception.ErrorGettingMappingSourceAndTargetFields",
                      e.toString()),
                  e);
            }
          }
        });

    wOutputStep.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent event) {
            definition.setOutputStepname(wOutputStep.getText());
            try {
              enableMappingButton(
                  wbEnterMapping, input, wInputStep.getText(), wOutputStep.getText());
            } catch (KettleException e) {
              // Show the missing/wrong step name error
              //
              new ErrorDialog(shell, "Error", "Unexpected error", e);
            }
          }
        });
    wbOutputStep.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            String stepName = selectTransformationStepname(!input, input);
            if (stepName != null) {
              wOutputStep.setText(stepName);
              definition.setOutputStepname(stepName);
              try {
                enableMappingButton(
                    wbEnterMapping, input, wInputStep.getText(), wOutputStep.getText());
              } catch (KettleException e) {
                // Show the missing/wrong stepname error
                new ErrorDialog(shell, "Error", "Unexpected error", e);
              }
            }
          }
        });

    FormData fdParametersComposite = new FormData();
    fdParametersComposite.left = new FormAttachment(0, 0);
    fdParametersComposite.top = new FormAttachment(0, 0);
    fdParametersComposite.right = new FormAttachment(100, 0);
    fdParametersComposite.bottom = new FormAttachment(100, 0);
    wInputComposite.setLayoutData(fdParametersComposite);

    wInputComposite.layout();
    wTab.setControl(wInputComposite);

    final ApplyChanges applyChanges =
        new MappingDefinitionTab(
            definition, wInputStep, wOutputStep, wMainPath, wDescription, wFieldMappings);
    changeList.add(applyChanges);

    // OK, suppose for some weird reason the user wants to remove an input
    // or output tab...
    wTabFolder.addCTabFolder2Listener(
        new CTabFolder2Adapter() {

          @Override
          public void close(CTabFolderEvent event) {
            if (event.item.equals(wTab)) {
              // The user has the audacity to try and close this mapping
              // definition tab.
              // We really should warn him that this is a bad idea...
              MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO);
              box.setText(
                  Messages.getString(
                      "MappingFieldRunnerDialog.CloseDefinitionTabAreYouSure.Title"));
              box.setMessage(
                  Messages.getString(
                      "MappingFieldRunnerDialog.CloseDefinitionTabAreYouSure.Message"));
              int answer = box.open();
              if (answer != SWT.YES) {
                event.doit = false;
              } else {
                // Remove it from our list to make sure it's gone...
                if (input) inputMappings.remove(definition);
                else outputMappings.remove(definition);

                // remove it from the changeList too...
                // Otherwise the dialog leaks memory.
                //
                changeList.remove(applyChanges);
              }
            }
          }
        });

    wTabFolder.setSelection(wTab);
  }
  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);
      }
    }
  }
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    if (input.getReplaceAllByValue() != null) {
      wReplaceByValue.setText(input.getReplaceAllByValue());
    }
    if (input.getReplaceAllMask() != null) {
      wMask.setText(input.getReplaceAllMask());
    }
    wSetEmptyStringAll.setSelection(input.isSetEmptyStringAll());

    wSelectFields.setSelection(input.isSelectFields());
    wSelectValuesType.setSelection(input.isSelectValuesType());

    Table table = wValueTypes.table;
    if (input.getValueTypes().length > 0) {
      table.removeAll();
    }
    for (int i = 0; i < input.getValueTypes().length; i++) {
      TableItem ti = new TableItem(table, SWT.NONE);
      ti.setText(0, "" + (i + 1));
      if (input.getValueTypes()[i].getTypeName() != null) {
        ti.setText(1, input.getValueTypes()[i].getTypeName());
      }
      if (input.getValueTypes()[i].getTypereplaceValue() != null) {
        ti.setText(2, input.getValueTypes()[i].getTypereplaceValue());
      }
      if (input.getValueTypes()[i].getTypereplaceMask() != null) {
        ti.setText(3, input.getValueTypes()[i].getTypereplaceMask());
      }
      ti.setText(
          4,
          input.getValueTypes()[i].isSetTypeEmptyString()
              ? BaseMessages.getString(PKG, "System.Combo.Yes")
              : BaseMessages.getString(PKG, "System.Combo.No"));
    }

    wValueTypes.setRowNums();
    wValueTypes.removeEmptyRows();
    wValueTypes.optWidth(true);

    table = wFields.table;
    if (input.getFields().length > 0) {
      table.removeAll();
    }
    for (int i = 0; i < input.getFields().length; i++) {
      TableItem ti = new TableItem(table, SWT.NONE);
      ti.setText(0, "" + (i + 1));
      if (input.getFields()[i].getFieldName() != null) {
        ti.setText(1, input.getFields()[i].getFieldName());
      }
      if (input.getFields()[i].getReplaceValue() != null) {
        ti.setText(2, input.getFields()[i].getReplaceValue());
      }
      if (input.getFields()[i].getReplaceMask() != null) {
        ti.setText(3, input.getFields()[i].getReplaceMask());
      }
      ti.setText(
          4,
          input.getFields()[i].isSetEmptyString()
              ? BaseMessages.getString(PKG, "System.Combo.Yes")
              : BaseMessages.getString(PKG, "System.Combo.No"));
    }

    wFields.setRowNums();
    wValueTypes.removeEmptyRows();
    wFields.optWidth(true);

    wStepname.selectAll();
    wStepname.setFocus();
  }
  /**
   * Read the data from the GetFilesRowsCountMeta object and show it in this dialog.
   *
   * @param in The GetFilesRowsCountMeta object to obtain the data from.
   */
  public void getData(GetFilesRowsCountMeta in) {
    if (in.getFileName() != null) {
      wFilenameList.removeAll();
      for (int i = 0; i < in.getFileName().length; i++) {
        wFilenameList.add(
            new String[] {
              in.getFileName()[i],
              in.getFileMask()[i],
              in.getExludeFileMask()[i],
              in.getRequiredFilesDesc(in.getFileRequired()[i]),
              in.getRequiredFilesDesc(in.getIncludeSubFolders()[i])
            });
      }
      wFilenameList.removeEmptyRows();
      wFilenameList.setRowNums();
      wFilenameList.optWidth(true);
    }
    wInclFilesCount.setSelection(in.includeCountFiles());

    if (in.getFilesCountFieldName() != null) {
      wInclFilesCountField.setText(in.getFilesCountFieldName());
    } else {
      wInclFilesCountField.setText("filescount");
    }

    if (in.getRowsCountFieldName() != null) {
      wRowsCountField.setText(in.getRowsCountFieldName());
    } else {
      wRowsCountField.setText(GetFilesRowsCountMeta.DEFAULT_ROWSCOUNT_FIELDNAME);
    }

    if (in.getRowSeparatorFormat() != null) {
      // Checking for 'CR' for backwards compatibility
      if (in.getRowSeparatorFormat().equals("CARRIAGERETURN")
          || in.getRowSeparatorFormat().equals("CR")) {
        wRowSeparatorFormat.select(0);
      } else if (in.getRowSeparatorFormat().equals("LINEFEED")
          || in.getRowSeparatorFormat().equals("LF")) {
        // Checking for 'LF' for backwards compatibility
        wRowSeparatorFormat.select(1);
      } else if (in.getRowSeparatorFormat().equals("CRLF")) {
        wRowSeparatorFormat.select(2);
      } else if (in.getRowSeparatorFormat().equals("TAB")) {
        wRowSeparatorFormat.select(3);
      } else {
        wRowSeparatorFormat.select(4);
      }
    } else {
      wRowSeparatorFormat.select(0);
    }

    if (in.getRowSeparator() != null) {
      wRowSeparator.setText(in.getRowSeparator());
    }

    wAddResult.setSelection(in.isAddResultFile());
    wFileField.setSelection(in.isFileField());
    if (in.setOutputFilenameField() != null) {
      wFilenameField.setText(in.setOutputFilenameField());
    }

    logDebug(BaseMessages.getString(PKG, "GetFilesRowsCountDialog.Log.GettingFieldsInfo"));

    setIncludeRownum();

    wStepname.selectAll();
    wStepname.setFocus();
  }