|
@@ -24,25 +24,22 @@ package com.dmdirc.addons.ui_swing.components;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.addons.ui_swing.UIUtilities;
|
26
|
26
|
import com.dmdirc.addons.ui_swing.actions.SearchAction;
|
27
|
|
-import com.dmdirc.addons.ui_swing.components.ImageButton;
|
28
|
27
|
import com.dmdirc.addons.ui_swing.components.frames.InputTextFrame;
|
29
|
28
|
import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
|
30
|
29
|
import com.dmdirc.addons.ui_swing.components.validating.ValidatingJTextField;
|
31
|
|
-import com.dmdirc.addons.ui_swing.dialogs.StandardQuestionDialog;
|
32
|
30
|
import com.dmdirc.addons.ui_swing.textpane.TextPane;
|
33
|
31
|
import com.dmdirc.config.IdentityManager;
|
34
|
|
-import com.dmdirc.util.validators.ValidationResponse;
|
35
|
|
-import com.dmdirc.util.validators.Validator;
|
36
|
32
|
import com.dmdirc.interfaces.ConfigChangeListener;
|
37
|
33
|
import com.dmdirc.ui.IconManager;
|
38
|
34
|
import com.dmdirc.ui.interfaces.SearchBar;
|
|
35
|
+import com.dmdirc.ui.interfaces.SearchBar.Direction;
|
39
|
36
|
import com.dmdirc.ui.messages.IRCDocument;
|
40
|
37
|
import com.dmdirc.ui.messages.IRCDocumentSearcher;
|
41
|
38
|
import com.dmdirc.ui.messages.LinePosition;
|
42
|
39
|
import com.dmdirc.util.ListenerList;
|
|
40
|
+import com.dmdirc.util.validators.ValidationResponse;
|
|
41
|
+import com.dmdirc.util.validators.Validator;
|
43
|
42
|
|
44
|
|
-import java.awt.Window;
|
45
|
|
-import java.awt.Dialog.ModalityType;
|
46
|
43
|
import java.awt.event.ActionEvent;
|
47
|
44
|
import java.awt.event.ActionListener;
|
48
|
45
|
import java.awt.event.KeyEvent;
|
|
@@ -51,6 +48,7 @@ import java.awt.event.KeyListener;
|
51
|
48
|
import javax.swing.JButton;
|
52
|
49
|
import javax.swing.JCheckBox;
|
53
|
50
|
import javax.swing.JComponent;
|
|
51
|
+import javax.swing.JLabel;
|
54
|
52
|
import javax.swing.JPanel;
|
55
|
53
|
import javax.swing.JTextField;
|
56
|
54
|
import javax.swing.KeyStroke;
|
|
@@ -88,24 +86,22 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
|
88
|
86
|
private int line;
|
89
|
87
|
/** Listener list. */
|
90
|
88
|
private final ListenerList listeners;
|
91
|
|
- /** Parent window. */
|
92
|
|
- private Window parentWindow;
|
93
|
89
|
/** Search validate text. */
|
94
|
90
|
private SearchValidator validator;
|
|
91
|
+ /** Wrap indicator. */
|
|
92
|
+ private JLabel wrapIndicator;
|
95
|
93
|
|
96
|
94
|
/**
|
97
|
95
|
* Creates a new instance of StatusBar.
|
98
|
96
|
*
|
99
|
97
|
* @param newParent parent frame for the dialog
|
100
|
|
- * @param parentWindow Parent window
|
101
|
98
|
*/
|
102
|
|
- public SwingSearchBar(final TextFrame newParent, final Window parentWindow) {
|
|
99
|
+ public SwingSearchBar(final TextFrame newParent) {
|
103
|
100
|
super();
|
104
|
101
|
|
105
|
102
|
listeners = new ListenerList();
|
106
|
103
|
|
107
|
104
|
this.parent = newParent;
|
108
|
|
- this.parentWindow = parentWindow;
|
109
|
105
|
|
110
|
106
|
getInputMap(JComponent.WHEN_FOCUSED).
|
111
|
107
|
put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), "searchAction");
|
|
@@ -127,12 +123,16 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
|
127
|
123
|
caseCheck = new JCheckBox();
|
128
|
124
|
validator = new SearchValidator();
|
129
|
125
|
searchBox = new ValidatingJTextField(validator);
|
|
126
|
+ wrapIndicator = new JLabel("Search wrapped",
|
|
127
|
+ IconManager.getIconManager().getIcon("linewrap"),
|
|
128
|
+ JLabel.LEFT);
|
130
|
129
|
|
131
|
130
|
nextButton.setText("Later");
|
132
|
131
|
prevButton.setText("Earlier");
|
133
|
132
|
nextButton.setEnabled(false);
|
134
|
133
|
prevButton.setEnabled(false);
|
135
|
134
|
caseCheck.setText("Case sensitive");
|
|
135
|
+ wrapIndicator.setVisible(false);
|
136
|
136
|
|
137
|
137
|
line = -1;
|
138
|
138
|
|
|
@@ -141,13 +141,14 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
|
141
|
141
|
|
142
|
142
|
/** Lays out components. */
|
143
|
143
|
private void layoutComponents() {
|
144
|
|
- this.setLayout(new MigLayout("ins 0, fill"));
|
|
144
|
+ this.setLayout(new MigLayout("ins 0, fill, hidemode 3"));
|
145
|
145
|
|
146
|
146
|
add(closeButton);
|
147
|
147
|
add(searchBox, "growx, pushx, sgy all");
|
148
|
148
|
add(prevButton, "sgx button, sgy all");
|
149
|
149
|
add(nextButton, "sgx button, sgy all");
|
150
|
150
|
add(caseCheck, "sgy all");
|
|
151
|
+ add(wrapIndicator, "");
|
151
|
152
|
}
|
152
|
153
|
|
153
|
154
|
/** Adds listeners to components. */
|
|
@@ -236,6 +237,7 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
|
236
|
237
|
public void search(final Direction direction, final String text,
|
237
|
238
|
final boolean caseSensitive) {
|
238
|
239
|
boolean foundText = false;
|
|
240
|
+ wrapIndicator.setVisible(false);
|
239
|
241
|
|
240
|
242
|
final boolean up = Direction.UP == direction;
|
241
|
243
|
|
|
@@ -257,37 +259,11 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
|
257
|
259
|
getEndLine())
|
258
|
260
|
|| (!up && result.getStartLine() < textPane.getSelectedRange().
|
259
|
261
|
getStartLine()))) {
|
260
|
|
- final StandardQuestionDialog dialog = new StandardQuestionDialog(
|
261
|
|
- parentWindow, ModalityType.MODELESS, "No more results",
|
262
|
|
- "Do you want to continue searching from the "
|
263
|
|
- + (up ? "end" : "beginning") + "?") {
|
264
|
|
-
|
265
|
|
- /**
|
266
|
|
- * A version number for this class. It should be changed whenever the class
|
267
|
|
- * structure is changed (or anything else that would prevent serialized
|
268
|
|
- * objects being unserialized with the new class).
|
269
|
|
- */
|
270
|
|
- private static final long serialVersionUID = 1;
|
271
|
|
-
|
272
|
|
- /**{@inheritDoc} */
|
273
|
|
- @Override
|
274
|
|
- public boolean save() {
|
|
262
|
+ wrapIndicator.setVisible(true);
|
275
|
263
|
textPane.setScrollBarPosition(result.getEndLine());
|
276
|
264
|
textPane.setSelectedTexT(result);
|
277
|
265
|
validator.setValidates(true);
|
278
|
266
|
searchBox.checkError();
|
279
|
|
- return true;
|
280
|
|
- }
|
281
|
|
-
|
282
|
|
- /**{@inheritDoc} */
|
283
|
|
- @Override
|
284
|
|
- public void cancelled() {
|
285
|
|
- validator.setValidates(true);
|
286
|
|
- searchBox.checkError();
|
287
|
|
- }
|
288
|
|
- };
|
289
|
|
- dialog.display();
|
290
|
|
- return;
|
291
|
267
|
} else {
|
292
|
268
|
//found, select and return found
|
293
|
269
|
textPane.setScrollBarPosition(result.getEndLine());
|