private void updateSelection(JTree tree) {
    int selection = tree.getSelectionCount() == 1 ? tree.getSelectionModel().getLeadSelectionRow() : -1;
    handleSelectionChange(selection == -1 ? null : selection);
  }
private void updateSelection(JTree tree)