private void getInfo(PaloCellOutputMeta myMeta) throws KettleException {
    stepname = textStepName.getText();
    List<DimensionField> fields = new ArrayList<DimensionField>();

    if (this.updateOptions.getCode(comboUpdateMode.getText()) == "ADD"
        && this.splashOptions.getCode(comboSplashMode.getText()) == "SET") {
      throw new KettleException(
          BaseMessages.getString(
              PKG,
              "PaloCellOutputDialog.UpdateSplashError",
              BaseMessages.getString(PKG, "PaloCellOutputDialog.UpdateMode"),
              comboUpdateMode.getText(),
              BaseMessages.getString(PKG, "PaloCellOutputDialog.SplashMode"),
              comboSplashMode.getText()));
    }

    try {
      Integer.parseInt(this.textCommitSize.getText());
    } catch (Exception e) {
      throw new KettleException(
          BaseMessages.getString(PKG, "PaloCellOutputDialog.CommitSizeErrorMessage"));
    }

    for (int i = 0; i < tableViewFields.table.getItemCount(); i++) {

      DimensionField field =
          new DimensionField(
              tableViewFields.table.getItem(i).getText(1),
              tableViewFields.table.getItem(i).getText(2),
              "" // tableViewFields.table.getItem(i).getText(3)
              );

      if (i != tableViewFields.table.getItemCount() - 1) {
        // if(tableViewFields.table.getItem(i).getText(3)!="String")
        // throw new
        // KettleException("Dimension input field must be from String type");
        fields.add(field);
      } else {
        myMeta.setMeasureField(field);
      }
    }

    myMeta.setCube(this.comboCube.getText());
    myMeta.setMeasureType(this.comboMeasureType.getText());
    myMeta.setUpdateMode(this.updateOptions.getCode(comboUpdateMode.getText()));
    myMeta.setSplashMode(this.splashOptions.getCode(comboSplashMode.getText()));
    myMeta.setLevels(fields);
    myMeta.setClearCube(this.buttonClearCube.getSelection());
    myMeta.setDatabaseMeta(transMeta.findDatabase(addConnectionLine.getText()));
    myMeta.setCommitSize(Integer.parseInt(this.textCommitSize.getText()));
    myMeta.setEnableDimensionCache(this.buttonEnableDimensionCache.getSelection());
    if (this.buttonEnableDimensionCache.getSelection()) {
      myMeta.setPreloadDimensionCache(this.buttonPreloadDimensionCache.getSelection());
    } else {
      myMeta.setPreloadDimensionCache(false);
    }
    myMeta.setChanged(true);
  }
  private void fillStoredData() {
    if (stepname != null) {
      textStepName.setText(stepname);
    }

    int index =
        addConnectionLine.indexOf(
            meta.getDatabaseMeta() != null ? meta.getDatabaseMeta().getName() : "");
    if (index >= 0) {
      addConnectionLine.select(index);
    }

    if (meta.getCube() != null) {
      comboCube.add(meta.getCube());
      comboCube.select(0);
    }

    for (PaloOption option : updateOptions) {
      comboUpdateMode.add(option.getDescription());
    }
    comboUpdateMode.select(
        comboUpdateMode.indexOf(this.updateOptions.getDescription(meta.getUpdateMode())));

    for (PaloOption option : splashOptions) {
      comboSplashMode.add(option.getDescription());
    }
    comboSplashMode.select(
        comboSplashMode.indexOf(this.splashOptions.getDescription(meta.getSplashMode())));

    textCommitSize.setText(String.valueOf(meta.getCommitSize()));
    buttonEnableDimensionCache.setSelection(meta.getEnableDimensionCache());
    buttonPreloadDimensionCache.setSelection(meta.getPreloadDimensionCache());
    buttonPreloadDimensionCache.setEnabled(buttonEnableDimensionCache.getSelection());

    comboMeasureType.setItems(new String[] {"Numeric", "String"});
    comboMeasureType.select(0);
    if (meta.getMeasureType() != null) {
      int indexType = comboMeasureType.indexOf(meta.getMeasureType());
      if (indexType >= 0) {
        comboMeasureType.select(indexType);
      }
    }

    tableViewFields.table.removeAll();

    if (meta.getFields().size() > 0) {
      for (DimensionField level : meta.getFields()) {
        tableViewFields.add(level.getDimensionName(), level.getFieldName());
      }
    }

    List<String> fieldNameList = null;
    try {
      RowMetaInterface r = transMeta.getPrevStepFields(stepname);
      fieldNameList = Arrays.asList(r.getFieldNames());
      Collections.sort(fieldNameList);
    } catch (Exception e) {
      // ignore
    }
    tableViewFields.setColumnInfo(
        1,
        new ColumnInfo(
            "Field",
            ColumnInfo.COLUMN_TYPE_CCOMBO,
            (fieldNameList == null ? null : fieldNameList.toArray(new String[0])),
            true));

    if (meta.getMeasure() != null) {
      final TableItem item = new TableItem(tableViewFields.table, SWT.NONE);
      item.setText(1, meta.getMeasure().getDimensionName());
      item.setText(2, meta.getMeasure().getFieldName());
      // item.setText(3,meta.getMeasure().getFieldType());
      item.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));
    }
    tableViewFields.setRowNums();
    tableViewFields.optWidth(true);

    buttonClearCube.setSelection(meta.getClearCube());
  }
 private void cancel() {
   stepname = null;
   meta.setChanged(changed);
   dispose();
 }
  public String open() {

    final Display display = getParent().getDisplay();
    shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
    props.setLook(shell);
    setShellImage(shell, meta);
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    int middle = props.getMiddlePct();
    int margin = Const.MARGIN;

    FormData fd;

    labelStepName = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(0, margin);
    labelStepName.setLayoutData(fd);

    textStepName = new Text(shell, SWT.BORDER);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(0, margin);
    textStepName.setLayoutData(fd);

    addConnectionLine = addConnectionLine(shell, textStepName, Const.MIDDLE_PCT, margin);

    labelCube = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(addConnectionLine, margin);
    labelCube.setLayoutData(fd);

    comboCube = new Combo(shell, SWT.READ_ONLY);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(addConnectionLine, margin);
    comboCube.setLayoutData(fd);

    labelMeasureType = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(comboCube, margin);
    labelMeasureType.setLayoutData(fd);

    comboMeasureType = new Combo(shell, SWT.READ_ONLY | SWT.FILL);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(comboCube, margin);
    comboMeasureType.setLayoutData(fd);

    labelUpdateMode = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(comboMeasureType, margin);
    labelUpdateMode.setLayoutData(fd);

    comboUpdateMode = new Combo(shell, SWT.READ_ONLY | SWT.FILL);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(comboMeasureType, margin);
    comboUpdateMode.setLayoutData(fd);

    labelSplashMode = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(comboUpdateMode, margin);
    labelSplashMode.setLayoutData(fd);

    comboSplashMode = new Combo(shell, SWT.READ_ONLY | SWT.FILL);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(comboUpdateMode, margin);
    comboSplashMode.setLayoutData(fd);

    labelCommitSize = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(comboSplashMode, margin);
    labelCommitSize.setLayoutData(fd);

    textCommitSize = new Text(shell, SWT.BORDER);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(comboSplashMode, margin);
    textCommitSize.setLayoutData(fd);

    labelClearCube = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(textCommitSize, margin);
    labelClearCube.setLayoutData(fd);

    buttonClearCube = new Button(shell, SWT.CHECK);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(textCommitSize, margin);
    buttonClearCube.setLayoutData(fd);

    labelEnableDimensionCache = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(buttonClearCube, margin);
    labelEnableDimensionCache.setLayoutData(fd);

    buttonEnableDimensionCache = new Button(shell, SWT.CHECK);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(buttonClearCube, margin);
    buttonEnableDimensionCache.setLayoutData(fd);

    labelPreloadDimensionCache = new Label(shell, SWT.RIGHT);
    fd = new FormData();
    fd.left = new FormAttachment(0, 0);
    fd.right = new FormAttachment(middle, -margin);
    fd.top = new FormAttachment(buttonEnableDimensionCache, margin);
    labelPreloadDimensionCache.setLayoutData(fd);

    buttonPreloadDimensionCache = new Button(shell, SWT.CHECK);
    fd = new FormData();
    fd.left = new FormAttachment(middle, 0);
    fd.right = new FormAttachment(100, 0);
    fd.top = new FormAttachment(buttonEnableDimensionCache, margin);
    buttonPreloadDimensionCache.setLayoutData(fd);

    ModifyListener lsMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            meta.setChanged();
          }
        };

    colinf =
        new ColumnInfo[] {
          new ColumnInfo(getLocalizedColumn(0), ColumnInfo.COLUMN_TYPE_TEXT, false, true),
          new ColumnInfo(
              getLocalizedColumn(1), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}, true),
        };

    tableViewFields =
        new TableView(null, shell, SWT.NONE | SWT.BORDER, colinf, 10, true, lsMod, props);

    tableViewFields.setSize(477, 105);
    tableViewFields.setBounds(5, 250, 477, 105);
    tableViewFields.setReadonly(true);
    tableViewFields.setSortable(false);
    tableViewFields.table.removeAll();
    fd = new FormData();
    fd.left = new FormAttachment(0, margin);
    fd.top = new FormAttachment(buttonPreloadDimensionCache, 3 * margin);
    fd.right = new FormAttachment(100, -150);
    fd.bottom = new FormAttachment(100, -50);
    tableViewFields.setLayoutData(fd);

    buttonGetFields = new Button(shell, SWT.NONE);
    fd = new FormData();
    fd.left = new FormAttachment(tableViewFields, margin);
    fd.top = new FormAttachment(buttonPreloadDimensionCache, 3 * margin);
    fd.right = new FormAttachment(100, 0);
    buttonGetFields.setLayoutData(fd);

    buttonClearFields = new Button(shell, SWT.NONE);
    fd = new FormData();
    fd.left = new FormAttachment(tableViewFields, margin);
    fd.top = new FormAttachment(buttonGetFields, margin);
    fd.right = new FormAttachment(100, 0);
    buttonClearFields.setLayoutData(fd);

    buttonOk = new Button(shell, SWT.CENTER);
    buttonCancel = new Button(shell, SWT.CENTER);
    buttonOk.setText(BaseMessages.getString("System.Button.OK"));
    buttonCancel.setText(BaseMessages.getString("System.Button.Cancel"));
    setButtonPositions(new Button[] {buttonOk, buttonCancel}, margin, null);

    buttonGetFields.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            doGetFields();
          }
        });
    buttonClearFields.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            doClearFields();
          }
        });
    buttonCancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            cancel();
          }
        });
    buttonOk.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            ok();
          }
        });
    addConnectionLine.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            doSelectConnection(false);
          }
        });
    comboCube.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            doSelectCube();
          }
        });
    buttonEnableDimensionCache.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent arg0) {
            buttonPreloadDimensionCache.setEnabled(buttonEnableDimensionCache.getSelection());
          }
        });

    this.fillLocalizedData();
    this.fillStoredData();
    this.doSelectConnection(false);

    props.setLook(tableViewFields);
    props.setLook(textStepName);
    props.setLook(comboCube);
    props.setLook(labelStepName);
    props.setLook(labelCube);
    props.setLook(labelMeasureType);
    props.setLook(comboMeasureType);
    props.setLook(labelUpdateMode);
    props.setLook(comboUpdateMode);
    props.setLook(labelSplashMode);
    props.setLook(comboSplashMode);
    props.setLook(buttonClearFields);
    props.setLook(buttonGetFields);
    props.setLook(buttonOk);
    props.setLook(buttonCancel);
    props.setLook(addConnectionLine);
    props.setLook(buttonClearCube);
    props.setLook(labelClearCube);
    props.setLook(textCommitSize);
    props.setLook(labelCommitSize);
    props.setLook(labelPreloadDimensionCache);
    props.setLook(buttonPreloadDimensionCache);
    props.setLook(labelEnableDimensionCache);
    props.setLook(buttonEnableDimensionCache);

    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });
    meta.setChanged(changed);
    setSize();
    shell.open();

    PaloCellInputDialog.showPaloLibWarningDialog(shell);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepname;
  }