4 import javax.imageio.ImageIO;
\r
5 import javax.swing.SwingUtilities;
\r
6 import java.awt.BorderLayout;
\r
7 import java.awt.Image;
\r
8 import java.awt.Rectangle;
\r
9 import java.awt.event.ActionEvent;
\r
10 import java.awt.event.ActionListener;
\r
11 import java.awt.event.WindowEvent;
\r
12 import java.awt.event.WindowListener;
\r
13 import java.io.BufferedReader;
\r
14 import java.io.BufferedWriter;
\r
15 import java.io.File;
\r
16 import java.io.FileReader;
\r
17 import java.io.FileWriter;
\r
18 import java.io.IOException;
\r
19 import java.net.Authenticator;
\r
20 import java.util.ArrayList;
\r
22 import javax.swing.JPanel;
\r
23 import javax.swing.JFrame;
\r
24 import javax.swing.JSlider;
\r
25 import javax.swing.JTable;
\r
26 import javax.swing.Timer;
\r
27 import javax.swing.event.ChangeEvent;
\r
28 import javax.swing.event.ChangeListener;
\r
29 import javax.swing.table.DefaultTableColumnModel;
\r
30 import javax.swing.table.TableColumn;
\r
31 import javax.swing.JComboBox;
\r
33 import tainavi.RecorderInfo;
\r
34 import tainavi.RecorderInfoList;
\r
36 public class Viewer extends JFrame {
\r
38 private static final long serialVersionUID = 1L;
\r
39 private JPanel jContentPane = null;
\r
40 private JPanel jPanel1 = null;
\r
41 private JComboBox jComboBox = null;
\r
42 private JPanel jPanel2 = null;
\r
43 private JTable jTable = null;
\r
44 private JPanel jPanel3 = null;
\r
45 private JSlider jSlider = null;
\r
46 private Timer jTimer = null;
\r
48 private final String defFile = "env/StatusView.def";
\r
50 private RecorderInfo recorder = null;
\r
53 * 鯛ナビのレコーダ一覧の中で"RD-"を含むもののみ抽出したリスト.
\r
55 private RecorderInfoList recorderList = new RecorderInfoList();
\r
57 private tainavi.GetRDStatus gs = new tainavi.GetRDStatus();
\r
62 * This method initializes jComboBox
\r
64 * @return javax.swing.JComboBox
\r
67 private JPanel getJPanel1() {
\r
68 if (jPanel1 == null) {
\r
69 jPanel1 = new JPanel();
\r
70 jPanel1.setLayout(new BorderLayout());
\r
71 jPanel1.add(jComboBox = new JComboBox(), BorderLayout.CENTER);
\r
73 jComboBox.addItem("");
\r
74 for (RecorderInfo re : recorderList) {
\r
75 jComboBox.addItem(re.getRecorderIPAddr());
\r
78 jComboBox.addActionListener(new ActionListener() {
\r
80 public void actionPerformed(ActionEvent e) {
\r
81 if (jTimer != null) {
\r
85 jTable.setValueAt("", 0, 1);
\r
86 jTable.setValueAt("", 1, 1);
\r
87 jTable.setValueAt("", 2, 1);
\r
88 jTable.setValueAt("", 3, 1);
\r
89 jTable.setValueAt("", 4, 1);
\r
90 jTable.setValueAt("", 5, 1);
\r
91 jTable.setValueAt("", 6, 1);
\r
92 jTable.setValueAt("", 7, 1);
\r
93 jTable.setValueAt("", 8, 1);
\r
94 jTable.setValueAt("", 9, 1);
\r
95 jTable.setValueAt("", 10, 1);
\r
96 jTable.setValueAt("", 11, 1);
\r
97 jTable.setValueAt("", 12, 1);
\r
98 jTable.setValueAt("", 13, 1);
\r
99 jTable.setValueAt("", 14, 1);
\r
100 jTable.setValueAt("", 15, 1);
\r
101 jTable.setValueAt("", 16, 1);
\r
102 jTable.setValueAt("", 17, 1);
\r
103 jTable.setValueAt("", 18, 1);
\r
104 jTable.setValueAt("", 19, 1);
\r
105 jTable.setValueAt("", 20, 1);
\r
107 if (jComboBox.getSelectedItem().equals("")) {
\r
111 recorder = recorderList.get(jComboBox.getSelectedIndex()-1);
\r
113 jTimer = new Timer(1*1000, new ActionListener() {
\r
115 public void actionPerformed(ActionEvent e) {
\r
116 String s = gs.getCurChannel(recorder.getRecorderIPAddr());
\r
118 jTable.setValueAt(gs.mod, 0, 1);
\r
119 jTable.setValueAt(gs.enc, 1, 1);
\r
120 jTable.setValueAt(gs.ch, 2, 1);
\r
121 jTable.setValueAt(gs.typ, 3, 1);
\r
122 jTable.setValueAt(gs.unk, 4, 1);
\r
123 jTable.setValueAt(gs.dvd, 5, 1);
\r
124 jTable.setValueAt(gs.opn, 6, 1);
\r
125 jTable.setValueAt(gs.title_no, 7, 1);
\r
126 jTable.setValueAt(gs.title, 8, 1);
\r
127 jTable.setValueAt(gs.title_len_s, 9, 1);
\r
128 jTable.setValueAt(gs.chapter, 10, 1);
\r
129 jTable.setValueAt(gs.chapter_name, 11, 1);
\r
130 jTable.setValueAt(gs.time_all_s, 12, 1);
\r
131 jTable.setValueAt(gs.time_chap_s, 13, 1);
\r
132 jTable.setValueAt(gs.title_chno, 14, 1);
\r
133 jTable.setValueAt(gs.title_chname, 15, 1);
\r
134 jTable.setValueAt(gs.title_date + " " + gs.title_time, 16, 1);
\r
135 jTable.setValueAt(gs.title_gnr, 17, 1);
\r
136 jTable.setValueAt(gs.title_chcode, 18, 1);
\r
137 jTable.setValueAt(gs.okk, 19, 1);
\r
138 jTable.setValueAt(gs.ply, 20, 1);
\r
140 if (jSlider.getMaximum() != gs.title_len) {
\r
141 jSlider.setMaximum(gs.title_len);
\r
143 jSlider.setValue((gs.time_all>=0)?(gs.time_all):(gs.title_len+gs.time_all));
\r
144 jSlider.updateUI();
\r
147 jTable.setValueAt("切断", 20, 1);
\r
159 private JPanel getJPanel2() {
\r
160 if (jPanel2 == null) {
\r
161 jPanel2 = new JPanel();
\r
166 jPanel2.setLayout(new BorderLayout());
\r
167 jPanel2.add(jTable = new JTable(row,col), BorderLayout.CENTER);
\r
169 DefaultTableColumnModel columnModel = (DefaultTableColumnModel)jTable.getColumnModel();
\r
170 TableColumn column = null;
\r
171 column = columnModel.getColumn(0);
\r
172 column.setPreferredWidth(100);
\r
173 column.setMinWidth(100);
\r
174 column.setMaxWidth(100);
\r
175 column = columnModel.getColumn(1);
\r
176 column.setPreferredWidth(200);
\r
178 jTable.setValueAt("表示メニュー", 0, 0);
\r
179 jTable.setValueAt("W録", 1, 0);
\r
180 jTable.setValueAt("チャンネル", 2, 0);
\r
181 jTable.setValueAt("HDD/DVD", 3, 0);
\r
182 jTable.setValueAt("HDD", 4, 0);
\r
183 jTable.setValueAt("DVD", 5, 0);
\r
184 jTable.setValueAt("トレイ", 6, 0);
\r
185 jTable.setValueAt("タイトル番号", 7, 0);
\r
186 jTable.setValueAt("タイトル名", 8, 0);
\r
187 jTable.setValueAt("長さ", 9, 0);
\r
188 jTable.setValueAt("チャプタ番号", 10, 0);
\r
189 jTable.setValueAt("チャプタ名", 11, 0);
\r
190 jTable.setValueAt("現在位置", 12, 0);
\r
191 jTable.setValueAt("チャプタ内位置", 13, 0);
\r
192 jTable.setValueAt("CH", 14, 0);
\r
193 jTable.setValueAt("チャンネル名", 15, 0);
\r
194 jTable.setValueAt("録画日時", 16, 0);
\r
195 jTable.setValueAt("ジャンル", 17, 0);
\r
196 jTable.setValueAt("放送局コード", 18, 0);
\r
197 jTable.setValueAt("追っかけ", 19, 0);
\r
198 jTable.setValueAt("動作", 20, 0);
\r
203 private JPanel getJPanel3() {
\r
204 if (jPanel3 == null) {
\r
205 jPanel3 = new JPanel();
\r
207 jPanel3.setLayout(new BorderLayout());
\r
208 jPanel3.add(jSlider = new JSlider(0,0,0), BorderLayout.CENTER);
\r
210 jSlider.addChangeListener(new ChangeListener() {
\r
212 public void stateChanged(ChangeEvent e) {
\r
213 if (jSlider.getValueIsAdjusting()) {
\r
215 jTable.setValueAt(gs.getHMS(jSlider.getValue()), 12, 1);
\r
218 if ( ! jTimer.isRunning() && ! gs.ply.equals("") && ! gs.ply.equals("録画") && gs.mod.equals("なし")) {
\r
219 String HMS = gs.getHMS(jSlider.getValue());
\r
221 tainavi.HDDRecorderUtils ru = new tainavi.HDDRecorderUtils();
\r
222 Authenticator.setDefault(ru.new MyAuthenticator(recorder.getRecorderUser(),recorder.getRecorderPasswd()));
\r
224 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/ts.htm?"+jSlider.getValue(), null);
\r
226 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0E", null);
\r
227 tainavi.CommonUtils.milSleep(500);
\r
228 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0E", null);
\r
229 tainavi.CommonUtils.milSleep(100);
\r
230 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0"+HMS.substring(0,1), null);
\r
231 tainavi.CommonUtils.milSleep(100);
\r
232 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0"+HMS.substring(1,2), null);
\r
233 tainavi.CommonUtils.milSleep(100);
\r
234 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=C4", null);
\r
235 tainavi.CommonUtils.milSleep(100);
\r
236 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0"+HMS.substring(3,4), null);
\r
237 tainavi.CommonUtils.milSleep(100);
\r
238 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0"+HMS.substring(4,5), null);
\r
239 tainavi.CommonUtils.milSleep(100);
\r
240 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=C4", null);
\r
241 tainavi.CommonUtils.milSleep(100);
\r
242 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0"+HMS.substring(6,7), null);
\r
243 tainavi.CommonUtils.milSleep(100);
\r
244 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=0"+HMS.substring(7,8), null);
\r
245 tainavi.CommonUtils.milSleep(100);
\r
246 ru.reqGET("http://"+recorder.getRecorderIPAddr()+":"+recorder.getRecorderPortNo()+"/remote/remote.htm?key=44", null);
\r
260 public static void main(String[] args) {
\r
261 SwingUtilities.invokeLater(new Runnable() {
\r
262 public void run() {
\r
263 Viewer thisClass = new Viewer();
\r
264 thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
\r
265 thisClass.setVisible(true);
\r
271 * This is the default constructor
\r
279 * This method initializes this
\r
283 private void initialize() {
\r
284 //this.setSize(300, 200);
\r
287 final Image image = ImageIO.read(new File("icon/remostat.png"));
\r
288 this.setIconImage(image);
\r
289 } catch (IOException e) {
\r
290 e.printStackTrace();
\r
295 Rectangle ra = new Rectangle();
\r
296 File f = new File(defFile);
\r
297 if ( f.exists() ) {
\r
301 BufferedReader reader = new BufferedReader(new FileReader(f));
\r
302 while ((str = reader.readLine()) != null) {
\r
308 ra.x = Integer.valueOf(str);
\r
311 ra.y = Integer.valueOf(str);
\r
314 ra.width = Integer.valueOf(str);
\r
319 catch (Exception e) {
\r
320 e.printStackTrace();
\r
324 // 鯛ナビと タイニーシンクの設定から
\r
325 //tainavi.Env env = tainavi.Env.load();
\r
326 RecorderInfoList recInfos = new RecorderInfoList();
\r
329 ArrayList<taiSync.RecorderInfo> syncrl = taiSync.RecorderInfo.load();
\r
332 for (RecorderInfo r : recInfos) {
\r
333 if (r.getRecorderIPAddr().equals("") == true || r.getRecorderId().indexOf("RD-") == -1) {
\r
337 RecorderInfo rn = new RecorderInfo();
\r
338 if (r.getRecorderIPAddr().equals("127.0.0.1") || r.getRecorderIPAddr().equals("localhost")) {
\r
339 for (taiSync.RecorderInfo sr : syncrl) {
\r
340 if (sr.getLocalPort() == Integer.valueOf(r.getRecorderPortNo())) {
\r
341 rn.setRecorderIPAddr(sr.getRecorderIPAddr());
\r
342 rn.setRecorderPortNo(sr.getRecorderPortNo());
\r
343 rn.setRecorderUser(sr.getRecorderUser());
\r
344 rn.setRecorderPasswd(sr.getRecorderPasswd());
\r
348 if (rn.getRecorderIPAddr().equals("")) {
\r
349 rn.setRecorderIPAddr(r.getRecorderIPAddr());
\r
350 rn.setRecorderPortNo(r.getRecorderPortNo());
\r
351 rn.setRecorderUser(r.getRecorderUser());
\r
352 rn.setRecorderPasswd(r.getRecorderPasswd());
\r
354 rn.setRecorderMacAddr(r.getRecorderMacAddr());
\r
355 rn.setRecorderBroadcast(r.getRecorderBroadcast());
\r
356 rn.setRecorderId(r.getRecorderId());
\r
358 recorderList.add(rn);
\r
361 //this.setResizable(false);
\r
362 this.setContentPane(getJContentPane());
\r
363 this.setTitle("RDリモートステータスビューア");
\r
366 Rectangle ws = this.getBounds();
\r
369 if (ra.width > ws.width) {
\r
370 ws.width = ra.width;
\r
372 this.setBounds(ws);
\r
374 // 前回選択していたレコーダーを再選択
\r
375 if ( ! recip.equals("")) {
\r
376 jComboBox.setSelectedItem(recip);
\r
380 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
\r
381 this.addWindowListener(new WindowListener() {
\r
383 public void windowActivated(WindowEvent e) {}
\r
384 public void windowClosed(WindowEvent e) {}
\r
385 public void windowDeactivated(WindowEvent e) {}
\r
386 public void windowDeiconified(WindowEvent e) {}
\r
387 public void windowIconified(WindowEvent e) {}
\r
388 public void windowOpened(WindowEvent e) {}
\r
391 public void windowClosing(WindowEvent e) {
\r
392 final Viewer thisClass = (Viewer) e.getSource();
\r
393 Rectangle r = thisClass.getBounds();
\r
395 File f = new File(defFile);
\r
397 BufferedWriter writer = new BufferedWriter(new FileWriter(f));
\r
398 if (recorder != null) {
\r
399 writer.write(recorder.getRecorderIPAddr()+"\n");
\r
402 writer.write("\n");
\r
404 writer.write(r.x+"\n");
\r
405 writer.write(r.y+"\n");
\r
406 writer.write(r.width+"\n");
\r
407 writer.write(r.height+"\n");
\r
410 catch (Exception e1) {
\r
411 e1.printStackTrace();
\r
418 * This method initializes jContentPane
\r
420 * @return javax.swing.JPanel
\r
422 private JPanel getJContentPane() {
\r
423 if (jContentPane == null) {
\r
424 jContentPane = new JPanel();
\r
425 jContentPane.setLayout(new BorderLayout());
\r
426 jContentPane.add(getJPanel1(), BorderLayout.NORTH);
\r
427 jContentPane.add(getJPanel2(), BorderLayout.CENTER);
\r
428 jContentPane.add(getJPanel3(), BorderLayout.SOUTH);
\r
430 return jContentPane;
\r