use of com.intellij.openapi.fileChooser.FileSaverDialog 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());
}
Aggregations