Skip to content

Commit b7b90a1

Browse files
committed
Fixing yet another bug with search backwards and the Find and Replace toolbars. Also making 'direction' panel keep its preferred size even with the new 'Wrap' checkbox
1 parent 082fa84 commit b7b90a1

4 files changed

Lines changed: 12 additions & 42 deletions

File tree

RSTAUI/src/main/java/org/fife/rsta/ui/search/FindDialog.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ private void init(SearchListener listener) {
137137
temp = new JPanel(new BorderLayout());
138138
bottomPanel.setBorder(UIUtil.getEmpty5Border());
139139
temp.add(searchConditionsPanel, BorderLayout.LINE_START);
140-
temp.add(dirPanel);
140+
JPanel temp2 = new JPanel(new BorderLayout());
141+
temp2.add(dirPanel, BorderLayout.NORTH);
142+
temp.add(temp2);
141143
bottomPanel.add(temp, BorderLayout.LINE_START);
142144

143145
// Now, make a panel containing all the above stuff.

RSTAUI/src/main/java/org/fife/rsta/ui/search/FindToolBar.java

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ public FindToolBar(SearchListener listener) {
9393

9494
// Keep focus in this component when tabbing through search controls
9595
setFocusCycleRoot(true);
96-
installKeyboardShortcuts();
9796

9897
markAllTimer = new Timer(300, new MarkAllEventNotifier());
9998
markAllTimer.setRepeats(false);
@@ -467,7 +466,7 @@ else if (regexCheckBox.isSelected()) {
467466
* called whenever a new search context is installed on this tool bar
468467
* (which should practically be never).
469468
*/
470-
protected void initUIFromContext() {
469+
private void initUIFromContext() {
471470
if (findCombo==null) { // First time through, stuff not initialized yet
472471
return;
473472
}
@@ -483,40 +482,6 @@ protected void initUIFromContext() {
483482
}
484483

485484

486-
private void installKeyboardShortcuts() {
487-
488-
InputMap im = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
489-
ActionMap am = getActionMap();
490-
491-
KeyStroke ks = KeyStroke.getKeyStroke("ENTER");
492-
im.put(ks, "searchForward");
493-
am.put("searchForward", new AbstractAction() {
494-
@Override
495-
public void actionPerformed(ActionEvent e) {
496-
doSearch(true);
497-
}
498-
});
499-
500-
// Shift+Enter and Ctrl+Enter both do a backwards search
501-
int shift = InputEvent.SHIFT_MASK;
502-
int ctrl = InputEvent.CTRL_MASK;
503-
if (System.getProperty("os.name").toLowerCase().contains("os x")) {
504-
ctrl = InputEvent.META_MASK;
505-
}
506-
ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, shift);
507-
im.put(ks, "searchBackward");
508-
ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, ctrl);
509-
im.put(ks, "searchBackward");
510-
am.put("searchBackward", new AbstractAction() {
511-
@Override
512-
public void actionPerformed(ActionEvent e) {
513-
doSearch(false);
514-
}
515-
});
516-
517-
}
518-
519-
520485
/**
521486
* Makes the Enter key activate the button. In Swing, this is a
522487
* complicated thing. It's LAF-dependent whether or not this works
@@ -745,7 +710,7 @@ else if (SearchContext.PROPERTY_REPLACE_WITH.equals(prop)) {
745710
}
746711
}
747712
else if (SearchContext.PROPERTY_SEARCH_WRAP.equals(prop)) {
748-
boolean newValue = ((Boolean)e.getNewValue()).booleanValue();
713+
boolean newValue = (Boolean)e.getNewValue();
749714
wrapCheckBox.setSelected(newValue);
750715
}
751716

RSTAUI/src/main/java/org/fife/rsta/ui/search/ReplaceDialog.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,10 @@ private void init(SearchListener listener) {
335335
temp = new JPanel(new BorderLayout());
336336
bottomPanel.setBorder(UIUtil.getEmpty5Border());
337337
temp.add(searchConditionsPanel, BorderLayout.LINE_START);
338-
temp.add(dirPanel);
338+
temp.add(searchConditionsPanel, BorderLayout.LINE_START);
339+
temp2 = new JPanel(new BorderLayout());
340+
temp2.add(dirPanel, BorderLayout.NORTH);
341+
temp.add(temp2);
339342
bottomPanel.add(temp, BorderLayout.LINE_START);
340343

341344
// Now, make a panel containing all the above stuff.

RSTAUIDemo/src/main/java/org/fife/rsta/ui/demo/RSTAUIDemoApp.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.fife.rsta.ui.demo;
22

3-
import java.awt.BorderLayout;
3+
import java.awt.*;
44
import java.awt.event.*;
55

66
import javax.swing.*;
@@ -168,13 +168,13 @@ public void searchEvent(SearchEvent e) {
168168
break;
169169
case FIND:
170170
result = SearchEngine.find(textArea, context);
171-
if (!result.wasFound()) {
171+
if (!result.wasFound() || result.isWrapped()) {
172172
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
173173
}
174174
break;
175175
case REPLACE:
176176
result = SearchEngine.replace(textArea, context);
177-
if (!result.wasFound()) {
177+
if (!result.wasFound() || result.isWrapped()) {
178178
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
179179
}
180180
break;

0 commit comments

Comments
 (0)