private static FindModel createDefaultFindModel(Project project, Editor editor) { FindModel findModel = new FindModel(); findModel.copyFrom(FindManager.getInstance(project).getFindInFileModel()); if (editor.getSelectionModel().hasSelection()) { String selectedText = editor.getSelectionModel().getSelectedText(); if (selectedText != null) { findModel.setStringToFind(selectedText); } } findModel.setPromptOnReplace(false); return findModel; }
private void searchFieldDocumentChanged() { setMatchesLimit(LivePreviewController.MATCHES_LIMIT); String text = mySearchTextComponent.getText(); myFindModel.setStringToFind(text); if (!StringUtil.isEmpty(text)) { updateResults(true); } else { nothingToSearchFor(); } if (mySearchTextComponent instanceof JTextArea) { adjustRows((JTextArea) mySearchTextComponent); } updateMultiLineStateIfNeed(); }
public void setTextInField(final String text) { mySearchTextComponent.setText(text); myFindModel.setStringToFind(text); }