タイニー番組ナビゲータ本体
Revisão | 145cb9355fa4b68d38f05e5933e4519d95dc33e3 (tree) |
---|---|
Hora | 2017-07-23 23:36:27 |
Autor | Masahiko Kimura <mkimura@u01....> |
Commiter | Masahiko Kimura |
「本体予約一覧」ビューで予約の進行状況を「リスト形式」ビューと同様背景色と「終了前xx分」といったテキストで表示する。
@@ -46,7 +46,7 @@ import tainavi.AbsTitleListView.TitleColumn; | ||
46 | 46 | * 本体予約一覧タブのクラス |
47 | 47 | * @since 3.15.4β {@link Viewer}から分離 |
48 | 48 | */ |
49 | -public abstract class AbsReserveListView extends JScrollPane { | |
49 | +public abstract class AbsReserveListView extends JScrollPane implements VWTimerRiseListener { | |
50 | 50 | |
51 | 51 | private static final long serialVersionUID = 1L; |
52 | 52 |
@@ -121,6 +121,10 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
121 | 121 | private static final String VALID_DEVNAME_COLOR = "#000000"; |
122 | 122 | private static final String INVALID_DEVNAME_COLOR = "#ff0000"; |
123 | 123 | |
124 | + private static final String PASSED_COLOR = "#b4b4b4"; | |
125 | + private static final String CURRENT_COLOR_EVEN = "#f0b4b4"; | |
126 | + private static final String CURRENT_COLOR_ODD = "#f88080"; | |
127 | + | |
124 | 128 | private static final String ICONFILE_EXEC = "icon/media-record-3.png"; |
125 | 129 | |
126 | 130 | /******************************************************************************* |
@@ -167,6 +171,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
167 | 171 | EXEC ("実行", 35), |
168 | 172 | TRACE ("追跡", 35), |
169 | 173 | AUTO ("自動", 35), |
174 | + OPTIONS ("オプション", 100), | |
170 | 175 | NEXTSTART ("次回実行予定", 150), |
171 | 176 | END ("終了", 50), |
172 | 177 | LENGTH ("長さ", 50), |
@@ -219,6 +224,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
219 | 224 | Boolean exec; |
220 | 225 | String trace; |
221 | 226 | String auto; |
227 | + String options; | |
222 | 228 | String nextstart; // YYYY/MM/DD(WD) hh:mm |
223 | 229 | String end; // hh:mm |
224 | 230 | String length; |
@@ -239,6 +245,8 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
239 | 245 | String hide_devicecolor; |
240 | 246 | Boolean hide_tunershort; |
241 | 247 | Boolean hide_recorded; |
248 | + String hide_nextstart; | |
249 | + String hide_nextend; | |
242 | 250 | |
243 | 251 | @Override |
244 | 252 | protected void myrefresh(RowItem o) { |
@@ -249,6 +257,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
249 | 257 | c.addData(exec); |
250 | 258 | c.addData(trace); |
251 | 259 | c.addData(auto); |
260 | + c.addData(options); | |
252 | 261 | c.addData(nextstart); |
253 | 262 | c.addData(end); |
254 | 263 | c.addData(length); |
@@ -341,6 +350,9 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
341 | 350 | // テーブルの実体 |
342 | 351 | private final RowItemList<ReservedItem> rowData = new RowItemList<ReservedItem>(); |
343 | 352 | |
353 | + // 現在放送中のタイマー | |
354 | + private boolean timer_now_enabled = false; | |
355 | + | |
344 | 356 | /******************************************************************************* |
345 | 357 | * コンストラクタ |
346 | 358 | ******************************************************************************/ |
@@ -386,6 +398,22 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
386 | 398 | // 対外的な |
387 | 399 | |
388 | 400 | /** |
401 | + * 現在時刻追従を開始する | |
402 | + * @see #stopTimer | |
403 | + * @see #pauseTimer | |
404 | + */ | |
405 | + private void startTimer() { | |
406 | + timer_now_enabled = true; | |
407 | + } | |
408 | + | |
409 | + /** | |
410 | + * 現在時刻追従を停止する | |
411 | + */ | |
412 | + private boolean stopTimer(boolean showmsg) { | |
413 | + return (timer_now_enabled = false); | |
414 | + } | |
415 | + | |
416 | + /** | |
389 | 417 | * 予約一覧を描画してほしいかなって |
390 | 418 | * ★synchronized(rowData)★ |
391 | 419 | * @see #cl_tabshown |
@@ -398,6 +426,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
398 | 426 | } |
399 | 427 | |
400 | 428 | private void _redrawReservedList() { |
429 | + stopTimer(true); | |
401 | 430 | |
402 | 431 | // |
403 | 432 | rowData.clear(); |
@@ -408,6 +437,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
408 | 437 | |
409 | 438 | // 現在日時 |
410 | 439 | String curDateTime = CommonUtils.getDateTime(0); |
440 | + String critDateTime = CommonUtils.getCritDateTime(); | |
411 | 441 | |
412 | 442 | // 繰り返し予約関連 |
413 | 443 | String itecolor = CommonUtils.color2str(env.getIterationItemForeground()); |
@@ -438,6 +468,37 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
438 | 468 | } |
439 | 469 | } |
440 | 470 | |
471 | + // 現在時刻と開始時刻、終了時刻の前後関係をチェックする | |
472 | + long cur_remain = -1; | |
473 | + long cur_wait = 0; | |
474 | + | |
475 | + String cridt = CommonUtils.getDateTime(-env.getCurrentAfter()); | |
476 | + String curdt = CommonUtils.getDateTime(0); | |
477 | + String nextdt = CommonUtils.getDateTime(env.getCurrentBefore()); | |
478 | + | |
479 | + // 開始時刻、終了時刻 | |
480 | + String nextstart = CommonUtils.getDate(CommonUtils.getCalendar(starts.get(n)), false)+" "+ro.getAhh()+":"+ro.getAmm(); | |
481 | + String nextend = CommonUtils.getDate(CommonUtils.getCalendar(ends.get(n)), false)+" "+ro.getZhh()+":"+ro.getZmm(); | |
482 | + | |
483 | + // 予約実行中の場合 | |
484 | + if ( nextstart.compareTo(cridt) <= 0 && cridt.compareTo(nextend) <= 0 || | |
485 | + nextstart.compareTo(curdt) <= 0 && curdt.compareTo(nextend) <= 0) { | |
486 | + cur_remain = CommonUtils.getCompareDateTime(nextend, curdt); | |
487 | + } | |
488 | + // 予約開始まで規定時間以内の場合 | |
489 | + else if ( nextstart.compareTo(cridt) > 0 && nextstart.compareTo(nextdt) <= 0 ) { | |
490 | + cur_wait = CommonUtils.getCompareDateTime(nextstart, curdt); | |
491 | + } | |
492 | + | |
493 | + // オプションに文字列としてセットする | |
494 | + String options = ""; | |
495 | + if ( cur_remain > 0 ) { | |
496 | + options = String.format("終了まで%3d分",cur_remain/60000); | |
497 | + } | |
498 | + else if ( cur_wait > 0 ){ | |
499 | + options = String.format("開始まで%3d分",cur_wait/60000); | |
500 | + } | |
501 | + | |
441 | 502 | ReservedItem sa = new ReservedItem(); |
442 | 503 | |
443 | 504 | sa.pattern = ro.getRec_pattern(); |
@@ -445,6 +506,7 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
445 | 506 | sa.exec = ro.getExec(); |
446 | 507 | sa.trace = ((ro.getPursues())?("追"):("")); |
447 | 508 | sa.auto = ((ro.getAutoreserved())?("○"):("")); |
509 | + sa.options = options; | |
448 | 510 | sa.nextstart = CommonUtils.getDate(CommonUtils.getCalendar(starts.get(n)))+" "+ro.getAhh()+":"+ro.getAmm(); // YYYY/MM/DD(WD) hh:mm |
449 | 511 | sa.end = ro.getZhh()+":"+ro.getZmm(); // hh:mm |
450 | 512 | sa.length = ro.getRec_min(); |
@@ -465,6 +527,8 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
465 | 527 | sa.hide_devicecolor = VALID_DEVNAME_COLOR; |
466 | 528 | sa.hide_tunershort = ro.getTunershort(); |
467 | 529 | sa.hide_recorded = ro.getRecorded(); |
530 | + sa.hide_nextstart = nextstart; | |
531 | + sa.hide_nextend = nextend; | |
468 | 532 | |
469 | 533 | sa.fireChanged(); |
470 | 534 |
@@ -483,6 +547,8 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
483 | 547 | ((DefaultTableModel)jTable_rowheader.getModel()).fireTableDataChanged(); |
484 | 548 | |
485 | 549 | setOverlapMark(); |
550 | + | |
551 | + startTimer(); | |
486 | 552 | } |
487 | 553 | |
488 | 554 | private String getRec_mode(ReserveList reserve) { String s = ((reserve.getAppsRsv())?(reserve.getRec_mvchapter()):(reserve.getRec_mode())); return (s==null)?(""):(s); } |
@@ -680,6 +746,44 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
680 | 746 | ******************************************************************************/ |
681 | 747 | |
682 | 748 | /** |
749 | + * 現在時刻追従処理 | |
750 | + */ | |
751 | + @Override | |
752 | + public void timerRised(VWTimerRiseEvent e) { | |
753 | + if ( ! timer_now_enabled ) { | |
754 | + return; | |
755 | + } | |
756 | + | |
757 | + stopTimer(false); | |
758 | + | |
759 | + // 更新前に選択していた行を確認する | |
760 | + String rsvid = null; | |
761 | + { | |
762 | + int row = jTable_rsved.getSelectedRow(); | |
763 | + if ( row >= 0 ) { | |
764 | + int vrow = jTable_rsved.convertRowIndexToModel(row); | |
765 | + rsvid = rowData.get(vrow).hide_rsvid; | |
766 | + } | |
767 | + } | |
768 | + | |
769 | + // タイマーはこの中で再開される | |
770 | + _redrawReservedList(); | |
771 | + | |
772 | + // 更新前に選択していた行を再度選択する | |
773 | + if ( rsvid != null ) { | |
774 | + int vrow = -1; | |
775 | + for ( ReservedItem c : rowData ) { | |
776 | + vrow++; | |
777 | + if ( c.hide_rsvid.equals(rsvid) ) { | |
778 | + int row = jTable_rsved.convertRowIndexToView(vrow); | |
779 | + jTable_rsved.setRowSelectionInterval(row,row); | |
780 | + break; | |
781 | + } | |
782 | + } | |
783 | + } | |
784 | + } | |
785 | + | |
786 | + /** | |
683 | 787 | * タブが開かれたら表を書き換える |
684 | 788 | * ★synchronized(rowData)★ |
685 | 789 | * @see #redrawReservedList() |
@@ -892,6 +996,30 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
892 | 996 | public void setDisabledColor(Color c) { disabledColor = c; } |
893 | 997 | private Color disabledColor = new Color(180,180,180); |
894 | 998 | |
999 | + // 過去の予約の背景色 | |
1000 | + public void setPassedColor(Color c) { passedColor = c; } | |
1001 | + private Color passedColor = CommonUtils.str2color(PASSED_COLOR); | |
1002 | + | |
1003 | + // 実行中の予約の背景色 | |
1004 | + private Color currentColorEven = CommonUtils.str2color(CURRENT_COLOR_EVEN); | |
1005 | + private Color currentColorOdd = CommonUtils.str2color(CURRENT_COLOR_ODD); | |
1006 | + | |
1007 | + // 実行中の予約の背景色をセットする | |
1008 | + public void setCurrentColor(Color c) { | |
1009 | + if ( c == null ) { | |
1010 | + currentColorEven = null; | |
1011 | + currentColorOdd = null; | |
1012 | + } | |
1013 | + else { | |
1014 | + currentColorOdd = c; | |
1015 | + currentColorEven = new Color( | |
1016 | + ((c.getRed()>=247)?(255):(c.getRed()+8)), | |
1017 | + ((c.getGreen()>=247)?(255):(c.getGreen()+8)), | |
1018 | + ((c.getBlue()>=247)?(255):(c.getBlue()+8)) | |
1019 | + ); | |
1020 | + } | |
1021 | + } | |
1022 | + | |
895 | 1023 | public void setTunerShortColor(Color c) { tunershortColor = c; } |
896 | 1024 | private Color tunershortColor = new Color(255,255,0); |
897 | 1025 |
@@ -902,6 +1030,9 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
902 | 1030 | private boolean prechkdisabled = false; |
903 | 1031 | private boolean prechktunershort = false; |
904 | 1032 | private boolean prechkrecorded = false; |
1033 | + private boolean prechkpassed = false; | |
1034 | + private boolean prechkcurrent = false; | |
1035 | + private boolean prechknextweek = false; | |
905 | 1036 | |
906 | 1037 | @Override |
907 | 1038 | public Component prepareRenderer(TableCellRenderer tcr, int row, int column) { |
@@ -915,7 +1046,14 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
915 | 1046 | else { |
916 | 1047 | fgColor = this.getForeground(); |
917 | 1048 | isRowPassed(row); |
918 | - if ( prechkdisabled ) { | |
1049 | + | |
1050 | +// fgColor = (prechknextweek)?(nextweekFgColor):(this.getForeground()); | |
1051 | + | |
1052 | + // 過去の予約の場合 | |
1053 | + if( prechkpassed && passedColor != null ) { | |
1054 | + bgColor = passedColor; | |
1055 | + } | |
1056 | + else if ( prechkdisabled ) { | |
919 | 1057 | bgColor = disabledColor; |
920 | 1058 | } |
921 | 1059 | else if ( prechktunershort ) { |
@@ -924,6 +1062,10 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
924 | 1062 | else if ( prechkrecorded ) { |
925 | 1063 | bgColor = recordedColor; |
926 | 1064 | } |
1065 | + // 実行中の予約の場合 | |
1066 | + else if( prechkcurrent && currentColorEven != null ) { | |
1067 | + bgColor = (isSepRowColor && row%2 == 1)?(currentColorEven):(currentColorOdd); | |
1068 | + } | |
927 | 1069 | else { |
928 | 1070 | bgColor = (isSepRowColor && row%2 == 1)?(evenColor):(super.getBackground()); |
929 | 1071 | } |
@@ -947,6 +1089,10 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
947 | 1089 | int row = this.convertRowIndexToModel(prow); |
948 | 1090 | ReservedItem c = rowView.get(row); |
949 | 1091 | |
1092 | + prechkpassed = false; | |
1093 | + prechkcurrent = false; | |
1094 | + prechknextweek = false; | |
1095 | + | |
950 | 1096 | { |
951 | 1097 | // 実行可能かどうか |
952 | 1098 | prechkrow = prow; |
@@ -954,6 +1100,21 @@ public abstract class AbsReserveListView extends JScrollPane { | ||
954 | 1100 | prechktunershort = c.hide_tunershort; |
955 | 1101 | prechkrecorded = c.hide_recorded; |
956 | 1102 | } |
1103 | + { | |
1104 | + // 終了済みの番組か否か | |
1105 | + String cDT = CommonUtils.getDateTime(0); | |
1106 | + | |
1107 | + prechkpassed = (cDT.compareTo(c.hide_nextend) >= 0); | |
1108 | + if ( ! prechkpassed ) { | |
1109 | + // 現在放送中 | |
1110 | + prechkcurrent = (cDT.compareTo(c.hide_nextstart) >= 0); | |
1111 | + } | |
1112 | + if ( ! prechkcurrent ) { | |
1113 | + // 来週かな | |
1114 | + String critDT = CommonUtils.getCritDateTime(7); | |
1115 | + prechknextweek = (critDT.compareTo(c.hide_nextstart) <= 0); | |
1116 | + } | |
1117 | + } | |
957 | 1118 | |
958 | 1119 | return true; |
959 | 1120 | } |
@@ -5295,6 +5295,7 @@ public class Viewer extends JFrame implements ChangeListener,VWTimerRiseListener | ||
5295 | 5295 | timer_now.addVWTimerRiseListener(this); |
5296 | 5296 | timer_now.addVWTimerRiseListener(listed); |
5297 | 5297 | timer_now.addVWTimerRiseListener(paper); |
5298 | + timer_now.addVWTimerRiseListener(reserved); | |
5298 | 5299 | |
5299 | 5300 | // タイマー起動 |
5300 | 5301 | timer_now.start(); |