Mercurial > hg > RemoteEditor > REPSessionManager
view rep/RPanel.java @ 182:e5a7aad3fbc0
*** empty log message ***
author | pin |
---|---|
date | Fri, 29 Aug 2008 13:35:49 +0900 |
parents | 763aad2da6b3 |
children | c2c47d7675a8 |
line wrap: on
line source
package rep; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; import rep.channel.REPSocketChannel; import java.util.*; public class RPanel extends JPanel implements ActionListener { /** * */ private static final long serialVersionUID = 1L; private JButton button; private JTextField textField; private String host; private JLabel label; private JTextArea textArea; //private JScrollPane scrollPane; private SessionViewer sessionViewer; //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<REPCommand>> e_list = new LinkedList<EditorPlus<REPCommand>>(); 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 SessionManager listener; private JComboBox comboEditor; private JComboBox comboSession; private JButton buttonSelect; private REPActionListener<REPCommand> actionListener; public RPanel() { button = new JButton("Connect"); textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp"); textArea = new JTextArea(); label = new JLabel("test"); //scrollPane = new JScrollPane(textArea); sessionViewer = new SessionViewer(); //viewerPane = new JScrollPane(sessionViewer.getTree()); 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(); buttonSelect = new JButton("Select"); button.setBounds(160, 5, 100, 20); 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); 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(450, 50, 100, 50); comboSession.setBounds(450, 100, 100, 50); buttonSelect.setBounds(450, 180, 100, 20); this.setLayout(null); this.add(textField); this.add( button); this.add(label); //this.add(textArea); //this.add(scrollPane, 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); this.add(buttonSelect); button.addActionListener(this); buttonSelect.addActionListener(this); } public void addSessionTree(int SID){ sessionViewer.addSessionTree(SID); } public void actionPerformed(ActionEvent event) { if (event.getSource() == button) { host = textField.getText(); listener.connectionOccured(new ConnectionEvent(listener, host)); }else if(event.getSource() == buttonSelect){ /* actionListener.ActionOccured(new REPActionEvent((EditorPlus) comboEditor.getSelectedItem(), (SessionPlus)comboSession.getSelectedItem())); */ actionListener.ActionOccured(new REPActionEvent<REPCommand>((EditorPlus<REPCommand>) e_list.get(editor_table.getSelectedRow()), (SessionPlus)s_list.get(session_table.getSelectedRow()))); } } public void addConnectionListener(ConnectionListener listener) { System.out.println(listener.toString()); this.listener = (SessionManager) listener; } public void setComboEditor(int eid, REPSocketChannel<REPCommand> channel) { //comboEditor.addItem("Editor:"+eid); comboEditor.addItem(new EditorPlus<REPCommand>(eid, channel)); } public void addREPActionListener(REPActionListener<REPCommand> listener2) { this.actionListener = listener2; } public void setComboSession(int sessionID, String string) { comboSession.addItem(new SessionPlus(sessionID, string)); } public void setTableEditor(int eid, REPSocketChannel<REPCommand> channel) { EditorPlus<REPCommand> ep = new EditorPlus<REPCommand>(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 = "" + string; 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); } }