1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.preferences.shortcut;
|
---|
3 |
|
---|
4 | import java.awt.Color;
|
---|
5 | import java.awt.Component;
|
---|
6 | import java.awt.Dimension;
|
---|
7 | import java.awt.GridBagConstraints;
|
---|
8 | import java.awt.GridBagLayout;
|
---|
9 | import java.awt.Insets;
|
---|
10 | import java.awt.Toolkit;
|
---|
11 |
|
---|
12 | import static org.openstreetmap.josm.tools.I18n.marktr;
|
---|
13 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
14 |
|
---|
15 | import java.awt.event.KeyEvent;
|
---|
16 | import java.lang.reflect.Field;
|
---|
17 | import java.util.ArrayList;
|
---|
18 | import java.util.LinkedHashMap;
|
---|
19 | import java.util.Map;
|
---|
20 |
|
---|
21 | import java.util.regex.PatternSyntaxException;
|
---|
22 | import javax.swing.AbstractAction;
|
---|
23 | import javax.swing.BorderFactory;
|
---|
24 | import javax.swing.BoxLayout;
|
---|
25 | import javax.swing.DefaultComboBoxModel;
|
---|
26 | import javax.swing.JCheckBox;
|
---|
27 | import javax.swing.JLabel;
|
---|
28 | import javax.swing.JPanel;
|
---|
29 | import javax.swing.JScrollPane;
|
---|
30 | import javax.swing.JTable;
|
---|
31 | import javax.swing.KeyStroke;
|
---|
32 | import javax.swing.ListSelectionModel;
|
---|
33 | import javax.swing.RowFilter;
|
---|
34 | import javax.swing.SwingConstants;
|
---|
35 | import javax.swing.event.DocumentEvent;
|
---|
36 | import javax.swing.event.DocumentListener;
|
---|
37 | import javax.swing.event.ListSelectionEvent;
|
---|
38 | import javax.swing.event.ListSelectionListener;
|
---|
39 | import javax.swing.table.AbstractTableModel;
|
---|
40 | import javax.swing.table.TableModel;
|
---|
41 | import javax.swing.table.DefaultTableCellRenderer;
|
---|
42 | import javax.swing.table.TableColumnModel;
|
---|
43 |
|
---|
44 | import javax.swing.table.TableRowSorter;
|
---|
45 | import org.openstreetmap.josm.Main;
|
---|
46 | import org.openstreetmap.josm.gui.widgets.JosmComboBox;
|
---|
47 | import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
|
---|
48 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
49 | import org.openstreetmap.josm.gui.widgets.JosmTextField;
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * This is the keyboard preferences content.
|
---|
53 | * If someone wants to merge it with ShortcutPreference.java, feel free.
|
---|
54 | */
|
---|
55 | public class PrefJPanel extends JPanel {
|
---|
56 |
|
---|
57 | // table of shortcuts
|
---|
58 | private AbstractTableModel model;
|
---|
59 | // comboboxes of modifier groups, mapping selectedIndex to real data
|
---|
60 | private static int[] modifInts = new int[]{
|
---|
61 | -1,
|
---|
62 | 0,
|
---|
63 | KeyEvent.SHIFT_DOWN_MASK,
|
---|
64 | KeyEvent.CTRL_DOWN_MASK,
|
---|
65 | KeyEvent.ALT_DOWN_MASK,
|
---|
66 | KeyEvent.META_DOWN_MASK,
|
---|
67 | KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK,
|
---|
68 | KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK,
|
---|
69 | KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK,
|
---|
70 | KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK,
|
---|
71 | KeyEvent.CTRL_DOWN_MASK | KeyEvent.META_DOWN_MASK,
|
---|
72 | KeyEvent.ALT_DOWN_MASK | KeyEvent.META_DOWN_MASK,
|
---|
73 | KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK,
|
---|
74 | KeyEvent.META_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK | KeyEvent.ALT_DOWN_MASK
|
---|
75 | };
|
---|
76 | // and here are the texts fro the comboboxes
|
---|
77 | private static String[] modifList = new String[] {
|
---|
78 | tr("disabled"),
|
---|
79 | tr("no modifier"),
|
---|
80 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[2]).getModifiers()),
|
---|
81 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[3]).getModifiers()),
|
---|
82 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[4]).getModifiers()),
|
---|
83 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[5]).getModifiers()),
|
---|
84 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[6]).getModifiers()),
|
---|
85 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[7]).getModifiers()),
|
---|
86 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[8]).getModifiers()),
|
---|
87 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[9]).getModifiers()),
|
---|
88 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[10]).getModifiers()),
|
---|
89 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[11]).getModifiers()),
|
---|
90 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[12]).getModifiers()),
|
---|
91 | KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, modifInts[13]).getModifiers())
|
---|
92 | };
|
---|
93 | // this are the display(!) texts for the checkboxes. Let the JVM do the i18n for us <g>.
|
---|
94 | // Ok, there's a real reason for this: The JVM should know best how the keys are labelled
|
---|
95 | // on the physical keyboard. What language pack is installed in JOSM is completely
|
---|
96 | // independent from the keyboard's labelling. But the operation system's locale
|
---|
97 | // usually matches the keyboard. This even works with my English Windows and my German
|
---|
98 | // keyboard.
|
---|
99 | private static String SHIFT = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.SHIFT_DOWN_MASK).getModifiers());
|
---|
100 | private static String CTRL = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK).getModifiers());
|
---|
101 | private static String ALT = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK).getModifiers());
|
---|
102 | private static String META = KeyEvent.getKeyModifiersText(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.META_DOWN_MASK).getModifiers());
|
---|
103 |
|
---|
104 | // A list of keys to present the user. Sadly this really is a list of keys Java knows about,
|
---|
105 | // not a list of real physical keys. If someone knows how to get that list?
|
---|
106 | private static Map<Integer, String> keyList = setKeyList();
|
---|
107 |
|
---|
108 | private static Map<Integer, String> setKeyList() {
|
---|
109 | Map<Integer, String> list = new LinkedHashMap<Integer, String>();
|
---|
110 | String unknown = Toolkit.getProperty("AWT.unknown", "Unknown");
|
---|
111 | // Assume all known keys are declared in KeyEvent as "public static int VK_*"
|
---|
112 | for (Field field : KeyEvent.class.getFields()) {
|
---|
113 | if (field.getName().startsWith("VK_")) {
|
---|
114 | try {
|
---|
115 | int i = field.getInt(null);
|
---|
116 | String s = KeyEvent.getKeyText(i);
|
---|
117 | if (s != null && s.length() > 0 && !s.contains(unknown)) {
|
---|
118 | list.put(Integer.valueOf(i), s);
|
---|
119 | //System.out.println(i+": "+s);
|
---|
120 | }
|
---|
121 | } catch (Exception e) {
|
---|
122 | e.printStackTrace();
|
---|
123 | }
|
---|
124 | }
|
---|
125 | }
|
---|
126 | list.put(Integer.valueOf(-1), "");
|
---|
127 | return list;
|
---|
128 | }
|
---|
129 |
|
---|
130 | private JCheckBox cbAlt = new JCheckBox();
|
---|
131 | private JCheckBox cbCtrl = new JCheckBox();
|
---|
132 | private JCheckBox cbMeta = new JCheckBox();
|
---|
133 | private JCheckBox cbShift = new JCheckBox();
|
---|
134 | private JCheckBox cbDefault = new JCheckBox();
|
---|
135 | private JCheckBox cbDisable = new JCheckBox();
|
---|
136 | private JosmComboBox tfKey = new JosmComboBox();
|
---|
137 |
|
---|
138 | JTable shortcutTable = new JTable();
|
---|
139 |
|
---|
140 | private JosmTextField filterField = new JosmTextField();
|
---|
141 |
|
---|
142 | /** Creates new form prefJPanel */
|
---|
143 | // Ain't those auto-generated comments helpful or what? <g>
|
---|
144 | public PrefJPanel(AbstractTableModel model) {
|
---|
145 | this.model = model;
|
---|
146 | initComponents();
|
---|
147 | }
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * Show only shortcuts with descriptions coontaing given substring
|
---|
151 | */
|
---|
152 | public void filter(String substring) {
|
---|
153 | filterField.setText(substring);
|
---|
154 | }
|
---|
155 |
|
---|
156 | private class ShortcutTableCellRenderer extends DefaultTableCellRenderer {
|
---|
157 |
|
---|
158 | private boolean name;
|
---|
159 |
|
---|
160 | public ShortcutTableCellRenderer(boolean name) {
|
---|
161 | this.name = name;
|
---|
162 | }
|
---|
163 |
|
---|
164 | @Override
|
---|
165 | public Component getTableCellRendererComponent(JTable table, Object value, boolean
|
---|
166 | isSelected, boolean hasFocus, int row, int column) {
|
---|
167 | int row1 = shortcutTable.convertRowIndexToModel(row);
|
---|
168 | Shortcut sc = (Shortcut)model.getValueAt(row1, -1);
|
---|
169 | if (sc==null) return null;
|
---|
170 | JLabel label = (JLabel) super.getTableCellRendererComponent(
|
---|
171 | table, name ? sc.getLongText() : sc.getKeyText(), isSelected, hasFocus, row, column);
|
---|
172 | label.setBackground(Main.pref.getUIColor("Table.background"));
|
---|
173 | if (isSelected) {
|
---|
174 | label.setForeground(Main.pref.getUIColor("Table.foreground"));
|
---|
175 | }
|
---|
176 | if(sc.getAssignedUser()) {
|
---|
177 | label.setBackground(Main.pref.getColor(
|
---|
178 | marktr("Shortcut Background: User"),
|
---|
179 | new Color(200,255,200)));
|
---|
180 | } else if(!sc.getAssignedDefault()) {
|
---|
181 | label.setBackground(Main.pref.getColor(
|
---|
182 | marktr("Shortcut Background: Modified"),
|
---|
183 | new Color(255,255,200)));
|
---|
184 | }
|
---|
185 | return label;
|
---|
186 | }
|
---|
187 | }
|
---|
188 |
|
---|
189 | private void initComponents() {
|
---|
190 | JPanel listPane = new JPanel();
|
---|
191 | JScrollPane listScrollPane = new JScrollPane();
|
---|
192 | JPanel shortcutEditPane = new JPanel();
|
---|
193 |
|
---|
194 | CbAction action = new CbAction(this);
|
---|
195 | setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
---|
196 | add(buildFilterPanel());
|
---|
197 | listPane.setLayout(new java.awt.GridLayout());
|
---|
198 |
|
---|
199 | // This is the list of shortcuts:
|
---|
200 | shortcutTable.setModel(model);
|
---|
201 | shortcutTable.getSelectionModel().addListSelectionListener(new CbAction(this));
|
---|
202 | shortcutTable.setFillsViewportHeight(true);
|
---|
203 | shortcutTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
---|
204 | shortcutTable.setAutoCreateRowSorter(true);
|
---|
205 | TableColumnModel mod = shortcutTable.getColumnModel();
|
---|
206 | mod.getColumn(0).setCellRenderer(new ShortcutTableCellRenderer(true));
|
---|
207 | mod.getColumn(1).setCellRenderer(new ShortcutTableCellRenderer(false));
|
---|
208 | listScrollPane.setViewportView(shortcutTable);
|
---|
209 |
|
---|
210 | listPane.add(listScrollPane);
|
---|
211 |
|
---|
212 | add(listPane);
|
---|
213 |
|
---|
214 | // and here follows the edit area. I won't object to someone re-designing it, it looks, um, "minimalistic" ;)
|
---|
215 | shortcutEditPane.setLayout(new java.awt.GridLayout(5, 2));
|
---|
216 |
|
---|
217 | cbDefault.setAction(action);
|
---|
218 | cbDefault.setText(tr("Use default"));
|
---|
219 | cbShift.setAction(action);
|
---|
220 | cbShift.setText(SHIFT); // see above for why no tr()
|
---|
221 | cbDisable.setAction(action);
|
---|
222 | cbDisable.setText(tr("Disable"));
|
---|
223 | cbCtrl.setAction(action);
|
---|
224 | cbCtrl.setText(CTRL); // see above for why no tr()
|
---|
225 | cbAlt.setAction(action);
|
---|
226 | cbAlt.setText(ALT); // see above for why no tr()
|
---|
227 | tfKey.setAction(action);
|
---|
228 | tfKey.setModel(new DefaultComboBoxModel(keyList.values().toArray()));
|
---|
229 | cbMeta.setAction(action);
|
---|
230 | cbMeta.setText(META); // see above for why no tr()
|
---|
231 |
|
---|
232 | shortcutEditPane.add(cbDefault);
|
---|
233 | shortcutEditPane.add(new JLabel());
|
---|
234 | shortcutEditPane.add(cbShift);
|
---|
235 | shortcutEditPane.add(cbDisable);
|
---|
236 | shortcutEditPane.add(cbCtrl);
|
---|
237 | shortcutEditPane.add(new JLabel(tr("Key:"), SwingConstants.LEFT));
|
---|
238 | shortcutEditPane.add(cbAlt);
|
---|
239 | shortcutEditPane.add(tfKey);
|
---|
240 | shortcutEditPane.add(cbMeta);
|
---|
241 |
|
---|
242 | shortcutEditPane.add(new JLabel(tr("Attention: Use real keyboard keys only!")));
|
---|
243 |
|
---|
244 | action.actionPerformed(null); // init checkboxes
|
---|
245 |
|
---|
246 | add(shortcutEditPane);
|
---|
247 | }
|
---|
248 |
|
---|
249 | private JPanel buildFilterPanel() {
|
---|
250 | // copied from PluginPreference
|
---|
251 | JPanel pnl = new JPanel(new GridBagLayout());
|
---|
252 | pnl.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
253 | GridBagConstraints gc = new GridBagConstraints();
|
---|
254 |
|
---|
255 | gc.anchor = GridBagConstraints.NORTHWEST;
|
---|
256 | gc.fill = GridBagConstraints.HORIZONTAL;
|
---|
257 | gc.weightx = 0.0;
|
---|
258 | gc.insets = new Insets(0,0,0,5);
|
---|
259 | pnl.add(new JLabel(tr("Search:")), gc);
|
---|
260 |
|
---|
261 | gc.gridx = 1;
|
---|
262 | gc.weightx = 1.0;
|
---|
263 | pnl.add(filterField, gc);
|
---|
264 | filterField.setToolTipText(tr("Enter a search expression"));
|
---|
265 | SelectAllOnFocusGainedDecorator.decorate(filterField);
|
---|
266 | filterField.getDocument().addDocumentListener(new FilterFieldAdapter());
|
---|
267 | pnl.setMaximumSize(new Dimension(300,10));
|
---|
268 | return pnl;
|
---|
269 | }
|
---|
270 |
|
---|
271 | private void disableAllModifierCheckboxes() {
|
---|
272 | cbDefault.setEnabled(false);
|
---|
273 | cbDisable.setEnabled(false);
|
---|
274 | cbShift.setEnabled(false);
|
---|
275 | cbCtrl.setEnabled(false);
|
---|
276 | cbAlt.setEnabled(false);
|
---|
277 | cbMeta.setEnabled(false);
|
---|
278 | }
|
---|
279 |
|
---|
280 | // this allows to edit shortcuts. it:
|
---|
281 | // * sets the edit controls to the selected shortcut
|
---|
282 | // * enabled/disables the controls as needed
|
---|
283 | // * writes the user's changes to the shortcut
|
---|
284 | // And after I finally had it working, I realized that those two methods
|
---|
285 | // are playing ping-pong (politically correct: table tennis, I know) and
|
---|
286 | // even have some duplicated code. Feel free to refactor, If you have
|
---|
287 | // more expirience with GUI coding than I have.
|
---|
288 | private class CbAction extends AbstractAction implements ListSelectionListener {
|
---|
289 | private PrefJPanel panel;
|
---|
290 | public CbAction (PrefJPanel panel) {
|
---|
291 | this.panel = panel;
|
---|
292 | }
|
---|
293 | @Override
|
---|
294 | public void valueChanged(ListSelectionEvent e) {
|
---|
295 | ListSelectionModel lsm = panel.shortcutTable.getSelectionModel(); // can't use e here
|
---|
296 | if (!lsm.isSelectionEmpty()) {
|
---|
297 | int row = panel.shortcutTable.convertRowIndexToModel(lsm.getMinSelectionIndex());
|
---|
298 | Shortcut sc = (Shortcut)panel.model.getValueAt(row, -1);
|
---|
299 | panel.cbDefault.setSelected(!sc.getAssignedUser());
|
---|
300 | panel.cbDisable.setSelected(sc.getKeyStroke() == null);
|
---|
301 | panel.cbShift.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.SHIFT_DOWN_MASK) != 0);
|
---|
302 | panel.cbCtrl.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.CTRL_DOWN_MASK) != 0);
|
---|
303 | panel.cbAlt.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.ALT_DOWN_MASK) != 0);
|
---|
304 | panel.cbMeta.setSelected(sc.getAssignedModifier() != -1 && (sc.getAssignedModifier() & KeyEvent.META_DOWN_MASK) != 0);
|
---|
305 | if (sc.getKeyStroke() != null) {
|
---|
306 | tfKey.setSelectedItem(keyList.get(sc.getKeyStroke().getKeyCode()));
|
---|
307 | } else {
|
---|
308 | tfKey.setSelectedItem(keyList.get(-1));
|
---|
309 | }
|
---|
310 | if (!sc.isChangeable()) {
|
---|
311 | disableAllModifierCheckboxes();
|
---|
312 | panel.tfKey.setEnabled(false);
|
---|
313 | } else {
|
---|
314 | panel.cbDefault.setEnabled(true);
|
---|
315 | actionPerformed(null);
|
---|
316 | }
|
---|
317 | model.fireTableRowsUpdated(row, row);
|
---|
318 | } else {
|
---|
319 | panel.disableAllModifierCheckboxes();
|
---|
320 | panel.tfKey.setEnabled(false);
|
---|
321 | }
|
---|
322 | }
|
---|
323 | @Override
|
---|
324 | public void actionPerformed(java.awt.event.ActionEvent e) {
|
---|
325 | ListSelectionModel lsm = panel.shortcutTable.getSelectionModel();
|
---|
326 | if (lsm != null && !lsm.isSelectionEmpty()) {
|
---|
327 | if (e != null) { // only if we've been called by a user action
|
---|
328 | int row = panel.shortcutTable.convertRowIndexToModel(lsm.getMinSelectionIndex());
|
---|
329 | Shortcut sc = (Shortcut)panel.model.getValueAt(row, -1);
|
---|
330 | if (panel.cbDisable.isSelected()) {
|
---|
331 | sc.setAssignedModifier(-1);
|
---|
332 | } else if (panel.tfKey.getSelectedItem() == null || panel.tfKey.getSelectedItem().equals("")) {
|
---|
333 | sc.setAssignedModifier(KeyEvent.VK_CANCEL);
|
---|
334 | } else {
|
---|
335 | sc.setAssignedModifier(
|
---|
336 | (panel.cbShift.isSelected() ? KeyEvent.SHIFT_DOWN_MASK : 0) |
|
---|
337 | (panel.cbCtrl.isSelected() ? KeyEvent.CTRL_DOWN_MASK : 0) |
|
---|
338 | (panel.cbAlt.isSelected() ? KeyEvent.ALT_DOWN_MASK : 0) |
|
---|
339 | (panel.cbMeta.isSelected() ? KeyEvent.META_DOWN_MASK : 0)
|
---|
340 | );
|
---|
341 | for (Map.Entry<Integer, String> entry : keyList.entrySet()) {
|
---|
342 | if (entry.getValue().equals(panel.tfKey.getSelectedItem())) {
|
---|
343 | sc.setAssignedKey(entry.getKey());
|
---|
344 | }
|
---|
345 | }
|
---|
346 | }
|
---|
347 | sc.setAssignedUser(!panel.cbDefault.isSelected());
|
---|
348 | valueChanged(null);
|
---|
349 | }
|
---|
350 | boolean state = !panel.cbDefault.isSelected();
|
---|
351 | panel.cbDisable.setEnabled(state);
|
---|
352 | state = state && !panel.cbDisable.isSelected();
|
---|
353 | panel.cbShift.setEnabled(state);
|
---|
354 | panel.cbCtrl.setEnabled(state);
|
---|
355 | panel.cbAlt.setEnabled(state);
|
---|
356 | panel.cbMeta.setEnabled(state);
|
---|
357 | panel.tfKey.setEnabled(state);
|
---|
358 | } else {
|
---|
359 | panel.disableAllModifierCheckboxes();
|
---|
360 | panel.tfKey.setEnabled(false);
|
---|
361 | }
|
---|
362 | }
|
---|
363 | }
|
---|
364 |
|
---|
365 | class FilterFieldAdapter implements DocumentListener {
|
---|
366 | public void filter() {
|
---|
367 | String expr = filterField.getText().trim();
|
---|
368 | if (expr.length()==0) { expr=null; }
|
---|
369 | try {
|
---|
370 | final TableRowSorter<? extends TableModel> sorter =
|
---|
371 | ((TableRowSorter<? extends TableModel> )shortcutTable.getRowSorter());
|
---|
372 | if (expr == null) {
|
---|
373 | sorter.setRowFilter(null);
|
---|
374 | } else {
|
---|
375 | expr = expr.replace("+", "\\+");
|
---|
376 | // split search string on whitespace, do case-insensitive AND search
|
---|
377 | ArrayList<RowFilter<Object, Object>> andFilters = new ArrayList<RowFilter<Object, Object>>();
|
---|
378 | for (String word : expr.split("\\s+")) {
|
---|
379 | andFilters.add(RowFilter.regexFilter("(?i)" + word));
|
---|
380 | }
|
---|
381 | sorter.setRowFilter(RowFilter.andFilter(andFilters));
|
---|
382 | }
|
---|
383 | model.fireTableDataChanged();
|
---|
384 | }
|
---|
385 | catch (PatternSyntaxException ex) { }
|
---|
386 | catch (ClassCastException ex2) { /* eliminate warning */ }
|
---|
387 | }
|
---|
388 |
|
---|
389 | @Override
|
---|
390 | public void changedUpdate(DocumentEvent arg0) { filter(); }
|
---|
391 | @Override
|
---|
392 | public void insertUpdate(DocumentEvent arg0) { filter(); }
|
---|
393 | @Override
|
---|
394 | public void removeUpdate(DocumentEvent arg0) { filter(); }
|
---|
395 | }
|
---|
396 |
|
---|
397 | }
|
---|