1
|
1 package rep;
|
|
2
|
2
|
3 import java.awt.Dimension;
|
1
|
4 import java.awt.event.ActionEvent;
|
|
5 import java.awt.event.ActionListener;
|
|
6 import javax.swing.JButton;
|
8
|
7 import javax.swing.JComboBox;
|
1
|
8 import javax.swing.JLabel;
|
|
9 import javax.swing.JPanel;
|
2
|
10 import javax.swing.JScrollPane;
|
54
|
11 import javax.swing.JTable;
|
1
|
12 import javax.swing.JTextArea;
|
|
13 import javax.swing.JTextField;
|
54
|
14 import javax.swing.table.DefaultTableModel;
|
134
|
15
|
|
16 import rep.channel.REPSocketChannel;
|
|
17
|
54
|
18 import java.util.*;
|
1
|
19
|
|
20 public class RPanel extends JPanel implements ActionListener {
|
|
21
|
140
|
22 /**
|
|
23 *
|
|
24 */
|
|
25 private static final long serialVersionUID = 1L;
|
1
|
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>();
|
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;
|
178
|
51 private SessionManager listener;
|
8
|
52 private JComboBox comboEditor;
|
|
53 private JComboBox comboSession;
|
|
54 private JButton buttonSelect;
|
140
|
55 private REPActionListener<REPCommand> 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);
|
179
|
112
|
1
|
113 }
|
|
114
|
2
|
115 public void addSessionTree(int SID){
|
|
116 sessionViewer.addSessionTree(SID);
|
|
117 }
|
|
118
|
1
|
119 public void actionPerformed(ActionEvent event) {
|
|
120 if (event.getSource() == button) {
|
2
|
121 host = textField.getText();
|
178
|
122 listener.connectionOccured(new ConnectionEvent(listener, host));
|
8
|
123 }else if(event.getSource() == buttonSelect){
|
61
|
124 /*
|
8
|
125 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(),
|
|
126 (SessionPlus)comboSession.getSelectedItem()));
|
61
|
127 */
|
140
|
128 actionListener.ActionOccured(new REPActionEvent<REPCommand>((EditorPlus<REPCommand>) e_list.get(editor_table.getSelectedRow()),
|
61
|
129 (SessionPlus)s_list.get(session_table.getSelectedRow())));
|
1
|
130 }
|
|
131 }
|
|
132
|
2
|
133 public void addConnectionListener(ConnectionListener listener) {
|
|
134 System.out.println(listener.toString());
|
178
|
135 this.listener = (SessionManager) listener;
|
2
|
136 }
|
122
|
137
|
2
|
138
|
134
|
139 public void setComboEditor(int eid, REPSocketChannel<REPCommand> channel) {
|
8
|
140 //comboEditor.addItem("Editor:"+eid);
|
140
|
141 comboEditor.addItem(new EditorPlus<REPCommand>(eid, channel));
|
8
|
142 }
|
|
143
|
140
|
144 public void addREPActionListener(REPActionListener<REPCommand> listener2) {
|
8
|
145 this.actionListener = listener2;
|
|
146 }
|
|
147
|
|
148 public void setComboSession(int sessionID, String string) {
|
|
149 comboSession.addItem(new SessionPlus(sessionID, string));
|
|
150 }
|
54
|
151
|
134
|
152 public void setTableEditor(int eid, REPSocketChannel<REPCommand> channel) {
|
54
|
153
|
140
|
154 EditorPlus<REPCommand> ep = new EditorPlus<REPCommand>(eid, channel);
|
54
|
155 e_list.add(ep);
|
|
156 Vector editor = new Vector();
|
|
157 e_eid = "Editor : " + eid;
|
|
158 e_socketchannel = "SocketChannel : " + channel;
|
|
159 editor.add(e_eid);
|
|
160 editor.add(e_socketchannel);
|
|
161 e_tableModel.addRow(editor);
|
|
162 }
|
|
163
|
|
164 public void setTableSession(int sessionID, String string) {
|
|
165 SessionPlus sp = new SessionPlus(sessionID, string);
|
|
166 s_list.add(sp);
|
|
167 Vector session = new Vector();
|
|
168 s_host = " ";
|
|
169 s_port = " ";
|
61
|
170 s_file = "" + string;
|
54
|
171 s_sid = "" + sessionID;
|
|
172 s_eid = " ";
|
|
173 session.add(s_host);
|
|
174 session.add(s_port);
|
|
175 session.add(s_file);
|
|
176 session.add(s_sid);
|
|
177 session.add(s_eid);
|
|
178 s_tableModel.addRow(session);
|
|
179 }
|
8
|
180
|
1
|
181 }
|