annotate rep/RPanel.java @ 217:4deaaaa6354e

*** empty log message ***
author kono
date Sun, 31 Aug 2008 00:26:35 +0900
parents 4d9b32666ed2
children 827c439d0da4
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
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
3 import java.awt.Dimension;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
4 import java.awt.event.ActionEvent;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
5 import java.awt.event.ActionListener;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
6 import javax.swing.JButton;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
7 import javax.swing.JLabel;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
8 import javax.swing.JPanel;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
9 import javax.swing.JScrollPane;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
10 import javax.swing.JTable;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
11 import javax.swing.JTextArea;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
12 import javax.swing.JTextField;
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
13 import javax.swing.SwingUtilities;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
14 import javax.swing.table.DefaultTableModel;
134
4ad47fad8fa4 *** empty log message ***
kent
parents: 122
diff changeset
15
4ad47fad8fa4 *** empty log message ***
kent
parents: 122
diff changeset
16 import rep.channel.REPSocketChannel;
4ad47fad8fa4 *** empty log message ***
kent
parents: 122
diff changeset
17
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
18 import java.util.*;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
19
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
20 public class RPanel extends JPanel implements ActionListener {
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
21
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
22 /**
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
23 *
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
24 */
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
25 private static final long serialVersionUID = 1L;
1
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 viewerPane;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
32 private JTable session_table;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
33 private JScrollPane s_sp;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
34 private JTable editor_table;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
35 private JScrollPane e_sp;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
36 private String[] session_column = {"HOST", "PORT", "FILE", "SID", "EID"};
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
37 private String[] editor_column = {"EID", "SOCKET_CHANNEL"};
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
38 private DefaultTableModel s_tableModel = new DefaultTableModel(session_column, 0);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
39 private DefaultTableModel e_tableModel = new DefaultTableModel(editor_column, 0);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
40 LinkedList<SessionPlus> s_list = new LinkedList<SessionPlus>();
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
41 LinkedList<EditorPlus<REPCommand>> e_list = new LinkedList<EditorPlus<REPCommand>>();
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
42 private String s_host;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
43 private String s_port;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
44 private String s_file;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
45 private String s_sid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
46 private String s_eid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
47 private String e_eid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
48 private String e_socketchannel;
178
a097b1d619a1 *** empty log message ***
pin
parents: 140
diff changeset
49 private SessionManager listener;
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
50 //private JComboBox comboEditor;
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
51 //private JComboBox comboSession;
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
52 private JButton buttonSelect;
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
53 private REPActionListener<REPCommand> actionListener;
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
54 private List<Session> sessionList;
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
55 private List<Editor> editorList;
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
56 private SessionManager manager;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
57
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
58 public RPanel() {
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
59 button = new JButton("Connect");
6
bdb91f4cea26 It Can connect SessionManagers each other.
pin
parents: 2
diff changeset
60 textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp");
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
61 textArea = new JTextArea();
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
62 label = new JLabel("test");
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
63 session_table = new JTable(s_tableModel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
64 s_sp = new JScrollPane(session_table);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
65 editor_table = new JTable(e_tableModel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
66 e_sp = new JScrollPane(editor_table);
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
67 buttonSelect = new JButton("Select");
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
68
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
69
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
70 button.setBounds(160, 5, 100, 20);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
71 textField.setBounds(5, 5, 150, 20);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
72 textArea.setEditable(false);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
73 textArea.setLineWrap(false);
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
74 session_table.setBounds(5,30,400,200);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
75 s_sp.setPreferredSize(new Dimension(200, 200));
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
76 s_sp.setBounds(5,30,400,100);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
77 e_sp.setPreferredSize(new Dimension(200, 200));
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
78 e_sp.setBounds(5,140,400,100);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
79 buttonSelect.setBounds(450, 180, 100, 20);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
80
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
81
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
82 this.setLayout(null);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
83 this.add(textField);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
84 this.add( button);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
85 this.add(label);
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
86 this.add(s_sp);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
87 this.add(e_sp);
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
88 this.add(buttonSelect);
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
89
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
90 button.addActionListener(this);
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
91 buttonSelect.addActionListener(this);
179
763aad2da6b3 *** empty log message ***
pin
parents: 178
diff changeset
92
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
93 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
94
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
95 public RPanel(SessionManager manager) {
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
96 this();
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
97 this.manager = manager;
192
6fb97c7a0b42 *** empty log message ***
pin
parents: 185
diff changeset
98 sessionList = manager.getSessionList();
6fb97c7a0b42 *** empty log message ***
pin
parents: 185
diff changeset
99 editorList = manager.getEditorList();
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
100 }
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
101
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
102 public void actionPerformed(ActionEvent event) {
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
103 if (event.getSource() == button) {
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
104 host = textField.getText();
178
a097b1d619a1 *** empty log message ***
pin
parents: 140
diff changeset
105 listener.connectionOccured(new ConnectionEvent(listener, host));
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
106 }else if(event.getSource() == buttonSelect){
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
107 /*
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
108 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(),
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
109 (SessionPlus)comboSession.getSelectedItem()));
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
110 */
213
4d9b32666ed2 *** empty log message ***
pin
parents: 212
diff changeset
111 actionListener.selectOccured(new REPActionEvent<REPCommand>((EditorPlus<REPCommand>) e_list.get(editor_table.getSelectedRow()),
212
e8f716498caf *** empty log message ***
pin
parents: 199
diff changeset
112 (SessionPlus)s_list.get(session_table.getSelectedRow()), listener));
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
113 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
114 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
115
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
116 public void addConnectionListener(ConnectionListener listener) {
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
117 System.out.println(listener.toString());
178
a097b1d619a1 *** empty log message ***
pin
parents: 140
diff changeset
118 this.listener = (SessionManager) listener;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
119 }
122
790c8dd42a7b *** empty log message ***
kono
parents: 61
diff changeset
120
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
121
134
4ad47fad8fa4 *** empty log message ***
kent
parents: 122
diff changeset
122 public void setComboEditor(int eid, REPSocketChannel<REPCommand> channel) {
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
123 //comboEditor.addItem("Editor:"+eid);
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
124 //comboEditor.addItem(new EditorPlus<REPCommand>(eid, channel));
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
125 }
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
126
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
127 public void addREPActionListener(REPActionListener<REPCommand> listener2) {
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
128 this.actionListener = listener2;
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
129 }
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
130
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
131 public void setComboSession(int sessionID, String string) {
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
132 //comboSession.addItem(new SessionPlus(sessionID, string));
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
133 }
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
134
134
4ad47fad8fa4 *** empty log message ***
kent
parents: 122
diff changeset
135 public void setTableEditor(int eid, REPSocketChannel<REPCommand> channel) {
195
63f36334e8dc *** empty log message ***
pin
parents: 192
diff changeset
136 System.out.println("RPanel.setTableEditor()");
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
137 EditorPlus<REPCommand> ep = new EditorPlus<REPCommand>(eid, channel);
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
138 e_list.add(ep);
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
139 Vector<String> editor = new Vector<String>();
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
140 e_eid = "Editor : " + eid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
141 e_socketchannel = "SocketChannel : " + channel;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
142 editor.add(e_eid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
143 editor.add(e_socketchannel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
144 e_tableModel.addRow(editor);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
145 }
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
146
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
147 public void setTableSession(int sessionID, String string) {
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
148 SessionPlus sp = new SessionPlus(sessionID, string);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
149 s_list.add(sp);
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
150 Vector<String> session = new Vector<String>();
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
151 s_host = " ";
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
152 s_port = " ";
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
153 s_file = "" + string;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
154 s_sid = "" + sessionID;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
155 s_eid = " ";
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
156 session.add(s_host);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
157 session.add(s_port);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
158 session.add(s_file);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
159 session.add(s_sid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
160 session.add(s_eid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
161 s_tableModel.addRow(session);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
162 }
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
163
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
164 public static void main(String[] args){
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
165 new RPanel();
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
166 }
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
167
198
ff3fcdcccc85 *** empty log message ***
pin
parents: 195
diff changeset
168 protected void setTableSession(LinkedList<Session> list) {
199
456ba58cd042 *** empty log message ***
pin
parents: 198
diff changeset
169 e_tableModel.setRowCount(0);
198
ff3fcdcccc85 *** empty log message ***
pin
parents: 195
diff changeset
170 for(Session session : list){
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
171 setTableSession(session.getSID(), session.getName());
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
172 }
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
173 }
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
174
198
ff3fcdcccc85 *** empty log message ***
pin
parents: 195
diff changeset
175 protected void setTableEditor(LinkedList<Editor> list) {
199
456ba58cd042 *** empty log message ***
pin
parents: 198
diff changeset
176 e_tableModel.setRowCount(0);
198
ff3fcdcccc85 *** empty log message ***
pin
parents: 195
diff changeset
177 for(Editor editor : list){
185
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
178 setTableEditor(editor.getEID(), editor.getChannel());
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
179 }
c2c47d7675a8 *** empty log message ***
pin
parents: 179
diff changeset
180 }
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
181
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
182 }