diff rep/Editor.java @ 122:790c8dd42a7b

*** empty log message ***
author kono
date Tue, 26 Aug 2008 16:33:47 +0900
parents 9381b4734a0b
children 617a47cb0150
line wrap: on
line diff
--- a/rep/Editor.java	Tue Aug 26 09:52:08 2008 +0900
+++ b/rep/Editor.java	Tue Aug 26 16:33:47 2008 +0900
@@ -1,6 +1,7 @@
 package rep;
 
 import java.nio.channels.SocketChannel;
+import java.util.LinkedList;
 import java.util.StringTokenizer;
 
 public class Editor {
@@ -11,6 +12,8 @@
 	private String port;
 	//public int getEID;
 	private String file;
+	private LinkedList<REPCommand> undoCommandList = new LinkedList<REPCommand>();
+	private LinkedList<Integer> temp = new LinkedList<Integer>();
 
 	public Editor(int editorNo, SocketChannel channel){
 		this.eid = editorNo;
@@ -82,4 +85,33 @@
 		myChannel = channel;
 	}
 
+	public void addUndoCommand(REPCommand command) {
+		if(command.cmd == REP.SMCMD_GET_UNDO_ACK){
+			command.setCMD((temp.get(0)).intValue());
+			temp.remove();
+		}
+		
+		undoCommandList.addFirst(command);
+		System.out.println(undoCommandList);
+//		if(undoCommandList.size() > 10){
+//			for(REPCommand undoCommand : undoCommandList){
+//				send(undoCommand);
+//			}
+//			undoCommandList.clear();
+//		}
+	}
+
+	public void undo() {
+		// TODO Auto-generated method stub
+		for(REPCommand undoCommand : undoCommandList){
+			send(undoCommand);
+		}
+		undoCommandList.clear();
+	}
+
+	public void setKindOfUndoCmd(int cmd) {
+		// TODO Auto-generated method stub
+		temp .add(cmd);
+	}
+
 }