changeset 198:ff3fcdcccc85

*** empty log message ***
author pin
date Sat, 30 Aug 2008 01:11:27 +0900
parents 8d7c74610b05
children 456ba58cd042
files rep/DoGUIUpdate.java rep/RPanel.java rep/SessionManager.java rep/SessionManagerGUI.java
diffstat 4 files changed, 42 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rep/DoGUIUpdate.java	Sat Aug 30 01:11:27 2008 +0900
@@ -0,0 +1,20 @@
+package rep;
+
+import java.util.LinkedList;
+
+public class DoGUIUpdate implements Runnable{
+	
+	private LinkedList<Session> slist;
+	private LinkedList<Editor> elist;
+	private SessionManagerGUI gui;
+
+	public DoGUIUpdate(LinkedList<Session> _slist, LinkedList<Editor> _elist, SessionManagerGUI _gui) {
+		gui = _gui; 
+		slist = _slist; elist = _elist;
+	}
+	
+	public void run() {
+		gui.update(slist, elist);
+	}
+
+}
--- a/rep/RPanel.java	Sat Aug 30 00:00:51 2008 +0900
+++ b/rep/RPanel.java	Sat Aug 30 01:11:27 2008 +0900
@@ -165,25 +165,16 @@
 		new RPanel();
 	}
 
-	public void update() {
-		SwingUtilities.invokeLater(new Runnable() {
-			public void run() {
-				setTableSession();
-				setTableEditor();
-			}
-		});
-	}
-
-	protected void setTableSession() {
+	protected void setTableSession(LinkedList<Session> list) {
 		s_tableModel = new DefaultTableModel(session_column, 0);
-		for(Session session : sessionList){
+		for(Session session : list){
 			setTableSession(session.getSID(), session.getName());
 		}
 	}
 
-	protected void setTableEditor() {
+	protected void setTableEditor(LinkedList<Editor> list) {
 		//e_tableModel = new DefaultTableModel(editor_column, 0);
-		for(Editor editor : editorList){
+		for(Editor editor : list){
 			setTableEditor(editor.getEID(), editor.getChannel());
 		}
 	}
--- a/rep/SessionManager.java	Sat Aug 30 00:00:51 2008 +0900
+++ b/rep/SessionManager.java	Sat Aug 30 01:11:27 2008 +0900
@@ -12,6 +12,8 @@
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 
+import javax.swing.SwingUtilities;
+
 import rep.channel.REPServerSocketChannel;
 import rep.channel.REPSocketChannel;
 import rep.handler.PacketSet;
@@ -21,40 +23,37 @@
 import rep.channel.REPSelector;
 import rep.xml.SessionXMLDecoder;
 import rep.xml.SessionXMLEncoder;
-
+import rep.channel.REPSelectionKey;
+/*
 //+-------+--------+--------+-------+--------+---------+------+
 //| cmd   | session| editor | seqid | lineno | textsiz | text |
 //|       | id     | id     |       |        |         |      |
 //+-------+--------+--------+-------+--------+---------+------+
 //o-------header section (network order)-------------o
-/*int cmd;	// command
+int cmd;	// command
 int sid;	// session ID : uniqu to editing file
 int eid;	// editor ID : owner editor ID = 1。Session に対して unique
 int seqno;	// Sequence number : sequence number はエディタごとに管理
 int lineno;	// line number
 int textsize;   // textsize : bytesize
-byte[] text;*/
+byte[] text;
+*/
 
 public class SessionManager implements ConnectionListener, REPActionListener{
 	
-	
-	//private SessionList sessionlist;
 	private LinkedList<Session> sessionList;
 	private SessionManagerGUI gui;
-	private REPSelector selector;
+	private REPSelector<REPCommand> selector;
 	private SessionManagerList smList;
 	private String myHost;
 	private boolean isMaster = true;
-	//private EditorList  ownEditorList;
 	private List<Editor> editorList;
 	private String maxHost;
 	private boolean isSimulation;
 	private List<PacketSet> packetSetList;
 	private BlockingQueue<SessionManagerEvent> waitingQueue;
-	//private List<SessionManagerNode> managerList;
 	private static int temp_port;
 	private static int send_port;
-	
 	static final int DEFAULT_PORT = 8766;
 	
 	public SessionManager(int port) {
@@ -118,7 +117,7 @@
 		if(e != null) {
 			e.exec();
 		}
-		for(SelectionKey key : selector.selectedKeys()){
+		for(REPSelectionKey<REPCommand> key : selector.selectedKeys1()){
 			if(key.isAcceptable()){
 				/*** serverChannelはenableになったSelectionKeyのchannel ***/
 				REPServerSocketChannel serverChannel = (REPServerSocketChannel)key.channel();
@@ -161,12 +160,14 @@
 			editor.setHost(myHost);
 			editorList.add(editor);
 
+			//リストのコピーをGUIに渡す
+			LinkedList<Session> sList = new LinkedList<Session>(sessionList);
+			LinkedList<Editor> eList = new LinkedList<Editor>(editorList);
 			//GUIに反映
-			//gui.setComboEditor(editor.getEID(), channel);
-			gui.update();
+			Runnable doRun = new DoGUIUpdate(sList, eList, gui);
+			SwingUtilities.invokeLater(doRun);
 		}
 
-
 		break;
 
 		case REP.SMCMD_JOIN_ACK:
--- a/rep/SessionManagerGUI.java	Sat Aug 30 00:00:51 2008 +0900
+++ b/rep/SessionManagerGUI.java	Sat Aug 30 01:11:27 2008 +0900
@@ -2,6 +2,7 @@
 
 import java.awt.Container;
 import java.awt.event.ComponentListener;
+import java.util.LinkedList;
 
 import javax.swing.JFrame;
 import rep.channel.REPSocketChannel;
@@ -71,8 +72,9 @@
 		//rp.setTableSession(sessionID, string);
 	}
 
-	public void update() {
-		rp.update();
+	public void update(LinkedList<Session> list, LinkedList<Editor> list2) {
+		rp.setTableSession(list);
+		rp.setTableEditor(list2);
 	}
 
 }
\ No newline at end of file