3 import java.awt.Color;
\r
4 import java.awt.Dimension;
\r
5 import java.awt.event.ActionEvent;
\r
6 import java.awt.event.ActionListener;
\r
7 import java.awt.event.ItemEvent;
\r
8 import java.awt.event.ItemListener;
\r
9 import java.awt.event.MouseAdapter;
\r
10 import java.awt.event.MouseEvent;
\r
11 import java.util.ArrayList;
\r
12 import java.util.regex.Matcher;
\r
13 import java.util.regex.Pattern;
\r
14 import java.util.regex.PatternSyntaxException;
\r
16 import javax.swing.DefaultComboBoxModel;
\r
17 import javax.swing.JButton;
\r
18 import javax.swing.JComboBox;
\r
19 import javax.swing.JDialog;
\r
20 import javax.swing.JLabel;
\r
21 import javax.swing.JOptionPane;
\r
22 import javax.swing.JPanel;
\r
23 import javax.swing.JScrollPane;
\r
24 import javax.swing.JTextField;
\r
25 import javax.swing.ListSelectionModel;
\r
26 import javax.swing.SpringLayout;
\r
27 import javax.swing.SwingConstants;
\r
28 import javax.swing.table.DefaultTableColumnModel;
\r
29 import javax.swing.table.DefaultTableModel;
\r
31 import tainavi.SearchKey.TargetId;
\r
32 import tainavi.TVProgram.ProgGenre;
\r
33 import tainavi.TVProgram.ProgSubgenre;
\r
37 * キーワード検索の設定のクラス(延長警告管理でも流用する)
\r
39 abstract class AbsKeywordDialog extends JDialog {
\r
41 private static final long serialVersionUID = 1L;
\r
43 public void setWindowTitle(String s) { windowTitle = s; }
\r
45 /*******************************************************************************
\r
47 ******************************************************************************/
\r
49 abstract void preview(SearchKey search);
\r
51 /*******************************************************************************
\r
53 ******************************************************************************/
\r
57 private static final int PARTS_HEIGHT = 30;
\r
58 private static final int SEP_WIDTH = 10;
\r
59 private static final int SEP_HEIGHT = 10;
\r
60 private static final int SEP_HEIGHT_NARROW = 3;
\r
62 private static final int LABEL_WIDTH_S = 50;
\r
63 private static final int LABEL_WIDTH_L = 75;
\r
65 private static final int TEXT_WIDTH = 300;
\r
67 private static final int UPDOWN_WIDTH = 50;
\r
68 private static final int BUTTON_WIDTH_S = 75;
\r
69 private static final int BUTTON_WIDTH_L = 100;
\r
71 private static final int TARGET_WIDTH = 175;
\r
72 private static final int REGEX_WIDTH = 300;
\r
74 private static final int CHECKBOX_WIDTH = 200;
\r
75 private static final int CHECKLABEL_WIDTH = CHECKBOX_WIDTH-25;
\r
77 private static final int CONDITION_WIDTH = 220;
\r
79 private static final int SELECTION_WIDTH = 150;
\r
81 private static final int TABLE_WIDTH = REGEX_WIDTH+TARGET_WIDTH*2+SEP_WIDTH*2; // スクロールバー分
\r
82 private static final int TABLEPANE_WIDTH = TABLE_WIDTH+25; // スクロールバー分
\r
83 private static final int TABLE_HEIGHT = 160;
\r
85 private static final int PANEL_WIDTH = TABLEPANE_WIDTH+UPDOWN_WIDTH+SEP_WIDTH*2;
\r
89 private static enum KDColumn {
\r
90 TARGET ("", TARGET_WIDTH+SEP_WIDTH/2),
\r
91 REGEX ("", REGEX_WIDTH+SEP_WIDTH),
\r
92 CONTAIN ("", TARGET_WIDTH+SEP_WIDTH/2)
\r
95 private String name;
\r
96 private int iniWidth;
\r
98 private KDColumn(String name, int iniWidth) {
\r
100 this.iniWidth = iniWidth;
\r
103 public String getName() {
\r
107 public int getIniWidth() {
\r
111 public int getColumn() {
\r
116 /*******************************************************************************
\r
118 ******************************************************************************/
\r
122 private JPanel jPanel = null;
\r
123 private JLabel jLabel_label = null;
\r
124 private JTextField jTextField_label = null;
\r
125 private JButton jButton_label = null;
\r
126 private JButton jButton_cancel = null;
\r
127 private JButton jButton_preview = null;
\r
128 private JComboBox jComboBox_target = null;
\r
129 private JComboBox jComboBox_regex = null;
\r
130 private JComboBox jComboBox_contain = null;
\r
131 private JButton jButton_add = null;
\r
132 private JButton jButton_replace = null;
\r
133 private JButton jButton_remove = null;
\r
134 private JComboBox jComboBox_condition = null;
\r
135 private JComboBox jComboBox_infection = null;
\r
136 private JScrollPane jScrollPane_keywords = null;
\r
137 private KDTable jTable_keywords = null;
\r
138 private JLabel jLabel_okiniiri = null;
\r
139 private JComboBox jComboBox_okiniiri = null;
\r
140 private JLabel jLabel_group = null;
\r
141 private JComboBox jComboBox_group = null;
\r
142 private JCheckBoxPanel jCheckBox_caseSensitive = null;
\r
143 private JCheckBoxPanel jCheckBox_showInStandby = null;
\r
144 private JButton jButton_up = null;
\r
145 private JButton jButton_down = null;
\r
149 private String windowTitle = "";
\r
150 private SearchProgram xKeys = null;
\r
151 private SearchGroupList xGroups = null;
\r
152 private SearchKey xKey = null;
\r
154 private boolean reg = false;
\r
156 private int selectedRow = -1;
\r
158 private ArrayList<TargetId> target_items = new ArrayList<TargetId>();
\r
159 private ArrayList<String> contain_items = new ArrayList<String>();
\r
160 private ArrayList<String> condition_items = new ArrayList<String>();
\r
161 private ArrayList<String> infection_items = new ArrayList<String>();
\r
162 private ArrayList<String> okiniiri_items = new ArrayList<String>();
\r
163 public void clean_target_items() { target_items.clear(); }
\r
164 public void add_target_item(TargetId ti) { target_items.add(ti); }
\r
165 public void clean_contain_items() { contain_items.clear(); }
\r
166 public void add_contain_item(String s) { contain_items.add(s); }
\r
167 public void clean_condition_items() { condition_items.clear(); }
\r
168 public void add_condition_item(String s) { condition_items.add(s); }
\r
169 public void clean_infection_items() { infection_items.clear(); }
\r
170 public void add_infection_item(String s) { infection_items.add(s); }
\r
171 public void clean_okiniiri_items() { okiniiri_items.clear(); }
\r
172 public void add_okiniiri_item(String s) { okiniiri_items.add(s); }
\r
176 public String getNewLabel() { return jTextField_label.getText(); }
\r
177 public String getNewGroup() { return (String)jComboBox_group.getSelectedItem(); }
\r
179 /*******************************************************************************
\r
181 ******************************************************************************/
\r
183 public AbsKeywordDialog() {
\r
194 this.setModal(true);
\r
195 this.setContentPane(getJPanel());
\r
196 // タイトルバーの高さも考慮する必要がある
\r
197 Dimension d = getJPanel().getPreferredSize();
\r
199 this.setPreferredSize(new Dimension(
\r
200 d.width+(this.getInsets().left+this.getInsets().right),
\r
201 d.height+(this.getInsets().top+this.getInsets().bottom)));
\r
202 this.setResizable(false);
\r
204 this.setTitle(windowTitle);
\r
207 /*******************************************************************************
\r
209 ******************************************************************************/
\r
216 public boolean isRegistered() { return reg; }
\r
218 /***************************************
\r
220 **************************************/
\r
222 // キーワード検索管理としてのオープン(右クリックメニューから新規)
\r
223 public void open(SearchProgram sKeys, SearchGroupList gList, ProgDetailList tvd) {
\r
225 SearchKey sK = new SearchKey();
\r
229 sK.setCondition("0");
\r
230 sK.alTarget.add(TargetId.TITLE);
\r
231 sK.alContain.add("0");
\r
232 sK.alKeyword.add(tvd.title);
\r
237 sK.setCondition("0");
\r
238 sK.alTarget.add(TargetId.CHANNEL);
\r
239 sK.alContain.add("0");
\r
240 sK.alKeyword.add(tvd.center);
\r
243 sK.setCaseSensitive(false);
\r
244 sK.setShowInStandby(true);
\r
246 open(tvd.title,sKeys,gList,sK);
\r
249 // キーワード検索管理としてのオープン(ツールバーから新規)
\r
250 public void open(String label, SearchProgram sKeys, SearchGroupList gList, SearchKey sK) {
\r
257 jComboBox_target.setSelectedIndex(0);
\r
258 jComboBox_contain.setSelectedIndex(0);
\r
259 jComboBox_condition.setSelectedIndex(0);
\r
260 for (int i=jTable_keywords.getRowCount()-1; i>=0; i--) {
\r
261 jTable_keywords.getRowItemList().remove(i);
\r
264 for (int i=0; i<sK.alTarget.size(); i++) {
\r
265 KDItem data = new KDItem();
\r
266 data.target = sK.alTarget.get(i);
\r
267 data.regex = sK.alKeyword.get(i);
\r
268 data.contain = contain_items.get(Integer.valueOf(sK.alContain.get(i)));
\r
269 data.fireChanged();
\r
270 jTable_keywords.getRowItemList().add(data);
\r
272 jTable_keywords.fireChanged();
\r
275 jTextField_label.setText(label);
\r
276 jTextField_label.setCaretPosition(0);
\r
279 if ( xGroups != null && xGroups.size() != 0 ) {
\r
280 jComboBox_group.setEnabled(true);
\r
281 jComboBox_group.addItem("");
\r
282 for ( SearchGroup gr : xGroups ) {
\r
283 jComboBox_group.addItem(gr.getName());
\r
288 jComboBox_okiniiri.setEnabled(true);
\r
289 jCheckBox_caseSensitive.setSelected(sK.getCaseSensitive());
\r
290 jCheckBox_showInStandby.setSelected(sK.getShowInStandby());
\r
291 jCheckBox_showInStandby.setEnabled(true);
\r
294 jButton_add.setText("登録");
\r
297 // 延長警告管理としてのオープン(新規)
\r
298 public void open(String title, String center, boolean isInfection, SearchProgram sKeys) {
\r
305 jTextField_label.setText("●"+title);
\r
308 jTextField_label.setText("○"+title);
\r
310 jTextField_label.setCaretPosition(0);
\r
312 jComboBox_regex.addItem("");
\r
313 jComboBox_target.setSelectedIndex(0);
\r
314 jComboBox_contain.setSelectedIndex(0);
\r
315 jComboBox_condition.setSelectedIndex(0);
\r
316 for (int i=jTable_keywords.getRowCount()-1; i>=0; i--) {
\r
317 jTable_keywords.getRowItemList().remove(i);
\r
320 KDItem d1 = new KDItem();
\r
321 d1.target = TargetId.TITLE;
\r
323 d1.contain = (String) jComboBox_contain.getItemAt(0);
\r
325 jTable_keywords.getRowItemList().add(d1);
\r
327 KDItem d2 = new KDItem();
\r
328 d2.target = TargetId.CHANNEL;
\r
330 d2.contain = (String) jComboBox_contain.getItemAt(0);
\r
333 jComboBox_infection.setSelectedItem(infection_items.get(0));
\r
336 jComboBox_infection.setSelectedItem(infection_items.get(1));
\r
338 jTable_keywords.getRowItemList().add(d2);
\r
340 jTable_keywords.fireChanged();
\r
343 jComboBox_okiniiri.setEnabled(false);
\r
344 jCheckBox_caseSensitive.setSelected(false);
\r
345 jCheckBox_showInStandby.setSelected(false);
\r
346 jCheckBox_showInStandby.setEnabled(false);
\r
349 jButton_label.setText("登録");
\r
352 /***************************************
\r
354 **************************************/
\r
356 // キーワード検索管理としてのオープン(更新)
\r
357 public void reopen(String label, SearchProgram sKeys) {
\r
362 for (SearchKey k : xKeys.getSearchKeys()) {
\r
363 if (k.getLabel().equals(label)) {
\r
371 // 延長警告管理としてのオープン(更新)
\r
372 public void reopen(String label, ExtProgram sKeys) {
\r
377 for (SearchKey k : sKeys.getSearchKeys()) {
\r
378 if (k.getLabel().equals(label)) {
\r
380 int idx = Integer.valueOf(k.getInfection());
\r
381 if (jComboBox_infection.getItemCount() >= idx) {
\r
382 jComboBox_infection.setSelectedIndex(idx);
\r
384 _reopen((SearchProgram)sKeys, k);
\r
390 private void _reopen(SearchProgram sKeys, SearchKey sKey) {
\r
394 jComboBox_regex.addItem("");
\r
395 jComboBox_target.setSelectedIndex(0);
\r
396 jComboBox_contain.setSelectedIndex(0);
\r
397 jComboBox_condition.setSelectedIndex(0);
\r
398 for (int i=jTable_keywords.getRowCount()-1; i>=0; i--) {
\r
399 jTable_keywords.getRowItemList().remove(i);
\r
402 jComboBox_condition.setSelectedIndex(Integer.valueOf(xKey.getCondition()));
\r
404 Matcher ma = Pattern.compile("(.*?)\t").matcher(xKey.getTarget());
\r
405 Matcher mb = Pattern.compile("(.*?)\t").matcher(xKey.getKeyword());
\r
406 Matcher mc = Pattern.compile("(.*?)\t").matcher(xKey.getContain());
\r
407 while (ma.find()) {
\r
410 KDItem data = new KDItem();
\r
411 data.target = TargetId.getTargetId(ma.group(1));
\r
412 data.regex = mb.group(1);
\r
413 data.contain = contain_items.get(Integer.valueOf(mc.group(1)));
\r
414 data.fireChanged();
\r
415 jTable_keywords.getRowItemList().add(data);
\r
418 jComboBox_okiniiri.setSelectedItem(xKey.getOkiniiri());
\r
420 jCheckBox_caseSensitive.setSelected(xKey.getCaseSensitive());
\r
421 if ( sKeys instanceof ExtProgram ) {
\r
422 jComboBox_okiniiri.setEnabled(false);
\r
423 jCheckBox_showInStandby.setSelected(false);
\r
424 jCheckBox_showInStandby.setEnabled(false);
\r
427 jComboBox_okiniiri.setEnabled(true);
\r
428 jCheckBox_showInStandby.setSelected(xKey.getShowInStandby());
\r
429 jCheckBox_showInStandby.setEnabled(true);
\r
432 jTextField_label.setText(xKey.getLabel());
\r
433 jTextField_label.setCaretPosition(0);
\r
436 jTable_keywords.fireChanged();
\r
439 jButton_label.setText("更新");
\r
445 protected SearchKey skCompile() {
\r
447 SearchKey sk = new SearchKey();
\r
452 for (int row=0; row<jTable_keywords.getRowCount(); row++) {
\r
454 KDItem c = jTable_keywords.getRowItemList().get(row);
\r
455 TargetId ti = c.target;
\r
456 tStr += ti.getId()+"\t";
\r
458 if ( ti.getUseRegexpr() ) {
\r
460 Pattern.compile(TraceProgram.replacePop(c.regex));
\r
462 catch (PatternSyntaxException ex) {
\r
463 showExprFmtWarn(c.contain);
\r
467 rStr += c.regex+"\t";
\r
469 for (int i=0; i<contain_items.size(); i++) {
\r
470 if (contain_items.get(i).equals(c.contain)) {
\r
476 sk.setTarget(tStr); // compile後は順番が変わるので残すことにする
\r
477 sk.setKeyword(rStr); // 同上
\r
478 sk.setContain(cStr); // 同上
\r
480 for (int i=0; i<condition_items.size(); i++) {
\r
481 if (condition_items.get(i).equals((String) jComboBox_condition.getSelectedItem())) {
\r
482 sk.setCondition(String.valueOf(i));
\r
486 for (int i=0; i<infection_items.size(); i++) {
\r
487 if (infection_items.get(i).equals((String) jComboBox_infection.getSelectedItem())) {
\r
488 sk.setInfection(String.valueOf(i));
\r
493 sk.setLabel(jTextField_label.getText());
\r
494 sk.setOkiniiri((String) jComboBox_okiniiri.getSelectedItem());
\r
495 sk.setCaseSensitive(jCheckBox_caseSensitive.isSelected());
\r
496 sk.setShowInStandby(jCheckBox_showInStandby.isSelected());
\r
498 new SearchProgram().compile(sk);
\r
504 * 正規表現がおかしかったら警告したい
\r
507 private void showExprFmtWarn(String expr) {
\r
508 JOptionPane.showMessageDialog(this, "正規表現の文法に則っていません: "+expr, "エラー", JOptionPane.ERROR_MESSAGE);
\r
511 /*******************************************************************************
\r
513 ******************************************************************************/
\r
518 private final ActionListener al_save = new ActionListener() {
\r
520 public void actionPerformed(ActionEvent e) {
\r
522 if ( addToSearchKeyList() ) {
\r
528 private boolean addToSearchKeyList() {
\r
529 if (jTextField_label.getText().equals("") || jTable_keywords.getRowCount()<=0) {
\r
534 for ( SearchKey k : xKeys.getSearchKeys() ) {
\r
535 if ( k != xKey && k.getLabel().equals(getNewLabel()) ) {
\r
536 JOptionPane.showConfirmDialog(this, "既に登録されています:"+getNewLabel(), "警告", JOptionPane.CLOSED_OPTION); // キーワード検索の追加ではダイアログで修正できるので止めない
\r
541 SearchKey sk = skCompile();
\r
547 if ( xKey == null ) {
\r
551 xKeys.replace(xKey, sk);
\r
553 reg = xKeys.save();
\r
556 String grpName = (String)jComboBox_group.getSelectedItem();
\r
557 if ( grpName != null && grpName.length() > 0 ) {
\r
558 xGroups.add(grpName,sk.getLabel());
\r
568 private final ActionListener al_cancel = new ActionListener() {
\r
570 public void actionPerformed(ActionEvent e) {
\r
578 private final ActionListener al_preview = new ActionListener() {
\r
580 public void actionPerformed(ActionEvent e) {
\r
581 SearchKey sk = skCompile();
\r
582 if (jTable_keywords.getRowCount() > 0 && sk != null) {
\r
589 * 条件選択コンボボックスが選択された
\r
591 private final ItemListener il_targetChanged = new ItemListener() {
\r
593 public void itemStateChanged(ItemEvent e) {
\r
595 if ( e.getStateChange() != ItemEvent.SELECTED ) {
\r
599 TargetId target = (TargetId) jComboBox_target.getSelectedItem();
\r
601 jComboBox_regex.setEditable(target.getUseRegexpr());
\r
602 jComboBox_regex.setEnabled(target.getUseKeyword());
\r
603 jComboBox_regex.removeAllItems();
\r
605 if (target == TargetId.LENGTH) {
\r
606 for (int i=1; i <= 120; i++) {
\r
607 jComboBox_regex.addItem(i+" 分以上である");
\r
609 jComboBox_regex.setSelectedIndex(29);
\r
611 else if (target == TargetId.STARTA) {
\r
612 for (int i=0; i < 24; i++) {
\r
613 jComboBox_regex.addItem(String.format("%02d:00以降である", (i+5)%24));
\r
615 jComboBox_regex.setSelectedIndex(18-5);
\r
617 else if (target == TargetId.STARTZ) {
\r
618 for (int i=0; i < 24; i++) {
\r
619 jComboBox_regex.addItem(String.format("%02d:00以前である", (i+5)%24));
\r
621 jComboBox_regex.setSelectedIndex(23-5);
\r
623 else if (target == TargetId.GENRE) {
\r
624 for ( ProgGenre genre : ProgGenre.values()) {
\r
625 jComboBox_regex.addItem(genre.toString());
\r
628 else if (target == TargetId.SUBGENRE) {
\r
629 for ( ProgSubgenre subgenre : ProgSubgenre.values()) {
\r
630 jComboBox_regex.addItem(subgenre.toString());
\r
634 jComboBox_regex.addItem("");
\r
643 private final ActionListener al_addTarget = new ActionListener() {
\r
645 public void actionPerformed(ActionEvent e) {
\r
646 TargetId ti = (TargetId) jComboBox_target.getSelectedItem();
\r
647 String re = (String) jComboBox_regex.getSelectedItem();
\r
649 if ( ti.getUseKeyword() && re.length() == 0 ) {
\r
650 // キーワードが必要なのに入力されていなければNG
\r
654 KDItem data = new KDItem();
\r
657 data.contain = (String) jComboBox_contain.getSelectedItem();
\r
658 data.fireChanged();
\r
659 if ( selectedRow == -1 ) {
\r
660 jTable_keywords.getRowItemList().add(data);
\r
663 jTable_keywords.getRowItemList().add(selectedRow+1, data);
\r
665 jTable_keywords.fireChanged();
\r
667 if (jComboBox_regex.getItemCount() <= 1) {
\r
668 jComboBox_regex.removeAllItems();
\r
669 jComboBox_regex.addItem("");
\r
673 jButton_replace.setEnabled(false);
\r
674 jButton_remove.setEnabled(false);
\r
682 private final ActionListener al_replaceTarget = new ActionListener() {
\r
684 public void actionPerformed(ActionEvent e) {
\r
685 if ( selectedRow == -1 ) {
\r
689 TargetId ti = (TargetId) jComboBox_target.getSelectedItem();
\r
690 String re = (String) jComboBox_regex.getSelectedItem();
\r
692 if ( ti.getUseKeyword() && re.length() == 0 ) {
\r
693 // キーワードが必要なのに入力されていなければNG
\r
697 KDItem data = jTable_keywords.getRowItemList().get(selectedRow);
\r
700 data.contain = (String) jComboBox_contain.getSelectedItem();
\r
701 data.fireChanged();
\r
702 jTable_keywords.fireChanged();
\r
704 if (jComboBox_regex.getItemCount() <= 1) {
\r
705 jComboBox_regex.removeAllItems();
\r
706 jComboBox_regex.addItem("");
\r
710 jButton_replace.setEnabled(false);
\r
711 jButton_remove.setEnabled(false);
\r
717 * 条件を削除する(コンボボックスに戻す)
\r
719 private final ActionListener al_removeTarget = new ActionListener() {
\r
721 public void actionPerformed(ActionEvent e) {
\r
722 if ( selectedRow == -1 ) {
\r
726 jTable_keywords.getRowItemList().remove(selectedRow);
\r
727 jTable_keywords.fireChanged();
\r
730 jButton_replace.setEnabled(false);
\r
731 jButton_remove.setEnabled(false);
\r
738 private final ActionListener al_upTarget = new ActionListener() {
\r
740 public void actionPerformed(ActionEvent e) {
\r
741 int row = jTable_keywords.getSelectedRow();
\r
742 if ( jTable_keywords.getRowItemList().up(row, 1) ) {
\r
743 jTable_keywords.fireChanged();
\r
744 jTable_keywords.setRowSelectionInterval(row-1,row-1);
\r
745 selectedRow = row-1;
\r
753 private final ActionListener al_downTarget = new ActionListener() {
\r
755 public void actionPerformed(ActionEvent e) {
\r
756 int row = jTable_keywords.getSelectedRow();
\r
757 if ( jTable_keywords.getRowItemList().down(row, 1) ) {
\r
758 jTable_keywords.fireChanged();
\r
759 jTable_keywords.setRowSelectionInterval(row+1,row+1);
\r
760 selectedRow = row+1;
\r
766 * 行を選択したら編集ブロックにコピーする
\r
768 private final MouseAdapter ml_keywordSelected = new MouseAdapter() {
\r
770 public void mouseClicked(MouseEvent e) {
\r
771 int row = jTable_keywords.getSelectedRow();
\r
776 KDItem c = jTable_keywords.getRowItemList().get(row);
\r
778 jComboBox_target.setSelectedItem(c.target);
\r
780 if ( ! c.target.getUseRegexpr() && c.target.getUseKeyword() ) {
\r
781 jComboBox_regex.setSelectedItem(c.regex);
\r
784 jComboBox_regex.removeAllItems();
\r
785 if ( c.target.getUseRegexpr() ) {
\r
786 jComboBox_regex.addItem(c.regex);
\r
790 jComboBox_contain.setSelectedItem(c.contain);
\r
793 jButton_replace.setEnabled(true);
\r
794 jButton_remove.setEnabled(true);
\r
799 /*******************************************************************************
\r
801 ******************************************************************************/
\r
803 private JPanel getJPanel() {
\r
804 if (jPanel == null) {
\r
805 jPanel = new JPanel();
\r
807 jPanel.setLayout(new SpringLayout());
\r
809 int y = SEP_HEIGHT;
\r
813 CommonSwingUtils.putComponentOn(jPanel, getJLabel_label("設定名"), LABEL_WIDTH_S, PARTS_HEIGHT, x, y);
\r
814 CommonSwingUtils.putComponentOn(jPanel, getJTextField_label(), TEXT_WIDTH, PARTS_HEIGHT, x+=LABEL_WIDTH_S, y);
\r
815 CommonSwingUtils.putComponentOn(jPanel, getJButton_label("登録"), BUTTON_WIDTH_S, PARTS_HEIGHT, x+=TEXT_WIDTH+SEP_WIDTH, y);
\r
816 CommonSwingUtils.putComponentOn(jPanel, getJButton_cancel("キャンセル"), BUTTON_WIDTH_S, PARTS_HEIGHT, x+=BUTTON_WIDTH_S+SEP_WIDTH, y);
\r
817 CommonSwingUtils.putComponentOn(jPanel, getJButton_preview("プレビュー"), BUTTON_WIDTH_S, PARTS_HEIGHT, PANEL_WIDTH-BUTTON_WIDTH_S-SEP_WIDTH, y);
\r
819 y += PARTS_HEIGHT+SEP_HEIGHT;
\r
821 CommonSwingUtils.putComponentOn(jPanel, getJComboBox_target(), TARGET_WIDTH, PARTS_HEIGHT, x, y);
\r
822 CommonSwingUtils.putComponentOn(jPanel, getJTextField_regex(), REGEX_WIDTH, PARTS_HEIGHT, x+=TARGET_WIDTH+SEP_WIDTH, y);
\r
823 CommonSwingUtils.putComponentOn(jPanel, getJComboBox_contain(), TARGET_WIDTH, PARTS_HEIGHT, x+=REGEX_WIDTH+SEP_WIDTH, y);
\r
825 y += PARTS_HEIGHT+SEP_HEIGHT_NARROW;
\r
826 x = SEP_HEIGHT+TABLE_WIDTH/2;
\r
827 CommonSwingUtils.putComponentOn(jPanel, getJButton_add("追加↓"), BUTTON_WIDTH_L, PARTS_HEIGHT, x-(BUTTON_WIDTH_L+SEP_WIDTH*2) , y);
\r
828 CommonSwingUtils.putComponentOn(jPanel, getJButton_replace("置換↓"), BUTTON_WIDTH_L, PARTS_HEIGHT, x+(SEP_WIDTH*2), y);
\r
830 CommonSwingUtils.putComponentOn(jPanel, getJCheckBox_caseSensitive("文字列比較は完全一致で",CHECKLABEL_WIDTH,false), CHECKBOX_WIDTH, PARTS_HEIGHT, PANEL_WIDTH-CHECKBOX_WIDTH-SEP_WIDTH, y);
\r
832 y += PARTS_HEIGHT+SEP_HEIGHT_NARROW;
\r
833 CommonSwingUtils.putComponentOn(jPanel, getJComboBox_condition(), CONDITION_WIDTH, PARTS_HEIGHT, SEP_WIDTH, y);
\r
834 CommonSwingUtils.putComponentOn(jPanel, getJComboBox_infection(), CONDITION_WIDTH, PARTS_HEIGHT, TABLE_WIDTH-CONDITION_WIDTH+SEP_WIDTH, y);
\r
836 y += PARTS_HEIGHT+SEP_HEIGHT_NARROW;
\r
837 CommonSwingUtils.putComponentOn(jPanel, getJScrollPane_keywords(), TABLEPANE_WIDTH, TABLE_HEIGHT, SEP_WIDTH, y);
\r
838 int yz = y + (TABLE_HEIGHT/2-(PARTS_HEIGHT+SEP_HEIGHT/2));
\r
839 CommonSwingUtils.putComponentOn(jPanel, getJButton_up("↑"), UPDOWN_WIDTH, PARTS_HEIGHT, TABLEPANE_WIDTH+SEP_WIDTH*2, yz);
\r
840 CommonSwingUtils.putComponentOn(jPanel, getJButton_down("↓"), UPDOWN_WIDTH, PARTS_HEIGHT, TABLEPANE_WIDTH+SEP_WIDTH*2, yz+=SEP_HEIGHT+PARTS_HEIGHT);
\r
841 CommonSwingUtils.putComponentOn(jPanel, getJButton_remove("削除"), UPDOWN_WIDTH, PARTS_HEIGHT, TABLEPANE_WIDTH+SEP_WIDTH*2, yz+=SEP_HEIGHT*2+PARTS_HEIGHT);
\r
843 y += TABLE_HEIGHT+SEP_HEIGHT;
\r
845 CommonSwingUtils.putComponentOn(jPanel, getJLabel_okiniiri("お気に入り度"), LABEL_WIDTH_L, PARTS_HEIGHT, x, y);
\r
846 CommonSwingUtils.putComponentOn(jPanel, getJComboBox_okiniiri(), SELECTION_WIDTH, PARTS_HEIGHT, x+=LABEL_WIDTH_L+SEP_WIDTH, y);
\r
847 CommonSwingUtils.putComponentOn(jPanel, getJLabel_group("グループ"), LABEL_WIDTH_L, PARTS_HEIGHT, x+=SELECTION_WIDTH+SEP_WIDTH, y);
\r
848 CommonSwingUtils.putComponentOn(jPanel, getJComboBox_group(), SELECTION_WIDTH, PARTS_HEIGHT, x+=LABEL_WIDTH_L+SEP_WIDTH, y);
\r
850 CommonSwingUtils.putComponentOn(jPanel, getJCheckBox_showInStandby("予約待機に表示する",CHECKLABEL_WIDTH,true), CHECKBOX_WIDTH, PARTS_HEIGHT, PANEL_WIDTH-CHECKBOX_WIDTH-SEP_WIDTH, y);
\r
852 y += PARTS_HEIGHT+SEP_HEIGHT*2;
\r
854 jPanel.setPreferredSize(new Dimension(PANEL_WIDTH, y));
\r
860 private JLabel getJLabel_label(String s) {
\r
861 if (jLabel_label == null) {
\r
862 jLabel_label = new JLabel(s);
\r
864 return(jLabel_label);
\r
868 private JTextField getJTextField_label() {
\r
869 if (jTextField_label == null) {
\r
870 jTextField_label = new JTextFieldWithPopup();
\r
872 return(jTextField_label);
\r
876 private JButton getJButton_label(String s) {
\r
877 if (jButton_label == null) {
\r
878 jButton_label = new JButton();
\r
879 jButton_label.setText(s);
\r
881 jButton_label.addActionListener(al_save);
\r
883 return(jButton_label);
\r
887 private JButton getJButton_cancel(String s) {
\r
888 if (jButton_cancel == null) {
\r
889 jButton_cancel = new JButton();
\r
890 jButton_cancel.setText(s);
\r
892 jButton_cancel.addActionListener(al_cancel);
\r
894 return jButton_cancel;
\r
898 private JButton getJButton_preview(String s) {
\r
899 if (jButton_preview == null) {
\r
900 jButton_preview = new JButton();
\r
901 jButton_preview.setText(s);
\r
903 jButton_preview.addActionListener(al_preview);
\r
905 return jButton_preview;
\r
910 private JComboBox getJComboBox_target() {
\r
911 if (jComboBox_target == null) {
\r
912 jComboBox_target = new JComboBox();
\r
914 DefaultComboBoxModel aModel = new DefaultComboBoxModel();
\r
915 jComboBox_target.setModel(aModel);
\r
916 for (TargetId k : target_items) {
\r
917 aModel.addElement(k);
\r
920 jComboBox_target.addItemListener(il_targetChanged);
\r
922 return(jComboBox_target);
\r
926 private JComboBox getJTextField_regex() {
\r
927 if (jComboBox_regex == null) {
\r
928 jComboBox_regex = new JComboBoxWithPopup();
\r
929 jComboBox_regex.setEditable(true);
\r
931 return(jComboBox_regex);
\r
935 private JComboBox getJComboBox_contain() {
\r
936 if (jComboBox_contain == null) {
\r
937 jComboBox_contain = new JComboBox();
\r
939 DefaultComboBoxModel aModel = new DefaultComboBoxModel();
\r
940 jComboBox_contain.setModel(aModel);
\r
941 for (String k : contain_items) {
\r
942 aModel.addElement(k);
\r
945 return(jComboBox_contain);
\r
949 private JComboBox getJComboBox_condition() {
\r
950 if (jComboBox_condition == null) {
\r
951 jComboBox_condition = new JComboBox();
\r
953 DefaultComboBoxModel aModel = new DefaultComboBoxModel();
\r
954 jComboBox_condition.setModel(aModel);
\r
955 for (String k : condition_items) {
\r
956 aModel.addElement(k);
\r
959 return(jComboBox_condition);
\r
963 private JComboBox getJComboBox_infection() {
\r
964 if (jComboBox_infection == null) {
\r
965 jComboBox_infection = new JComboBox();
\r
967 if (infection_items.size() > 0) {
\r
968 DefaultComboBoxModel aModel = new DefaultComboBoxModel();
\r
969 jComboBox_infection.setModel(aModel);
\r
970 for (String k : infection_items) {
\r
971 aModel.addElement(k);
\r
975 jComboBox_infection.setEnabled(false);
\r
978 return(jComboBox_infection);
\r
982 private JLabel getJLabel_okiniiri(String s) {
\r
983 if (jLabel_okiniiri == null) {
\r
984 jLabel_okiniiri = new JLabel(s,SwingConstants.RIGHT);
\r
986 return(jLabel_okiniiri);
\r
988 private JComboBox getJComboBox_okiniiri() {
\r
989 if (jComboBox_okiniiri == null) {
\r
990 jComboBox_okiniiri = new JComboBox();
\r
992 DefaultComboBoxModel aModel = new DefaultComboBoxModel();
\r
993 jComboBox_okiniiri.setModel(aModel);
\r
994 for (String k : okiniiri_items) {
\r
995 aModel.addElement(k);
\r
998 return(jComboBox_okiniiri);
\r
1003 private JLabel getJLabel_group(String s) {
\r
1004 if (jLabel_group == null) {
\r
1005 jLabel_group = new JLabel(s,SwingConstants.RIGHT);
\r
1007 return(jLabel_group);
\r
1009 private JComboBox getJComboBox_group() {
\r
1010 if (jComboBox_group == null) {
\r
1011 jComboBox_group = new JComboBox();
\r
1013 jComboBox_group.setEnabled(false);
\r
1015 return(jComboBox_group);
\r
1019 private JCheckBoxPanel getJCheckBox_caseSensitive(String s,int labelWidth, boolean b) {
\r
1020 if (jCheckBox_caseSensitive == null) {
\r
1021 jCheckBox_caseSensitive = new JCheckBoxPanel(s,labelWidth,true);
\r
1022 jCheckBox_caseSensitive.setSelected(b);
\r
1024 return(jCheckBox_caseSensitive);
\r
1028 private JCheckBoxPanel getJCheckBox_showInStandby(String s,int labelWidth, boolean b) {
\r
1029 if (jCheckBox_showInStandby == null) {
\r
1030 jCheckBox_showInStandby = new JCheckBoxPanel(s,labelWidth,true);
\r
1031 jCheckBox_showInStandby.setSelected(b);
\r
1033 return(jCheckBox_showInStandby);
\r
1037 private JButton getJButton_add(String s) {
\r
1038 if (jButton_add == null) {
\r
1039 jButton_add = new JButton();
\r
1040 jButton_add.setText(s);
\r
1041 jButton_add.setEnabled(true);
\r
1043 jButton_add.addActionListener(al_addTarget);
\r
1045 return(jButton_add);
\r
1049 private JButton getJButton_replace(String s) {
\r
1050 if (jButton_replace == null) {
\r
1051 jButton_replace = new JButton();
\r
1052 jButton_replace.setText(s);
\r
1053 jButton_replace.setEnabled(false);
\r
1054 jButton_replace.setForeground(Color.BLUE);
\r
1056 jButton_replace.addActionListener(al_replaceTarget);
\r
1058 return(jButton_replace);
\r
1062 private JButton getJButton_remove(String s) {
\r
1063 if (jButton_remove == null) {
\r
1064 jButton_remove = new JButton();
\r
1065 jButton_remove.setText(s);
\r
1066 jButton_remove.setEnabled(false);
\r
1067 jButton_remove.setForeground(Color.RED);
\r
1069 jButton_remove.addActionListener(al_removeTarget);
\r
1071 return(jButton_remove);
\r
1074 private JButton getJButton_up(String s) {
\r
1075 if (jButton_up == null) {
\r
1076 jButton_up = new JButton();
\r
1077 jButton_up.setText(s);
\r
1079 jButton_up.addActionListener(al_upTarget);
\r
1081 return(jButton_up);
\r
1084 private JButton getJButton_down(String s) {
\r
1085 if (jButton_down == null) {
\r
1086 jButton_down = new JButton();
\r
1087 jButton_down.setText(s);
\r
1089 jButton_down.addActionListener(al_downTarget);
\r
1091 return(jButton_down);
\r
1095 private JScrollPane getJScrollPane_keywords() {
\r
1096 if (jScrollPane_keywords == null) {
\r
1097 jScrollPane_keywords = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
\r
1098 jScrollPane_keywords.setViewportView(getJTable_keywords());
\r
1100 return jScrollPane_keywords;
\r
1104 private KDTable getJTable_keywords() {
\r
1105 if (jTable_keywords == null) {
\r
1107 jTable_keywords = new KDTable(false, new RowItemList<KDItem>());
\r
1110 ArrayList<String> cola = new ArrayList<String>();
\r
1111 for ( KDColumn rc : KDColumn.values() ) {
\r
1112 if ( rc.getIniWidth() >= 0 ) {
\r
1113 cola.add(rc.getName());
\r
1116 jTable_keywords.setModel(new DefaultTableModel(cola.toArray(new String[0]), 0));
\r
1118 jTable_keywords.setAutoResizeMode(JNETable.AUTO_RESIZE_OFF);
\r
1119 jTable_keywords.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
\r
1120 jTable_keywords.getTableHeader().setReorderingAllowed(false);
\r
1123 DefaultTableColumnModel columnModel = (DefaultTableColumnModel)jTable_keywords.getColumnModel();
\r
1124 //TableColumn column = null;
\r
1125 for ( KDColumn rc : KDColumn.values() ) {
\r
1126 if ( rc.getIniWidth() < 0 ) {
\r
1129 columnModel.getColumn(rc.ordinal()).setPreferredWidth(rc.getIniWidth());;
\r
1133 jTable_keywords.addMouseListener(ml_keywordSelected);
\r
1135 return(jTable_keywords);
\r
1138 /*******************************************************************************
\r
1140 ******************************************************************************/
\r
1142 private class KDItem extends RowItem implements Cloneable {
\r
1148 protected void myrefresh(RowItem o) {
\r
1149 KDItem c = (KDItem) o;
\r
1150 c.addData(target);
\r
1152 c.addData(contain);
\r
1156 public KDItem clone() {
\r
1157 return (KDItem) super.clone();
\r
1161 private class KDTable extends JNETable {
\r
1163 private static final long serialVersionUID = 1L;
\r
1165 RowItemList<KDItem> rowdata = null;
\r
1167 public KDTable(boolean b, RowItemList<KDItem> rowdata) {
\r
1169 this.rowdata = rowdata;
\r
1172 public RowItemList<KDItem> getRowItemList() { return rowdata; }
\r
1174 public void fireChanged() { ((DefaultTableModel) this.getModel()).fireTableDataChanged(); }
\r
1177 public int getRowCount() { return rowdata.size(); }
\r
1180 public Object getValueAt(int row, int column) {
\r
1181 return rowdata.get(row).get(column);
\r
1185 public void setValueAt(Object aValue, int row, int column) {
\r
1186 KDItem c = rowdata.get(row);
\r
1187 if ( column == KDColumn.TARGET.getColumn() ) {
\r
1188 c.target = (TargetId) aValue;
\r
1190 else if ( column == KDColumn.REGEX.getColumn() ) {
\r
1191 c.regex = (String) aValue;
\r
1193 else if ( column == KDColumn.CONTAIN.getColumn() ) {
\r
1194 c.contain = (String) aValue;
\r
1201 /*******************************************************************************
\r
1202 * 延長警告管理では以下をオーバーライドしてください
\r
1203 ******************************************************************************/
\r
1205 protected void setItems() {
\r
1206 setWindowTitle("キーワード検索の設定");
\r
1208 clean_target_items();
\r
1209 add_target_item(TargetId.TITLEANDDETAIL);
\r
1210 add_target_item(TargetId.TITLE);
\r
1211 add_target_item(TargetId.DETAIL);
\r
1212 add_target_item(TargetId.CHANNEL);
\r
1213 add_target_item(TargetId.GENRE);
\r
1214 add_target_item(TargetId.SUBGENRE);
\r
1215 add_target_item(TargetId.NEW);
\r
1216 add_target_item(TargetId.LAST);
\r
1217 add_target_item(TargetId.REPEAT);
\r
1218 add_target_item(TargetId.FIRST);
\r
1219 add_target_item(TargetId.SPECIAL);
\r
1220 add_target_item(TargetId.RATING);
\r
1221 add_target_item(TargetId.NOSCRUMBLE);
\r
1222 add_target_item(TargetId.LIVE);
\r
1223 add_target_item(TargetId.BILINGUAL);
\r
1224 add_target_item(TargetId.STANDIN);
\r
1225 add_target_item(TargetId.MULTIVOICE);
\r
1226 add_target_item(TargetId.LENGTH);
\r
1227 add_target_item(TargetId.STARTA);
\r
1228 add_target_item(TargetId.STARTZ);
\r
1229 add_target_item(TargetId.STARTDATETIME);
\r
1231 clean_contain_items();
\r
1232 add_contain_item("を含む番組");
\r
1233 add_contain_item("を含む番組を除く");
\r
1235 clean_condition_items();
\r
1236 add_condition_item("次のすべての条件に一致");
\r
1237 add_condition_item("次のいずれかの条件に一致");
\r
1239 clean_infection_items();
\r
1240 //add_infection_item();
\r
1242 clean_okiniiri_items();
\r
1243 for (String okini : TVProgram.OKINIIRI) {
\r
1244 add_okiniiri_item(okini);
\r