Save As Dialog in RCP application [message #463486] |
Mon, 12 February 2007 13:23  |
Eclipse User |
|
|
|
Originally posted by: unidad.gmx.net
Hi!
I'm new to RCP and building a little RCP Editor app.
I'd like do build a "Save as dialog" with that a user can
save a copy of the current edited file in my editor
somewhere in the filesystem. (inside or outside the workplace.)
I've learned, that the class
org.eclipse.ui.dialogs.SaveAsDialog
doesn't work for standalone RCP applications.
Now I'm trying to build my own dialog.
My problem is:
How can I create a new IFile-object, that has no correspondence in the
workplace?
I have the absolute path where the new file should be created,
but I don't manage to create a IFile out of the path.
I need something like this:
IFile file = createMagicIFileInstanceOutOfChosenPath(chosenPathName);
....
file.create(stream, false, null);
....
Any ideas?
Greetings, Herman
|
|
|
|
|
|
Re: Save As Dialog in RCP application [message #463506 is a reply to message #463486] |
Mon, 12 February 2007 17:58   |
Eclipse User |
|
|
|
If you want to save a file in (out of) the workspace, you have to
implement separate editor inputs.
For example:
- if the file is in the workspace, you would use FileEditorInput
- if the file is external, you can use JavaEditorInput
When you save the file, you can use the following:
File file = new File("abc");
try {
IFileStore store = EFS.getStore(file.toURI());
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile[] files = root.findFilesForLocation(new Path(store.toURI()
.getPath()));
IEditorInput input = null;
if (files != null && files.length == 1) {
// the file is in the workspace
input = new FileEditorInput(files[0]);
} else {
// the file is external
input = new JavaFileEditorInput(store);
}
setInput(input);
} catch (CoreException e) {
// catch exception
}
Snjeza
Hermann Maier wrote:
> Hi!
>
> I'm new to RCP and building a little RCP Editor app.
>
> I'd like do build a "Save as dialog" with that a user can
> save a copy of the current edited file in my editor
> somewhere in the filesystem. (inside or outside the workplace.)
>
> I've learned, that the class
> org.eclipse.ui.dialogs.SaveAsDialog
> doesn't work for standalone RCP applications.
>
> Now I'm trying to build my own dialog.
> My problem is:
>
> How can I create a new IFile-object, that has no correspondence in the
> workplace?
>
> I have the absolute path where the new file should be created,
> but I don't manage to create a IFile out of the path.
>
> I need something like this:
> IFile file = createMagicIFileInstanceOutOfChosenPath(chosenPathName);
> ...
> file.create(stream, false, null);
> ...
>
> Any ideas?
>
> Greetings, Herman
|
|
|
|
|
|
|
Re: Save As Dialog in RCP application [message #463740 is a reply to message #463719] |
Thu, 15 February 2007 03:32  |
Eclipse User |
|
|
|
Paul Webster wrote:
> JavaFileEditorInput (which is like an IEditorInput for java.io.File)
> is in JDT
No, it is not. It is an internal class in 'org.eclipse.ui.editors' which
will be deleted soon. If you use 3.3 you should use the
'FileStoreEditorInput' which is in 'org.eclipse.ui.ide'.
Dani
>
> PW
|
|
|
Powered by
FUDForum. Page generated in 0.05166 seconds