示例#1
0
    @Override
    public String toString(Account t) {
      if (null == t) {
        return null;
      }

      return (usefull ? GuiUtils.getFullName(t, amap) : t.getName());
    }
示例#2
0
  @Override
  public TableCell<T, Account> call(TableColumn<T, Account> p) {
    List<Account> accounts = new ArrayList<>();
    final Map<String, Account> acctmap = new HashMap<>();
    try {
      accounts.addAll(amap.getAll());
      for (Account a : accounts) {
        acctmap.put(usefull ? GuiUtils.getFullName(a, amap) : a.getName(), a);
      }
    } catch (MapperException me) {
      log.error(me, me);
    }

    Collections.sort(
        accounts,
        new Comparator<Account>() {

          @Override
          public int compare(Account o1, Account o2) {
            return Collator.getInstance()
                .compare(GuiUtils.getFullName(o1, amap), GuiUtils.getFullName(o2, amap));
          }
        });

    AccountStringConverter asc = new AccountStringConverter(acctmap);
    ObservableList<Account> obsl = FXCollections.observableArrayList(accounts);
    ComboBoxTableCell<T, Account> cell =
        new ComboBoxTableCell<T, Account>(asc, obsl) {
          @Override
          public void updateItem(Account acct, boolean empty) {
            super.updateItem(acct, empty);
            if (null == acct || empty) {
              setText(null);
            } else {
              setText(usefull ? GuiUtils.getFullName(acct, amap) : acct.getName());
            }
          }
        };

    cell.setComboBoxEditable(false);
    return cell;
  }