annotate src/name/blackcap/clipman/SearchDialog.kt @ 28:f1fcc1281dad

Use BorderFactory; clean up Find dialog.
author David Barts <n5jrn@me.com>
date Wed, 29 Jan 2020 13:39:14 -0800
parents 8aa2dfac27eb
children c4f53bc01732
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
1 /*
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
2 * The dialog that controls a search.
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
3 */
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
4 package name.blackcap.clipman
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
5
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
6 import java.awt.Color
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
7 import java.awt.Toolkit
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
8 import java.awt.event.ActionEvent
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
9 import java.awt.event.ActionListener
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
10 import javax.swing.*
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
11 import javax.swing.border.*
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
12 import javax.swing.event.DocumentEvent
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
13 import javax.swing.event.DocumentListener
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
14
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
15 class SearchDialog: JDialog(frame.v), ActionListener, DocumentListener {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
16 /* the search term */
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
17 private val _searchFor = JTextField(25).also {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
18 it.border = BorderFactory.createLineBorder(Color.GRAY, 1)
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
19 it.horizontalAlignment = JTextField.LEFT
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
20 it.alignmentX = JTextField.LEFT_ALIGNMENT
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
21 it.text = ""
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
22 it.document.addDocumentListener(this)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
23 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
24 val searchFor: String
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
25 get() {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
26 return _searchFor.text
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
27 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
28
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
29 /* whether or not we should ignore case */
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
30 private val _ignoreCase = JCheckBox("Ignore case", true)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
31 val ignoreCase: Boolean
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
32 get() {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
33 return _ignoreCase.isSelected()
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
34 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
35
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
36 /* whether or not searches should wrap around */
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
37 private val _autoWrap = JCheckBox("Auto wrap", false)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
38 val autoWrap: Boolean
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
39 get() {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
40 return _autoWrap.isSelected()
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
41 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
42
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
43 /* which direction to search */
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
44 private val _forwards = JRadioButton("Forward", true)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
45 private val _backwards = JRadioButton("Backward", false)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
46 private val _direction = ButtonGroup().apply {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
47 add(_forwards)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
48 add(_backwards)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
49 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
50 val direction: PasteboardQueue.Direction
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
51 get() {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
52 if (_forwards.isSelected()) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
53 return PasteboardQueue.Direction.FORWARDS
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
54 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
55 if (_backwards.isSelected()) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
56 return PasteboardQueue.Direction.BACKWARDS
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
57 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
58 throw RuntimeException("impossible button state!")
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
59 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
60
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
61 /* standard spacing between elements (18 pixels = 1/4") and half that */
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
62 private val BW = 9
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
63 private val BW2 = 2 * BW
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
64
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
65 /* where to begin searching from. unlike the other properties, this
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
66 one is read/write. null means to start from the beginning on
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
67 forward searches, and from the end on backward searches (i.e.
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
68 search everything) */
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
69 var origin: PasteboardQueue.Offset? = null
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
70
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
71 private val _find = JButton("Find").also {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
72 it.actionCommand = "Find"
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
73 it.addActionListener(this)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
74 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
75
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
76 private val _cancel = JButton("Cancel").also {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
77 it.actionCommand = "Cancel"
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
78 it.addActionListener(this)
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
79 }
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
80
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
81 /* initializer */
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
82 init {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
83 title = "Find"
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
84 contentPane.apply {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
85 add(Box(BoxLayout.Y_AXIS).apply {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
86 add(Box(BoxLayout.Y_AXIS).apply {
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
87 add(JLabel("Search for:").apply {
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
88 horizontalAlignment = JLabel.LEFT
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
89 alignmentX = JLabel.LEFT_ALIGNMENT
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
90 })
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
91 add(_searchFor)
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
92 alignmentX = Box.CENTER_ALIGNMENT
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
93 border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
94 })
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
95 add(Box(BoxLayout.X_AXIS).apply {
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
96 add(Box.createGlue())
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
97 add(Box(BoxLayout.Y_AXIS).apply {
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
98 add(JLabel("Settings:").apply {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
99 horizontalAlignment = JLabel.CENTER
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
100 alignmentX = JLabel.LEFT_ALIGNMENT
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
101 })
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
102 add(_ignoreCase)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
103 add(_autoWrap)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
104 })
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
105 add(Box.createGlue())
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
106 add(Box(BoxLayout.Y_AXIS).apply {
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
107 add(JLabel("Direction:").apply {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
108 horizontalAlignment = JLabel.CENTER
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
109 alignmentX = JLabel.LEFT_ALIGNMENT
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
110 })
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
111 add(_forwards)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
112 add(_backwards)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
113 })
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
114 add(Box.createGlue())
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
115 alignmentX = Box.CENTER_ALIGNMENT
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
116 border = BorderFactory.createEmptyBorder(BW, BW2, BW, BW2)
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
117 })
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
118 add(Box(BoxLayout.X_AXIS).apply {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
119 add(Box.createGlue())
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
120 add(_cancel)
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
121 add(Box.createGlue())
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
122 add(_find)
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
123 add(Box.createGlue())
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
124 border = BorderFactory.createEmptyBorder(BW, BW2, BW2, BW2)
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
125 })
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
126 })
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
127 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
128 rootPane.setDefaultButton(_find)
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
129 pack()
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
130 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
131
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
132 override fun actionPerformed(e: ActionEvent) {
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
133 when (e.actionCommand) {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
134 "Find" -> {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
135 setVisible(false)
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
136 find()
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
137 }
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
138 "Cancel" -> setVisible(false)
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
139 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
140 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
141
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
142 override fun setVisible(visible: Boolean) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
143 if (visible) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
144 _searchFor.run {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
145 requestFocusInWindow()
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
146 selectAll()
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
147 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
148 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
149 super.setVisible(visible)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
150 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
151
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
152 fun find(): Unit {
28
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
153 if (searchFor.isEmpty()) {
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
154 Toolkit.getDefaultToolkit().beep()
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
155 origin = null
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
156 return
f1fcc1281dad Use BorderFactory; clean up Find dialog.
David Barts <n5jrn@me.com>
parents: 27
diff changeset
157 }
27
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
158 fun doFind(o: PasteboardQueue.Offset?) = queue.v.find(searchFor,
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
159 direction = direction, foldCase = ignoreCase, origin = o)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
160 var result = doFind(origin)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
161 if (result == null && origin != null && autoWrap) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
162 result = doFind(null)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
163 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
164 if (result == null) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
165 Toolkit.getDefaultToolkit().beep()
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
166 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
167 origin = result
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
168 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
169
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
170 /* changing the search string resets the search origin */
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
171 override fun changedUpdate(e: DocumentEvent) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
172 if (e.document === _searchFor.document) {
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
173 origin = null
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
174 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
175 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
176 override fun insertUpdate(e: DocumentEvent) = changedUpdate(e)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
177 override fun removeUpdate(e: DocumentEvent) = changedUpdate(e)
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
178 }
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
179
8aa2dfac27eb Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
diff changeset
180 val searchDialog = SearchDialog()