1
|
1 package rep;
|
|
2
|
2
|
3 import java.awt.Dimension;
|
1
|
4 import java.awt.event.ActionEvent;
|
|
5 import java.awt.event.ActionListener;
|
253
|
6 import java.awt.event.MouseEvent;
|
|
7 import java.awt.event.MouseListener;
|
|
8
|
1
|
9 import javax.swing.JButton;
|
|
10 import javax.swing.JLabel;
|
|
11 import javax.swing.JPanel;
|
2
|
12 import javax.swing.JScrollPane;
|
54
|
13 import javax.swing.JTable;
|
1
|
14 import javax.swing.JTextArea;
|
|
15 import javax.swing.JTextField;
|
54
|
16 import javax.swing.table.DefaultTableModel;
|
134
|
17
|
|
18 import rep.channel.REPSocketChannel;
|
|
19
|
54
|
20 import java.util.*;
|
1
|
21
|
253
|
22 public class RPanel extends JPanel implements ActionListener, MouseListener {
|
1
|
23
|
140
|
24 /**
|
|
25 *
|
|
26 */
|
|
27 private static final long serialVersionUID = 1L;
|
227
|
28 private JButton connectButton;
|
2
|
29 private JTextField textField;
|
|
30 private String host;
|
1
|
31 private JLabel label;
|
2
|
32 private JTextArea textArea;
|
54
|
33 //private JScrollPane viewerPane;
|
|
34 private JTable session_table;
|
|
35 private JScrollPane s_sp;
|
|
36 private JTable editor_table;
|
|
37 private JScrollPane e_sp;
|
|
38 private String[] session_column = {"HOST", "PORT", "FILE", "SID", "EID"};
|
|
39 private String[] editor_column = {"EID", "SOCKET_CHANNEL"};
|
|
40 private DefaultTableModel s_tableModel = new DefaultTableModel(session_column, 0);
|
|
41 private DefaultTableModel e_tableModel = new DefaultTableModel(editor_column, 0);
|
279
|
42 //LinkedList<SessionPlus> s_list = new LinkedList<SessionPlus>();
|
140
|
43 LinkedList<EditorPlus<REPCommand>> e_list = new LinkedList<EditorPlus<REPCommand>>();
|
54
|
44 private String s_host;
|
|
45 private String s_port;
|
|
46 private String s_file;
|
|
47 private String s_sid;
|
|
48 private String s_eid;
|
|
49 private String e_eid;
|
|
50 private String e_socketchannel;
|
227
|
51 private JButton selectButton;
|
259
|
52 private JButton closeButton;
|
222
|
53 private SessionManagerEventListener listener;
|
251
|
54 private LinkedList<Editor> editorList;
|
|
55 private LinkedList<Session> sessionList;
|
1
|
56
|
|
57 public RPanel() {
|
227
|
58 connectButton = new JButton("Connect");
|
6
|
59 textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp");
|
2
|
60 textArea = new JTextArea();
|
1
|
61 label = new JLabel("test");
|
54
|
62 session_table = new JTable(s_tableModel);
|
|
63 s_sp = new JScrollPane(session_table);
|
|
64 editor_table = new JTable(e_tableModel);
|
|
65 e_sp = new JScrollPane(editor_table);
|
258
|
66 selectButton = new JButton("Select Session");
|
259
|
67 closeButton = new JButton("Close Session");
|
2
|
68
|
|
69
|
227
|
70 connectButton.setBounds(160, 5, 100, 20);
|
2
|
71 textField.setBounds(5, 5, 150, 20);
|
|
72 textArea.setEditable(false);
|
|
73 textArea.setLineWrap(false);
|
54
|
74 session_table.setBounds(5,30,400,200);
|
|
75 s_sp.setPreferredSize(new Dimension(200, 200));
|
|
76 s_sp.setBounds(5,30,400,100);
|
|
77 e_sp.setPreferredSize(new Dimension(200, 200));
|
|
78 e_sp.setBounds(5,140,400,100);
|
258
|
79 selectButton.setBounds(430, 215, 130, 20);
|
259
|
80 closeButton.setBounds(430, 105, 130, 20);
|
54
|
81
|
1
|
82
|
2
|
83 this.setLayout(null);
|
|
84 this.add(textField);
|
228
|
85 this.add(connectButton);
|
2
|
86 this.add(label);
|
54
|
87 this.add(s_sp);
|
|
88 this.add(e_sp);
|
227
|
89 this.add(selectButton);
|
259
|
90 this.add(closeButton);
|
1
|
91
|
227
|
92 connectButton.addActionListener(this);
|
|
93 selectButton.addActionListener(this);
|
259
|
94 closeButton.addActionListener(this);
|
253
|
95 editor_table.addMouseListener(this);
|
179
|
96
|
1
|
97 }
|
185
|
98
|
1
|
99 public void actionPerformed(ActionEvent event) {
|
227
|
100 if (event.getSource() == connectButton) {
|
2
|
101 host = textField.getText();
|
222
|
102 listener.buttonPressed(new ConnectButtonEvent(listener, host));
|
227
|
103
|
|
104 }else if(event.getSource() == selectButton){
|
253
|
105 System.out.println("RPanel.actionPerformed() : editorSelectedRow = " + editor_table.getSelectedRow());
|
227
|
106 listener.buttonPressed(
|
251
|
107 new SelectButtonEvent(editorList.get(editor_table.getSelectedRow()),
|
|
108 sessionList.get(session_table.getSelectedRow()), listener));
|
259
|
109 }else if(event.getSource() == closeButton){
|
|
110 listener.buttonPressed(new CloseButtonEvent(sessionList.get(session_table.getSelectedRow()), listener));
|
1
|
111 }
|
|
112 }
|
54
|
113
|
134
|
114 public void setTableEditor(int eid, REPSocketChannel<REPCommand> channel) {
|
253
|
115 System.out.println("RPanel.setTableEditor() : channel = " + channel);
|
185
|
116 Vector<String> editor = new Vector<String>();
|
54
|
117 e_eid = "Editor : " + eid;
|
|
118 e_socketchannel = "SocketChannel : " + channel;
|
|
119 editor.add(e_eid);
|
|
120 editor.add(e_socketchannel);
|
|
121 e_tableModel.addRow(editor);
|
|
122 }
|
|
123
|
|
124 public void setTableSession(int sessionID, String string) {
|
279
|
125 //SessionPlus sp = new SessionPlus(sessionID, string);
|
|
126 //s_list.add(sp);
|
185
|
127 Vector<String> session = new Vector<String>();
|
54
|
128 s_host = " ";
|
|
129 s_port = " ";
|
61
|
130 s_file = "" + string;
|
54
|
131 s_sid = "" + sessionID;
|
|
132 s_eid = " ";
|
|
133 session.add(s_host);
|
|
134 session.add(s_port);
|
|
135 session.add(s_file);
|
|
136 session.add(s_sid);
|
|
137 session.add(s_eid);
|
|
138 s_tableModel.addRow(session);
|
|
139 }
|
185
|
140
|
|
141 public static void main(String[] args){
|
|
142 new RPanel();
|
|
143 }
|
|
144
|
198
|
145 protected void setTableSession(LinkedList<Session> list) {
|
218
|
146 s_tableModel.setRowCount(0);
|
251
|
147 sessionList = list;
|
198
|
148 for(Session session : list){
|
185
|
149 setTableSession(session.getSID(), session.getName());
|
|
150 }
|
|
151 }
|
|
152
|
198
|
153 protected void setTableEditor(LinkedList<Editor> list) {
|
199
|
154 e_tableModel.setRowCount(0);
|
251
|
155 editorList = list;
|
198
|
156 for(Editor editor : list){
|
185
|
157 setTableEditor(editor.getEID(), editor.getChannel());
|
|
158 }
|
|
159 }
|
8
|
160
|
222
|
161 public void addREPActionListener(SessionManagerEventListener listener) {
|
|
162 this.listener = listener;
|
|
163 }
|
|
164
|
253
|
165 public void mouseClicked(MouseEvent e) {
|
|
166 System.out.println("RPanel.mouseClicked() : editorChannel = " + editorList.get(editor_table.getSelectedRow()).getChannel());
|
|
167 }
|
|
168
|
|
169 public void mouseEntered(MouseEvent e) {
|
|
170
|
|
171 }
|
|
172
|
|
173 public void mouseExited(MouseEvent e) {
|
|
174
|
|
175 }
|
|
176
|
|
177 public void mousePressed(MouseEvent e) {
|
|
178
|
|
179 }
|
|
180
|
|
181 public void mouseReleased(MouseEvent e) {
|
|
182
|
|
183 }
|
|
184
|
1
|
185 }
|