mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-94641 Save Project As Template: impossible to overwrite the existing template
This commit is contained in:
@@ -21,7 +21,9 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.ValidationInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -113,8 +115,22 @@ public class SaveProjectAsTemplateDialog extends DialogWrapper {
|
||||
if (StringUtil.isEmpty(myName.getText())) {
|
||||
return new ValidationInfo("Template name should not be empty");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOKAction() {
|
||||
File file = getTemplateFile();
|
||||
return file.exists() ? new ValidationInfo("Template already exists") : null;
|
||||
if (file.exists()) {
|
||||
if (Messages.showYesNoDialog(myPanel,
|
||||
FileUtil.getNameWithoutExtension(file) + " exists already.\n" +
|
||||
"Do you want to replace it with the new one?", "Template Already Exists",
|
||||
Messages.getWarningIcon()) == Messages.NO) {
|
||||
return;
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
super.doOKAction();
|
||||
}
|
||||
|
||||
File getTemplateFile() {
|
||||
|
||||
Reference in New Issue
Block a user