package jetbrains.mps.execution.lib.ui;
/*Generated by MPS */
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import com.intellij.openapi.fileChooser.FileChooserDialog;
import com.intellij.openapi.fileChooser.FileChooserFactory;
import com.intellij.openapi.vfs.VirtualFile;
public class FieldWithPathChooseDialog extends TextFieldWithBrowseButton.NoPathCompletion {
private final FileChooserDescriptor myChooser;
public FieldWithPathChooseDialog() {
this(new FileChooserDescriptor(false, true, false, false, false, false));
}
public FieldWithPathChooseDialog(FileChooserDescriptor descriptor) {
this.myChooser = descriptor;
addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent p0) {
FileChooserDialog dialog = FileChooserFactory.getInstance().createFileChooser(FieldWithPathChooseDialog.this.myChooser, null, FieldWithPathChooseDialog.this);
VirtualFile[] selectedFiles = dialog.choose(null);
if (selectedFiles.length > 0 && selectedFiles[0] != null) {
FieldWithPathChooseDialog.this.setText(selectedFiles[0].getPath());
}
}
});
}
public void setEditable(boolean editable) {
super.setEditable(editable);
getButton().setEnabled(editable);
}
public boolean getEditable() {
return isEditable();
}
public void setTitle(String title) {
this.myChooser.setTitle(title);
}
public String getTitle() {
return this.myChooser.getTitle();
}
}