• R/O
  • HTTP
  • SSH
  • HTTPS

TinyBannavi: Commit

タイニー番組ナビゲータ本体


Commit MetaInfo

Revisiónc487302692d2739cff2a132e80b10d32d323ef0f (tree)
Tiempo2013-12-21 01:24:19
Autorpeeweedee <peeweedee@user...>
Commiterpeeweedee

Log Message

ESCキーでツールバー検索のキャンセルα版

Cambiar Resumen

Diferencia incremental

--- a/TinyBannavi/src/tainavi/AbsPaperView.java
+++ b/TinyBannavi/src/tainavi/AbsPaperView.java
@@ -1798,7 +1798,6 @@ public abstract class AbsPaperView extends JPanel implements TickTimerListener,H
17981798
17991799 if ( timer_now_enabled ) {
18001800
1801- MWin.appendMessage(prevDT4Now+", "+curDT);
18021801 if (prevDT4Now != null && ! prevDT4Now.equals(curDT)) {
18031802 // 日付切り替え
18041803 StdAppendError(MSGID+"日付が変わったので番組表を切り替えます("+CommonUtils.getDateTime(0)+")");
--- a/TinyBannavi/src/tainavi/AbsRecordedListView.java
+++ b/TinyBannavi/src/tainavi/AbsRecordedListView.java
@@ -197,6 +197,20 @@ public abstract class AbsRecordedListView extends JPanel {
197197 return rowView.size();
198198 }
199199
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+
200214 public ReservedTableModel(String[] colname, int i) {
201215 super(colname,i);
202216 }
@@ -211,7 +225,7 @@ public abstract class AbsRecordedListView extends JPanel {
211225 private JNETable jTable_reced = null;
212226 private JTable jTable_rowheader = null;
213227
214- private DefaultTableModel tableModel_reced = null;
228+ private ReservedTableModel tableModel_reced = null;
215229
216230 private DefaultTableModel rowheaderModel_reced = null;
217231
@@ -319,7 +333,7 @@ public abstract class AbsRecordedListView extends JPanel {
319333 rowView.add(a);
320334 }
321335
322- tableModel_reced.fireTableDataChanged();
336+ tableModel_reced.fireTableDataChanged(false);
323337 ((DefaultTableModel)jTable_rowheader.getModel()).fireTableDataChanged();
324338
325339 jta_detail.setText(null);
@@ -333,10 +347,11 @@ public abstract class AbsRecordedListView extends JPanel {
333347 */
334348 public void redrawListByKeywordFilter(SearchKey keyword, String target) {
335349
336- rowView.clear();
337-
338350 // 情報を一行ずつチェックする
339351 if ( keyword != null ) {
352+
353+ rowView.clear();
354+
340355 for ( RecordedItem a : rowData ) {
341356
342357 ProgDetailList tvd = new ProgDetailList();
@@ -350,16 +365,28 @@ public abstract class AbsRecordedListView extends JPanel {
350365 rowView.add(a);
351366 }
352367 }
368+
369+ // fire!
370+ tableModel_reced.fireTableDataChanged(true);
371+ rowheaderModel_reced.fireTableDataChanged();
353372 }
354373 else {
374+ if ( ! tableModel_reced.getFiltered() ) {
375+ System.out.println("xxx");
376+ return;
377+ }
378+ System.out.println("yyy");
379+
380+ rowView.clear();
381+
355382 for ( RecordedItem a : rowData ) {
356383 rowView.add(a);
357384 }
385+
386+ // fire!
387+ tableModel_reced.fireTableDataChanged(false);
388+ rowheaderModel_reced.fireTableDataChanged();
358389 }
359-
360- // fire!
361- tableModel_reced.fireTableDataChanged();
362- rowheaderModel_reced.fireTableDataChanged();
363390 }
364391
365392 /**
--- a/TinyBannavi/src/tainavi/AbsReserveListView.java
+++ b/TinyBannavi/src/tainavi/AbsReserveListView.java
@@ -4,7 +4,6 @@ import java.awt.Color;
44 import java.awt.Component;
55 import java.awt.Dimension;
66 import java.awt.Font;
7-import java.awt.Insets;
87 import java.awt.Point;
98 import java.awt.event.ActionEvent;
109 import java.awt.event.ActionListener;
@@ -19,9 +18,7 @@ import java.util.GregorianCalendar;
1918 import java.util.HashMap;
2019 import java.util.Map.Entry;
2120
22-import javax.swing.AbstractCellEditor;
2321 import javax.swing.ImageIcon;
24-import javax.swing.JButton;
2522 import javax.swing.JLabel;
2623 import javax.swing.JMenuItem;
2724 import javax.swing.JPopupMenu;
@@ -33,7 +30,6 @@ import javax.swing.event.RowSorterEvent.Type;
3330 import javax.swing.event.RowSorterListener;
3431 import javax.swing.table.DefaultTableColumnModel;
3532 import javax.swing.table.DefaultTableModel;
36-import javax.swing.table.TableCellEditor;
3733 import javax.swing.table.TableCellRenderer;
3834 import javax.swing.table.TableColumn;
3935 import javax.swing.table.TableModel;
@@ -314,6 +310,19 @@ public abstract class AbsReserveListView extends JScrollPane {
314310 this.rDat = rowdata;
315311 }
316312
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+ }
317326 }
318327
319328 //private final ReservedItem sa = new ReservedItem();
@@ -321,7 +330,7 @@ public abstract class AbsReserveListView extends JScrollPane {
321330 private JNETableReserved jTable_rsved = null;
322331 private JTable jTable_rowheader = null;
323332
324- private DefaultTableModel tableModel_rsved = null;
333+ private ReservedTableModel tableModel_rsved = null;
325334
326335 private DefaultTableModel rowheaderModel_rsved = null;
327336
@@ -466,7 +475,7 @@ public abstract class AbsReserveListView extends JScrollPane {
466475 rowViewTemp.add(a);
467476 }
468477
469- tableModel_rsved.fireTableDataChanged();
478+ tableModel_rsved.fireTableDataChanged(false);
470479 ((DefaultTableModel)jTable_rowheader.getModel()).fireTableDataChanged();
471480
472481 setOverlapMark();
@@ -479,10 +488,11 @@ public abstract class AbsReserveListView extends JScrollPane {
479488 */
480489 public void redrawListByKeywordFilter(SearchKey keyword, String target) {
481490
482- rowViewTemp.clear();
483-
484491 // 情報を一行ずつチェックする
485492 if ( keyword != null ) {
493+
494+ rowViewTemp.clear();
495+
486496 for ( ReservedItem a : rowData ) {
487497
488498 ProgDetailList tvd = new ProgDetailList();
@@ -496,16 +506,26 @@ public abstract class AbsReserveListView extends JScrollPane {
496506 rowViewTemp.add(a);
497507 }
498508 }
509+
510+ // fire!
511+ tableModel_rsved.fireTableDataChanged(true);
512+ rowheaderModel_rsved.fireTableDataChanged();
499513 }
500514 else {
515+ if ( ! tableModel_rsved.getFiltered() ) {
516+ return;
517+ }
518+
519+ rowViewTemp.clear();
520+
501521 for ( ReservedItem a : rowData ) {
502522 rowViewTemp.add(a);
503523 }
524+
525+ // fire!
526+ tableModel_rsved.fireTableDataChanged(false);
527+ rowheaderModel_rsved.fireTableDataChanged();
504528 }
505-
506- // fire!
507- tableModel_rsved.fireTableDataChanged();
508- rowheaderModel_rsved.fireTableDataChanged();
509529 }
510530
511531 /**
--- a/TinyBannavi/src/tainavi/AbsToolBar.java
+++ b/TinyBannavi/src/tainavi/AbsToolBar.java
@@ -775,6 +775,17 @@ public abstract class AbsToolBar extends JToolBar implements HDDRecorderSelectab
775775 public void removeHDDRecorderChangeListener(HDDRecorderListener l) {
776776 lsnrs_infochg.remove(l);
777777 }
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+ }
778789
779790
780791 /*******************************************************************************
@@ -1137,7 +1148,7 @@ public abstract class AbsToolBar extends JToolBar implements HDDRecorderSelectab
11371148 ******************************************************************************/
11381149
11391150 // キーワード検索ボックス
1140- private JTextField getJTextField_keyword() {
1151+ private JTextFieldWithPopup getJTextField_keyword() {
11411152 if (jTextField_keyword == null) {
11421153 jTextField_keyword = new JTextFieldWithPopup(16);
11431154 Dimension d = jTextField_keyword.getPreferredSize();
--- /dev/null
+++ b/TinyBannavi/src/tainavi/CancelEvent.java
@@ -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+}
--- /dev/null
+++ b/TinyBannavi/src/tainavi/CancelListener.java
@@ -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+}
--- a/TinyBannavi/src/tainavi/JTextFieldWithPopup.java
+++ b/TinyBannavi/src/tainavi/JTextFieldWithPopup.java
@@ -1,19 +1,70 @@
11 package tainavi;
22
3-import javax.swing.JTextField;
3+import java.awt.event.ActionEvent;
4+import java.awt.event.KeyEvent;
5+import java.util.ArrayList;
46
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;
513
614 public class JTextFieldWithPopup extends JTextField {
715
816 private static final long serialVersionUID = 1L;
917
18+ private static final String ESCKEYACTION = "escape-cancel";
19+
1020 public JTextFieldWithPopup() {
1121 super();
1222 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());
1328 }
1429
1530 public JTextFieldWithPopup(int col) {
1631 super(col);
1732 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);
1869 }
1970 }
--- a/TinyBannavi/src/tainavi/Viewer.java
+++ b/TinyBannavi/src/tainavi/Viewer.java
@@ -78,7 +78,7 @@ import tainavi.VWUpdate.UpdateResult;
7878 /**
7979 * メインな感じ
8080 */
81-public class Viewer extends JFrame implements ChangeListener,TickTimerListener,HDDRecorderListener {
81+public class Viewer extends JFrame implements ChangeListener,TickTimerListener,HDDRecorderListener,CancelListener {
8282
8383 private static final long serialVersionUID = 1L;
8484
@@ -1492,6 +1492,23 @@ public class Viewer extends JFrame implements ChangeListener,TickTimerListener,H
14921492 }
14931493
14941494 /**
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+ /**
14951512 * タイマーイベントが発生
14961513 */
14971514 @Override
@@ -5032,6 +5049,9 @@ public class Viewer extends JFrame implements ChangeListener,TickTimerListener,H
50325049 toolBar.addHDDRecorderSelectionListener(paper); // 新聞形式
50335050 toolBar.addHDDRecorderSelectionListener(autores); // 自動予約一覧
50345051 toolBar.addHDDRecorderSelectionListener(rdialog); // 予約ダイアログ
5052+
5053+ // [ツールバー/キーワード入力] キャンセル動作
5054+ toolBar.addKeywordCancelListener(this);
50355055
50365056 // [タイマー] タイトルバー更新/リスト形式の現在時刻ノード/新聞形式の現在時刻ノード
50375057 timer_now.addTickTimerRiseListener(this);
Show on old repository browser