error launching text editor [message #145333] |
Tue, 28 March 2006 09:21  |
Eclipse User |
|
|
|
Originally posted by: jr_gz.hotmail.com
Hello everybody.
IŽm building a small plug-in with a Samplemenu(contains a SampleAction)
and I wonna open a file(ItŽs out of the workspace) in the text editor when
I execute the SampleAction, but when I execute it I recieve the next
error:
Unhandled event loop exception
Reason:
Workspace is closed.
The code that IŽm using is the next(SampleAction.java):
public void run(IAction action) {
MessageDialog.openInformation(window.getShell(),"Example1HelloWorld
Plug-in",
"Hello, Eclipse world");
IWorkspace ws = ResourcesPlugin.getWorkspace(); //****
IProject project = ws.getRoot().getProject("External Files");
IPath location = new Path("C:\\jr.txt");
IFile file = project.getFile(location.lastSegment());
IEditorInput input=null;
input = new FileEditorInput(file);
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().
openEditor(input, "org.eclipse.ui.DefaultTextEditor");
} catch (PartInitException e) {
e.printStackTrace();
}
}
The error ocurre in the second instruction(****).
I think that I can resolve the error if I DonŽt use "ws" and "project",
but then how can I indicate the IFile?
Can anybody help me?
Thanks a lot.
|
|
|
|
Powered by
FUDForum. Page generated in 0.07844 seconds