タイニー番組ナビゲータ本体
Revisión | c487302692d2739cff2a132e80b10d32d323ef0f (tree) |
---|---|
Tiempo | 2013-12-21 01:24:19 |
Autor | peeweedee <peeweedee@user...> |
Commiter | peeweedee |
ESCキーでツールバー検索のキャンセルα版
@@ -1798,7 +1798,6 @@ public abstract class AbsPaperView extends JPanel implements TickTimerListener,H | ||
1798 | 1798 | |
1799 | 1799 | if ( timer_now_enabled ) { |
1800 | 1800 | |
1801 | - MWin.appendMessage(prevDT4Now+", "+curDT); | |
1802 | 1801 | if (prevDT4Now != null && ! prevDT4Now.equals(curDT)) { |
1803 | 1802 | // 日付切り替え |
1804 | 1803 | StdAppendError(MSGID+"日付が変わったので番組表を切り替えます("+CommonUtils.getDateTime(0)+")"); |
@@ -197,6 +197,20 @@ public abstract class AbsRecordedListView extends JPanel { | ||
197 | 197 | return rowView.size(); |
198 | 198 | } |
199 | 199 | |
200 | + private boolean filtered = false; | |
201 | + | |
202 | + public boolean getFiltered() { return filtered; } | |
203 | + | |
204 | + @Deprecated | |
205 | + public void fireTableDataChanged() { | |
206 | + throw new NullPointerException(); | |
207 | + } | |
208 | + | |
209 | + public void fireTableDataChanged(boolean filtered) { | |
210 | + super.fireTableDataChanged(); | |
211 | + this.filtered = filtered; | |
212 | + } | |
213 | + | |
200 | 214 | public ReservedTableModel(String[] colname, int i) { |
201 | 215 | super(colname,i); |
202 | 216 | } |
@@ -211,7 +225,7 @@ public abstract class AbsRecordedListView extends JPanel { | ||
211 | 225 | private JNETable jTable_reced = null; |
212 | 226 | private JTable jTable_rowheader = null; |
213 | 227 | |
214 | - private DefaultTableModel tableModel_reced = null; | |
228 | + private ReservedTableModel tableModel_reced = null; | |
215 | 229 | |
216 | 230 | private DefaultTableModel rowheaderModel_reced = null; |
217 | 231 |
@@ -319,7 +333,7 @@ public abstract class AbsRecordedListView extends JPanel { | ||
319 | 333 | rowView.add(a); |
320 | 334 | } |
321 | 335 | |
322 | - tableModel_reced.fireTableDataChanged(); | |
336 | + tableModel_reced.fireTableDataChanged(false); | |
323 | 337 | ((DefaultTableModel)jTable_rowheader.getModel()).fireTableDataChanged(); |
324 | 338 | |
325 | 339 | jta_detail.setText(null); |
@@ -333,10 +347,11 @@ public abstract class AbsRecordedListView extends JPanel { | ||
333 | 347 | */ |
334 | 348 | public void redrawListByKeywordFilter(SearchKey keyword, String target) { |
335 | 349 | |
336 | - rowView.clear(); | |
337 | - | |
338 | 350 | // 情報を一行ずつチェックする |
339 | 351 | if ( keyword != null ) { |
352 | + | |
353 | + rowView.clear(); | |
354 | + | |
340 | 355 | for ( RecordedItem a : rowData ) { |
341 | 356 | |
342 | 357 | ProgDetailList tvd = new ProgDetailList(); |
@@ -350,16 +365,28 @@ public abstract class AbsRecordedListView extends JPanel { | ||
350 | 365 | rowView.add(a); |
351 | 366 | } |
352 | 367 | } |
368 | + | |
369 | + // fire! | |
370 | + tableModel_reced.fireTableDataChanged(true); | |
371 | + rowheaderModel_reced.fireTableDataChanged(); | |
353 | 372 | } |
354 | 373 | else { |
374 | + if ( ! tableModel_reced.getFiltered() ) { | |
375 | + System.out.println("xxx"); | |
376 | + return; | |
377 | + } | |
378 | + System.out.println("yyy"); | |
379 | + | |
380 | + rowView.clear(); | |
381 | + | |
355 | 382 | for ( RecordedItem a : rowData ) { |
356 | 383 | rowView.add(a); |
357 | 384 | } |
385 | + | |
386 | + // fire! | |
387 | + tableModel_reced.fireTableDataChanged(false); | |
388 | + rowheaderModel_reced.fireTableDataChanged(); | |
358 | 389 | } |
359 | - | |
360 | - // fire! | |
361 | - tableModel_reced.fireTableDataChanged(); | |
362 | - rowheaderModel_reced.fireTableDataChanged(); | |
363 | 390 | } |
364 | 391 | |
365 | 392 | /** |
@@ -4,7 +4,6 @@ import java.awt.Color; | ||
4 | 4 | import java.awt.Component; |
5 | 5 | import java.awt.Dimension; |
6 | 6 | import java.awt.Font; |
7 | -import java.awt.Insets; | |
8 | 7 | import java.awt.Point; |
9 | 8 | import java.awt.event.ActionEvent; |
10 | 9 | import java.awt.event.ActionListener; |
@@ -19,9 +18,7 @@ import java.util.GregorianCalendar; | ||
19 | 18 | import java.util.HashMap; |
20 | 19 | import java.util.Map.Entry; |
21 | 20 | |
22 | -import javax.swing.AbstractCellEditor; | |
23 | 21 | import javax.swing.ImageIcon; |
24 | -import javax.swing.JButton; | |
25 | 22 | import javax.swing.JLabel; |
26 | 23 | import javax.swing.JMenuItem; |
27 | 24 | import javax.swing.JPopupMenu; |
@@ -33,7 +30,6 @@ import javax.swing.event.RowSorterEvent.Type; | ||
33 | 30 | import javax.swing.event.RowSorterListener; |
34 | 31 | import javax.swing.table.DefaultTableColumnModel; |
35 | 32 | import javax.swing.table.DefaultTableModel; |
36 | -import javax.swing.table.TableCellEditor; | |
37 | 33 | import javax.swing.table.TableCellRenderer; |
38 | 34 | import javax.swing.table.TableColumn; |
39 | 35 | import javax.swing.table.TableModel; |
@@ -314,6 +310,19 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
314 | 310 | this.rDat = rowdata; |
315 | 311 | } |
316 | 312 | |
313 | + private boolean filtered = false; | |
314 | + | |
315 | + public boolean getFiltered() { return filtered; } | |
316 | + | |
317 | + @Deprecated | |
318 | + public void fireTableDataChanged() { | |
319 | + throw new NullPointerException(); | |
320 | + } | |
321 | + | |
322 | + public void fireTableDataChanged(boolean filtered) { | |
323 | + super.fireTableDataChanged(); | |
324 | + this.filtered = filtered; | |
325 | + } | |
317 | 326 | } |
318 | 327 | |
319 | 328 | //private final ReservedItem sa = new ReservedItem(); |
@@ -321,7 +330,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
321 | 330 | private JNETableReserved jTable_rsved = null; |
322 | 331 | private JTable jTable_rowheader = null; |
323 | 332 | |
324 | - private DefaultTableModel tableModel_rsved = null; | |
333 | + private ReservedTableModel tableModel_rsved = null; | |
325 | 334 | |
326 | 335 | private DefaultTableModel rowheaderModel_rsved = null; |
327 | 336 |
@@ -466,7 +475,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
466 | 475 | rowViewTemp.add(a); |
467 | 476 | } |
468 | 477 | |
469 | - tableModel_rsved.fireTableDataChanged(); | |
478 | + tableModel_rsved.fireTableDataChanged(false); | |
470 | 479 | ((DefaultTableModel)jTable_rowheader.getModel()).fireTableDataChanged(); |
471 | 480 | |
472 | 481 | setOverlapMark(); |
@@ -479,10 +488,11 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
479 | 488 | */ |
480 | 489 | public void redrawListByKeywordFilter(SearchKey keyword, String target) { |
481 | 490 | |
482 | - rowViewTemp.clear(); | |
483 | - | |
484 | 491 | // 情報を一行ずつチェックする |
485 | 492 | if ( keyword != null ) { |
493 | + | |
494 | + rowViewTemp.clear(); | |
495 | + | |
486 | 496 | for ( ReservedItem a : rowData ) { |
487 | 497 | |
488 | 498 | ProgDetailList tvd = new ProgDetailList(); |
@@ -496,16 +506,26 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
496 | 506 | rowViewTemp.add(a); |
497 | 507 | } |
498 | 508 | } |
509 | + | |
510 | + // fire! | |
511 | + tableModel_rsved.fireTableDataChanged(true); | |
512 | + rowheaderModel_rsved.fireTableDataChanged(); | |
499 | 513 | } |
500 | 514 | else { |
515 | + if ( ! tableModel_rsved.getFiltered() ) { | |
516 | + return; | |
517 | + } | |
518 | + | |
519 | + rowViewTemp.clear(); | |
520 | + | |
501 | 521 | for ( ReservedItem a : rowData ) { |
502 | 522 | rowViewTemp.add(a); |
503 | 523 | } |
524 | + | |
525 | + // fire! | |
526 | + tableModel_rsved.fireTableDataChanged(false); | |
527 | + rowheaderModel_rsved.fireTableDataChanged(); | |
504 | 528 | } |
505 | - | |
506 | - // fire! | |
507 | - tableModel_rsved.fireTableDataChanged(); | |
508 | - rowheaderModel_rsved.fireTableDataChanged(); | |
509 | 529 | } |
510 | 530 | |
511 | 531 | /** |
@@ -775,6 +775,17 @@ public abstract class AbsToolBar extends JToolBar implements HDDRecorderSelectab | ||
775 | 775 | public void removeHDDRecorderChangeListener(HDDRecorderListener l) { |
776 | 776 | lsnrs_infochg.remove(l); |
777 | 777 | } |
778 | + | |
779 | + /** | |
780 | + * | |
781 | + */ | |
782 | + public void addKeywordCancelListener(CancelListener l) { | |
783 | + jTextField_keyword.addCancelListener(l); | |
784 | + } | |
785 | + | |
786 | + public void removeKeywordCancelChangeListener(CancelListener l) { | |
787 | + jTextField_keyword.removeCancelListener(l); | |
788 | + } | |
778 | 789 | |
779 | 790 | |
780 | 791 | /******************************************************************************* |
@@ -1137,7 +1148,7 @@ public abstract class AbsToolBar extends JToolBar implements HDDRecorderSelectab | ||
1137 | 1148 | ******************************************************************************/ |
1138 | 1149 | |
1139 | 1150 | // キーワード検索ボックス |
1140 | - private JTextField getJTextField_keyword() { | |
1151 | + private JTextFieldWithPopup getJTextField_keyword() { | |
1141 | 1152 | if (jTextField_keyword == null) { |
1142 | 1153 | jTextField_keyword = new JTextFieldWithPopup(16); |
1143 | 1154 | Dimension d = jTextField_keyword.getPreferredSize(); |
@@ -0,0 +1,21 @@ | ||
1 | +package tainavi; | |
2 | + | |
3 | +import java.util.EventObject; | |
4 | + | |
5 | +public class CancelEvent extends EventObject { | |
6 | + | |
7 | + private static final long serialVersionUID = 1L; | |
8 | + | |
9 | + public static enum Cause { TOOLBAR_SEARCH }; | |
10 | + | |
11 | + // この引数の群れはいいのか? | |
12 | + public CancelEvent(Object source, Cause cause) { | |
13 | + super(source); | |
14 | + this.cause = cause; | |
15 | + } | |
16 | + | |
17 | + private Cause cause; | |
18 | + | |
19 | + public Cause getCause() { return cause; } | |
20 | + | |
21 | +} |
@@ -0,0 +1,9 @@ | ||
1 | +package tainavi; | |
2 | + | |
3 | +import java.util.EventListener; | |
4 | + | |
5 | +public interface CancelListener extends EventListener { | |
6 | + | |
7 | + public void cancelRised(CancelEvent e); | |
8 | + | |
9 | +} |
@@ -1,19 +1,70 @@ | ||
1 | 1 | package tainavi; |
2 | 2 | |
3 | -import javax.swing.JTextField; | |
3 | +import java.awt.event.ActionEvent; | |
4 | +import java.awt.event.KeyEvent; | |
5 | +import java.util.ArrayList; | |
4 | 6 | |
7 | +import javax.swing.AbstractAction; | |
8 | +import javax.swing.ActionMap; | |
9 | +import javax.swing.InputMap; | |
10 | +import javax.swing.JComponent; | |
11 | +import javax.swing.JTextField; | |
12 | +import javax.swing.KeyStroke; | |
5 | 13 | |
6 | 14 | public class JTextFieldWithPopup extends JTextField { |
7 | 15 | |
8 | 16 | private static final long serialVersionUID = 1L; |
9 | 17 | |
18 | + private static final String ESCKEYACTION = "escape-cancel"; | |
19 | + | |
10 | 20 | public JTextFieldWithPopup() { |
11 | 21 | super(); |
12 | 22 | this.addMouseListener(new TextEditPopupMenu()); |
23 | + | |
24 | + InputMap im = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); | |
25 | + ActionMap am = this.getActionMap(); | |
26 | + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESCKEYACTION); | |
27 | + am.put(ESCKEYACTION, new CancelAction()); | |
13 | 28 | } |
14 | 29 | |
15 | 30 | public JTextFieldWithPopup(int col) { |
16 | 31 | super(col); |
17 | 32 | this.addMouseListener(new TextEditPopupMenu()); |
33 | + | |
34 | + InputMap im = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); | |
35 | + ActionMap am = this.getActionMap(); | |
36 | + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESCKEYACTION); | |
37 | + am.put(ESCKEYACTION, new CancelAction()); | |
38 | + } | |
39 | + | |
40 | + // | |
41 | + | |
42 | + private class CancelAction extends AbstractAction { | |
43 | + | |
44 | + private static final long serialVersionUID = 1L; | |
45 | + | |
46 | + @Override | |
47 | + public void actionPerformed(ActionEvent e) { | |
48 | + JTextFieldWithPopup jtf = (JTextFieldWithPopup) e.getSource(); | |
49 | + | |
50 | + CancelEvent ev = new CancelEvent(jtf, CancelEvent.Cause.TOOLBAR_SEARCH); | |
51 | + for ( CancelListener l : cancel_listeners ) { | |
52 | + l.cancelRised(ev); | |
53 | + } | |
54 | + } | |
55 | + }; | |
56 | + | |
57 | + // | |
58 | + | |
59 | + private ArrayList<CancelListener> cancel_listeners = new ArrayList<CancelListener>(); | |
60 | + | |
61 | + public void addCancelListener(CancelListener l) { | |
62 | + if ( ! cancel_listeners.contains(l) ) { | |
63 | + cancel_listeners.add(l); | |
64 | + } | |
65 | + } | |
66 | + | |
67 | + public void removeCancelListener(CancelListener l) { | |
68 | + cancel_listeners.remove(l); | |
18 | 69 | } |
19 | 70 | } |
@@ -78,7 +78,7 @@ import tainavi.VWUpdate.UpdateResult; | ||
78 | 78 | /** |
79 | 79 | * メインな感じ |
80 | 80 | */ |
81 | -public class Viewer extends JFrame implements ChangeListener,TickTimerListener,HDDRecorderListener { | |
81 | +public class Viewer extends JFrame implements ChangeListener,TickTimerListener,HDDRecorderListener,CancelListener { | |
82 | 82 | |
83 | 83 | private static final long serialVersionUID = 1L; |
84 | 84 |
@@ -1492,6 +1492,23 @@ public class Viewer extends JFrame implements ChangeListener,TickTimerListener,H | ||
1492 | 1492 | } |
1493 | 1493 | |
1494 | 1494 | /** |
1495 | + * | |
1496 | + */ | |
1497 | + @Override | |
1498 | + public void cancelRised(CancelEvent e) { | |
1499 | + if ( mainWindow.isTabSelected(MWinTab.RSVED) ) { | |
1500 | + if ( e.getCause() == CancelEvent.Cause.TOOLBAR_SEARCH ) { | |
1501 | + reserved.redrawListByKeywordFilter(null,null); | |
1502 | + } | |
1503 | + } | |
1504 | + else if ( mainWindow.isTabSelected(MWinTab.RECED) ) { | |
1505 | + if ( e.getCause() == CancelEvent.Cause.TOOLBAR_SEARCH ) { | |
1506 | + recorded.redrawListByKeywordFilter(null,null); | |
1507 | + } | |
1508 | + } | |
1509 | + } | |
1510 | + | |
1511 | + /** | |
1495 | 1512 | * タイマーイベントが発生 |
1496 | 1513 | */ |
1497 | 1514 | @Override |
@@ -5032,6 +5049,9 @@ public class Viewer extends JFrame implements ChangeListener,TickTimerListener,H | ||
5032 | 5049 | toolBar.addHDDRecorderSelectionListener(paper); // 新聞形式 |
5033 | 5050 | toolBar.addHDDRecorderSelectionListener(autores); // 自動予約一覧 |
5034 | 5051 | toolBar.addHDDRecorderSelectionListener(rdialog); // 予約ダイアログ |
5052 | + | |
5053 | + // [ツールバー/キーワード入力] キャンセル動作 | |
5054 | + toolBar.addKeywordCancelListener(this); | |
5035 | 5055 | |
5036 | 5056 | // [タイマー] タイトルバー更新/リスト形式の現在時刻ノード/新聞形式の現在時刻ノード |
5037 | 5057 | timer_now.addTickTimerRiseListener(this); |