diff --git a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java index 3fbf95bf8a47..fb4da97d1fc8 100644 --- a/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java +++ b/platform/lvcs-impl/src/com/intellij/history/integration/ui/views/HistoryDialog.java @@ -467,7 +467,7 @@ public abstract class HistoryDialog extends FrameW return; } - CreatePatchConfigurationPanel p = new CreatePatchConfigurationPanel(); + CreatePatchConfigurationPanel p = new CreatePatchConfigurationPanel(myProject); p.setFileName(getDefaultPatchFile()); if (!showAsDialog(p)) return; myModel.createPatch(p.getFileName(), p.isReversePatch()); diff --git a/platform/platform-resources-en/src/messages/VcsBundle.properties b/platform/platform-resources-en/src/messages/VcsBundle.properties index a6d3e11aba3b..b3d2f117db02 100644 --- a/platform/platform-resources-en/src/messages/VcsBundle.properties +++ b/platform/platform-resources-en/src/messages/VcsBundle.properties @@ -548,3 +548,4 @@ line.annotation.aspect.author=Author line.annotation.aspect.date=Date line.annotation.aspect.revision=Revision annotation.commit.number=Commit number +create.patch.file.path=&Patch file: diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java index 42ac02e16028..f72518bf367f 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchCommitExecutor.java @@ -112,7 +112,7 @@ public class CreatePatchCommitExecutor implements CommitExecutorWithHelp, Projec } private class CreatePatchCommitSession implements CommitSession { - private final CreatePatchConfigurationPanel myPanel = new CreatePatchConfigurationPanel(); + private final CreatePatchConfigurationPanel myPanel = new CreatePatchConfigurationPanel(myProject); @Nullable public JComponent getAdditionalConfigurationUI() { diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.form b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.form index 25f224b6e0df..3626819b8639 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.form +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.form @@ -14,7 +14,7 @@ - + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java index c7ed002c3f64..b0fb6d2d886a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/CreatePatchConfigurationPanel.java @@ -22,7 +22,17 @@ */ package com.intellij.openapi.vcs.changes.patch; +import com.intellij.openapi.fileChooser.FileChooser; +import com.intellij.openapi.fileChooser.FileChooserFactory; +import com.intellij.openapi.fileChooser.FileSaverDescriptor; +import com.intellij.openapi.fileChooser.FileSaverDialog; +import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.TextFieldWithBrowseButton; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileWrapper; import com.intellij.util.Consumer; import javax.swing.*; @@ -37,15 +47,22 @@ public class CreatePatchConfigurationPanel { private JLabel myErrorLabel; private Consumer myOkEnabledListener; - public CreatePatchConfigurationPanel() { + public CreatePatchConfigurationPanel(final Project project) { myFileNameField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setSelectedFile(new File(myFileNameField.getText())); - if (fileChooser.showSaveDialog(myFileNameField) != JFileChooser.APPROVE_OPTION) { - return; + final FileSaverDialog dialog = + FileChooserFactory.getInstance().createSaveFileDialog( + new FileSaverDescriptor("Save patch to", ""), myPanel); + final String path = FileUtil.toSystemIndependentName(myFileNameField.getText().trim()); + final int idx = path.lastIndexOf("/"); + VirtualFile baseDir = idx == -1 ? project.getBaseDir() : + (LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path.substring(0, idx)))); + baseDir = baseDir == null ? project.getBaseDir() : baseDir; + final String name = idx == -1 ? path : path.substring(idx + 1); + final VirtualFileWrapper fileWrapper = dialog.save(baseDir, name); + if (fileWrapper != null) { + myFileNameField.setText(fileWrapper.getFile().getPath()); } - myFileNameField.setText(fileChooser.getSelectedFile().getPath()); } }); @@ -53,6 +70,7 @@ public class CreatePatchConfigurationPanel { public void inputMethodTextChanged(final InputMethodEvent event) { checkName(); } + public void caretPositionChanged(final InputMethodEvent event) { } }); @@ -60,9 +78,11 @@ public class CreatePatchConfigurationPanel { public void keyTyped(final KeyEvent e) { checkName(); } + public void keyPressed(final KeyEvent e) { checkName(); } + public void keyReleased(final KeyEvent e) { checkName(); }