annotate rep/RPanel.java @ 84:54334d83194a

*** empty log message ***
author pin
date Fri, 21 Dec 2007 16:03:04 +0900
parents 491962300d0a
children 790c8dd42a7b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
1 package rep;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
2
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
3 import java.awt.BorderLayout;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
4 import java.awt.Component;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
5 import java.awt.Dimension;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
6 import java.awt.FlowLayout;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
7 import java.awt.event.ActionEvent;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
8 import java.awt.event.ActionListener;
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
9 import java.nio.channels.SocketChannel;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
10
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
11 import javax.swing.AbstractButton;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
12 import javax.swing.JButton;
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
13 import javax.swing.JComboBox;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
14 import javax.swing.JLabel;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
15 import javax.swing.JPanel;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
16 import javax.swing.JScrollBar;
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
17 import javax.swing.JScrollPane;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
18 import javax.swing.JTable;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
19 import javax.swing.JTextArea;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
20 import javax.swing.JTextField;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
21 import javax.swing.table.DefaultTableModel;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
22 import java.util.*;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
23
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
24 public class RPanel extends JPanel implements ActionListener {
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
25
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
26 private JButton button;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
27 private JTextField textField;
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
28 private String host;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
29 private JLabel label;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
30 private JTextArea textArea;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
31 //private JScrollPane scrollPane;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
32 private SessionViewer sessionViewer;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
33 //private JScrollPane viewerPane;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
34 private JTable session_table;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
35 private JScrollPane s_sp;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
36 private JTable editor_table;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
37 private JScrollPane e_sp;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
38 private String[] session_column = {"HOST", "PORT", "FILE", "SID", "EID"};
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
39 private String[] editor_column = {"EID", "SOCKET_CHANNEL"};
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
40 private DefaultTableModel s_tableModel = new DefaultTableModel(session_column, 0);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
41 private DefaultTableModel e_tableModel = new DefaultTableModel(editor_column, 0);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
42 LinkedList<SessionPlus> s_list = new LinkedList<SessionPlus>();
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
43 LinkedList<EditorPlus> e_list = new LinkedList<EditorPlus>();
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
44 private String s_host;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
45 private String s_port;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
46 private String s_file;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
47 private String s_sid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
48 private String s_eid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
49 private String e_eid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
50 private String e_socketchannel;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
51 private ConnectionListener listener;
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
52 private JComboBox comboEditor;
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
53 private JComboBox comboSession;
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
54 private JButton buttonSelect;
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
55 private REPActionListener actionListener;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
56
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
57 public RPanel() {
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
58 button = new JButton("Connect");
6
bdb91f4cea26 It Can connect SessionManagers each other.
pin
parents: 2
diff changeset
59 textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp");
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
60 textArea = new JTextArea();
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
61 label = new JLabel("test");
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
62 //scrollPane = new JScrollPane(textArea);
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
63 sessionViewer = new SessionViewer();
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
64 //viewerPane = new JScrollPane(sessionViewer.getTree());
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
65 session_table = new JTable(s_tableModel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
66 s_sp = new JScrollPane(session_table);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
67 editor_table = new JTable(e_tableModel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
68 e_sp = new JScrollPane(editor_table);
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
69 //scrollBar = new JScrollBar(JScrollBar.VERTICAL);
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
70 comboEditor = new JComboBox();
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
71 comboSession = new JComboBox();
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
72 buttonSelect = new JButton("Select");
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
73
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
74
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
75 button.setBounds(160, 5, 100, 20);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
76 textField.setBounds(5, 5, 150, 20);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
77 textArea.setEditable(false);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
78 textArea.setLineWrap(false);
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
79 //scrollPane.setBounds(5, 30, 200, 200);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
80 //scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
81 //viewerPane.setBounds(5, 30, 200, 200);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
82 //viewerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
83 session_table.setBounds(5,30,400,200);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
84 s_sp.setPreferredSize(new Dimension(200, 200));
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
85 s_sp.setBounds(5,30,400,100);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
86 e_sp.setPreferredSize(new Dimension(200, 200));
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
87 e_sp.setBounds(5,140,400,100);
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
88 //scrollPane.setPreferredSize(new Dimension(200, 200));
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
89 //textArea.setBounds(5, 30, 200, 200);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
90 //textArea.add(scrollBar, BorderLayout.EAST);
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
91 comboEditor.setBounds(450, 50, 100, 50);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
92 comboSession.setBounds(450, 100, 100, 50);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
93 buttonSelect.setBounds(450, 180, 100, 20);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
94
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
95
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
96 this.setLayout(null);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
97 this.add(textField);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
98 this.add( button);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
99 this.add(label);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
100 //this.add(textArea);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
101 //this.add(scrollPane, BorderLayout.CENTER);
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
102 ///this.add(viewerPane, BorderLayout.CENTER);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
103 this.add(s_sp);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
104 this.add(e_sp);
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
105 //this.add(label, BorderLayout.CENTER);
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
106 //this.add(comboEditor);
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
107 //this.add(comboSession);
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
108 this.add(buttonSelect);
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
109
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
110 button.addActionListener(this);
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
111 buttonSelect.addActionListener(this);
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
112 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
113
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
114 public void addSessionTree(int SID){
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
115 sessionViewer.addSessionTree(SID);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
116 }
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
117
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
118 public void actionPerformed(ActionEvent event) {
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
119 if (event.getSource() == button) {
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
120 host = textField.getText();
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
121 listener.connectionOccured(new ConnectionEvent(host));
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
122 }else if(event.getSource() == buttonSelect){
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
123 /*
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
124 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(),
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
125 (SessionPlus)comboSession.getSelectedItem()));
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
126 */
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
127 actionListener.ActionOccured(new REPActionEvent((EditorPlus) e_list.get(editor_table.getSelectedRow()),
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
128 (SessionPlus)s_list.get(session_table.getSelectedRow())));
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
129 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
130 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
131
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
132 public void addConnectionListener(ConnectionListener listener) {
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
133 System.out.println(listener.toString());
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
134 this.listener = listener;
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
135 }
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
136
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
137 public void setComboEditor(int eid, SocketChannel channel) {
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
138 //comboEditor.addItem("Editor:"+eid);
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
139 comboEditor.addItem(new EditorPlus(eid, channel));
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
140 }
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
141
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
142 public void REPActionListener(REPActionListener listener2) {
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
143 this.actionListener = listener2;
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
144 }
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
145
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
146 public void setComboSession(int sessionID, String string) {
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
147 comboSession.addItem(new SessionPlus(sessionID, string));
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
148 }
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
149
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
150 public void setTableEditor(int eid, SocketChannel channel) {
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
151 //comboEditor.addItem("Editor:"+eid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
152
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
153 EditorPlus ep = new EditorPlus(eid, channel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
154 e_list.add(ep);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
155 Vector editor = new Vector();
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
156 e_eid = "Editor : " + eid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
157 e_socketchannel = "SocketChannel : " + channel;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
158 editor.add(e_eid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
159 editor.add(e_socketchannel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
160 e_tableModel.addRow(editor);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
161 }
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
162
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
163 public void setTableSession(int sessionID, String string) {
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
164 SessionPlus sp = new SessionPlus(sessionID, string);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
165 s_list.add(sp);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
166 Vector session = new Vector();
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
167 s_host = " ";
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
168 s_port = " ";
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
169 s_file = "" + string;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
170 s_sid = "" + sessionID;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
171 s_eid = " ";
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
172 session.add(s_host);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
173 session.add(s_port);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
174 session.add(s_file);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
175 session.add(s_sid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
176 session.add(s_eid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
177 s_tableModel.addRow(session);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
178 }
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
179
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
180 }