Mercurial > hg > RemoteEditor > Eclipse
changeset 187:e240db025af4
*** empty log message ***
author | pin |
---|---|
date | Tue, 07 Oct 2008 22:13:41 +0900 |
parents | 8910ffda5273 |
children | 5572e6ef4b39 |
files | bin/remoteeditor/editors/RemoteEditor$1.class bin/remoteeditor/editors/RemoteEditor.class src/remoteeditor/editors/RemoteEditor.java |
diffstat | 3 files changed, 32 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/remoteeditor/editors/RemoteEditor.java Mon Sep 29 05:18:05 2008 +0900 +++ b/src/remoteeditor/editors/RemoteEditor.java Tue Oct 07 22:13:41 2008 +0900 @@ -34,6 +34,7 @@ private int mysid = 0; private String filename = "afro"; private String BR = System.getProperty("line.separator"); + public boolean others = false; public RemoteEditor() { super(); @@ -118,6 +119,7 @@ break; case REP.SMCMD_SYNC: + receiveSync(command); break; case REP.REPCMD_INSERT: @@ -141,6 +143,24 @@ } } + private void receiveSync(REPCommand command) { + int lines = document.getNumberOfLines(); + for(int i = 0; i < lines; i++){ + + String text = null; + try { + text = document.get(document.getLineOffset(i), document.getLineLength(i)); + } catch (BadLocationException e) { + e.printStackTrace(); + } + REPCommand deleteCommand = new REPCommand(REP.REPCMD_DELETE, mysid, myeid, myseq++, i, text.length(), text); + repsend.send(deleteCommand); + REPCommand insertCommand = new REPCommand(REP.REPCMD_INSERT, mysid, myeid, myseq++, i, text.length(), text); + repsend.send(insertCommand); + + } + } + private void deleteText(int lineNo, int len, String string) throws BadLocationException { final int offset = document.getLineOffset(lineNo); @@ -149,7 +169,9 @@ viewer.getTextWidget().getDisplay().syncExec(new Runnable() { public void run() { try { + others = true; document.replace(offset, replaceLength, ""); + others = false; } catch (BadLocationException e) { e.printStackTrace(); } @@ -164,7 +186,9 @@ viewer.getTextWidget().getDisplay().syncExec(new Runnable() { public void run() { try { + others = true; document.replace(offset, 0, changedText); + others = false; } catch (BadLocationException e) { e.printStackTrace(); } @@ -172,12 +196,9 @@ }); } - public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { - // TODO Auto-generated method stub + public void documentAboutToBeChanged(DocumentEvent event) { + if(others == true) return; - } - - public void documentAboutToBeChanged(DocumentEvent event) { IDocument bDoc = event.getDocument(); int lineno = 0; String replacedText = null; @@ -200,6 +221,8 @@ } public void documentChanged(DocumentEvent event) { + if(others == true) return; + IDocument doc = event.getDocument(); int numberOfLines = doc.getNumberOfLines(); int lineno = 0; @@ -222,14 +245,14 @@ private void sendInsert(int lineno, String text) { REPCommand command = new REPCommand(REP.REPCMD_INSERT, mysid, myeid, this.myseq++, lineno, text.length(), text); - //repsend.send(command); - System.out.println("RemoteEditor.sendInsert() : command = " + command.toString()); + repsend.send(command); + //System.out.println("RemoteEditor.sendInsert() : command = " + command.toString()); } private void sendDelete(int lineno, String text) { REPCommand command = new REPCommand(REP.REPCMD_DELETE, mysid, myeid, this.myseq++, lineno, text.length(), text); - //repsend.send(command); - System.out.println("RemoteEditor.sendDelete() : command = " + command.toString()); + repsend.send(command); + //System.out.println("RemoteEditor.sendDelete() : command = " + command.toString()); } private String getLineText(int lineno, IDocument document2) {