// Listen to the Variable... button
  public static final String getVariableName(Shell shell, VariableSpace space) {
    String keys[] = space.listVariables();
    Arrays.sort(keys);

    int size = keys.length;
    String key[] = new String[size];
    String val[] = new String[size];
    String str[] = new String[size];

    for (int i = 0; i < keys.length; i++) {
      key[i] = keys[i];
      val[i] = space.getVariable(key[i]);
      str[i] = key[i] + "  [" + val[i] + "]";
    }

    EnterSelectionDialog esd =
        new EnterSelectionDialog(
            shell,
            str,
            Messages.getString("System.Dialog.SelectEnvironmentVar.Title"),
            Messages.getString("System.Dialog.SelectEnvironmentVar.Message"));
    esd.clearModal();
    if (esd.open() != null) {
      int nr = esd.getSelectionNr();
      String var = key[nr];

      return var;
    } else {
      return null;
    }
  }
  public void setVariables(VariableSpace space) {
    this.variables = new HashMap<String, String>();

    for (String name : space.listVariables()) {
      String value = space.getVariable(name);
      this.variables.put(name, value);
    }
  }
  public void getUsedVariables(JobMeta jobMeta) {
    Properties sp = new Properties();
    VariableSpace space = Variables.getADefaultVariableSpace();

    String[] keys = space.listVariables();
    for (int i = 0; i < keys.length; i++) {
      sp.put(keys[i], space.getVariable(keys[i]));
    }

    List<String> vars = jobMeta.getUsedVariables();
    if (vars != null && vars.size() > 0) {
      HashMap<String, String> newVariables = new HashMap<String, String>();

      for (int i = 0; i < vars.size(); i++) {
        String varname = vars.get(i);
        if (!varname.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
          newVariables.put(varname, Const.NVL(variables.get(varname), sp.getProperty(varname, "")));
        }
      }
      // variables.clear();
      variables.putAll(newVariables);
    }
  }
Exemplo n.º 4
0
 public String[] listVariables() {
   return variables.listVariables();
 }