changeset 185:c2c47d7675a8

*** empty log message ***
author pin
date Fri, 29 Aug 2008 16:44:39 +0900
parents 3c82100cdadd
children d22384c0026c
files rep/REPActionListener.java rep/RPanel.java rep/SessionManager.java rep/SessionManagerGUI.java
diffstat 4 files changed, 62 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/rep/REPActionListener.java	Fri Aug 29 16:38:11 2008 +0900
+++ b/rep/REPActionListener.java	Fri Aug 29 16:44:39 2008 +0900
@@ -1,5 +1,7 @@
 package rep;
 
+//implemented class is SessionManager.
+
 public interface REPActionListener<P> {
 	
 	public void ActionOccured(REPActionEvent<P> event);
--- a/rep/RPanel.java	Fri Aug 29 16:38:11 2008 +0900
+++ b/rep/RPanel.java	Fri Aug 29 16:44:39 2008 +0900
@@ -4,13 +4,13 @@
 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.SwingUtilities;
 import javax.swing.table.DefaultTableModel;
 
 import rep.channel.REPSocketChannel;
@@ -28,8 +28,6 @@
 	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;
@@ -49,26 +47,23 @@
 	private String e_eid;
 	private String e_socketchannel;
 	private SessionManager listener;
-	private JComboBox comboEditor;
-	private JComboBox comboSession;
+	//private JComboBox comboEditor;
+	//private JComboBox comboSession;
 	private JButton buttonSelect;
 	private REPActionListener<REPCommand> actionListener;
+	private List<Session> sessionList;
+	private List<Editor> editorList;
+	private SessionManager manager;
 
 	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");
 		
 		
@@ -76,20 +71,11 @@
 		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);
 				
 
@@ -97,25 +83,23 @@
 		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);
+		
+		sessionList = manager.getSessionList();
+		editorList = manager.getEditorList();
 
 	}
 	
-	public void addSessionTree(int SID){
-		sessionViewer.addSessionTree(SID);
+	public RPanel(SessionManager manager) {
+		this();
+		this.manager = manager;
 	}
-	
+
 	public void actionPerformed(ActionEvent event) {
 		if (event.getSource() == button) {
 			host = textField.getText();
@@ -138,7 +122,7 @@
 
 	public void setComboEditor(int eid, REPSocketChannel<REPCommand> channel) {
 		//comboEditor.addItem("Editor:"+eid);
-		comboEditor.addItem(new EditorPlus<REPCommand>(eid, channel));
+		//comboEditor.addItem(new EditorPlus<REPCommand>(eid, channel));
 	}
 
 	public void addREPActionListener(REPActionListener<REPCommand> listener2) {
@@ -146,14 +130,14 @@
 	}
 
 	public void setComboSession(int sessionID, String string) {
-		comboSession.addItem(new SessionPlus(sessionID, 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();
+		Vector<String> editor = new Vector<String>();
 		e_eid = "Editor : " + eid;
 		e_socketchannel = "SocketChannel : " + channel;
 		editor.add(e_eid);
@@ -164,7 +148,7 @@
 	public void setTableSession(int sessionID, String string) {
 		SessionPlus sp = new SessionPlus(sessionID, string);
 		s_list.add(sp);
-		Vector session = new Vector();
+		Vector<String> session = new Vector<String>();
 		s_host = " ";
 		s_port = " ";
 		s_file = "" + string;
@@ -177,5 +161,32 @@
 		session.add(s_eid);
 		s_tableModel.addRow(session);
 	}
+	
+	public static void main(String[] args){
+		new RPanel();
+	}
+
+	public void update() {
+		SwingUtilities.invokeLater(new Runnable() {
+			public void run() {
+				setTableSession();
+				setTableEditor();
+			}
+		});
+	}
+
+	protected void setTableSession() {
+		s_tableModel = new DefaultTableModel(session_column, 0);
+		for(Session session : sessionList){
+			setTableSession(session.getSID(), session.getName());
+		}
+	}
+
+	protected void setTableEditor() {
+		e_tableModel = new DefaultTableModel(editor_column, 0);
+		for(Editor editor : editorList){
+			setTableEditor(editor.getEID(), editor.getChannel());
+		}
+	}
 
 }
--- a/rep/SessionManager.java	Fri Aug 29 16:38:11 2008 +0900
+++ b/rep/SessionManager.java	Fri Aug 29 16:44:39 2008 +0900
@@ -550,4 +550,14 @@
 		packetSetList.add(set);
 	}
 
+	public List<Session> getSessionList() {
+		// TODO Auto-generated method stub
+		return sessionList;
+	}
+
+	public List<Editor> getEditorList() {
+		// TODO Auto-generated method stub
+		return editorList;
+	}
+
 }
--- a/rep/SessionManagerGUI.java	Fri Aug 29 16:38:11 2008 +0900
+++ b/rep/SessionManagerGUI.java	Fri Aug 29 16:44:39 2008 +0900
@@ -1,6 +1,8 @@
 package rep;
 
 import java.awt.Container;
+import java.awt.event.ComponentListener;
+
 import javax.swing.JFrame;
 import rep.channel.REPSocketChannel;
 
@@ -9,7 +11,7 @@
 	
 	private SessionManager manager;
 	
-	public static void main(String[] args) {
+	public static void main(String[] args){
 		SessionManagerGUI gui = new SessionManagerGUI();
 		Thread th = new Thread( gui ); 
 		th.start();
@@ -31,13 +33,13 @@
 		frame = new JFrame("SessionManager");
 		frame.setBounds(100, 100, 600, 300);
 		//rp =  new ConnectionPanel();
-		rp = new RPanel();
+		rp = new RPanel(manager);
 		Container cont = frame.getContentPane();
 		cont.add(rp);
 
 		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-		//frame.pack();
 		frame.setVisible(true);
+		
 	}
 
 	public void addConnectionListener(ConnectionListener listener) {
@@ -70,7 +72,7 @@
 	}
 
 	public void update() {
-		
+		rp.update();
 	}
 
 }
\ No newline at end of file