IDEA-135089 Search and replace multiline text allows to input only three lines

This commit is contained in:
Vassiliy.Kudryashov
2015-01-14 16:30:52 +03:00
parent ba2dc0e0db
commit 2806b9890b
2 changed files with 18 additions and 3 deletions
@@ -450,6 +450,9 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
else {
nothingToSearchFor();
}
if (mySearchField instanceof JTextArea) {
UIUtil.adjustRows((JTextArea)mySearchField, 2, 6);
}
}
public boolean isRegexp() {
@@ -637,6 +640,9 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
private void replaceFieldDocumentChanged() {
setMatchesLimit(LivePreviewController.MATCHES_LIMIT);
myFindModel.setStringToReplace(myReplaceField.getText());
if (myReplaceField instanceof JTextArea) {
UIUtil.adjustRows((JTextArea)myReplaceField, 2, 6);
}
}
private boolean canReplaceCurrent() {
@@ -697,12 +703,17 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
super.paintBorder(g);
paintBorderOfTextField(g);
}
@Override
public Dimension getPreferredSize() {
return super.getPreferredSize();
}
};
((JTextArea)editorTextField).setColumns(25);
((JTextArea)editorTextField).setRows(3);
((JTextArea)editorTextField).setRows(2);
final JScrollPane scrollPane = new JBScrollPane(editorTextField,
ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
myLeftComponent.add(scrollPane, constraint);
componentRef.set(scrollPane);
}
@@ -3215,6 +3215,10 @@ public class UIUtil {
textComponent.getActionMap().put("redoKeystroke", REDO_ACTION);
}
public static void adjustRows(JTextArea area, int minRows, int maxRows) {
area.setRows(Math.max(minRows, Math.min(maxRows, area.getText().split("\n").length)));
}
public static void playSoundFromResource(final String resourceName) {
final Class callerClass = ReflectionUtil.getGrandCallerClass();
if (callerClass == null) return;