|
30 | 30 | import com.jidesoft.swing.event.SearchableListener; |
31 | 31 |
|
32 | 32 | import sc.fiji.snt.SNTUtils; |
33 | | -import sc.fiji.snt.util.SNTColor; |
34 | 33 |
|
35 | 34 | import javax.swing.*; |
36 | | -import javax.swing.event.DocumentEvent; |
37 | | -import javax.swing.event.DocumentListener; |
38 | 35 | import java.awt.*; |
39 | 36 | import java.awt.event.KeyEvent; |
40 | 37 | import java.io.Serial; |
@@ -133,41 +130,19 @@ private void updateHistoryMenu() { |
133 | 130 | JToggleButton createSubFilteringButton() { |
134 | 131 | final JToggleButton button = new JToggleButton(); |
135 | 132 | formatButton(button, IconFactory.GLYPH.FILTER); |
136 | | - button.setToolTipText("Restricts filtering to selected " + objectDescription +".\nCombines filters to restrict matches"); |
137 | | - button.setActionCommand("Restrict filtering to selected " + objectDescription); // to be displayed in SNTCommandFinder |
| 133 | + button.setToolTipText("Combine selection filters to restrict matches: Restricts filtering to selected " + objectDescription); |
| 134 | + button.setActionCommand("Combine selection filters to restrict matches"); // to be displayed in SNTCommandFinder |
138 | 135 | button.setRequestFocusEnabled(false); |
139 | 136 | button.setFocusable(false); |
140 | | - button.addActionListener(e -> { |
141 | | - setSubFilteringEnabled(button.isSelected()); |
142 | | - setStatusLabelPlaceholder(statusLabelPlaceholder); // update label |
143 | | - }); |
144 | | - getSearchField().getDocument().addDocumentListener(new DocumentListener() { |
145 | | - @Override |
146 | | - public void changedUpdate(final DocumentEvent e) { |
147 | | - disable(); |
148 | | - } |
149 | | - @Override |
150 | | - public void removeUpdate(final DocumentEvent e) { |
151 | | - disable(); |
152 | | - } |
153 | | - @Override |
154 | | - public void insertUpdate(final DocumentEvent e) { |
155 | | - disable(); |
156 | | - } |
157 | | - void disable() { // text searches disable subFiltering |
158 | | - setSubFilteringEnabled(false); |
159 | | - button.setSelected(false); |
160 | | - button.setEnabled(getSearchingText().isBlank()); |
161 | | - } |
162 | | - }); |
| 137 | + button.addActionListener(e -> setSubFilteringEnabled(button.isSelected())); |
163 | 138 | return button; |
164 | 139 | } |
165 | 140 |
|
166 | 141 | public void setStatusLabelPlaceholder(final String placeholder) { |
167 | 142 | statusLabelPlaceholder = placeholder; |
168 | 143 | if (_statusLabel != null) { |
169 | 144 | if (subFilteringEnabled) { |
170 | | - _statusLabel.setText("Filtering on selected paths only"); |
| 145 | + _statusLabel.setText("Combining selection filters"); |
171 | 146 | _statusLabel.setIcon(getSubFilteringStatusIcon()); |
172 | 147 | } else { |
173 | 148 | _statusLabel.setText(statusLabelPlaceholder); |
@@ -391,6 +366,8 @@ private JLabel statusLabel() { |
391 | 366 |
|
392 | 367 | public void setSubFilteringEnabled(final boolean enable) { |
393 | 368 | this.subFilteringEnabled = enable; |
| 369 | + if (_textField != null) _textField.setEnabled(!subFilteringEnabled); // subfiltering disables text searches |
| 370 | + setStatusLabelPlaceholder(statusLabelPlaceholder); // update label |
394 | 371 | } |
395 | 372 |
|
396 | 373 | /** |
|
0 commit comments