/** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    for (DatabaseMeta dbMeta : transMeta.getDatabases()) {
      wReferenceDB.add(dbMeta.getName());
      wCompareDB.add(dbMeta.getName());
    }

    wReferenceDB.setText(
        input.getReferenceConnection() != null ? input.getReferenceConnection().getName() : "");
    wReferenceSchema.setText(Const.NVL(input.getReferenceSchemaField(), ""));
    wReferenceTable.setText(Const.NVL(input.getReferenceTableField(), ""));
    wCompareDB.setText(
        input.getCompareConnection() != null ? input.getCompareConnection().getName() : "");
    wCompareSchema.setText(Const.NVL(input.getCompareSchemaField(), ""));
    wCompareTable.setText(Const.NVL(input.getCompareTableField(), ""));
    wKeyFields.setText(Const.NVL(input.getKeyFieldsField(), ""));
    wExcludeFields.setText(Const.NVL(input.getExcludeFieldsField(), ""));

    wNrErrors.setText(Const.NVL(input.getNrErrorsField(), ""));
    wNrRecordsReference.setText(Const.NVL(input.getNrRecordsReferenceField(), ""));
    wNrRecordsCompare.setText(Const.NVL(input.getNrRecordsCompareField(), ""));
    wNrErrorsLeftJoin.setText(Const.NVL(input.getNrErrorsLeftJoinField(), ""));
    wNrErrorsInnerJoin.setText(Const.NVL(input.getNrErrorsInnerJoinField(), ""));
    wNrErrorsRightJoin.setText(Const.NVL(input.getNrErrorsRightJoinField(), ""));

    wKeyDesc.setText(Const.NVL(input.getKeyDescriptionField(), ""));
    wReferenceValue.setText(Const.NVL(input.getValueReferenceField(), ""));
    wCompareValue.setText(Const.NVL(input.getValueCompareField(), ""));

    setComboValues();

    wStepname.selectAll();
    wStepname.setFocus();
  }
  public void createControl(Composite parent) {
    int margin = Const.MARGIN;

    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NONE);
    props.setLook(composite);

    FormLayout compLayout = new FormLayout();
    compLayout.marginHeight = Const.FORM_MARGIN;
    compLayout.marginWidth = Const.FORM_MARGIN;
    composite.setLayout(compLayout);

    wSourceDB = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wSourceDB);
    for (int i = 0; i < databases.size(); i++) {
      DatabaseMeta dbInfo = databases.get(i);
      wSourceDB.add(dbInfo.getName());
    }
    fdSourceDB = new FormData();
    fdSourceDB.top = new FormAttachment(0, 0);
    fdSourceDB.left = new FormAttachment(0, 0);
    fdSourceDB.bottom = new FormAttachment(100, 0);
    fdSourceDB.right = new FormAttachment(50, 0);
    wSourceDB.setLayoutData(fdSourceDB);
    wSourceDB.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            setPageComplete(false);
          }
        });

    wTargetDB = new List(composite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    props.setLook(wTargetDB);
    for (int i = 0; i < databases.size(); i++) {
      DatabaseMeta dbInfo = databases.get(i);
      wTargetDB.add(dbInfo.getName());
    }
    fdTargetDB = new FormData();
    fdTargetDB.top = new FormAttachment(0, 0);
    fdTargetDB.left = new FormAttachment(50, margin);
    fdTargetDB.bottom = new FormAttachment(100, 0);
    fdTargetDB.right = new FormAttachment(100, 0);
    wTargetDB.setLayoutData(fdTargetDB);
    wTargetDB.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            setPageComplete(false);
          }
        });

    // set the composite as the control for this page
    setControl(composite);
  }
  public void removeConnection() {
    try {
      Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems();

      if (connections != null && !connections.isEmpty()) {
        for (Object obj : connections) {
          if (obj != null && obj instanceof UIDatabaseConnection) {
            UIDatabaseConnection connection = (UIDatabaseConnection) obj;

            DatabaseMeta databaseMeta = connection.getDatabaseMeta();

            // Make sure this connection already exists and store its id for updating
            ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName());
            if (idDatabase == null) {
              MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
              mb.setMessage(
                  BaseMessages.getString(
                      PKG,
                      "RepositoryExplorerDialog.Connection.Delete.DoesNotExists.Message",
                      databaseMeta.getName()));
              mb.setText(
                  BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title"));
              mb.open();
            } else {
              repository.deleteDatabaseMeta(databaseMeta.getName());
            }
          }
        }
      } else {
        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
        mb.setMessage(
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message"));
        mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title"));
        mb.open();
      }
    } catch (KettleException e) {
      if (mainController == null || !mainController.handleLostRepository(e)) {
        new ErrorDialog(
            shell,
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"),
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Remove.UnexpectedError.Message"),
            e);
      }
    } finally {
      refreshConnectionList();
    }
  }
 /**
  * Insert all the databases from the repository into the TransMeta object, overwriting optionally
  *
  * @param TransMeta The transformation to load into.
  * @param overWriteShared if an object with the same name exists, overwrite
  * @throws KettleException
  */
 protected void readDatabases(
     TransMeta transMeta, boolean overWriteShared, List<DatabaseMeta> databaseMetas) {
   for (DatabaseMeta databaseMeta : databaseMetas) {
     if (overWriteShared || transMeta.findDatabase(databaseMeta.getName()) == null) {
       if (databaseMeta.getName() != null) {
         databaseMeta.shareVariablesWith(transMeta);
         transMeta.addOrReplaceDatabase(databaseMeta);
         if (!overWriteShared) {
           databaseMeta.setChanged(false);
         }
       }
     }
   }
   transMeta.clearChangedDatabases();
 }
 public void addDatabases() {
   connections = new String[jobMeta.nrDatabases()];
   for (int i = 0; i < jobMeta.nrDatabases(); i++) {
     DatabaseMeta ci = jobMeta.getDatabase(i);
     connections[i] = ci.getName();
   }
 }
  public String getXML() {
    StringBuilder retval = new StringBuilder(400);

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    ").append(XMLHandler.addTagValue("commit", commitSize));
    retval.append("    ").append(XMLHandler.addTagValue("update_bypassed", updateBypassed));
    retval.append("    <lookup>").append(Const.CR);
    retval.append("      ").append(XMLHandler.addTagValue("schema", schemaName));
    retval.append("      ").append(XMLHandler.addTagValue("table", tableName));

    for (int i = 0; i < keyStream.length; i++) {
      retval.append("      <key>").append(Const.CR);
      retval.append("        ").append(XMLHandler.addTagValue("name", keyStream[i]));
      retval.append("        ").append(XMLHandler.addTagValue("field", keyLookup[i]));
      retval.append("        ").append(XMLHandler.addTagValue("condition", keyCondition[i]));
      retval.append("        ").append(XMLHandler.addTagValue("name2", keyStream2[i]));
      retval.append("      </key>").append(Const.CR);
    }

    for (int i = 0; i < updateLookup.length; i++) {
      retval.append("      <value>").append(Const.CR);
      retval.append("        ").append(XMLHandler.addTagValue("name", updateLookup[i]));
      retval.append("        ").append(XMLHandler.addTagValue("rename", updateStream[i]));
      retval.append("        ").append(XMLHandler.addTagValue("update", update[i].booleanValue()));
      retval.append("      </value>").append(Const.CR);
    }

    retval.append("    </lookup>").append(Const.CR);

    return retval.toString();
  }
  @Override
  public String getXML() {
    StringBuilder retval = new StringBuilder(200);

    retval.append(super.getXML());
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue("connection", connection == null ? null : connection.getName()));
    retval.append("      ").append(XMLHandler.addTagValue("schemaname", schemaname));
    retval.append("      ").append(XMLHandler.addTagValue("tablename", tablename));
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue("success_condition", getSuccessConditionCode(successCondition)));
    retval.append("      ").append(XMLHandler.addTagValue("rows_count_value", rowsCountValue));
    retval.append("      ").append(XMLHandler.addTagValue("is_custom_sql", iscustomSQL));
    retval.append("      ").append(XMLHandler.addTagValue("is_usevars", isUseVars));
    retval.append("      ").append(XMLHandler.addTagValue("custom_sql", customSQL));
    retval.append("      ").append(XMLHandler.addTagValue("add_rows_result", isAddRowsResult));
    retval.append("      ").append(XMLHandler.addTagValue("maximum_timeout", maximumTimeout));
    retval.append("      ").append(XMLHandler.addTagValue("check_cycle_time", checkCycleTime));
    retval.append("      ").append(XMLHandler.addTagValue("success_on_timeout", successOnTimeout));
    retval.append("      ").append(XMLHandler.addTagValue("clear_result_rows", isClearResultList));
    return retval.toString();
  }
  public String getXML() {
    StringBuilder retval = new StringBuilder(300);

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    ").append(XMLHandler.addTagValue("schema", schemaName));
    retval.append("    ").append(XMLHandler.addTagValue("table", tableName));
    retval.append("    ").append(XMLHandler.addTagValue("encoding", encoding));
    retval.append("    ").append(XMLHandler.addTagValue("delimiter", delimiter));
    retval.append("    ").append(XMLHandler.addTagValue("enclosure", enclosure));
    retval.append("    ").append(XMLHandler.addTagValue("escape_char", escapeChar));
    retval.append("    ").append(XMLHandler.addTagValue("replace", replacingData));
    retval.append("    ").append(XMLHandler.addTagValue("ignore", ignoringErrors));
    retval.append("    ").append(XMLHandler.addTagValue("local", localFile));
    retval.append("    ").append(XMLHandler.addTagValue("fifo_file_name", fifoFileName));
    retval.append("    ").append(XMLHandler.addTagValue("bulk_size", bulkSize));

    for (int i = 0; i < fieldTable.length; i++) {
      retval.append("      <mapping>").append(Const.CR);
      retval.append("        ").append(XMLHandler.addTagValue("stream_name", fieldTable[i]));
      retval.append("        ").append(XMLHandler.addTagValue("field_name", fieldStream[i]));
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue(
                  "field_format_ok", getFieldFormatTypeCode(fieldFormatType[i])));
      retval.append("      </mapping>").append(Const.CR);
    }

    return retval.toString();
  }
  public String getXML() {
    StringBuilder retval = new StringBuilder(300);

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    ").append(XMLHandler.addTagValue("schema", schemaName));
    retval.append("    ").append(XMLHandler.addTagValue("table", tableName));
    retval.append("    ").append(XMLHandler.addTagValue("load_action", loadAction));
    retval.append("    ").append(XMLHandler.addTagValue("PsqlPath", PsqlPath));
    retval.append("    ").append(XMLHandler.addTagValue("dbname_override", dbNameOverride));
    retval.append("    ").append(XMLHandler.addTagValue("enclosure", enclosure));
    retval.append("    ").append(XMLHandler.addTagValue("delimiter", delimiter));
    retval.append("    ").append(XMLHandler.addTagValue("stop_on_error", stopOnError));

    for (int i = 0; i < fieldTable.length; i++) {
      retval.append("      <mapping>").append(Const.CR);
      retval.append("        ").append(XMLHandler.addTagValue("stream_name", fieldTable[i]));
      retval.append("        ").append(XMLHandler.addTagValue("field_name", fieldStream[i]));
      retval.append("        ").append(XMLHandler.addTagValue("date_mask", dateMask[i]));
      retval.append("      </mapping>").append(Const.CR);
    }

    return retval.toString();
  }
  protected void okPressed() {
    boolean hasErrors = popupValidationErrorDialogIfNecessary();

    if (!hasErrors) {
      try {
        conceptUtil.setId(wId.getText());
      } catch (ObjectAlreadyExistsException e) {
        if (logger.isErrorEnabled()) {
          logger.error("an exception occurred", e);
        }
        MessageDialog.openError(
            getShell(),
            Messages.getString("General.USER_TITLE_ERROR"),
            Messages.getString(
                "PhysicalTableDialog.USER_ERROR_PHYSICAL_TABLE_ID_EXISTS", wId.getText()));
        return;
      }

      // attempt to set the connection
      IStructuredSelection selection = (IStructuredSelection) comboViewer.getSelection();
      DatabaseMeta con = (DatabaseMeta) selection.getFirstElement();
      BusinessModel busModel = (BusinessModel) conceptUtil;
      if (!DUMMY_CON_NAME.equals(con.getName())) {
        busModel.setConnection((DatabaseMeta) con);
      } else {
        busModel.clearConnection();
      }

      super.okPressed();
    }
  }
  private void replaceSharedObjects(AbstractMeta abstractMeta) {
    for (DatabaseMeta databaseMeta : getSharedObjects(DatabaseMeta.class)) {
      // Database...
      int index = abstractMeta.indexOfDatabase(databaseMeta);
      if (index < 0) {
        abstractMeta.addDatabase(databaseMeta);
      } else {
        DatabaseMeta imported = abstractMeta.getDatabase(index);
        // Preserve the object id so we can update without having to look up the id
        imported.setObjectId(databaseMeta.getObjectId());
        if (equals(databaseMeta, imported)
            || !getPromptResult(
                BaseMessages.getString(
                    PKG,
                    "RepositoryImporter.Dialog.ConnectionExistsOverWrite.Message",
                    imported.getName()),
                BaseMessages.getString(
                    PKG,
                    "RepositoryImporter.Dialog.ConnectionExistsOverWrite.DontShowAnyMoreMessage"),
                IMPORT_ASK_ABOUT_REPLACE_DB)) {
          imported.replaceMeta(databaseMeta);
          // We didn't actually change anything
          imported.clearChanged();
        } else {
          imported.setChanged();
        }
      }
    }

    for (SlaveServer slaveServer : getSharedObjects(SlaveServer.class)) {
      int index = abstractMeta.getSlaveServers().indexOf(slaveServer);
      if (index < 0) {
        abstractMeta.getSlaveServers().add(slaveServer);
      } else {
        SlaveServer imported = abstractMeta.getSlaveServers().get(index);
        // Preserve the object id so we can update without having to look up the id
        imported.setObjectId(slaveServer.getObjectId());
        if (equals(slaveServer, imported)
            || !getPromptResult(
                BaseMessages.getString(
                    PKG,
                    "RepositoryImporter.Dialog.SlaveServerExistsOverWrite.Message",
                    imported.getName()),
                BaseMessages.getString(
                    PKG,
                    "RepositoryImporter.Dialog.ConnectionExistsOverWrite.DontShowAnyMoreMessage"),
                IMPORT_ASK_ABOUT_REPLACE_SS)) {
          imported.replaceMeta(slaveServer);
          // We didn't actually change anything
          imported.clearChanged();
        } else {
          imported.setChanged();
        }
      }
    }
  }
 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);
 }
  /**
   * Adds db connection text boxes for input
   *
   * @return the last control specified
   */
  protected Control addDbConnectionInputs() {
    List<String> ibConnections = new ArrayList<String>();
    for (DatabaseMeta dbMeta : transMeta.getDatabases()) {
      if (dbMeta.getDatabaseInterface() instanceof IngresDatabaseMeta) {
        ibConnections.add(dbMeta.getName());
      }
    }
    serverConnection =
        addStandardSelect(
            "Connection", wStepname, ibConnections.toArray(new String[ibConnections.size()]));

    return serverConnection;
  }
 /** Adapted from KettleDatabaseRepositoryDatabaseDelegate.saveDatabaseMeta */
 protected boolean equals(DatabaseMeta databaseMeta, DatabaseMeta databaseMeta2) {
   if (!equals(databaseMeta.getName(), databaseMeta2.getName())) {
     return false;
   } else if (!equals(databaseMeta.getPluginId(), databaseMeta2.getPluginId())) {
     return false;
   } else if (!equals(databaseMeta.getAccessType(), databaseMeta2.getAccessType())) {
     return false;
   } else if (!equals(databaseMeta.getHostname(), databaseMeta2.getHostname())) {
     return false;
   } else if (!equals(databaseMeta.getDatabaseName(), databaseMeta2.getDatabaseName())) {
     return false;
   } else if (!equals(
       databaseMeta.getDatabasePortNumberString(), databaseMeta2.getDatabasePortNumberString())) {
     return false;
   } else if (!equals(databaseMeta.getUsername(), databaseMeta2.getUsername())) {
     return false;
   } else if (!equals(databaseMeta.getPassword(), databaseMeta2.getPassword())) {
     return false;
   } else if (!equals(databaseMeta.getServername(), databaseMeta2.getServername())) {
     return false;
   } else if (!equals(databaseMeta.getDataTablespace(), databaseMeta2.getDataTablespace())) {
     return false;
   } else if (!equals(databaseMeta.getIndexTablespace(), databaseMeta2.getIndexTablespace())) {
     return false;
   }
   Map<Object, Object> databaseMeta2Attributes =
       new HashMap<Object, Object>(databaseMeta2.getAttributes());
   for (Entry<Object, Object> databaseMetaEntry :
       new HashMap<Object, Object>(databaseMeta.getAttributes()).entrySet()) {
     Object value = databaseMeta2Attributes.remove(databaseMetaEntry.getKey());
     if (!equals(value, databaseMetaEntry.getValue())) {
       return false;
     }
   }
   if (databaseMeta2Attributes.size() > 0) {
     return false;
   }
   return true;
 }
 /**
  * Add a database to the list of shared databases in ~/.kettle/shared.xml
  *
  * @param databaseMeta
  * @throws KettleException in case there is an error
  * @throws KettleObjectExistsException if a database with the same name already exists
  */
 public static void addSharedDatabase(DatabaseMeta databaseMeta)
     throws KettleObjectExistsException, KettleException {
   // First verify existence...
   //
   List<DatabaseMeta> sharedDatabases = loadSharedDatabases();
   DatabaseMeta found = DatabaseMeta.findDatabase(sharedDatabases, databaseMeta.getName());
   if (found != null) {
     throw new KettleObjectExistsException(
         "A database with name '"
             + databaseMeta.getName()
             + "' already exists in the shared databases list.");
   }
   try {
     SharedObjects sharedObjects = new SharedObjects();
     sharedObjects.storeObject(databaseMeta);
     sharedObjects.saveToFile();
   } catch (Exception e) {
     throw new KettleException(
         "It was not possible to add database '"
             + databaseMeta.getName()
             + "' to the shared.xml file");
   }
 }
  public void saveSharedObjects(
      final RepositoryElementInterface element, final String versionComment)
      throws KettleException {
    TransMeta transMeta = (TransMeta) element;
    // First store the databases and other depending objects in the transformation.
    //

    // Only store if the database has actually changed or doesn't have an object ID (imported)
    //
    for (DatabaseMeta databaseMeta : transMeta.getDatabases()) {
      if (databaseMeta.hasChanged() || databaseMeta.getObjectId() == null) {
        if (databaseMeta.getObjectId() == null
            || unifiedRepositoryConnectionAclService.hasAccess(
                databaseMeta.getObjectId(), RepositoryFilePermission.WRITE)) {
          repo.save(databaseMeta, versionComment, null);
        } else {
          log.logError(
              BaseMessages.getString(
                  PKG,
                  "PurRepository.ERROR_0004_DATABASE_UPDATE_ACCESS_DENIED",
                  databaseMeta.getName()));
        }
      }
    }

    // Store the slave servers...
    //
    for (SlaveServer slaveServer : transMeta.getSlaveServers()) {
      if (slaveServer.hasChanged() || slaveServer.getObjectId() == null) {
        repo.save(slaveServer, versionComment, null);
      }
    }

    // Store the cluster schemas
    //
    for (ClusterSchema clusterSchema : transMeta.getClusterSchemas()) {
      if (clusterSchema.hasChanged() || clusterSchema.getObjectId() == null) {
        repo.save(clusterSchema, versionComment, null);
      }
    }

    // Save the partition schemas
    //
    for (PartitionSchema partitionSchema : transMeta.getPartitionSchemas()) {
      if (partitionSchema.hasChanged() || partitionSchema.getObjectId() == null) {
        repo.save(partitionSchema, versionComment, null);
      }
    }
  }
Exemple #17
0
  public String getXML() {
    StringBuffer retval = new StringBuffer();

    retval.append(
        "    "
            + XMLHandler.addTagValue(
                "connection", databaseMeta == null ? "" : databaseMeta.getName()));

    retval.append("    ").append(XMLHandler.openTag(XML_TAG_FUNCTION)).append(Const.CR);
    if (function != null && !Const.isEmpty(function.getName())) {
      retval.append("    " + XMLHandler.addTagValue("name", function.getName()));
      retval.append("    " + XMLHandler.addTagValue("description", function.getDescription()));
      retval.append("    " + XMLHandler.addTagValue("group", function.getGroup()));
      retval.append("    " + XMLHandler.addTagValue("application", function.getApplication()));
      retval.append("    " + XMLHandler.addTagValue("host", function.getHost()));
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_FUNCTION)).append(Const.CR);

    retval.append("    ").append(XMLHandler.openTag(XML_TAG_PARAMETERS)).append(Const.CR);
    for (SapParameter parameter : parameters) {
      retval.append("    ").append(XMLHandler.openTag(XML_TAG_PARAMETER));
      retval.append(XMLHandler.addTagValue("field_name", parameter.getFieldName(), false));
      retval.append(XMLHandler.addTagValue("sap_type", parameter.getSapType().getCode(), false));
      retval.append(XMLHandler.addTagValue("table_name", parameter.getTableName(), false));
      retval.append(XMLHandler.addTagValue("parameter_name", parameter.getParameterName(), false));
      retval.append(
          XMLHandler.addTagValue(
              "target_type", ValueMeta.getTypeDesc(parameter.getTargetType()), false));
      retval.append("    ").append(XMLHandler.closeTag(XML_TAG_PARAMETER)).append(Const.CR);
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_PARAMETERS)).append(Const.CR);

    retval.append("    ").append(XMLHandler.openTag(XML_TAG_FIELDS)).append(Const.CR);
    for (SapOutputField parameter : outputFields) {
      retval.append("    ").append(XMLHandler.openTag(XML_TAG_FIELD));
      retval.append(XMLHandler.addTagValue("field_name", parameter.getSapFieldName(), false));
      retval.append(XMLHandler.addTagValue("sap_type", parameter.getSapType().getCode(), false));
      retval.append(XMLHandler.addTagValue("table_name", parameter.getTableName(), false));
      retval.append(XMLHandler.addTagValue("new_name", parameter.getNewName(), false));
      retval.append(
          XMLHandler.addTagValue(
              "target_type", ValueMeta.getTypeDesc(parameter.getTargetType()), false));
      retval.append("    ").append(XMLHandler.closeTag(XML_TAG_FIELD)).append(Const.CR);
    }
    retval.append("    ").append(XMLHandler.closeTag(XML_TAG_FIELDS)).append(Const.CR);

    return retval.toString();
  }
  public String getXML() {
    StringBuilder retval = new StringBuilder(300);
    retval.append("    ").append(XMLHandler.addTagValue("commit", commitSize));
    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    ").append(XMLHandler.addTagValue("sql_field", sqlField));

    retval.append("    ").append(XMLHandler.addTagValue("insert_field", insertField));
    retval.append("    ").append(XMLHandler.addTagValue("update_field", updateField));
    retval.append("    ").append(XMLHandler.addTagValue("delete_field", deleteField));
    retval.append("    ").append(XMLHandler.addTagValue("read_field", readField));
    retval.append("    ").append(XMLHandler.addTagValue("sqlFromfile", sqlFromfile));
    retval.append("    ").append(XMLHandler.addTagValue("sendOneStatement", sendOneStatement));
    return retval.toString();
  }
  public String getXML() {
    StringBuffer retval = new StringBuffer(500);

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection",
                databaseMeta == null
                    ? ""
                    : databaseMeta.getName())); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("commit", commitSize)); // $NON-NLS-1$ //$NON-NLS-2$
    retval.append("    <lookup>").append(Const.CR); // $NON-NLS-1$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("schema", schemaName)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("table", tableName)); // $NON-NLS-1$ //$NON-NLS-2$

    for (int i = 0; i < keyStream.length; i++) {
      retval.append("      <key>").append(Const.CR); // $NON-NLS-1$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("name", keyStream[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("field", keyLookup[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue("condition", keyCondition[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("name2", keyStream2[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval.append("      </key>").append(Const.CR); // $NON-NLS-1$
    }

    retval.append("    </lookup>").append(Const.CR); // $NON-NLS-1$

    return retval.toString();
  }
  public String getXML() {
    StringBuilder retval = new StringBuilder();

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection", databaseMeta == null ? "" : databaseMeta.getName()));
    retval.append("    ").append(XMLHandler.addTagValue("table", tablename));
    retval.append("    ").append(XMLHandler.addTagValue("fifo_file_name", fifoFileName));
    retval.append("    ").append(XMLHandler.addTagValue("sql_path", sqlPath));
    retval.append("    ").append(XMLHandler.addTagValue("encoding", encoding));
    retval.append("    ").append(XMLHandler.addTagValue("delimiter", delimiter));
    retval.append("    ").append(XMLHandler.addTagValue("continue_on_error", continueOnError));
    retval.append("    ").append(XMLHandler.addTagValue("error_file_name", errorFileName));
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("use_standard_conversion", useStandardConversion));
    retval.append("    ").append(XMLHandler.addTagValue("use_authentication", useAuthentication));
    retval.append("    ").append(XMLHandler.addTagValue("use_dynamic_vnode", useDynamicVNode));
    retval.append("    ").append(XMLHandler.addTagValue("use_SSV_delimiter", useSSV));
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("escape_special_characters", escapingSpecialCharacters));
    retval.append("    ").append(XMLHandler.addTagValue("use_vwload", usingVwload));
    retval.append("    ").append(XMLHandler.addTagValue("truncate_table", truncatingTable));
    retval.append("    ").append(XMLHandler.addTagValue("max_errors", maxNrErrors));
    retval.append("    ").append(XMLHandler.addTagValue("buffer_size", bufferSize));

    retval.append("    <fields>").append(Const.CR);

    for (int i = 0; i < fieldDatabase.length; i++) {
      retval.append("        <field>").append(Const.CR);
      retval.append("          ").append(XMLHandler.addTagValue("column_name", fieldDatabase[i]));
      retval.append("          ").append(XMLHandler.addTagValue("stream_name", fieldStream[i]));
      retval.append("        </field>").append(Const.CR);
    }
    retval.append("    </fields>").append(Const.CR);

    return retval.toString();
  }
  public String getXML() {
    StringBuilder retval = new StringBuilder(200);

    retval.append(super.getXML());
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue("connection", connection == null ? null : connection.getName()));
    retval.append("      ").append(XMLHandler.addTagValue("schemaname", schemaname));
    retval.append("      ").append(XMLHandler.addTagValue("tablename", tablename));
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue("success_condition", getSuccessConditionCode(successCondition)));
    retval.append("      ").append(XMLHandler.addTagValue("limit", limit));
    retval.append("      ").append(XMLHandler.addTagValue("is_custom_sql", iscustomSQL));
    retval.append("      ").append(XMLHandler.addTagValue("is_usevars", isUseVars));
    retval.append("      ").append(XMLHandler.addTagValue("custom_sql", customSQL));
    retval.append("      ").append(XMLHandler.addTagValue("add_rows_result", isAddRowsResult));
    retval.append("      ").append(XMLHandler.addTagValue("clear_result_rows", isClearResultList));

    return retval.toString();
  }
  public String getXML() {
    StringBuffer retval = new StringBuffer(200);

    retval.append(super.getXML());
    retval.append("      ").append(XMLHandler.addTagValue("schemaname", schemaname));
    retval.append("      ").append(XMLHandler.addTagValue("tablename", tablename));
    retval.append("      ").append(XMLHandler.addTagValue("filename", filename));
    retval.append("      ").append(XMLHandler.addTagValue("separator", separator));
    retval.append("      ").append(XMLHandler.addTagValue("enclosed", enclosed));
    retval.append("      ").append(XMLHandler.addTagValue("optionenclosed", optionenclosed));
    retval.append("      ").append(XMLHandler.addTagValue("lineterminated", lineterminated));
    retval.append("      ").append(XMLHandler.addTagValue("limitlines", limitlines));
    retval.append("      ").append(XMLHandler.addTagValue("listcolumn", listcolumn));
    retval.append("      ").append(XMLHandler.addTagValue("highpriority", highpriority));
    retval.append("      ").append(XMLHandler.addTagValue("outdumpvalue", outdumpvalue));
    retval.append("      ").append(XMLHandler.addTagValue("iffileexists", iffileexists));
    retval.append("      ").append(XMLHandler.addTagValue("addfiletoresult", addfiletoresult));
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue("connection", connection == null ? null : connection.getName()));

    return retval.toString();
  }
  public String getXML() {
    StringBuffer retval = new StringBuffer(512);

    retval
        .append("      ")
        .append(XMLHandler.addTagValue("schema", schemaName)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("table", tablename)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue(
                "connectionRead",
                databaseReadMeta == null
                    ? ""
                    : databaseReadMeta.getName())); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue(
                "connectionWrite",
                databaseWriteMeta == null
                    ? ""
                    : databaseWriteMeta.getName())); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("commit", commitSize)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("cache_size", cacheSize)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("replace", replaceFields)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("crc", useHash)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("crcfield", hashField)); // $NON-NLS-1$ //$NON-NLS-2$

    retval.append("      <fields>").append(Const.CR); // $NON-NLS-1$
    for (int i = 0; i < keyField.length; i++) {
      retval.append("        <key>").append(Const.CR); // $NON-NLS-1$
      retval
          .append("          ")
          .append(XMLHandler.addTagValue("name", keyField[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("          ")
          .append(XMLHandler.addTagValue("lookup", keyLookup[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval.append("        </key>").append(Const.CR); // $NON-NLS-1$
    }

    retval.append("        <return>").append(Const.CR); // $NON-NLS-1$
    retval
        .append("          ")
        .append(
            XMLHandler.addTagValue(
                "name",
                Const.isEmpty(technicalKeyField)
                    ? ""
                    : technicalKeyField)); //$NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("          ")
        .append(
            XMLHandler.addTagValue(
                "creation_method", techKeyCreation)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("          ")
        .append(XMLHandler.addTagValue("use_autoinc", useAutoinc)); // $NON-NLS-1$ //$NON-NLS-2$
    retval.append("        </return>").append(Const.CR); // $NON-NLS-1$

    retval.append("      </fields>").append(Const.CR); // $NON-NLS-1$

    // If sequence is empty: use auto-increment field!
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("sequence", sequenceFrom)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue(
                "last_update_field", lastUpdateField)); // $NON-NLS-1$ //$NON-NLS-2$

    return retval.toString();
  }
  /**
   * @return The object that is selected in the tree or null if we couldn't figure it out. (titles
   *     etc. == null)
   */
  public TreeSelection[] getTreeObjects(final Tree tree, Tree selectionTree, Tree coreObjectsTree) {
    List<TreeSelection> objects = new ArrayList<TreeSelection>();

    if (selectionTree != null && !selectionTree.isDisposed() && tree.equals(selectionTree)) {
      TreeItem[] selection = selectionTree.getSelection();
      for (int s = 0; s < selection.length; s++) {
        TreeItem treeItem = selection[s];
        String[] path = ConstUI.getTreeStrings(treeItem);

        TreeSelection object = null;

        switch (path.length) {
          case 0:
            break;
          case 1: // ------complete-----
            if (path[0].equals(
                Spoon.STRING_TRANSFORMATIONS)) { // the top level Transformations entry

              object = new TreeSelection(path[0], TransMeta.class);
            }
            if (path[0].equals(Spoon.STRING_JOBS)) { // the top level Jobs entry

              object = new TreeSelection(path[0], JobMeta.class);
            }
            break;

          case 2: // ------complete-----
            if (path[0].equals(
                Spoon.STRING_BUILDING_BLOCKS)) { // the top level Transformations entry

              if (path[1].equals(Spoon.STRING_TRANS_BASE)) {
                object = new TreeSelection(path[1], PluginInterface.class);
              }
            }
            if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) { // Transformation title

              object = new TreeSelection(path[1], spoon.delegates.trans.getTransformation(path[1]));
            }
            if (path[0].equals(Spoon.STRING_JOBS)) { // Jobs title

              object = new TreeSelection(path[1], spoon.delegates.jobs.getJob(path[1]));
            }
            break;

          case 3: // ------complete-----
            if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) { // Transformations title

              TransMeta transMeta = spoon.delegates.trans.getTransformation(path[1]);
              if (path[2].equals(Spoon.STRING_CONNECTIONS)) {
                object = new TreeSelection(path[2], DatabaseMeta.class, transMeta);
              }
              if (path[2].equals(Spoon.STRING_STEPS)) {
                object = new TreeSelection(path[2], StepMeta.class, transMeta);
              }
              if (path[2].equals(Spoon.STRING_HOPS)) {
                object = new TreeSelection(path[2], TransHopMeta.class, transMeta);
              }
              if (path[2].equals(Spoon.STRING_PARTITIONS)) {
                object = new TreeSelection(path[2], PartitionSchema.class, transMeta);
              }
              if (path[2].equals(Spoon.STRING_SLAVES)) {
                object = new TreeSelection(path[2], SlaveServer.class, transMeta);
              }
              if (path[2].equals(Spoon.STRING_CLUSTERS)) {
                object = new TreeSelection(path[2], ClusterSchema.class, transMeta);
              }
            }
            if (path[0].equals(Spoon.STRING_JOBS)) { // Jobs title

              JobMeta jobMeta = spoon.delegates.jobs.getJob(path[1]);
              if (path[2].equals(Spoon.STRING_CONNECTIONS)) {
                object = new TreeSelection(path[2], DatabaseMeta.class, jobMeta);
              }
              if (path[2].equals(Spoon.STRING_JOB_ENTRIES)) {
                object = new TreeSelection(path[2], JobEntryCopy.class, jobMeta);
              }
              if (path[2].equals(Spoon.STRING_SLAVES)) {
                object = new TreeSelection(path[2], SlaveServer.class, jobMeta);
              }
            }
            break;

          case 4: // ------complete-----
            if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) { // The name of a transformation
              final TransMeta transMeta = spoon.delegates.trans.getTransformation(path[1]);

              if (transMeta != null) {
                if (path[2].equals(Spoon.STRING_CONNECTIONS)) {
                  String dbName = path[3];
                  DatabaseMeta databaseMeta = transMeta.findDatabase(dbName);
                  if (databaseMeta != null) {
                    dbName = databaseMeta.getName();
                  }

                  object = new TreeSelection(dbName, databaseMeta, transMeta);
                }
                if (path[2].equals(Spoon.STRING_STEPS)) {
                  object = new TreeSelection(path[3], transMeta.findStep(path[3]), transMeta);
                }
                if (path[2].equals(Spoon.STRING_HOPS)) {
                  object = new TreeSelection(path[3], transMeta.findTransHop(path[3]), transMeta);
                }
                if (path[2].equals(Spoon.STRING_PARTITIONS)) {
                  object =
                      new TreeSelection(path[3], transMeta.findPartitionSchema(path[3]), transMeta);
                }
                if (path[2].equals(Spoon.STRING_SLAVES)) {
                  object =
                      new TreeSelection(path[3], transMeta.findSlaveServer(path[3]), transMeta);
                }
                if (path[2].equals(Spoon.STRING_CLUSTERS)) {
                  object =
                      new TreeSelection(path[3], transMeta.findClusterSchema(path[3]), transMeta);
                }
              }
            }
            if (path[0].equals(Spoon.STRING_JOBS)) { // The name of a job
              JobMeta jobMeta = spoon.delegates.jobs.getJob(path[1]);
              if (jobMeta != null && path[2].equals(Spoon.STRING_CONNECTIONS)) {
                String dbName = path[3];
                DatabaseMeta databaseMeta = jobMeta.findDatabase(dbName);
                if (databaseMeta != null) {
                  dbName = databaseMeta.getName();
                }

                object = new TreeSelection(dbName, databaseMeta, jobMeta);
              }
              if (jobMeta != null && path[2].equals(Spoon.STRING_JOB_ENTRIES)) {
                object = new TreeSelection(path[3], jobMeta.findJobEntry(path[3]), jobMeta);
              }
              if (jobMeta != null && path[2].equals(Spoon.STRING_SLAVES)) {
                object = new TreeSelection(path[3], jobMeta.findSlaveServer(path[3]), jobMeta);
              }
            }
            break;

          case 5:
            if (path[0].equals(Spoon.STRING_TRANSFORMATIONS)) { // The name of a transformation

              TransMeta transMeta = spoon.delegates.trans.getTransformation(path[1]);
              if (transMeta != null && path[2].equals(Spoon.STRING_CLUSTERS)) {
                ClusterSchema clusterSchema = transMeta.findClusterSchema(path[3]);
                object =
                    new TreeSelection(
                        path[4], clusterSchema.findSlaveServer(path[4]), clusterSchema, transMeta);
              }
            }
            break;
          default:
            break;
        }

        if (object != null) {
          objects.add(object);
        }
      }
    }
    if (tree != null && coreObjectsTree != null && tree.equals(coreObjectsTree)) {
      TreeItem[] selection = coreObjectsTree.getSelection();
      for (int s = 0; s < selection.length; s++) {
        TreeItem treeItem = selection[s];
        String[] path = ConstUI.getTreeStrings(treeItem);

        TreeSelection object = null;

        switch (path.length) {
          case 0:
            break;
          case 2: // Job entries
            if (spoon.showJob) {
              PluginRegistry registry = PluginRegistry.getInstance();
              Class<? extends PluginTypeInterface> pluginType = JobEntryPluginType.class;
              PluginInterface plugin = registry.findPluginWithName(pluginType, path[1]);

              // Retry for Start
              //
              if (plugin == null) {
                if (path[1].equals(JobMeta.STRING_SPECIAL_START)) {
                  plugin = registry.findPluginWithId(pluginType, JobMeta.STRING_SPECIAL);
                }
              }
              // Retry for Dummy
              //
              if (plugin == null) {
                if (path[1].equals(JobMeta.STRING_SPECIAL_DUMMY)) {
                  plugin = registry.findPluginWithId(pluginType, JobMeta.STRING_SPECIAL);
                }
              }

              if (plugin != null) {
                object = new TreeSelection(path[1], plugin);
              }
            }

            if (spoon.showTrans) {
              // Steps
              object =
                  new TreeSelection(
                      path[1],
                      PluginRegistry.getInstance()
                          .findPluginWithName(StepPluginType.class, path[1]));
            }
            break;
          default:
            break;
        }

        if (object != null) {
          objects.add(object);
        }
      }
    }

    return objects.toArray(new TreeSelection[objects.size()]);
  }
  public String getXML() {
    StringBuffer retval = new StringBuffer(300);

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection",
                databaseMeta == null
                    ? ""
                    : databaseMeta.getName())); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("errors", maxErrors)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("schema", schemaName)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("table", tableName)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("load_method", loadMethod)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("load_action", loadAction)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("PsqlPath", PsqlPath)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("control_file", controlFile)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("data_file", dataFile)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("log_file", logFile)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("erase_files", eraseFiles)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("encoding", encoding)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue("dbname_override", dbNameOverride)); // $NON-NLS-1$ //$NON-NLS-2$

    for (int i = 0; i < fieldTable.length; i++) {
      retval.append("      <mapping>").append(Const.CR); // $NON-NLS-1$
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue("stream_name", fieldTable[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue("field_name", fieldStream[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("date_mask", dateMask[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval.append("      </mapping>").append(Const.CR); // $NON-NLS-1$
    }

    return retval.toString();
  }
  public void editConnection() {
    try {
      Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems();

      if (connections != null && !connections.isEmpty()) {
        // Grab the first item in the list & send it to the database dialog
        DatabaseMeta databaseMeta =
            ((UIDatabaseConnection) connections.toArray()[0]).getDatabaseMeta();

        // Make sure this connection already exists and store its id for updating
        ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName());
        if (idDatabase == null) {
          MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
          mb.setMessage(
              BaseMessages.getString(
                  PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Message"));
          mb.setText(
              BaseMessages.getString(
                  PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Title"));
          mb.open();
        } else {
          getDatabaseDialog().setDatabaseMeta(databaseMeta);
          String dbName = getDatabaseDialog().open();
          if (dbName != null) {
            dbName = dbName.trim();
            if (!dbName.isEmpty()) {
              ObjectId idRenamed = repository.getDatabaseID(dbName);
              if (idRenamed == null || idRenamed.equals(idDatabase)) {
                // renaming to non-existing name or updating the current
                repository.insertLogEntry(
                    BaseMessages.getString(
                        PKG,
                        "ConnectionsController.Message.UpdatingDatabase",
                        databaseMeta.getName()));
                repository.save(databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION, null);
              } else {
                // trying to rename to an existing name - show error dialog
                showAlreadyExistsMessage();
              }
            }
          }
          // We should be able to tell the difference between a cancel and an empty database name
          //
          // else {
          // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
          // mb.setMessage(BaseMessages.getString(PKG,
          // "RepositoryExplorerDialog.Connection.Edit.MissingName.Message"));
          // mb.setText(BaseMessages.getString(PKG,
          // "RepositoryExplorerDialog.Connection.Edit.MissingName.Title"));
          // mb.open();
          // }
        }
      } else {
        MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
        mb.setMessage(
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message"));
        mb.setText(
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Title"));
        mb.open();
      }
    } catch (KettleException e) {
      if (mainController == null || !mainController.handleLostRepository(e)) {
        new ErrorDialog(
            shell,
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"),
            BaseMessages.getString(
                PKG, "RepositoryExplorerDialog.Connection.Edit.UnexpectedError.Message"),
            e);
      }
    } finally {
      refreshConnectionList();
    }
  }
  protected void loadTransformationDetails(final DataNode rootNode, final TransMeta transMeta)
      throws KettleException {
    transMeta.setExtendedDescription(getString(rootNode, PROP_EXTENDED_DESCRIPTION));
    transMeta.setTransversion(getString(rootNode, PROP_TRANS_VERSION));
    transMeta.setTransstatus((int) rootNode.getProperty(PROP_TRANS_STATUS).getLong());

    if (rootNode.hasProperty(PROP_STEP_READ)) {
      transMeta
          .getTransLogTable()
          .setStepRead(
              StepMeta.findStep(transMeta.getSteps(), getString(rootNode, PROP_STEP_READ)));
    }
    if (rootNode.hasProperty(PROP_STEP_WRITE)) {
      transMeta
          .getTransLogTable()
          .setStepWritten(
              StepMeta.findStep(transMeta.getSteps(), getString(rootNode, PROP_STEP_WRITE)));
    }
    if (rootNode.hasProperty(PROP_STEP_INPUT)) {
      transMeta
          .getTransLogTable()
          .setStepInput(
              StepMeta.findStep(transMeta.getSteps(), getString(rootNode, PROP_STEP_INPUT)));
    }
    if (rootNode.hasProperty(PROP_STEP_OUTPUT)) {
      transMeta
          .getTransLogTable()
          .setStepOutput(
              StepMeta.findStep(transMeta.getSteps(), getString(rootNode, PROP_STEP_OUTPUT)));
    }
    if (rootNode.hasProperty(PROP_STEP_UPDATE)) {
      transMeta
          .getTransLogTable()
          .setStepUpdate(
              StepMeta.findStep(transMeta.getSteps(), getString(rootNode, PROP_STEP_UPDATE)));
    }
    if (rootNode.hasProperty(PROP_STEP_REJECTED)) {
      transMeta
          .getTransLogTable()
          .setStepRejected(
              StepMeta.findStep(transMeta.getSteps(), getString(rootNode, PROP_STEP_REJECTED)));
    }

    if (rootNode.hasProperty(PROP_DATABASE_LOG)) {
      String id = rootNode.getProperty(PROP_DATABASE_LOG).getRef().getId().toString();
      DatabaseMeta conn =
          DatabaseMeta.findDatabase(transMeta.getDatabases(), new StringObjectId(id));
      transMeta.getTransLogTable().setConnectionName(conn.getName());
    }
    transMeta.getTransLogTable().setTableName(getString(rootNode, PROP_TABLE_NAME_LOG));
    transMeta
        .getTransLogTable()
        .setBatchIdUsed(rootNode.getProperty(PROP_USE_BATCHID).getBoolean());
    transMeta
        .getTransLogTable()
        .setLogFieldUsed(rootNode.getProperty(PROP_USE_LOGFIELD).getBoolean());

    if (rootNode.hasProperty(PROP_ID_DATABASE_MAXDATE)) {
      String id = rootNode.getProperty(PROP_ID_DATABASE_MAXDATE).getRef().getId().toString();
      transMeta.setMaxDateConnection(
          DatabaseMeta.findDatabase(transMeta.getDatabases(), new StringObjectId(id)));
    }
    transMeta.setMaxDateTable(getString(rootNode, PROP_TABLE_NAME_MAXDATE));
    transMeta.setMaxDateField(getString(rootNode, PROP_FIELD_NAME_MAXDATE));
    transMeta.setMaxDateOffset(rootNode.getProperty(PROP_OFFSET_MAXDATE).getDouble());
    transMeta.setMaxDateDifference(rootNode.getProperty(PROP_DIFF_MAXDATE).getDouble());

    transMeta.setCreatedUser(getString(rootNode, PROP_CREATED_USER));
    transMeta.setCreatedDate(getDate(rootNode, PROP_CREATED_DATE));

    transMeta.setModifiedUser(getString(rootNode, PROP_MODIFIED_USER));
    transMeta.setModifiedDate(getDate(rootNode, PROP_MODIFIED_DATE));

    // Optional:
    transMeta.setSizeRowset(Const.ROWS_IN_ROWSET);
    long val_size_rowset = rootNode.getProperty(PROP_SIZE_ROWSET).getLong();
    if (val_size_rowset > 0) {
      transMeta.setSizeRowset((int) val_size_rowset);
    }

    if (rootNode.hasProperty(PROP_ID_DIRECTORY)) {
      String id_directory = getString(rootNode, PROP_ID_DIRECTORY);
      if (log.isDetailed()) {
        log.logDetailed(toString(), PROP_ID_DIRECTORY + "=" + id_directory); // $NON-NLS-1$
      }
      // Set right directory...
      transMeta.setRepositoryDirectory(
          repo.findDirectory(new StringObjectId(id_directory))); // always reload the
      // folder structure
    }

    transMeta.setUsingUniqueConnections(rootNode.getProperty(PROP_UNIQUE_CONNECTIONS).getBoolean());
    boolean feedbackShown = true;
    if (rootNode.hasProperty(PROP_FEEDBACK_SHOWN)) {
      feedbackShown = rootNode.getProperty(PROP_FEEDBACK_SHOWN).getBoolean();
    }
    transMeta.setFeedbackShown(feedbackShown);
    transMeta.setFeedbackSize((int) rootNode.getProperty(PROP_FEEDBACK_SIZE).getLong());
    boolean usingThreadPriorityManagement = true;
    if (rootNode.hasProperty(PROP_USING_THREAD_PRIORITIES)) {
      usingThreadPriorityManagement =
          rootNode.getProperty(PROP_USING_THREAD_PRIORITIES).getBoolean();
    }
    transMeta.setUsingThreadPriorityManagment(usingThreadPriorityManagement);
    transMeta.setSharedObjectsFile(getString(rootNode, PROP_SHARED_FILE));
    String transTypeCode = getString(rootNode, PROP_TRANSFORMATION_TYPE);
    transMeta.setTransformationType(TransformationType.getTransformationTypeByCode(transTypeCode));

    // Performance monitoring for steps...
    //
    boolean capturingStepPerformanceSnapShots = true;
    if (rootNode.hasProperty(PROP_CAPTURE_STEP_PERFORMANCE)) {
      capturingStepPerformanceSnapShots =
          rootNode.getProperty(PROP_CAPTURE_STEP_PERFORMANCE).getBoolean();
    }
    transMeta.setCapturingStepPerformanceSnapShots(capturingStepPerformanceSnapShots);
    transMeta.setStepPerformanceCapturingDelay(
        getLong(rootNode, PROP_STEP_PERFORMANCE_CAPTURING_DELAY));
    transMeta.setStepPerformanceCapturingSizeLimit(
        getString(rootNode, PROP_STEP_PERFORMANCE_CAPTURING_SIZE_LIMIT));
    transMeta
        .getPerformanceLogTable()
        .setTableName(getString(rootNode, PROP_STEP_PERFORMANCE_LOG_TABLE));
    transMeta.getTransLogTable().setLogSizeLimit(getString(rootNode, PROP_LOG_SIZE_LIMIT));

    // Load the logging tables too..
    //
    RepositoryAttributeInterface attributeInterface =
        new PurRepositoryAttribute(rootNode, transMeta.getDatabases());
    for (LogTableInterface logTable : transMeta.getLogTables()) {
      logTable.loadFromRepository(attributeInterface);
    }

    AttributesMapUtil.loadAttributesMap(rootNode, transMeta);
  }
  public String getXML() {
    StringBuffer retval = new StringBuffer(500);

    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "connection",
                databaseMeta == null
                    ? ""
                    : databaseMeta.getName())); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("cache", cached)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(
            XMLHandler.addTagValue(
                "cache_load_all", loadingAllDataInCache)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("    ")
        .append(XMLHandler.addTagValue("cache_size", cacheSize)); // $NON-NLS-1$ //$NON-NLS-2$
    retval.append("    <lookup>").append(Const.CR); // $NON-NLS-1$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("schema", schemaName)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("table", tablename)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(XMLHandler.addTagValue("orderby", orderByClause)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue(
                "fail_on_multiple", failingOnMultipleResults)); // $NON-NLS-1$ //$NON-NLS-2$
    retval
        .append("      ")
        .append(
            XMLHandler.addTagValue(
                "eat_row_on_failure", eatingRowOnLookupFailure)); // $NON-NLS-1$ //$NON-NLS-2$

    for (int i = 0; i < streamKeyField1.length; i++) {
      retval.append("      <key>").append(Const.CR); // $NON-NLS-1$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("name", streamKeyField1[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("field", tableKeyField[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue("condition", keyCondition[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("name2", streamKeyField2[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval.append("      </key>").append(Const.CR); // $NON-NLS-1$
    }

    for (int i = 0; i < returnValueField.length; i++) {
      retval.append("      <value>").append(Const.CR); // $NON-NLS-1$
      retval
          .append("        ")
          .append(XMLHandler.addTagValue("name", returnValueField[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue("rename", returnValueNewName[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue(
                  "default", returnValueDefault[i])); // $NON-NLS-1$ //$NON-NLS-2$
      retval
          .append("        ")
          .append(
              XMLHandler.addTagValue(
                  "type",
                  ValueMeta.getTypeDesc(returnValueDefaultType[i]))); // $NON-NLS-1$ //$NON-NLS-2$
      retval.append("      </value>").append(Const.CR); // $NON-NLS-1$
    }

    retval.append("    </lookup>").append(Const.CR); // $NON-NLS-1$

    return retval.toString();
  }
  /**
   * Saves the database information into a given repository.
   *
   * @param databaseMeta The database metadata object to store
   * @throws KettleException if an error occurs.
   */
  public void saveDatabaseMeta(DatabaseMeta databaseMeta) throws KettleException {
    try {
      // If we don't have an ID, we don't know which entry in the database we need to update.
      // See if a database with the same name is already available...
      if (databaseMeta.getObjectId() == null) {
        databaseMeta.setObjectId(getDatabaseID(databaseMeta.getName()));
      }

      // Still not found? --> Insert
      if (databaseMeta.getObjectId() == null) {
        // Insert new Note in repository
        //
        databaseMeta.setObjectId(
            insertDatabase(
                databaseMeta.getName(),
                databaseMeta.getPluginId(),
                DatabaseMeta.getAccessTypeDesc(databaseMeta.getAccessType()),
                databaseMeta.getHostname(),
                databaseMeta.getDatabaseName(),
                databaseMeta.getDatabasePortNumberString(),
                databaseMeta.getUsername(),
                databaseMeta.getPassword(),
                databaseMeta.getServername(),
                databaseMeta.getDataTablespace(),
                databaseMeta.getIndexTablespace()));
      } else {
        // --> found entry with the same name...

        // Update the note...
        updateDatabase(
            databaseMeta.getObjectId(),
            databaseMeta.getName(),
            databaseMeta.getPluginId(),
            DatabaseMeta.getAccessTypeDesc(databaseMeta.getAccessType()),
            databaseMeta.getHostname(),
            databaseMeta.getDatabaseName(),
            databaseMeta.getDatabasePortNumberString(),
            databaseMeta.getUsername(),
            databaseMeta.getPassword(),
            databaseMeta.getServername(),
            databaseMeta.getDataTablespace(),
            databaseMeta.getIndexTablespace());
      }

      // For the extra attributes, just delete them and re-add them.
      delDatabaseAttributes(databaseMeta.getObjectId());

      // OK, now get a list of all the attributes set on the database connection...
      //
      Properties attributes = databaseMeta.getAttributes();
      Enumeration<Object> keys = databaseMeta.getAttributes().keys();
      while (keys.hasMoreElements()) {
        String code = (String) keys.nextElement();
        String attribute = (String) attributes.get(code);

        // Save this attribute
        //
        insertDatabaseAttribute(databaseMeta.getObjectId(), code, attribute);
      }
    } catch (KettleDatabaseException dbe) {
      throw new KettleException(
          "Error saving database connection or one of its attributes to the repository.", dbe);
    }
  }
  public String open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();

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

    if (!SAPLibraryTester.isJCoLibAvailable()) {
      int style = SWT.ICON_ERROR;
      MessageBox messageBox = new MessageBox(shell, style);
      messageBox.setMessage(BaseMessages.getString(PKG, "SapInputDialog.JCoLibNotFound"));
      messageBox.open();
      // dispose();
      // return stepname;
    }

    if (!SAPLibraryTester.isJCoImplAvailable()) {
      int style = SWT.ICON_ERROR;
      MessageBox messageBox = new MessageBox(shell, style);
      messageBox.setMessage(BaseMessages.getString(PKG, "SapInputDialog.JCoImplNotFound"));
      messageBox.open();
      // dispose();
      // return stepname;
    }

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

    ModifyListener lsConnectionMod =
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            input.setChanged();
          }
        };
    backupChanged = input.hasChanged();

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

    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "SapInputDialog.shell.Title"));

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

    // Stepname line
    wlStepname = new Label(shell, SWT.RIGHT);
    wlStepname.setText(BaseMessages.getString(PKG, "SapInputDialog.Stepname.Label"));
    props.setLook(wlStepname);
    fdlStepname = new FormData();
    fdlStepname.left = new FormAttachment(0, 0);
    fdlStepname.right = new FormAttachment(middle, -margin);
    fdlStepname.top = new FormAttachment(0, margin);
    wlStepname.setLayoutData(fdlStepname);
    wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    wStepname.setText(stepname);
    props.setLook(wStepname);
    wStepname.addModifyListener(lsMod);
    fdStepname = new FormData();
    fdStepname.left = new FormAttachment(middle, 0);
    fdStepname.top = new FormAttachment(0, margin);
    fdStepname.right = new FormAttachment(100, 0);
    wStepname.setLayoutData(fdStepname);
    Control lastControl = wStepname;

    // Connection line
    //
    wConnection = addConnectionLine(shell, lastControl, middle, margin);
    List<String> items = new ArrayList<String>();
    for (DatabaseMeta dbMeta : transMeta.getDatabases()) {
      if (dbMeta.getDatabaseInterface() instanceof SAPR3DatabaseMeta) {
        items.add(dbMeta.getName());
      }
    }
    wConnection.setItems(items.toArray(new String[items.size()]));
    if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) {
      wConnection.select(0);
    }
    wConnection.addModifyListener(lsConnectionMod);
    lastControl = wConnection;

    // Function
    //
    wlFunction = new Label(shell, SWT.RIGHT);
    wlFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.Function.Label"));
    props.setLook(wlFunction);
    FormData fdlFunction = new FormData();
    fdlFunction.left = new FormAttachment(0, 0);
    fdlFunction.right = new FormAttachment(middle, -margin);
    fdlFunction.top = new FormAttachment(lastControl, margin);
    wlFunction.setLayoutData(fdlFunction);
    wbFunction = new Button(shell, SWT.PUSH);
    props.setLook(wbFunction);

    wbFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.FindFunctionButton.Label"));
    FormData fdbFunction = new FormData();
    fdbFunction.right = new FormAttachment(100, 0);
    fdbFunction.top = new FormAttachment(lastControl, margin);
    wbFunction.setLayoutData(fdbFunction);
    wbFunction.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            getFunction();
          }
        });

    wFunction = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wFunction);
    wFunction.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            function = new SAPFunction(((Text) e.widget).getText());
            input.setChanged();
          }
        });
    FormData fdFunction = new FormData();
    fdFunction.left = new FormAttachment(middle, 0);
    fdFunction.right = new FormAttachment(wbFunction, -margin);
    fdFunction.top = new FormAttachment(lastControl, margin);
    wFunction.setLayoutData(fdFunction);
    lastControl = wFunction;

    // The parameter input fields...
    //
    wlInput = new Label(shell, SWT.NONE);
    wlInput.setText(BaseMessages.getString(PKG, "SapInputDialog.Input.Label"));
    props.setLook(wlInput);
    FormData fdlInput = new FormData();
    fdlInput.left = new FormAttachment(0, 0);
    fdlInput.top = new FormAttachment(lastControl, margin);
    wlInput.setLayoutData(fdlInput);

    ColumnInfo[] ciKey =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.Field"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              new String[] {""},
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              SapType.getDescriptions()),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TableOrStruct"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPParameterName"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TargetType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              ValueMeta.getTypes()),
        };
    inputFieldColumns.add(ciKey[0]);

    wInput =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciKey,
            input.getParameters().size(),
            lsMod,
            props);

    FormData fdInput = new FormData();
    fdInput.left = new FormAttachment(0, 0);
    fdInput.top = new FormAttachment(wlInput, margin);
    fdInput.right = new FormAttachment(100, 0);
    fdInput.bottom = new FormAttachment(40, 0);
    wInput.setLayoutData(fdInput);
    lastControl = wInput;

    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    // wPreview = new Button(shell, SWT.PUSH);
    // wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview"));
    wGet = new Button(shell, SWT.PUSH);
    wGet.setText(BaseMessages.getString(PKG, "SapInputDialog.GetFields.Button"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wAbout = new Button(shell, SWT.PUSH);
    wAbout.setText(BaseMessages.getString(PKG, "SapInputDialog.About.Button"));
    // Preview not possible without inputRowSets in BaseStep.getRow()
    // setButtonPositions(new Button[] { wOK, wPreview, wAbout , wGet, wCancel}, margin, null);
    setButtonPositions(new Button[] {wOK, wAbout, wGet, wCancel}, margin, null);

    // The output fields...
    //
    wlOutput = new Label(shell, SWT.NONE);
    wlOutput.setText(BaseMessages.getString(PKG, "SapInputDialog.Output.Label"));
    props.setLook(wlOutput);
    FormData fdlOutput = new FormData();
    fdlOutput.left = new FormAttachment(0, 0);
    fdlOutput.top = new FormAttachment(wInput, margin);
    wlOutput.setLayoutData(fdlOutput);

    ColumnInfo[] ciReturn =
        new ColumnInfo[] {
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPField"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              new String[] {},
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              SapType.getDescriptions(),
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TableOrStruct"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.NewName"),
              ColumnInfo.COLUMN_TYPE_TEXT,
              false),
          new ColumnInfo(
              BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TargetType"),
              ColumnInfo.COLUMN_TYPE_CCOMBO,
              ValueMeta.getTypes()),
        };
    outputFieldColumns.add(ciReturn[0]);

    wOutput =
        new TableView(
            transMeta,
            shell,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL,
            ciReturn,
            input.getOutputFields().size(),
            lsMod,
            props);

    FormData fdOutput = new FormData();
    fdOutput.left = new FormAttachment(0, 0);
    fdOutput.top = new FormAttachment(wlOutput, margin);
    fdOutput.right = new FormAttachment(100, 0);
    fdOutput.bottom = new FormAttachment(wOK, -8 * margin);
    wOutput.setLayoutData(fdOutput);
    lastControl = wOutput;

    this.wAscLink = new Link(this.shell, SWT.NONE);
    FormData fdAscLink = new FormData();
    fdAscLink.left = new FormAttachment(0, 0);
    fdAscLink.top = new FormAttachment(wOutput, margin);
    wAscLink.setLayoutData(fdAscLink);
    this.wAscLink.setText(BaseMessages.getString(PKG, "SapInputDialog.Provided.Info"));
    lastControl = wAscLink;

    // Add listeners
    lsOK =
        new Listener() {
          public void handleEvent(Event e) {
            ok();
          }
        };
    lsPreview =
        new Listener() {
          public void handleEvent(Event e) {
            preview();
          }
        };
    lsGet =
        new Listener() {
          public void handleEvent(Event e) {
            get();
          }
        };
    lsCancel =
        new Listener() {
          public void handleEvent(Event e) {
            cancel();
          }
        };
    Listener lsAbout =
        new Listener() {
          public void handleEvent(Event e) {
            about();
          }
        };

    wOK.addListener(SWT.Selection, lsOK);
    // wPreview.addListener(SWT.Selection, lsPreview);
    wGet.addListener(SWT.Selection, lsGet);
    wCancel.addListener(SWT.Selection, lsCancel);
    this.wAbout.addListener(SWT.Selection, lsAbout);

    this.wAscLink.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(final Event event) {
            Program.launch(event.text);
          }
        });

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

    wStepname.addSelectionListener(lsDef);
    wFunction.addSelectionListener(lsDef);

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

    getData();

    // Set the shell size, based upon previous time...
    setSize();

    input.setChanged(backupChanged);

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