Opening an Editor or a file directly [message #221941] |
Tue, 22 August 2006 04:11 |
Eclipse User |
|
|
|
Originally posted by: meokoken.gmail.com
Hi,
May I know of the ways in which I can open a specific file in an editor?
Or how do I open an editor without opening a file?
Is it a must to have the file in a project before I can open it? Can I
open a file directly without having it save in a project in the eclipse
workspace?
Currently there are 2 ways which I can open the file. Both requires my
file to be in a project.
The first way is to save the file first in a project and then else where
in my code, I create an action button, which runs:
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
IWorkspace ws = ResourcesPlugin.getWorkspace();
IProject project = ws.getRoot().getProject("MY_PROJECT_NAME");
IFile newFile = project.getFile("/MY_FILENAME.extension");
try {
IDE.openEditor(page, newFile, true);
} catch (PartInitException e) {
e.printStackTrace();
}
The 2nd way is similar to the first, as I am extending the shapes example
given in GEF, it provides a WizardNewFileCreationPage which uses roughly
the same method as my first method to open a file.
I need to be able to open a file directly without creating a project.
Someone please help. Thanks in advance.
|
|
|
Re: Opening an Editor or a file directly [message #221962 is a reply to message #221941] |
Tue, 22 August 2006 11:18 |
Eclipse User |
|
|
|
Originally posted by: lamont_gilbert.rigidsoftware.com
Meo Kok Eng wrote:
> Hi,
>
> May I know of the ways in which I can open a specific file in an editor?
> Or how do I open an editor without opening a file?
>
> Is it a must to have the file in a project before I can open it? Can I
> open a file directly without having it save in a project in the eclipse
> workspace?
>
> Currently there are 2 ways which I can open the file. Both requires my
> file to be in a project.
>
>
> The first way is to save the file first in a project and then else where
> in my code, I create an action button, which runs:
>
>
> IWorkbenchPage page =
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
>
> IWorkspace ws = ResourcesPlugin.getWorkspace();
>
> IProject project = ws.getRoot().getProject("MY_PROJECT_NAME");
> IFile newFile = project.getFile("/MY_FILENAME.extension");
> try {
> IDE.openEditor(page, newFile, true);
> } catch (PartInitException e) {
> e.printStackTrace();
> }
>
>
>
> The 2nd way is similar to the first, as I am extending the shapes example
> given in GEF, it provides a WizardNewFileCreationPage which uses roughly
> the same method as my first method to open a file.
>
>
> I need to be able to open a file directly without creating a project.
> Someone please help. Thanks in advance.
Editors expect IEditorInputs. They don't care how you create them. I'm not
at all familiar with sending an IFile to an editor. Maybe the method uses
a default wrapper of some sort for IFiles.
--
Respectfully,
CL Gilbert
"Verily, verily, I say unto you, He that entereth not by the door() into the
sheepfold{}, but climbeth up some other *way, the same is a thief and a
robber."
|
|
|
Powered by
FUDForum. Page generated in 0.04109 seconds