use of com.intellij.openapi.fileChooser.FileSaverDescriptor in project android by JetBrains.
the class SaveFileListener method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
String path = myTextField.getText().trim();
if (path.length() == 0) {
String defaultLocation = getDefaultLocation();
path = defaultLocation != null && defaultLocation.length() > 0 ? defaultLocation : SystemProperties.getUserHome();
}
File file = new File(path);
if (!file.exists()) {
path = SystemProperties.getUserHome();
}
FileSaverDescriptor descriptor = new FileSaverDescriptor(myDialogTitle, "Save as *." + myExtension, myExtension);
FileSaverDialog saveFileDialog = FileChooserFactory.getInstance().createSaveFileDialog(descriptor, myContentPanel);
VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(file.exists() ? file : new File(path));
if (vf == null) {
vf = VfsUtil.getUserHomeDir();
}
VirtualFileWrapper result = saveFileDialog.save(vf, null);
if (result == null || result.getFile() == null) {
return;
}
myTextField.setText(result.getFile().getPath());
}
use of com.intellij.openapi.fileChooser.FileSaverDescriptor 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.fileChooser.FileSaverDescriptor 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