view src/remoteeditor/action/RemoteEditorAction.java @ 34:7d80c9318695

*** empty log message ***
author pin
date Wed, 31 Jan 2007 02:06:52 +0900
parents
children 7f346cf2a07b
line wrap: on
line source

package remoteeditor.action;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.internal.WorkbenchPage;

public class RemoteEditorAction implements IWorkbenchWindowActionDelegate {
	
	public RemoteEditorAction(){
		
	}

	public void dispose() {

	}

	public void init(IWorkbenchWindow window) {

	}

	public void run(IAction action) {
		IWorkbench workbench = PlatformUI.getWorkbench();
		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);
		
		//System.out.println(editorinput.getName());
		
		try {
			editorPart = workbenchPage.openEditor(editorinput, "remoteeditor.editors.RemoteEditor");
			System.out.println("test");
		} catch (PartInitException e) {
			e.printStackTrace();
		}
		

	}

	public void selectionChanged(IAction action, ISelection selection) {

	}

}