Problem with IFileEditorInput [message #165698] |
Wed, 26 January 2005 11:23  |
Eclipse User |
|
|
|
Originally posted by: ass4.alu.um.es
I am developing a graphical editor with GEF. I try to save the contents of
the diagram to a file in the doSave() method:
public void doSave(IProgressMonitor monitor)
{
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream outStream = new ObjectOutputStream(out);
outStream.writeObject(content);
outStream.close();
IFile file = ((IFileEditorInput)getEditorInput()).getFile();
file.setContents(new ByteArrayInputStream(out.toByteArray()),
true, false, monitor);
out.close();
getCommandStack().markSaveLocation();
}
catch (Exception e) {
e.printStackTrace();
}
}
But, when the line IFile file =
((IFileEditorInput)getEditorInput()).getFile(); is executed I receive a
ClassCastException in that line. I donŽt know why because I have in the
class path the ide.jar (this is the file in which IFileEditorInput.class
is in).
Please, could anybody tell me how I can to solve this problem?
|
|
|
Re: Problem with IFileEditorInput [message #165706 is a reply to message #165698] |
Wed, 26 January 2005 11:43  |
Eclipse User |
|
|
|
A ClassCastException doesn't mean that the JVM can't find IFileEditorInput.
It means that the IEditorInput is of some other type. Find out what that
type is. It should be the same input as passed to the editor's setInput()
method.
"Aurelio Sanchez" <ass4@alu.um.es> wrote in message
news:ct8g54$c1u$1@www.eclipse.org...
> I am developing a graphical editor with GEF. I try to save the contents of
> the diagram to a file in the doSave() method:
>
> public void doSave(IProgressMonitor monitor)
> {
> try {
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> ObjectOutputStream outStream = new ObjectOutputStream(out);
> outStream.writeObject(content);
> outStream.close();
> IFile file = ((IFileEditorInput)getEditorInput()).getFile();
> file.setContents(new ByteArrayInputStream(out.toByteArray()),
> true, false, monitor);
> out.close();
> getCommandStack().markSaveLocation();
> }
> catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> But, when the line IFile file =
> ((IFileEditorInput)getEditorInput()).getFile(); is executed I receive a
> ClassCastException in that line. I don
|
|
|
Powered by
FUDForum. Page generated in 0.03096 seconds