void (@Nullable Callable<? extends DiffElement<?>> chooser, boolean isTarget) { @NotNull TextFieldWithBrowseButton dirField = isTarget ? myTargetDirField : mySourceDirField; dirField.setEditable(false); if (chooser != null && myModel.getSettings().enableChoosers) { dirField.setButtonEnabled(true); dirField.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { final DiffElement<?> newElement = chooser.call(); if (newElement == null) return; if (StringUtil.equals(dirField.getText(), newElement.getPath())) return; dirField.setText(newElement.getPath()); if (isTarget) { myModel.setTargetDir(newElement); } else { myModel.setSourceDir(newElement); } myModel.clear(); myModel.reloadModel(true); myModel.updateFromUI(); } catch (Exception err) { LOG.warn(err); } } }); } else { Dimension preferredSize = dirField.getPreferredSize(); dirField.setButtonEnabled(false); dirField.getButton().setVisible(false); dirField.setPreferredSize(preferredSize); } }