diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java index 0f7e7ae14dc1..19f65c5202a3 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/surroundWith/JavaWithRunnableSurrounder.java @@ -74,6 +74,11 @@ public class JavaWithRunnableSurrounder extends JavaStatementsSurrounder{ editor.getCaretModel().moveToOffset(textOffset); editor.getSelectionModel().removeSelection(); new VariableInplaceRenamer(variable, editor){ + @Override + protected boolean shouldSelectAll() { + return true; + } + @Override protected void moveOffsetAfter(boolean success) { super.moveOffsetAfter(success); diff --git a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java index c57894747d03..c2a2981a89aa 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/introduce/inplace/InplaceVariableIntroducer.java @@ -80,6 +80,11 @@ public class InplaceVariableIntroducer extends VariableInp initOccurrencesMarkers(); } + @Override + protected boolean shouldSelectAll() { + return true; + } + @Override protected StartMarkAction startRename() throws StartMarkAction.AlreadyStartedException { return null; diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java index 9da647f7a4f4..07ecad7713a7 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameDialog.java @@ -115,7 +115,12 @@ public class RenameDialog extends RefactoringDialog { private void createNewNameComponent() { String[] suggestedNames = getSuggestedNames(); - myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor); + myNameSuggestionsField = new NameSuggestionsField(suggestedNames, myProject, FileTypes.PLAIN_TEXT, myEditor) { + @Override + protected boolean shouldSelectAll() { + return false; + } + }; if (myPsiElement instanceof PsiFile && myEditor == null) { myNameSuggestionsField.selectNameWithoutExtension(); } diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java index 15c1267fd004..fc32f5e340b4 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java @@ -404,6 +404,8 @@ public class VariableInplaceRenamer { myEditor.getCaretModel().moveToOffset(rangeMarker.isValid() ? rangeMarker.getStartOffset() : offset); if (selectedRange != null){ myEditor.getSelectionModel().setSelection(selectedRange.getStartOffset(), selectedRange.getEndOffset()); + } else if (!shouldSelectAll()){ + myEditor.getSelectionModel().removeSelection(); } } }; @@ -444,6 +446,10 @@ public class VariableInplaceRenamer { return true; } + protected boolean shouldSelectAll() { + return false; + } + protected void navigateToAlreadyStarted(Document oldDocument, int exitCode) { final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(oldDocument); if (file != null) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java index ccdf4202f269..fda256aca006 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java +++ b/platform/lang-impl/src/com/intellij/refactoring/ui/NameSuggestionsField.java @@ -36,7 +36,8 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.EventListenerList; import java.awt.*; -import java.awt.event.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.EventListener; import java.util.List; @@ -104,7 +105,7 @@ public class NameSuggestionsField extends JPanel { if (selectionModel.hasSelection() && selected != null && !selected.isEmpty()) { myEditor.getSelectionModel().setSelection(selected.getStartOffset(), selected.getEndOffset()); } - else { + else if (shouldSelectAll()) { myEditor.getSelectionModel().setSelection(0, myEditor.getDocument().getTextLength()); } break; @@ -113,6 +114,10 @@ public class NameSuggestionsField extends JPanel { }); } + protected boolean shouldSelectAll() { + return true; + } + public void selectNameWithoutExtension() { SwingUtilities.invokeLater(new Runnable() { public void run() {