Mercurial > hg > RemoteEditor > Eclipse
changeset 155:0dfb6413a31e
*** empty log message ***
author | pin |
---|---|
date | Sun, 24 Aug 2008 18:08:10 +0900 |
parents | 6a3c982bd72a |
children | 7ebd30e5e385 |
files | src/pathfinder/mergetest/EditorSimulatorWithoutMerger.java src/pathfinder/mergetest/SelectorSimulator.java src/pathfinder/mergetest/SessionManagerSimulatorWithMerger.java src/sample/merge/TranslaterImp1.java |
diffstat | 4 files changed, 24 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pathfinder/mergetest/EditorSimulatorWithoutMerger.java Sun Aug 24 13:43:50 2008 +0900 +++ b/src/pathfinder/mergetest/EditorSimulatorWithoutMerger.java Sun Aug 24 18:08:10 2008 +0900 @@ -50,16 +50,15 @@ sendOneCommand(cmd, replacedText); }else if(cmd.eid == -2){ - // Merged Commands. - String replacedText = text.edit(cmd); - //sendOneCommand(cmd, replacedText); /* 終了条件 */ if (cmd.cmd==REP.SMCMD_QUIT){ ns.writeLog("\tEditor"+eid+" catch QUIT command emited by itself.", 3); running=false; break; }else{ - cs.write(new REPCommand(cmd)); + // Merged Commands. + String replacedText = text.edit(cmd); + returnMergedCommand(cmd, replacedText); } } else { @@ -73,6 +72,12 @@ } } + private void returnMergedCommand(REPCommand cmd, String replacedText) { + REPCommand command = new REPCommand(cmd); + if(command.cmd == REP.REPCMD_DELETE)command.setString(replacedText); + cs.write(command); + } + private void manage(REPCommand cmd) { // TODO Auto-generated method stub switch(cmd.cmd){
--- a/src/pathfinder/mergetest/SelectorSimulator.java Sun Aug 24 13:43:50 2008 +0900 +++ b/src/pathfinder/mergetest/SelectorSimulator.java Sun Aug 24 18:08:10 2008 +0900 @@ -19,16 +19,20 @@ selectedKeys = new ArrayList<SelectionKeySimulator<P>>(); synchronized(ns){ - boolean empty = false; + boolean empty = true; //while(empty){ for(SelectionKeySimulator<P> key : keyList){ ChannelSimulator<P> channel = key.channel(); - if(channel.readQisEmpty()){ - empty = true; - }else{ +// if(channel.readQisEmpty()){ +// empty = true; +// }else{ +// empty = false; +// selectedKeys.add(key); +// break; +// } + if(!channel.readQisEmpty()){ empty = false; selectedKeys.add(key); - break; } }
--- a/src/pathfinder/mergetest/SessionManagerSimulatorWithMerger.java Sun Aug 24 13:43:50 2008 +0900 +++ b/src/pathfinder/mergetest/SessionManagerSimulatorWithMerger.java Sun Aug 24 18:08:10 2008 +0900 @@ -48,12 +48,8 @@ ns.writeLog("SessionManager start.", 1); /* Main Loop */ - - //Selectorを用いた実装 - //while(running && (MAX_PACKET==0 || count<MAX_PACKET)){ while(running){ - - // Main Loop + selector.select(); for(SelectionKeySimulator<P> key : selector.selectedKeys()){ @@ -147,22 +143,23 @@ } }else{ - //エディタからの新たな編集コマンド editorList.get(eid).transSendCmd(command); nextChannel.write(pack(command)); - } + }else if(command.eid == REP.MERGE_EID){ //マージのときにエディタからの割り込みがないか確認 + //if(eid == 2)System.out.println(" Merged Command : " + command); if(editorList.get(eid).checkMergeConflict(command)){ LinkedList<REPCommand> againList = editorList.get(eid).getMergeAgain(); for(REPCommand againCommand : againList){ channel.write(pack(againCommand)); + System.out.println("Remerge : " + againCommand); } } + }else{ - //他のエディタからのコマンドはマージャへ追加し次のエディタへ送信する REPCommand[] cmds = editorList.get(eid).transReceiveCmd(command); for(REPCommand cmd : cmds){
--- a/src/sample/merge/TranslaterImp1.java Sun Aug 24 13:43:50 2008 +0900 +++ b/src/sample/merge/TranslaterImp1.java Sun Aug 24 18:08:10 2008 +0900 @@ -244,6 +244,7 @@ public boolean checkMergeConflict(REPCommand command) { sentMergedList.remove(); + if(mergeAgainList.size() > 0){ mergeAgainList.add(command); if(sentMergedList.size() == 0){