1
|
1 package rep;
|
|
2
|
|
3 import java.awt.BorderLayout;
|
|
4 import java.awt.Component;
|
2
|
5 import java.awt.Dimension;
|
1
|
6 import java.awt.FlowLayout;
|
|
7 import java.awt.event.ActionEvent;
|
|
8 import java.awt.event.ActionListener;
|
8
|
9 import java.nio.channels.SocketChannel;
|
1
|
10
|
|
11 import javax.swing.AbstractButton;
|
|
12 import javax.swing.JButton;
|
8
|
13 import javax.swing.JComboBox;
|
1
|
14 import javax.swing.JLabel;
|
|
15 import javax.swing.JPanel;
|
2
|
16 import javax.swing.JScrollBar;
|
|
17 import javax.swing.JScrollPane;
|
54
|
18 import javax.swing.JTable;
|
1
|
19 import javax.swing.JTextArea;
|
|
20 import javax.swing.JTextField;
|
54
|
21 import javax.swing.table.DefaultTableModel;
|
|
22 import java.util.*;
|
1
|
23
|
|
24 public class RPanel extends JPanel implements ActionListener {
|
|
25
|
|
26 private JButton button;
|
2
|
27 private JTextField textField;
|
|
28 private String host;
|
1
|
29 private JLabel label;
|
2
|
30 private JTextArea textArea;
|
54
|
31 //private JScrollPane scrollPane;
|
2
|
32 private SessionViewer sessionViewer;
|
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);
|
|
42 LinkedList<SessionPlus> s_list = new LinkedList<SessionPlus>();
|
|
43 LinkedList<EditorPlus> e_list = new LinkedList<EditorPlus>();
|
|
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;
|
2
|
51 private ConnectionListener listener;
|
8
|
52 private JComboBox comboEditor;
|
|
53 private JComboBox comboSession;
|
|
54 private JButton buttonSelect;
|
|
55 private REPActionListener actionListener;
|
1
|
56
|
|
57 public RPanel() {
|
|
58 button = 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 //scrollPane = new JScrollPane(textArea);
|
2
|
63 sessionViewer = new SessionViewer();
|
54
|
64 //viewerPane = new JScrollPane(sessionViewer.getTree());
|
|
65 session_table = new JTable(s_tableModel);
|
|
66 s_sp = new JScrollPane(session_table);
|
|
67 editor_table = new JTable(e_tableModel);
|
|
68 e_sp = new JScrollPane(editor_table);
|
2
|
69 //scrollBar = new JScrollBar(JScrollBar.VERTICAL);
|
8
|
70 comboEditor = new JComboBox();
|
|
71 comboSession = new JComboBox();
|
|
72 buttonSelect = new JButton("Select");
|
2
|
73
|
|
74
|
|
75 button.setBounds(160, 5, 100, 20);
|
|
76 textField.setBounds(5, 5, 150, 20);
|
|
77 textArea.setEditable(false);
|
|
78 textArea.setLineWrap(false);
|
54
|
79 //scrollPane.setBounds(5, 30, 200, 200);
|
|
80 //scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
81 //viewerPane.setBounds(5, 30, 200, 200);
|
|
82 //viewerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
83 session_table.setBounds(5,30,400,200);
|
|
84 s_sp.setPreferredSize(new Dimension(200, 200));
|
|
85 s_sp.setBounds(5,30,400,100);
|
|
86 e_sp.setPreferredSize(new Dimension(200, 200));
|
|
87 e_sp.setBounds(5,140,400,100);
|
2
|
88 //scrollPane.setPreferredSize(new Dimension(200, 200));
|
|
89 //textArea.setBounds(5, 30, 200, 200);
|
|
90 //textArea.add(scrollBar, BorderLayout.EAST);
|
54
|
91 comboEditor.setBounds(450, 50, 100, 50);
|
|
92 comboSession.setBounds(450, 100, 100, 50);
|
|
93 buttonSelect.setBounds(450, 180, 100, 20);
|
|
94
|
1
|
95
|
2
|
96 this.setLayout(null);
|
|
97 this.add(textField);
|
|
98 this.add( button);
|
|
99 this.add(label);
|
|
100 //this.add(textArea);
|
|
101 //this.add(scrollPane, BorderLayout.CENTER);
|
54
|
102 ///this.add(viewerPane, BorderLayout.CENTER);
|
|
103 this.add(s_sp);
|
|
104 this.add(e_sp);
|
1
|
105 //this.add(label, BorderLayout.CENTER);
|
61
|
106 //this.add(comboEditor);
|
|
107 //this.add(comboSession);
|
8
|
108 this.add(buttonSelect);
|
1
|
109
|
|
110 button.addActionListener(this);
|
8
|
111 buttonSelect.addActionListener(this);
|
1
|
112 }
|
|
113
|
2
|
114 public void addSessionTree(int SID){
|
|
115 sessionViewer.addSessionTree(SID);
|
|
116 }
|
|
117
|
1
|
118 public void actionPerformed(ActionEvent event) {
|
|
119 if (event.getSource() == button) {
|
2
|
120 host = textField.getText();
|
|
121 listener.connectionOccured(new ConnectionEvent(host));
|
8
|
122 }else if(event.getSource() == buttonSelect){
|
61
|
123 /*
|
8
|
124 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(),
|
|
125 (SessionPlus)comboSession.getSelectedItem()));
|
61
|
126 */
|
|
127 actionListener.ActionOccured(new REPActionEvent((EditorPlus) e_list.get(editor_table.getSelectedRow()),
|
|
128 (SessionPlus)s_list.get(session_table.getSelectedRow())));
|
1
|
129 }
|
|
130 }
|
|
131
|
2
|
132 public void addConnectionListener(ConnectionListener listener) {
|
|
133 System.out.println(listener.toString());
|
|
134 this.listener = listener;
|
|
135 }
|
|
136
|
8
|
137 public void setComboEditor(int eid, SocketChannel channel) {
|
|
138 //comboEditor.addItem("Editor:"+eid);
|
|
139 comboEditor.addItem(new EditorPlus(eid, channel));
|
|
140 }
|
|
141
|
|
142 public void REPActionListener(REPActionListener listener2) {
|
|
143 this.actionListener = listener2;
|
|
144 }
|
|
145
|
|
146 public void setComboSession(int sessionID, String string) {
|
|
147 comboSession.addItem(new SessionPlus(sessionID, string));
|
|
148 }
|
54
|
149
|
|
150 public void setTableEditor(int eid, SocketChannel channel) {
|
|
151 //comboEditor.addItem("Editor:"+eid);
|
|
152
|
|
153 EditorPlus ep = new EditorPlus(eid, channel);
|
|
154 e_list.add(ep);
|
|
155 Vector editor = new Vector();
|
|
156 e_eid = "Editor : " + eid;
|
|
157 e_socketchannel = "SocketChannel : " + channel;
|
|
158 editor.add(e_eid);
|
|
159 editor.add(e_socketchannel);
|
|
160 e_tableModel.addRow(editor);
|
|
161 }
|
|
162
|
|
163 public void setTableSession(int sessionID, String string) {
|
|
164 SessionPlus sp = new SessionPlus(sessionID, string);
|
|
165 s_list.add(sp);
|
|
166 Vector session = new Vector();
|
|
167 s_host = " ";
|
|
168 s_port = " ";
|
61
|
169 s_file = "" + string;
|
54
|
170 s_sid = "" + sessionID;
|
|
171 s_eid = " ";
|
|
172 session.add(s_host);
|
|
173 session.add(s_port);
|
|
174 session.add(s_file);
|
|
175 session.add(s_sid);
|
|
176 session.add(s_eid);
|
|
177 s_tableModel.addRow(session);
|
|
178 }
|
8
|
179
|
1
|
180 }
|