diff src/remoteeditor/action/RemoteEditorAction.java @ 213:bea1625524fe default tip

when you put and join to SessionManager, this plugin open a window for inputting address and port of SessionManager
author kazz
date Mon, 20 Dec 2010 14:14:41 +0900
parents f3a608f17a39
children
line wrap: on
line diff
--- a/src/remoteeditor/action/RemoteEditorAction.java	Sun Dec 19 23:01:45 2010 +0900
+++ b/src/remoteeditor/action/RemoteEditorAction.java	Mon Dec 20 14:14:41 2010 +0900
@@ -3,7 +3,14 @@
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbench;
@@ -21,9 +28,28 @@
 public class RemoteEditorAction implements IWorkbenchWindowActionDelegate {
 	
 	private IDocument document;
-
+	private Shell shell;
+	private Text hostname;
+	private Text port;
+	private IAction action;
+	
 	public RemoteEditorAction(){
-		
+		Display display = Display.getDefault();
+		this.shell = new Shell(display);
+		this.shell.setText("Connection To SessionManager");
+		this.shell.setLayout(new FillLayout());
+		this.hostname = new Text(shell, SWT.SINGLE|SWT.BORDER);
+		hostname.setText("localhost");
+		this.port = new Text(shell, SWT.SINGLE|SWT.BORDER);
+		port.setText("8766");
+		Button button = new Button(shell, SWT.NULL);
+		button.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				connect();
+				shell.dispose();
+			}
+		});
+		button.setText("connect");
 	}
 
 	public void dispose() {
@@ -34,8 +60,7 @@
 
 	}
 
-	public void run(IAction action) {
-		System.out.println(action.getId());
+	public void connect() {
 		if(action.getId().equals("EclipseRemoteEditor.action1")){
 			IWorkbench workbench = PlatformUI.getWorkbench();
 			IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
@@ -47,16 +72,8 @@
 //			TextEditor 外部から IDocument を取得する方法
 			ITextEditor editor = (ITextEditor) editorPart;
 			document = editor.getDocumentProvider().getDocument(editorinput);
-			REPEditor repEditor = new REPEditor(new REPTextImpl2(document, display), true);
+			REPEditor repEditor = new REPEditor(new REPTextImpl2(document, display), true, hostname.getText(), new Integer(port.getText()));
 			repEditor.start();
-
-//			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();
 		
@@ -74,14 +91,15 @@
 			document = editor.getDocumentProvider().getDocument(editorinput);
 			REPEditor repEditor = new REPEditor(new REPTextImpl2(document, display), false);
 			repEditor.start();
-			
-//			workbenchPage.closeEditor(editorPart, true);
-//			try {
-//				editorPart = workbenchPage.openEditor(editorinput, "remoteeditor.editors.RemoteEditor");
-//			} catch (PartInitException e) {
-//				e.printStackTrace();
-//			}
 		}
+	
+	}	
+	
+	public void run(IAction action) {
+		System.out.println(action.getId());
+		this.action = action;
+		shell.pack();
+		shell.open();
 		/*
 		IWorkbench workbench = PlatformUI.getWorkbench();
 		//Display display = workbench.getDisplay();