Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/RPanel.java @ 54:ece6aaddfec4
add Table of Editor and Session
author | chiaki |
---|---|
date | Tue, 13 Nov 2007 20:42:43 +0900 |
parents | b774b87cc2c1 |
children | 6ead43b2475e |
comparison
equal
deleted
inserted
replaced
53:b87c9b39739a | 54:ece6aaddfec4 |
---|---|
13 import javax.swing.JComboBox; | 13 import javax.swing.JComboBox; |
14 import javax.swing.JLabel; | 14 import javax.swing.JLabel; |
15 import javax.swing.JPanel; | 15 import javax.swing.JPanel; |
16 import javax.swing.JScrollBar; | 16 import javax.swing.JScrollBar; |
17 import javax.swing.JScrollPane; | 17 import javax.swing.JScrollPane; |
18 import javax.swing.JTable; | |
18 import javax.swing.JTextArea; | 19 import javax.swing.JTextArea; |
19 import javax.swing.JTextField; | 20 import javax.swing.JTextField; |
21 import javax.swing.table.DefaultTableModel; | |
22 import java.util.*; | |
20 | 23 |
21 public class RPanel extends JPanel implements ActionListener { | 24 public class RPanel extends JPanel implements ActionListener { |
22 | 25 |
23 private JButton button; | 26 private JButton button; |
24 private JTextField textField; | 27 private JTextField textField; |
25 private String host; | 28 private String host; |
26 private JLabel label; | 29 private JLabel label; |
27 private JTextArea textArea; | 30 private JTextArea textArea; |
28 private JScrollBar scrollBar; | 31 //private JScrollPane scrollPane; |
29 private JScrollPane scrollPane; | |
30 private SessionViewer sessionViewer; | 32 private SessionViewer sessionViewer; |
31 private JScrollPane viewerPane; | 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; | |
32 private ConnectionListener listener; | 51 private ConnectionListener listener; |
33 private JComboBox comboEditor; | 52 private JComboBox comboEditor; |
34 private JComboBox comboSession; | 53 private JComboBox comboSession; |
35 private JButton buttonSelect; | 54 private JButton buttonSelect; |
36 private REPActionListener actionListener; | 55 private REPActionListener actionListener; |
38 public RPanel() { | 57 public RPanel() { |
39 button = new JButton("Connect"); | 58 button = new JButton("Connect"); |
40 textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp"); | 59 textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp"); |
41 textArea = new JTextArea(); | 60 textArea = new JTextArea(); |
42 label = new JLabel("test"); | 61 label = new JLabel("test"); |
43 scrollPane = new JScrollPane(textArea); | 62 //scrollPane = new JScrollPane(textArea); |
44 sessionViewer = new SessionViewer(); | 63 sessionViewer = new SessionViewer(); |
45 viewerPane = new JScrollPane(sessionViewer.getTree()); | 64 //viewerPane = new JScrollPane(sessionViewer.getTree()); |
65 | |
66 SessionPlus s1 = new SessionPlus(1, "session 1"); | |
67 SessionPlus s2 = new SessionPlus(2, "session 2"); | |
68 s_list.add(s1); | |
69 s_list.add(s2); | |
70 | |
71 Vector vec = new Vector(); | |
72 s_host = "host-1"; | |
73 s_port = "port-1"; | |
74 s_file = "file-1"; | |
75 s_sid = "" + s1.getSID(); | |
76 s_eid = "eid-1"; | |
77 vec.add(s_host); | |
78 vec.add(s_port); | |
79 vec.add(s_file); | |
80 vec.add(s_sid); | |
81 vec.add(s_eid); | |
82 | |
83 Vector vec2 = new Vector(); | |
84 s_host = "host-2"; | |
85 s_port = "port-2"; | |
86 s_file = "file-2"; | |
87 s_sid = "" + s2.getSID(); | |
88 s_eid = "eid-2"; | |
89 vec2.add(s_host); | |
90 vec2.add(s_port); | |
91 vec2.add(s_file); | |
92 vec2.add(s_sid); | |
93 vec2.add(s_eid); | |
94 | |
95 | |
96 //veve = s_list.get(i); | |
97 s_tableModel.addRow(vec); | |
98 s_tableModel.addRow(vec2); | |
99 | |
100 session_table = new JTable(s_tableModel); | |
101 s_sp = new JScrollPane(session_table); | |
102 editor_table = new JTable(e_tableModel); | |
103 e_sp = new JScrollPane(editor_table); | |
46 //scrollBar = new JScrollBar(JScrollBar.VERTICAL); | 104 //scrollBar = new JScrollBar(JScrollBar.VERTICAL); |
47 comboEditor = new JComboBox(); | 105 comboEditor = new JComboBox(); |
48 comboSession = new JComboBox(); | 106 comboSession = new JComboBox(); |
49 buttonSelect = new JButton("Select"); | 107 buttonSelect = new JButton("Select"); |
50 | 108 |
51 | 109 |
52 button.setBounds(160, 5, 100, 20); | 110 button.setBounds(160, 5, 100, 20); |
53 textField.setBounds(5, 5, 150, 20); | 111 textField.setBounds(5, 5, 150, 20); |
54 textArea.setEditable(false); | 112 textArea.setEditable(false); |
55 textArea.setLineWrap(false); | 113 textArea.setLineWrap(false); |
56 scrollPane.setBounds(5, 30, 200, 200); | 114 //scrollPane.setBounds(5, 30, 200, 200); |
57 scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); | 115 //scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
58 viewerPane.setBounds(5, 30, 200, 200); | 116 //viewerPane.setBounds(5, 30, 200, 200); |
59 viewerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); | 117 //viewerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
118 session_table.setBounds(5,30,400,200); | |
119 s_sp.setPreferredSize(new Dimension(200, 200)); | |
120 s_sp.setBounds(5,30,400,100); | |
121 e_sp.setPreferredSize(new Dimension(200, 200)); | |
122 e_sp.setBounds(5,140,400,100); | |
60 //scrollPane.setPreferredSize(new Dimension(200, 200)); | 123 //scrollPane.setPreferredSize(new Dimension(200, 200)); |
61 //textArea.setBounds(5, 30, 200, 200); | 124 //textArea.setBounds(5, 30, 200, 200); |
62 //textArea.add(scrollBar, BorderLayout.EAST); | 125 //textArea.add(scrollBar, BorderLayout.EAST); |
63 comboEditor.setBounds(250, 50, 100, 50); | 126 comboEditor.setBounds(450, 50, 100, 50); |
64 comboSession.setBounds(250, 100, 100, 50); | 127 comboSession.setBounds(450, 100, 100, 50); |
65 buttonSelect.setBounds(250, 180, 100, 20); | 128 buttonSelect.setBounds(450, 180, 100, 20); |
129 | |
66 | 130 |
67 this.setLayout(null); | 131 this.setLayout(null); |
68 this.add(textField); | 132 this.add(textField); |
69 this.add( button); | 133 this.add( button); |
70 this.add(label); | 134 this.add(label); |
71 //this.add(textArea); | 135 //this.add(textArea); |
72 //this.add(scrollPane, BorderLayout.CENTER); | 136 //this.add(scrollPane, BorderLayout.CENTER); |
73 this.add(viewerPane, BorderLayout.CENTER); | 137 ///this.add(viewerPane, BorderLayout.CENTER); |
138 this.add(s_sp); | |
139 this.add(e_sp); | |
74 //this.add(label, BorderLayout.CENTER); | 140 //this.add(label, BorderLayout.CENTER); |
75 this.add(comboEditor); | 141 this.add(comboEditor); |
76 this.add(comboSession); | 142 this.add(comboSession); |
77 this.add(buttonSelect); | 143 this.add(buttonSelect); |
78 | 144 |
87 public void actionPerformed(ActionEvent event) { | 153 public void actionPerformed(ActionEvent event) { |
88 if (event.getSource() == button) { | 154 if (event.getSource() == button) { |
89 host = textField.getText(); | 155 host = textField.getText(); |
90 listener.connectionOccured(new ConnectionEvent(host)); | 156 listener.connectionOccured(new ConnectionEvent(host)); |
91 }else if(event.getSource() == buttonSelect){ | 157 }else if(event.getSource() == buttonSelect){ |
158 System.out.println(session_table.getSelectedRow()); | |
159 System.out.println(s_list.get(session_table.getSelectedRow()).getSID()); | |
160 System.out.println(editor_table.getSelectedRow()); | |
161 System.out.println(e_list.get(editor_table.getSelectedRow()).getEID()); | |
162 | |
92 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(), | 163 actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(), |
93 (SessionPlus)comboSession.getSelectedItem())); | 164 (SessionPlus)comboSession.getSelectedItem())); |
94 } | 165 } |
95 } | 166 } |
96 | 167 |
109 } | 180 } |
110 | 181 |
111 public void setComboSession(int sessionID, String string) { | 182 public void setComboSession(int sessionID, String string) { |
112 comboSession.addItem(new SessionPlus(sessionID, string)); | 183 comboSession.addItem(new SessionPlus(sessionID, string)); |
113 } | 184 } |
185 | |
186 public void setTableEditor(int eid, SocketChannel channel) { | |
187 //comboEditor.addItem("Editor:"+eid); | |
188 | |
189 EditorPlus ep = new EditorPlus(eid, channel); | |
190 e_list.add(ep); | |
191 Vector editor = new Vector(); | |
192 e_eid = "Editor : " + eid; | |
193 e_socketchannel = "SocketChannel : " + channel; | |
194 editor.add(e_eid); | |
195 editor.add(e_socketchannel); | |
196 e_tableModel.addRow(editor); | |
197 } | |
198 | |
199 public void setTableSession(int sessionID, String string) { | |
200 SessionPlus sp = new SessionPlus(sessionID, string); | |
201 s_list.add(sp); | |
202 Vector session = new Vector(); | |
203 s_host = " "; | |
204 s_port = " "; | |
205 s_file = " "; | |
206 s_sid = "" + sessionID; | |
207 s_eid = " "; | |
208 session.add(s_host); | |
209 session.add(s_port); | |
210 session.add(s_file); | |
211 session.add(s_sid); | |
212 session.add(s_eid); | |
213 s_tableModel.addRow(session); | |
214 } | |
114 | 215 |
115 } | 216 } |