Mercurial > hg > RemoteEditor > REPSessionManager
changeset 54:ece6aaddfec4
add Table of Editor and Session
author | chiaki |
---|---|
date | Tue, 13 Nov 2007 20:42:43 +0900 |
parents | b87c9b39739a |
children | 57a16534ba5a |
files | rep/RPanel.java |
diffstat | 1 files changed, 114 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/rep/RPanel.java Tue Nov 13 20:25:05 2007 +0900 +++ b/rep/RPanel.java Tue Nov 13 20:42:43 2007 +0900 @@ -15,8 +15,11 @@ import javax.swing.JPanel; import javax.swing.JScrollBar; import javax.swing.JScrollPane; +import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import java.util.*; public class RPanel extends JPanel implements ActionListener { @@ -25,10 +28,26 @@ private String host; private JLabel label; private JTextArea textArea; - private JScrollBar scrollBar; - private JScrollPane scrollPane; + //private JScrollPane scrollPane; private SessionViewer sessionViewer; - private JScrollPane viewerPane; + //private JScrollPane viewerPane; + private JTable session_table; + private JScrollPane s_sp; + private JTable editor_table; + private JScrollPane e_sp; + private String[] session_column = {"HOST", "PORT", "FILE", "SID", "EID"}; + private String[] editor_column = {"EID", "SOCKET_CHANNEL"}; + private DefaultTableModel s_tableModel = new DefaultTableModel(session_column, 0); + private DefaultTableModel e_tableModel = new DefaultTableModel(editor_column, 0); + LinkedList<SessionPlus> s_list = new LinkedList<SessionPlus>(); + LinkedList<EditorPlus> e_list = new LinkedList<EditorPlus>(); + private String s_host; + private String s_port; + private String s_file; + private String s_sid; + private String s_eid; + private String e_eid; + private String e_socketchannel; private ConnectionListener listener; private JComboBox comboEditor; private JComboBox comboSession; @@ -40,9 +59,48 @@ textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp"); textArea = new JTextArea(); label = new JLabel("test"); - scrollPane = new JScrollPane(textArea); + //scrollPane = new JScrollPane(textArea); sessionViewer = new SessionViewer(); - viewerPane = new JScrollPane(sessionViewer.getTree()); + //viewerPane = new JScrollPane(sessionViewer.getTree()); + + SessionPlus s1 = new SessionPlus(1, "session 1"); + SessionPlus s2 = new SessionPlus(2, "session 2"); + s_list.add(s1); + s_list.add(s2); + + Vector vec = new Vector(); + s_host = "host-1"; + s_port = "port-1"; + s_file = "file-1"; + s_sid = "" + s1.getSID(); + s_eid = "eid-1"; + vec.add(s_host); + vec.add(s_port); + vec.add(s_file); + vec.add(s_sid); + vec.add(s_eid); + + Vector vec2 = new Vector(); + s_host = "host-2"; + s_port = "port-2"; + s_file = "file-2"; + s_sid = "" + s2.getSID(); + s_eid = "eid-2"; + vec2.add(s_host); + vec2.add(s_port); + vec2.add(s_file); + vec2.add(s_sid); + vec2.add(s_eid); + + + //veve = s_list.get(i); + s_tableModel.addRow(vec); + s_tableModel.addRow(vec2); + + session_table = new JTable(s_tableModel); + s_sp = new JScrollPane(session_table); + editor_table = new JTable(e_tableModel); + e_sp = new JScrollPane(editor_table); //scrollBar = new JScrollBar(JScrollBar.VERTICAL); comboEditor = new JComboBox(); comboSession = new JComboBox(); @@ -53,16 +111,22 @@ textField.setBounds(5, 5, 150, 20); textArea.setEditable(false); textArea.setLineWrap(false); - scrollPane.setBounds(5, 30, 200, 200); - scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - viewerPane.setBounds(5, 30, 200, 200); - viewerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + //scrollPane.setBounds(5, 30, 200, 200); + //scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + //viewerPane.setBounds(5, 30, 200, 200); + //viewerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + session_table.setBounds(5,30,400,200); + s_sp.setPreferredSize(new Dimension(200, 200)); + s_sp.setBounds(5,30,400,100); + e_sp.setPreferredSize(new Dimension(200, 200)); + e_sp.setBounds(5,140,400,100); //scrollPane.setPreferredSize(new Dimension(200, 200)); //textArea.setBounds(5, 30, 200, 200); //textArea.add(scrollBar, BorderLayout.EAST); - comboEditor.setBounds(250, 50, 100, 50); - comboSession.setBounds(250, 100, 100, 50); - buttonSelect.setBounds(250, 180, 100, 20); + comboEditor.setBounds(450, 50, 100, 50); + comboSession.setBounds(450, 100, 100, 50); + buttonSelect.setBounds(450, 180, 100, 20); + this.setLayout(null); this.add(textField); @@ -70,7 +134,9 @@ this.add(label); //this.add(textArea); //this.add(scrollPane, BorderLayout.CENTER); - this.add(viewerPane, BorderLayout.CENTER); + ///this.add(viewerPane, BorderLayout.CENTER); + this.add(s_sp); + this.add(e_sp); //this.add(label, BorderLayout.CENTER); this.add(comboEditor); this.add(comboSession); @@ -89,6 +155,11 @@ host = textField.getText(); listener.connectionOccured(new ConnectionEvent(host)); }else if(event.getSource() == buttonSelect){ + System.out.println(session_table.getSelectedRow()); + System.out.println(s_list.get(session_table.getSelectedRow()).getSID()); + System.out.println(editor_table.getSelectedRow()); + System.out.println(e_list.get(editor_table.getSelectedRow()).getEID()); + actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(), (SessionPlus)comboSession.getSelectedItem())); } @@ -111,5 +182,35 @@ public void setComboSession(int sessionID, String string) { comboSession.addItem(new SessionPlus(sessionID, string)); } + + public void setTableEditor(int eid, SocketChannel channel) { + //comboEditor.addItem("Editor:"+eid); + + EditorPlus ep = new EditorPlus(eid, channel); + e_list.add(ep); + Vector editor = new Vector(); + e_eid = "Editor : " + eid; + e_socketchannel = "SocketChannel : " + channel; + editor.add(e_eid); + editor.add(e_socketchannel); + e_tableModel.addRow(editor); + } + + public void setTableSession(int sessionID, String string) { + SessionPlus sp = new SessionPlus(sessionID, string); + s_list.add(sp); + Vector session = new Vector(); + s_host = " "; + s_port = " "; + s_file = " "; + s_sid = "" + sessionID; + s_eid = " "; + session.add(s_host); + session.add(s_port); + session.add(s_file); + session.add(s_sid); + session.add(s_eid); + s_tableModel.addRow(session); + } }