Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem with IFileEditorInput
Problem with IFileEditorInput [message #165698] Wed, 26 January 2005 16:23 Go to next message
Eclipse UserFriend
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 16:43 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
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
Previous Topic:Direct Edit on creation
Next Topic:Deleting a Connection
Goto Forum:
  


Current Time: Sat Apr 27 03:25:45 GMT 2024

Powered by FUDForum. Page generated in 0.02591 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top