public DemoPartitionerDialog(
     Shell parent, StepMeta stepMeta, StepPartitioningMeta partitioningMeta, TransMeta transMeta) {
   super(
       parent,
       (BaseStepMeta) stepMeta.getStepMetaInterface(),
       transMeta,
       partitioningMeta.getPartitioner().getDescription());
   this.stepMeta = stepMeta;
   this.partitioningMeta = partitioningMeta;
   partitioner = (DemoPartitioner) partitioningMeta.getPartitioner();
   fieldName = partitioner.getFieldName();
 }
  public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
    props.setLook(shell);
    setShellImage(shell, stepMeta.getStepMetaInterface());

    ModifyListener lsMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            partitioningMeta.hasChanged(true);
          }
        };
    changed = partitioningMeta.hasChanged();

    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;

    shell.setLayout(formLayout);
    shell.setText(partitioner.getDescription()); // $NON-NLS-1$

    int margin = Const.MARGIN;

    int middle = props.getMiddlePct();

    wlFieldname = new Label(shell, SWT.RIGHT);
    wlFieldname.setText("Fieldname"); // $NON-NLS-1$
    props.setLook(wlFieldname);
    fdlFieldname = new FormData();
    fdlFieldname.left = new FormAttachment(0, 0);
    fdlFieldname.right = new FormAttachment(middle, -margin);
    fdlFieldname.top = new FormAttachment(0, margin);
    wlFieldname.setLayoutData(fdlFieldname);
    wFieldname = new CCombo(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wFieldname.setText(fieldName == null ? "" : fieldName);
    props.setLook(wFieldname);
    wFieldname.addModifyListener(lsMod);
    fdFieldname = new FormData();
    fdFieldname.left = new FormAttachment(middle, 0);
    fdFieldname.top = new FormAttachment(0, margin);
    fdFieldname.right = new FormAttachment(100, 0);
    wFieldname.setLayoutData(fdFieldname);

    try {
      RowMetaInterface inputFields = transMeta.getPrevStepFields(stepMeta);
      if (inputFields != null) {
        String[] fieldNames = inputFields.getFieldNames();
        Arrays.sort(fieldNames);
        wFieldname.setItems(fieldNames);
      }
    } catch (KettleStepException e) {
      new ErrorDialog(shell, "Error", "Error obtaining list of input fields:", e);
    }

    // Some buttons
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); // $NON-NLS-1$
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); // $NON-NLS-1$
    fdOK = new FormData();

    setButtonPositions(new Button[] {wOK, wCancel}, margin, null);

    // Add listeners
    lsCancel =
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        };
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };

    wCancel.addListener(SWT.Selection, lsCancel);
    wOK.addListener(SWT.Selection, lsOK);

    lsDef =
        new SelectionAdapter() {
          public void widgetDefaultSelected(SelectionEvent e) {
            ok();
          }
        };

    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            cancel();
          }
        });

    // Set the shell size, based upon previous time...
    setSize();
    getData();
    partitioningMeta.hasChanged(changed);

    setSize();

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return stepname;
  }
 private void ok() {
   fieldName = wFieldname.getText();
   partitioner.setFieldName(fieldName);
   dispose();
 }