annotate rep/RPanel.java @ 182:e5a7aad3fbc0

*** empty log message ***
author pin
date Fri, 29 Aug 2008 13:35:49 +0900
parents 763aad2da6b3
children c2c47d7675a8
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;
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
7 import javax.swing.JComboBox;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
8 import javax.swing.JLabel;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
9 import javax.swing.JPanel;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
10 import javax.swing.JScrollPane;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
11 import javax.swing.JTable;
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
12 import javax.swing.JTextArea;
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
13 import javax.swing.JTextField;
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 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>();
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
43 LinkedList<EditorPlus<REPCommand>> e_list = new LinkedList<EditorPlus<REPCommand>>();
54
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;
178
a097b1d619a1 *** empty log message ***
pin
parents: 140
diff changeset
51 private SessionManager 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;
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
55 private REPActionListener<REPCommand> 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);
179
763aad2da6b3 *** empty log message ***
pin
parents: 178
diff changeset
112
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
113 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
114
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
115 public void addSessionTree(int SID){
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
116 sessionViewer.addSessionTree(SID);
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
117 }
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
118
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
119 public void actionPerformed(ActionEvent event) {
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
120 if (event.getSource() == button) {
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
121 host = textField.getText();
178
a097b1d619a1 *** empty log message ***
pin
parents: 140
diff changeset
122 listener.connectionOccured(new ConnectionEvent(listener, host));
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
123 }else if(event.getSource() == buttonSelect){
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
124 /*
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
125 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(),
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
126 (SessionPlus)comboSession.getSelectedItem()));
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
127 */
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
128 actionListener.ActionOccured(new REPActionEvent<REPCommand>((EditorPlus<REPCommand>) e_list.get(editor_table.getSelectedRow()),
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
129 (SessionPlus)s_list.get(session_table.getSelectedRow())));
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
130 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
131 }
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
132
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
133 public void addConnectionListener(ConnectionListener listener) {
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
134 System.out.println(listener.toString());
178
a097b1d619a1 *** empty log message ***
pin
parents: 140
diff changeset
135 this.listener = (SessionManager) listener;
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
136 }
122
790c8dd42a7b *** empty log message ***
kono
parents: 61
diff changeset
137
2
02fa9a68d9a2 *** empty log message ***
pin
parents: 1
diff changeset
138
134
4ad47fad8fa4 *** empty log message ***
kent
parents: 122
diff changeset
139 public void setComboEditor(int eid, REPSocketChannel<REPCommand> channel) {
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
140 //comboEditor.addItem("Editor:"+eid);
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
141 comboEditor.addItem(new EditorPlus<REPCommand>(eid, channel));
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
142 }
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
143
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
144 public void addREPActionListener(REPActionListener<REPCommand> listener2) {
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
145 this.actionListener = listener2;
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
146 }
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
147
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
148 public void setComboSession(int sessionID, String string) {
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
149 comboSession.addItem(new SessionPlus(sessionID, string));
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
150 }
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
151
134
4ad47fad8fa4 *** empty log message ***
kent
parents: 122
diff changeset
152 public void setTableEditor(int eid, REPSocketChannel<REPCommand> channel) {
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
153
140
01062be677e9 *** empty log message ***
kono
parents: 134
diff changeset
154 EditorPlus<REPCommand> ep = new EditorPlus<REPCommand>(eid, channel);
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
155 e_list.add(ep);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
156 Vector editor = new Vector();
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
157 e_eid = "Editor : " + eid;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
158 e_socketchannel = "SocketChannel : " + channel;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
159 editor.add(e_eid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
160 editor.add(e_socketchannel);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
161 e_tableModel.addRow(editor);
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
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
164 public void setTableSession(int sessionID, String string) {
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
165 SessionPlus sp = new SessionPlus(sessionID, string);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
166 s_list.add(sp);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
167 Vector session = new Vector();
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
168 s_host = " ";
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
169 s_port = " ";
61
491962300d0a Slect button for table is made
chiaki
parents: 56
diff changeset
170 s_file = "" + string;
54
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
171 s_sid = "" + sessionID;
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
172 s_eid = " ";
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
173 session.add(s_host);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
174 session.add(s_port);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
175 session.add(s_file);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
176 session.add(s_sid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
177 session.add(s_eid);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
178 s_tableModel.addRow(session);
ece6aaddfec4 add Table of Editor and Session
chiaki
parents: 8
diff changeset
179 }
8
b774b87cc2c1 *** empty log message ***
pin
parents: 6
diff changeset
180
1
3f5bf0255f5e *** empty log message ***
pin
parents:
diff changeset
181 }