add confirmation dialog in File Saver
authorKonstantin Bulenkov <kb@jetbrains.com>
Fri, 12 Mar 2010 11:50:05 +0000 (14:50 +0300)
committerKonstantin Bulenkov <kb@jetbrains.com>
Fri, 12 Mar 2010 11:50:05 +0000 (14:50 +0300)
platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileSaverDialogImpl.java
platform/platform-resources-en/src/messages/UIBundle.properties

index 7bd17500ab7e56f3493c47d85519b5cf721b05b1..c6a3ba1906483b336c61bde1d01548e0f577f766 100644 (file)
  */
 package com.intellij.openapi.fileChooser.ex;
 
-import com.intellij.openapi.fileChooser.FileSystemTree;
 import com.intellij.openapi.fileChooser.FileSaverDescriptor;
 import com.intellij.openapi.fileChooser.FileSaverDialog;
+import com.intellij.openapi.fileChooser.FileSystemTree;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.vfs.VirtualFileWrapper;
 import com.intellij.ui.DocumentAdapter;
@@ -160,4 +161,18 @@ public class FileSaverDialogImpl extends FileChooserDialogImpl implements FileSa
     //double check. FileChooserFactoryImpl sets enable ok button 
     super.setOKActionEnabled(isFileNameExist());
   }
+
+  @Override
+  protected void doOKAction() {
+    final File file = getFile();
+    if (file != null && file.exists()) {
+      if (OK_EXIT_CODE != Messages.showYesNoDialog(this.getRootPane(),
+                                                  UIBundle.message("file.chooser.save.dialog.confirmation", file.getName()),
+                                                  UIBundle.message("file.chooser.save.dialog.confirmation.title"),
+                                                  Messages.getWarningIcon())) {
+        return;
+      }
+    }
+    super.doOKAction();
+  }
 }
index 6fcceb24c51813d6f782b7f09b4a93b44cb86fdf..8c4ebe8683aa9ad93b548167a16975f8f15811b3 100644 (file)
@@ -98,6 +98,8 @@ welcome.script.text.not.specified.message=Not specified
 
 file.chooser.default.title=Select Path
 file.chooser.save.dialog.default.title=Select File to Save
+file.chooser.save.dialog.confirmation={0} is already exists.\nDo you want to replace it?
+file.chooser.save.dialog.confirmation.title=Confirm Save as
 file.chooser.select.object.title=Select {0}
 delete.dialog.title=Delete
 file.chooser.could.not.erase.file.or.folder.error.messabe=Could not erase file or folder: {0}