# HG changeset patch # User pin # Date 1220158539 -32400 # Node ID cbd67817e9cddc1d3e1239e20c176f0217c3c91f # Parent e4ed00c8242267047359c52198d6d3852c5c5e15 *** empty log message *** diff -r e4ed00c82422 -r cbd67817e9cd rep/RPanel.java --- a/rep/RPanel.java Sun Aug 31 13:33:33 2008 +0900 +++ b/rep/RPanel.java Sun Aug 31 13:55:39 2008 +0900 @@ -22,7 +22,7 @@ * */ private static final long serialVersionUID = 1L; - private JButton button; + private JButton connectButton; private JTextField textField; private String host; private JLabel label; @@ -45,12 +45,12 @@ private String s_eid; private String e_eid; private String e_socketchannel; - private JButton buttonSelect; + private JButton selectButton; //private SessionManager manager; private SessionManagerEventListener listener; public RPanel() { - button = new JButton("Connect"); + connectButton = new JButton("Connect"); textField = new JTextField("firefly.cr.ie.u-ryukyu.ac.jp"); textArea = new JTextArea(); label = new JLabel("test"); @@ -58,10 +58,10 @@ s_sp = new JScrollPane(session_table); editor_table = new JTable(e_tableModel); e_sp = new JScrollPane(editor_table); - buttonSelect = new JButton("Select"); + selectButton = new JButton("Select"); - button.setBounds(160, 5, 100, 20); + connectButton.setBounds(160, 5, 100, 20); textField.setBounds(5, 5, 150, 20); textArea.setEditable(false); textArea.setLineWrap(false); @@ -70,28 +70,31 @@ s_sp.setBounds(5,30,400,100); e_sp.setPreferredSize(new Dimension(200, 200)); e_sp.setBounds(5,140,400,100); - buttonSelect.setBounds(450, 180, 100, 20); + selectButton.setBounds(450, 180, 100, 20); this.setLayout(null); this.add(textField); - this.add( button); + this.add( connectButton); this.add(label); this.add(s_sp); this.add(e_sp); - this.add(buttonSelect); + this.add(selectButton); - button.addActionListener(this); - buttonSelect.addActionListener(this); + connectButton.addActionListener(this); + selectButton.addActionListener(this); } public void actionPerformed(ActionEvent event) { - if (event.getSource() == button) { + if (event.getSource() == connectButton) { host = textField.getText(); listener.buttonPressed(new ConnectButtonEvent(listener, host)); - }else if(event.getSource() == buttonSelect){ - listener.buttonPressed(new SelectButtonEvent((EditorPlus) e_list.get(editor_table.getSelectedRow()), + + }else if(event.getSource() == selectButton){ + System.out.println("RPanel.actionPerformed():editorSelectedRow = " + editor_table.getSelectedRow()); + listener.buttonPressed( + new SelectButtonEvent((EditorPlus) e_list.get(editor_table.getSelectedRow()), (SessionPlus)s_list.get(session_table.getSelectedRow()), listener)); } } @@ -139,6 +142,7 @@ protected void setTableEditor(LinkedList list) { e_tableModel.setRowCount(0); for(Editor editor : list){ + System.out.println(editor.getChannel()); setTableEditor(editor.getEID(), editor.getChannel()); } } diff -r e4ed00c82422 -r cbd67817e9cd rep/SelectButtonEvent.java --- a/rep/SelectButtonEvent.java Sun Aug 31 13:33:33 2008 +0900 +++ b/rep/SelectButtonEvent.java Sun Aug 31 13:55:39 2008 +0900 @@ -9,10 +9,10 @@ private int eid; private SessionManager manager; - public SelectButtonEvent(EditorPlus

plus, SessionPlus plus2, SessionManagerEventListener listener) { - this.editorChannel = plus.getChannel(); - this.eid = plus.getEID(); - this.sid = plus2.getSID(); + public SelectButtonEvent(EditorPlus

editor, SessionPlus session, SessionManagerEventListener listener) { + this.editorChannel = editor.getChannel(); + this.eid = editor.getEID(); + this.sid = session.getSID(); this.manager = (SessionManager)listener; } diff -r e4ed00c82422 -r cbd67817e9cd rep/Session.java --- a/rep/Session.java Sun Aug 31 13:33:33 2008 +0900 +++ b/rep/Session.java Sun Aug 31 13:55:39 2008 +0900 @@ -13,10 +13,9 @@ private LinkedList routingTable = new LinkedList(); private boolean isOwner = false; - public Session(int sessionID, String string, REPSocketChannel channel) { - masterEditor = new Editor(sessionID, channel); - this.sessionID = sessionID; - this.sessionName = string; + public Session(int sid, String name, Editor editor) { + this(sid, editor); + sessionName = name; } public Session(Editor editor) { masterEditor = editor; @@ -53,8 +52,8 @@ editor.setEID(eid); editorList.add(editor); } - public void setSID(int sessionID2) { - sessionID = sessionID2; + public void setSID(int sid) { + sessionID = sid; } public void addToRoutingTable(Editor editor) { routingTable.add(new REPNode(editor)); diff -r e4ed00c82422 -r cbd67817e9cd rep/SessionList.java --- a/rep/SessionList.java Sun Aug 31 13:33:33 2008 +0900 +++ b/rep/SessionList.java Sun Aug 31 13:55:39 2008 +0900 @@ -44,7 +44,7 @@ public int addSession(REPSocketChannel channel, String string) { sessionID++; // session3.put(sessionID, new Session(sessionID, string, channel)); - sessionLinkedList.add(new Session(sessionID, string, channel)); +// sessionLinkedList.add(new Session(sessionID, string, channel)); return sessionID; } @@ -126,7 +126,7 @@ } public void addSession(REPSocketChannel channel, String string, int i) { - tmpSessionList.add(new Session(0, string, channel)); +// tmpSessionList.add(new Session(0, string, channel)); } // public String getXML() { diff -r e4ed00c82422 -r cbd67817e9cd rep/SessionManager.java --- a/rep/SessionManager.java Sun Aug 31 13:33:33 2008 +0900 +++ b/rep/SessionManager.java Sun Aug 31 13:55:39 2008 +0900 @@ -166,15 +166,15 @@ { //エディタのリストに追加 Editor editor = new Editor(editorList.size(), channel); - editorList.add(editor); + //editorList.add(editor); //Sessionを生成 int sid = sessionList.size(); editor = new Editor(0, channel); editor.setHost(myHost); - Session session = new Session(sid, editor); + Session session = new Session(sid, receivedCommand.string, editor); session.hasOwner(true); - sessionList.add(new Session(sid, editor)); + sessionList.add(session); guiUpdate(); @@ -542,19 +542,25 @@ REPSocketChannel channel = event.getEditorChannel(); int sid = event.getSID(); Session session = getSession(sid); - //selector.wakeup(); + + Editor editor = getEditor(channel); + if(editor == null){ + System.out.println("SessionManager.selectSession():editor = " + editor); + return; + } + + session.addEditor(editor); + + System.out.println(session.hasOwner()); if(session.hasOwner()){ - Editor editor = new Editor(channel); - session.addEditor(new Editor(channel)); REPCommand sendCommand = new REPCommand(); sendCommand.setCMD(REP.SMCMD_JOIN_ACK); sendCommand.setEID(editor.getEID()); sendCommand.setSID(sid); channel.write(sendCommand); }else { - REPSocketChannel editorChannel = event.getEditorChannel(); sid = event.getSID(); - Editor editor = new Editor(editorChannel); + editor = new Editor(channel); editor.setHost(myHost); session = getSession(sid); session.addEditor(editor); diff -r e4ed00c82422 -r cbd67817e9cd test/sematest/PutTester.java --- a/test/sematest/PutTester.java Sun Aug 31 13:33:33 2008 +0900 +++ b/test/sematest/PutTester.java Sun Aug 31 13:55:39 2008 +0900 @@ -17,7 +17,7 @@ REPCommand command = new REPCommand(); command.setCMD(REP.SMCMD_PUT); - command.setString("put test"); + command.setString("PutTest.txt"); channel.write(command); channel.read();