diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java index 99be619dcd9..e299d26e4e7 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java @@ -1361,7 +1361,7 @@ private void activateInFindReplaceLogicIf(SearchOptions option, boolean shouldAc private void decorate() { if (fIsRegExCheckBox.getSelection()) { regexOk = SearchDecoration.validateRegex(fFindField.getText(), fFindFieldDecoration); - updateButtonState(regexOk); + updateButtonState(!regexOk); } else { fFindFieldDecoration.hide(); @@ -1406,6 +1406,7 @@ private void assignIDs() { fReplaceSelectionButton.setData(ID_DATA_KEY, "replaceOne"); fReplaceFindButton.setData(ID_DATA_KEY, "replaceFindOne"); fReplaceAllButton.setData(ID_DATA_KEY, "replaceAll"); + fFindNextButton.setData(ID_DATA_KEY, "findNext"); } } diff --git a/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/DialogAccess.java b/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/DialogAccess.java index 4a4a75ed5d5..86b8e767b2a 100644 --- a/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/DialogAccess.java +++ b/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/DialogAccess.java @@ -71,6 +71,8 @@ class DialogAccess implements IFindReplaceUIAccess { private final Button replaceAllButton; + private final Button findNextButton; + DialogAccess(IFindReplaceTarget findReplaceTarget, Dialog findReplaceDialog) { this.findReplaceTarget= findReplaceTarget; this.findReplaceDialog= findReplaceDialog; @@ -89,6 +91,7 @@ class DialogAccess implements IFindReplaceUIAccess { replaceButton= widgetExtractor.findButton("replaceOne"); replaceFindButton= widgetExtractor.findButton("replaceFindOne"); replaceAllButton= widgetExtractor.findButton("replaceAll"); + findNextButton= widgetExtractor.findButton("findNext"); } void restoreInitialConfiguration() { @@ -205,6 +208,10 @@ public String getSelectedFindText() { return findCombo.getText().substring(selection.x, selection.y); } + public Button getReplaceButton() { + return replaceButton; + } + public Combo getFindCombo() { return findCombo; } @@ -219,6 +226,10 @@ public void performReplace() { replaceButton.notifyListeners(SWT.Selection, null); } + public void performFindNext() { + findNextButton.notifyListeners(SWT.Selection, null); + } + @Override public void performReplaceAndFind() { replaceFindButton.notifyListeners(SWT.Selection, null); diff --git a/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java b/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java index e802945dee6..bf832a97c12 100644 --- a/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java +++ b/tests/org.eclipse.ui.workbench.texteditor.tests/src/org/eclipse/ui/workbench/texteditor/tests/FindReplaceDialogTest.java @@ -222,4 +222,17 @@ public void testRegExSearch_nonIncremental() { assertEquals(2, (target.getSelection()).y); } + @Test + public void testReplaceButtonEnabledWithRegexSearched() { + initializeTextViewerWithFindReplaceUI("one two three"); + + DialogAccess dialog= getDialog(); + dialog.setFindText("two"); + dialog.select(SearchOptions.REGEX); + dialog.setReplaceText("two2"); + dialog.performFindNext(); + + assertTrue(dialog.getReplaceButton().isEnabled()); + } + }