private void initLivePreview() { myLivePreviewController.on(); myLivePreviewController.setUserActivityDelay(0); updateResults(false); myLivePreviewController.setUserActivityDelay( LivePreviewController.USER_ACTIVITY_TRIGGERING_DELAY); mySearchResults.addListener(this); }
private void updateResults(final boolean allowedToChangedEditorSelection) { final String text = myFindModel.getStringToFind(); if (text.length() == 0) { nothingToSearchFor(); } else { if (myFindModel.isRegularExpressions()) { try { Pattern.compile(text); } catch (Exception e) { setNotFoundBackground(); myClickToHighlightLabel.setVisible(false); mySearchResults.clear(); myMatchInfoLabel.setText("Incorrect regular expression"); return; } } final FindManager findManager = FindManager.getInstance(myProject); if (allowedToChangedEditorSelection) { findManager.setFindWasPerformed(); FindModel copy = new FindModel(); copy.copyFrom(myFindModel); copy.setReplaceState(false); findManager.setFindNextModel(copy); } if (myLivePreviewController != null) { myLivePreviewController.updateInBackground(myFindModel, allowedToChangedEditorSelection); } } }
private void updateUIWithFindModel() { boolean needToResetSearchFocus = mySearchTextComponent.hasFocus(); boolean needToResetReplaceFocus = myReplaceTextComponent.hasFocus(); updateSearchComponent(); updateReplaceComponent(); if (myFindModel.isReplaceState()) { if (myReplaceFieldWrapper.getParent() == null) { myLeftPanel.add(myReplaceFieldWrapper, BorderLayout.CENTER); } if (myReplaceToolbarWrapper.getParent() == null) { myRightPanel.add(myReplaceToolbarWrapper, BorderLayout.CENTER); } if (needToResetReplaceFocus) { myReplaceTextComponent.requestFocusInWindow(); } } else { if (myReplaceFieldWrapper.getParent() != null) { myLeftPanel.remove(myReplaceFieldWrapper); } if (myReplaceToolbarWrapper.getParent() != null) { myRightPanel.remove(myReplaceToolbarWrapper); } } if (needToResetSearchFocus) mySearchTextComponent.requestFocusInWindow(); mySearchActionsToolbar1.updateActionsImmediately(); mySearchActionsToolbar2.updateActionsImmediately(); myReplaceActionsToolbar1.updateActionsImmediately(); myReplaceActionsToolbar2.updateActionsImmediately(); myReplaceToolbarWrapper.revalidate(); revalidate(); repaint(); myLivePreviewController.setTrackingSelection(!myFindModel.isGlobal()); }
@Override public void removeNotify() { super.removeNotify(); myLivePreviewController.off(); mySearchResults.removeListener(this); addTextToRecent(mySearchTextComponent); if (myReplaceTextComponent != null) { addTextToRecent(myReplaceTextComponent); } }
public void close() { IdeFocusManager.getInstance(myProject).requestFocus(myEditor.getContentComponent(), false); myLivePreviewController.dispose(); myEditor.setHeaderComponent(null); }
private void moveCursor(SearchResults.Direction direction) { myLivePreviewController.moveCursor(direction); }
public void replaceCurrent() { if (mySearchResults.getCursor() != null) { myLivePreviewController.performReplace(); } }
private boolean canReplaceCurrent() { return myLivePreviewController != null && myLivePreviewController.canReplace(); }