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

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

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

      TableItem tableItem = new TableItem(wParams.table, SWT.NONE);
      tableItem.setText(1, paramName);
      tableItem.setText(2, Const.NVL(defaultValue, ""));
      tableItem.setText(3, Const.NVL(paramValue, ""));
      tableItem.setText(4, Const.NVL(description, ""));
    }
    wParams.removeEmptyRows();
    wParams.setRowNums();
    wParams.optWidth(true);
  }
  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 ConfigurationDialog(
      Shell parent, ExecutionConfiguration configuration, AbstractMeta meta) {
    super(parent);
    this.parent = parent;
    this.configuration = configuration;
    this.abstractMeta = meta;
    initCheckboxFlag();

    // Fill the parameters, maybe do this in another place?
    Map<String, String> params = configuration.getParams();
    params.clear();
    String[] paramNames = meta.listParameters();
    for (String name : paramNames) {
      params.put(name, "");
    }

    props = PropsUI.getInstance();
  }
  protected void buttonsSectionLayout(
      Class<?> PKG,
      String prefix,
      final String docTitle,
      final String docUrl,
      final String docHeader) {

    // Bottom buttons and separator

    Button alwaysShowOption = new Button(shell, SWT.CHECK);
    props.setLook(alwaysShowOption);
    fd_tabFolder.bottom = new FormAttachment(100, -106);
    alwaysShowOption.setSelection(abstractMeta.isAlwaysShowRunOptions());

    alwaysShowOption.setToolTipText(BaseMessages.getString(PKG, prefix + ".alwaysShowOption"));

    alwaysShowOption.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Button btn = (Button) e.getSource();
            alwaysShowRunOptions = btn.getSelection();
          }
        });

    FormData fd_alwaysShowOption = new FormData();
    fd_alwaysShowOption.left = new FormAttachment(0, 15);
    fd_alwaysShowOption.top = new FormAttachment(tabFolder, 15);
    alwaysShowOption.setLayoutData(fd_alwaysShowOption);
    alwaysShowOption.setText(BaseMessages.getString(PKG, prefix + ".AlwaysOption.Value"));

    wCancel = new Button(shell, SWT.PUSH);
    FormData fd_wCancel = new FormData();
    wCancel.setLayoutData(fd_wCancel);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    wCancel.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            cancel();
          }
        });

    wOK = new Button(shell, SWT.PUSH);
    FormData fd_wOK = new FormData();
    fd_wOK.top = new FormAttachment(wCancel, 0, SWT.TOP);
    fd_wOK.right = new FormAttachment(wCancel, -5);
    wOK.setLayoutData(fd_wOK);
    wOK.setText(BaseMessages.getString(PKG, prefix + ".Button.Launch"));
    wOK.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            ok();
          }
        });

    Button btnHelp = new Button(shell, SWT.NONE);
    btnHelp.setImage(GUIResource.getInstance().getImageHelpWeb());
    btnHelp.setText(BaseMessages.getString(PKG, "System.Button.Help"));
    btnHelp.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.Help"));
    FormData fd_btnHelp = new FormData();
    fd_btnHelp.left = new FormAttachment(0, 15);
    btnHelp.setLayoutData(fd_btnHelp);
    btnHelp.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent evt) {
            HelpUtils.openHelpDialog(parent.getShell(), docTitle, docUrl, docHeader);
          }
        });

    Label separator = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL);
    fd_wCancel.top = new FormAttachment(separator, 15);
    fd_btnHelp.top = new FormAttachment(separator, 15);
    fd_wCancel.right = new FormAttachment(separator, 0, SWT.RIGHT);
    FormData fd_separator = new FormData();
    fd_separator.right = new FormAttachment(100, -15);
    fd_separator.left = new FormAttachment(0, 15);
    fd_separator.top = new FormAttachment(alwaysShowOption, 15);
    fd_separator.bottom = new FormAttachment(alwaysShowOption, 17, SWT.BOTTOM);
    separator.setLayoutData(fd_separator);
  }
  protected void parametersSectionLayout(Class<?> PKG, String prefix) {

    tabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(tabFolder, Props.WIDGET_STYLE_TAB);
    fdDetails.bottom = new FormAttachment(tabFolder, -16);
    fd_tabFolder = new FormData();
    fd_tabFolder.right = new FormAttachment(100, -15);
    fd_tabFolder.left = new FormAttachment(0, 15);
    fd_tabFolder.top = new FormAttachment(0, 276);
    tabFolder.setLayoutData(fd_tabFolder);

    // Parameters
    CTabItem tbtmParameters = new CTabItem(tabFolder, SWT.NONE);
    tbtmParameters.setText(BaseMessages.getString(PKG, prefix + ".Params.Label"));
    Composite parametersComposite = new Composite(tabFolder, SWT.NONE);
    props.setLook(parametersComposite);

    parametersComposite.setLayout(new FormLayout());
    tbtmParameters.setControl(parametersComposite);

    ColumnInfo[] cParams = {
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Argument"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          126), // Stepname
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Default"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          138), // Preview size
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Value"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          142), // Preview size
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".ParamsColumn.Description"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          true,
          181), // Preview size
    };

    String[] namedParams = abstractMeta.listParameters();
    int nrParams = namedParams.length;
    wParams =
        new TableView(
            abstractMeta,
            parametersComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            cParams,
            nrParams,
            false,
            null,
            props,
            false);
    FormData fdParams = new FormData();
    fdParams.top = new FormAttachment(0, 10);
    fdParams.left = new FormAttachment(0, 10);
    wParams.setLayoutData(fdParams);

    tabFolder.setSelection(0);

    Button argsButton = new Button(parametersComposite, SWT.NONE);
    fdParams.right = new FormAttachment(argsButton, 0, SWT.RIGHT);
    fdParams.bottom = new FormAttachment(argsButton, -6);
    FormData fd_argsButton = new FormData();
    fd_argsButton.right = new FormAttachment(100, -10);
    fd_argsButton.bottom = new FormAttachment(100, -10);
    argsButton.setLayoutData(fd_argsButton);
    argsButton.setText(BaseMessages.getString(PKG, prefix + ".Arguments.Label"));

    argsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            new ArgumentsDialog(shell, configuration, abstractMeta);
          }
        });

    // Variables
    CTabItem tbtmVariables = new CTabItem(tabFolder, SWT.NONE);
    tbtmVariables.setText(BaseMessages.getString(PKG, prefix + ".Variables.Label"));

    Composite variablesComposite = new Composite(tabFolder, SWT.NONE);
    props.setLook(variablesComposite);
    variablesComposite.setLayout(new FormLayout());
    tbtmVariables.setControl(variablesComposite);

    ColumnInfo[] cVariables = {
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".VariablesColumn.Argument"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          287), // Stepname
      new ColumnInfo(
          BaseMessages.getString(PKG, prefix + ".VariablesColumn.Value"),
          ColumnInfo.COLUMN_TYPE_TEXT,
          false,
          false,
          300), // Preview size
    };

    int nrVariables =
        configuration.getVariables() != null ? configuration.getVariables().size() : 0;
    wVariables =
        new TableView(
            abstractMeta,
            variablesComposite,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
            cVariables,
            nrVariables,
            false,
            null,
            props,
            false);

    FormData fdVariables = new FormData();
    fdVariables.top = new FormAttachment(0, 10);
    fdVariables.left = new FormAttachment(0, 10);
    fdVariables.bottom = new FormAttachment(0, 221);
    fdVariables.right = new FormAttachment(100, -10);

    wVariables.setLayoutData(fdVariables);
  }
 private void setCheckboxFlag() {
   abstractMeta.setAlwaysShowRunOptions(alwaysShowRunOptions);
   abstractMeta.setShowDialog(alwaysShowRunOptions);
 }
 private void initCheckboxFlag() {
   alwaysShowRunOptions = abstractMeta.isAlwaysShowRunOptions();
 }