* {@inheritDoc}
* @see org.formic.wizard.step.GuiStep#init()
*/
public Component init()
{
GuiForm form = createForm();
String files = fieldName("files");
fileChooser = new FileChooser(JFileChooser.DIRECTORIES_ONLY);
// allow just .vim dirs to not be hidden
fileChooser.getFileChooser().setFileHidingEnabled(false);
fileChooser.getFileChooser().addChoosableFileFilter(new FileFilter(){
public boolean accept(java.io.File f) {
String path = f.getAbsolutePath();
return f.isDirectory() && (
path.matches(".*/\\.vim(/.*|$)") ||
!path.matches(".*/\\..*"));
}
public String getDescription() {
return null;
}
});
String skip = fieldName("skip");
skipCheckBox = new JCheckBox(Installer.getString(skip));
skipCheckBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
boolean selected = ((JCheckBox)e.getSource()).isSelected();
JTextField fileField = fileChooser.getTextField();
fileField.setEnabled(!selected);
fileChooser.getButton().setEnabled(!selected);
if (dirList != null){
dirList.setEnabled(!selected);
}
// hacky
Validator validator = (Validator)
fileField.getClientProperty("validator");
setValid(selected || validator.isValid(fileField.getText()));
}
});
panel = new JPanel(new MigLayout(
"wrap 2", "[fill]", "[] [] [] [fill, grow]"));
panel.add(form.createMessagePanel(), "span");
panel.add(new JLabel(Installer.getString(files)), "split");
panel.add(fileChooser, "skip");
panel.add(skipCheckBox, "span");
form.bind(files,
fileChooser.getTextField(),
new ValidatorBuilder()
.required()
.isDirectory()
.fileExists()