changeset 103:dca742322984

*** empty log message ***
author pin
date Sat, 22 Dec 2007 19:05:12 +0900
parents e83dd125e0c6
children a2089a730a2e
files .classpath bin/remoteeditor/editors/RemoteEditor$1.class bin/remoteeditor/editors/RemoteEditor.class plugin.xml src/remoteeditor/action/RemoteEditorAction.java src/remoteeditor/editors/RemoteEditor.java
diffstat 6 files changed, 49 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/.classpath	Sat Dec 22 17:46:56 2007 +0900
+++ b/.classpath	Sat Dec 22 19:05:12 2007 +0900
@@ -3,6 +3,5 @@
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry kind="lib" path="org.eclipse.core.resources_3.2.1.R32x_v20060914.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
Binary file bin/remoteeditor/editors/RemoteEditor$1.class has changed
Binary file bin/remoteeditor/editors/RemoteEditor.class has changed
--- a/plugin.xml	Sat Dec 22 17:46:56 2007 +0900
+++ b/plugin.xml	Sat Dec 22 19:05:12 2007 +0900
@@ -48,10 +48,10 @@
                menubarPath="EclipseRemoteEditor.menu1/EclipseRemoteEditor.separator1"
                />
          <action
+               class="remoteeditor.action.RemoteEditorAction"
                id="EclipseRemoteEditor.action2"
                label="SMCMD_JOIN"
-               menubarPath="EclipseRemoteEditor.menu1/EclipseRemoteEditor.separator2"
-               style="push"/>
+               menubarPath="EclipseRemoteEditor.menu1/EclipseRemoteEditor.separator2"/>
       </actionSet>
    </extension>
    
--- a/src/remoteeditor/action/RemoteEditorAction.java	Sat Dec 22 17:46:56 2007 +0900
+++ b/src/remoteeditor/action/RemoteEditorAction.java	Sat Dec 22 19:05:12 2007 +0900
@@ -4,7 +4,7 @@
 import java.io.File;
 import java.io.InputStream;
 
-import org.eclipse.core.resources.IContainer;
+//import org.eclipse.core.resources.IContainer;
 //import org.eclipse.core.resources.IFile;
 //import org.eclipse.core.resources.IProject;
 //import org.eclipse.core.resources.IWorkspace;
@@ -49,12 +49,39 @@
 
 	public void run(IAction action) {
 		
-		IWorkbench workbench = PlatformUI.getWorkbench();
+		System.out.println(action.getId());
+		if(action.getId().equals("EclipseRemoteEditor.action1")){
+			IWorkbench workbench = PlatformUI.getWorkbench();
+			//Display display = workbench.getDisplay();
+			IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+			IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
+			IEditorPart editorPart = workbenchPage.getActiveEditor();
+			//System.out.println(editorPart.getEditorInput().toString());
+			IEditorInput editorinput = editorPart.getEditorInput();
+			workbenchPage.closeEditor(editorPart, true);
+			try {
+				editorPart = workbenchPage.openEditor(editorinput, "remoteeditor.editors.RemoteEditor");
+			} catch (PartInitException e) {
+				e.printStackTrace();
+			}
+		}else if(action.getId().equals("EclipseRemoteEditor.action2")){
+			IWorkbench workbench = PlatformUI.getWorkbench();
 		
-		UntitledTextFileWizard obj = new UntitledTextFileWizard();
-		obj.init(workbench, null);
-		obj.performFinish();
-		
+			UntitledTextFileWizard wizard = new UntitledTextFileWizard();
+			wizard.init(workbench, null);
+			wizard.performFinish();
+			
+			IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+			IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
+			IEditorPart editorPart = workbenchPage.getActiveEditor();
+			IEditorInput editorinput = editorPart.getEditorInput();
+			workbenchPage.closeEditor(editorPart, true);
+			try {
+				editorPart = workbenchPage.openEditor(editorinput, "remoteeditor.editors.RemoteEditor");
+			} catch (PartInitException e) {
+				e.printStackTrace();
+			}
+		}
 		/*
 		IWorkbench workbench = PlatformUI.getWorkbench();
 		//Display display = workbench.getDisplay();
--- a/src/remoteeditor/editors/RemoteEditor.java	Sat Dec 22 17:46:56 2007 +0900
+++ b/src/remoteeditor/editors/RemoteEditor.java	Sat Dec 22 19:05:12 2007 +0900
@@ -75,6 +75,7 @@
 		viewer.addTextListener(this);
 		document = viewer.getDocument();
 		filename = this.getEditorInput().getName();
+		
 		int port = 8766;
 		String host = "localhost";
 		InetSocketAddress addr = new InetSocketAddress(host, port);
@@ -105,7 +106,11 @@
 		repreceive.addCommandListener(this);
 		//repsend.send(new REPCommand(REP.REPCMD_READ, mysid, myeid, myseq, 0, 0, ""));
 		//joinPart();
-		putPart();
+		if(document.getLength() < 1){
+			joinPart();
+		}else {
+			putPart();
+		}
 	}
 	
 	private void getSocketString(SocketChannel sc2) {
@@ -127,7 +132,7 @@
 		String replacedText = event.getReplacedText();
 		String inputText = event.getText();
 				
-		// ページ先頭からの文字数(改行を含む)による座標
+		// ソスyソス[ソスWソス謫ェソスソスソスソスフ包ソスソスソスソスソス(ソスソスsソスソスワゑソス)ソスノゑソスソスW
 		int textOffset = event.getOffset();
 		
 		System.out.println("replace = " + replacedText);
@@ -140,7 +145,7 @@
 		int numberOfLinesNew = 0;
 		String lineText = null;
 		try {
-			line = document.getNumberOfLines(0, textOffset); // lineno を取得してます。
+			line = document.getNumberOfLines(0, textOffset); // lineno ソスソス謫セソスソスソストまゑソスソスB
 			offset = document.getLineOffset(line-1);
 			length = document.getLineLength(line-1);
 			lineText = document.get(offset, length);
@@ -149,7 +154,7 @@
 			e1.printStackTrace();
 		}
 		if(numberOfLinesNew > numberOfLinesOld){
-			//insert, delete, replace を 行数で判断
+			//insert, delete, replace ソスソス ソスsソスソスソスナ費ソスソスf
 			cmd = REP.REPCMD_INSERT;
 			lineText = "\n";
 			//line += 1;
@@ -236,6 +241,8 @@
 			mysid = command.sid;
 			myeid = command.eid;
 			trans.myeid = myeid;
+			REPCommand sendCommand = new REPCommand(REP.REPCMD_READ, mysid, myeid, 0, 0, 0, "");
+			repsend.send(sendCommand);
 			//putPart();
 			break;
 		case REP.SMCMD_PUT_ACK:
@@ -248,7 +255,7 @@
 			break;
 		case REP.REPCMD_INSERT:
 			try {
-					if(command.eid == myeid) break;	//あとで消す
+					if(command.eid == myeid) break;	//ソスソスソスニで州ソス
 					textInsert(command.lineno, command.len, command.string);
 				} catch (Exception e) {
 					e.printStackTrace();
@@ -256,7 +263,7 @@
 			break;
 		case REP.REPCMD_REPLACE:
 			try {
-					if(command.eid == myeid) break;//あとで消す
+					if(command.eid == myeid) break;//ソスソスソスニで州ソス
 					repsend.send(command);
 					changeText(command.cmd, command.lineno, command.len, command.string);
 				} catch (Exception e1) {
@@ -265,7 +272,7 @@
 			break;
 		case REP.REPCMD_DELETE:
 			try {
-					if(command.eid == myeid) break;//あとで消す
+					if(command.eid == myeid) break;//ソスソスソスニで州ソス
 					textDelete(command.lineno, command.len, command.string);
 				} catch (BadLocationException e1) {
 					e1.printStackTrace();