use of com.intellij.openapi.vfs.VirtualFileWrapper in project intellij-community by JetBrains.
the class MacFileSaverDialog method save.
@Nullable
@Override
public VirtualFileWrapper save(@Nullable VirtualFile baseDir, @Nullable String filename) {
myFileDialog.setDirectory(baseDir == null ? null : baseDir.getCanonicalPath());
myFileDialog.setFile(filename);
myFileDialog.setFilenameFilter((dir, name) -> {
File file = new File(dir, name);
return myDescriptor.isFileSelectable(fileToVirtualFile(file));
});
myFileDialog.setVisible(true);
String file = myFileDialog.getFile();
if (file == null) {
return null;
}
return new VirtualFileWrapper(new File(myFileDialog.getDirectory() + File.separator + file));
}
use of com.intellij.openapi.vfs.VirtualFileWrapper in project intellij-community by JetBrains.
the class FileSaverDialogImpl method save.
@Override
@Nullable
public VirtualFileWrapper save(@Nullable VirtualFile baseDir, @Nullable final String filename) {
init();
restoreSelection(baseDir);
myFileSystemTree.addListener(new FileSystemTree.Listener() {
@Override
public void selectionChanged(final List<VirtualFile> selection) {
updateFileName(selection);
updateOkButton();
}
}, myDisposable);
if (filename != null) {
myFileName.setText(filename);
}
show();
if (getExitCode() == OK_EXIT_CODE) {
final File file = getFile();
return file == null ? null : new VirtualFileWrapper(file);
}
return null;
}
use of com.intellij.openapi.vfs.VirtualFileWrapper in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method saveAsSelectedFile.
private void saveAsSelectedFile() {
BlobFile fileSelection = getFileSelection();
assert fileSelection != null;
FileSaverDescriptor fileDescriptor = new FileSaverDescriptor(SAVE_AS, "Select location to save blob file.");
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(fileDescriptor, this.project);
final VirtualFileWrapper save = dialog.save(LocalFileSystem.getInstance().findFileByPath(System.getProperty("user.home")), "");
if (save != null) {
downloadSelectedFile(save.getFile(), false);
}
}
use of com.intellij.openapi.vfs.VirtualFileWrapper in project azure-tools-for-java by Microsoft.
the class NewCertificateDialog method getFileSaverListener.
private ActionListener getFileSaverListener(final TextFieldWithBrowseButton field, final TextFieldWithBrowseButton fieldToUpdate, final String suffixToReplace, final String suffix) {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor(message("newCertDlgBrwFldr"), "", suffixToReplace), field);
final VirtualFile baseDir = myProject.getBaseDir();
final VirtualFileWrapper save = dialog.save(baseDir, "");
if (save != null) {
field.setText(FileUtil.toSystemDependentName(save.getFile().getAbsolutePath()));
if (fieldToUpdate.getText().isEmpty()) {
fieldToUpdate.setText(Utils.replaceLastSubString(field.getText(), suffixToReplace, suffix));
}
}
}
};
}
Aggregations