Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput
cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332624] Sun, 02 November 2008 21:41 Go to next message
Eclipse UserFriend
Hi there!
I have plugin written for 3.2. Now I try to run with 3.3, when I save my
editor context I get exception.
My EditorInput implements only IEditorInput. What is the problem?

java.lang.ClassCastException: ira.editors.EditorInput cannot be cast to
org.eclipse.ui.ide.FileStoreEditorInput
at ira.editors.Editor.doSave(Editor.java:122)
at org.eclipse.ui.internal.DefaultSaveable.doSave(DefaultSaveab le.java:54)
at org.eclipse.ui.Saveable.doSave(Saveable.java:212)
at
org.eclipse.ui.internal.SaveableHelper.doSaveModel(SaveableH elper.java:339)
at org.eclipse.ui.internal.SaveablesList$4.run(SaveablesList.ja va:610)
at org.eclipse.ui.internal.SaveableHelper$4.run(SaveableHelper. java:266)
at
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:458)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:366)
at
org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:758)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at
org.eclipse.jface.window.ApplicationWindow.run(ApplicationWi ndow.java:755)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow. java:2487)
at
org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOpe ration(SaveableHelper.java:274)
at org.eclipse.ui.internal.SaveablesList.saveModels(SaveablesLi st.java:619)
at
org.eclipse.ui.internal.SaveablesList.promptForSaving(Saveab lesList.java:583)
at
org.eclipse.ui.internal.SaveablesList.promptForSavingIfNeces sary(SaveablesList.java:423)
at
org.eclipse.ui.internal.SaveablesList.preCloseParts(Saveable sList.java:383)
at
org.eclipse.ui.internal.WorkbenchPage.closeEditors(Workbench Page.java:1315)
at
org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchP age.java:1402)
at org.eclipse.ui.internal.EditorPane.doHide(EditorPane.java:61 )
at org.eclipse.ui.internal.PartStack.close(PartStack.java:543)
at org.eclipse.ui.internal.EditorStack.close(EditorStack.java:2 06)
at org.eclipse.ui.internal.PartStack$1.close(PartStack.java:122 )
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation$1.handleEvent(TabbedStackPresentation.java:83)
at
org.eclipse.ui.internal.presentations.util.AbstractTabFolder .fireEvent(AbstractTabFolder.java:267)
at
org.eclipse.ui.internal.presentations.util.AbstractTabFolder .fireEvent(AbstractTabFolder.java:276)
at
org.eclipse.ui.internal.presentations.defaultpresentation.De faultTabFolder.access$1(DefaultTabFolder.java:1)
at
org.eclipse.ui.internal.presentations.defaultpresentation.De faultTabFolder$1.closeButtonPressed(DefaultTabFolder.java:70 )
at
org.eclipse.ui.internal.presentations.PaneFolder.notifyClose Listeners(PaneFolder.java:626)
at
org.eclipse.ui.internal.presentations.PaneFolder$3.close(Pan eFolder.java:206)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:21 71)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.j ava:324)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at myrcp.Application.run(Application.java:195)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.eclipse.equinox.internal.app.EclipseAppContainer.callMet hodWithException(EclipseAppContainer.java:574)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:195)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:386)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332626 is a reply to message #332624] Mon, 03 November 2008 00:12 Go to previous messageGo to next message
Eclipse UserFriend
The problem is:

I created both MyEditor and MyEditorInput classes. When I create new
MyEditor I pass instance of my MyEditorInput.But when I open file, workbench
creates MyEditor but call init() with FileStoreEditorInput as parameter.So,
when I call getEditorInput() I may have my MyEditoInput or
FileStoreEditorInput. It causes the problem, because I try to cast them.I
can check if I get MyEditoInput or FileStoreEditorInput, but it doesn't look
nice. So, what is right way to handle this situation?

Thank you,

Andrey
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332642 is a reply to message #332626] Mon, 03 November 2008 12:59 Go to previous messageGo to next message
Eclipse UserFriend
Do you need to be able to open an IFile? Or if you are associated with
a file extension and you need to operate in the workspace, why write
MyEditorInput?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332644 is a reply to message #332626] Mon, 03 November 2008 13:18 Go to previous messageGo to next message
Eclipse UserFriend
Andrey Ilinykh wrote:
> I created both MyEditor and MyEditorInput classes. When I create new
> MyEditor I pass instance of my MyEditorInput.But when I open file, workbench
> creates MyEditor but call init() with FileStoreEditorInput as parameter.So,
> when I call getEditorInput() I may have my MyEditoInput or
> FileStoreEditorInput. It causes the problem, because I try to cast them.I
> can check if I get MyEditoInput or FileStoreEditorInput, but it doesn't look
> nice. So, what is right way to handle this situation?

When you open a file outside of the workspace (like File > Open...),
Eclipse will use a FileStoreEditorInput (as you discovered). As far as I
know, there is no way of knowing that MyEditorInput is supposed to match
with MyEditor so I'm not even sure how your code originally worked in
3.2. What are you adding to MyEditorInput that can't be satisfied by the
framework's original IEditorInput implementations?
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332650 is a reply to message #332642] Mon, 03 November 2008 17:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: andrey.int.com

I have simple RCP application with several Views and Editors. I have to open
data file, modify it and save.
I don't use workspace at all.My understanding is I have to implement
IEditorInput interface.

"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:gemt12$i01$2@build.eclipse.org...
> Do you need to be able to open an IFile? Or if you are associated with a
> file extension and you need to operate in the workspace, why write
> MyEditorInput?
>
> PW
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332656 is a reply to message #332644] Tue, 04 November 2008 04:21 Go to previous messageGo to next message
Eclipse UserFriend
> 3.2. What are you adding to MyEditorInput that can't be satisfied by the
> framework's original IEditorInput implementations?
I need simple thing- read and write file. IEditorInput doesn't allow to do
it. So, I implemented my own EditorInput
which keeps path to the file. It was fine in 3.1 (not 3.2, I was mistaken).
But now I have a problem.
What is the right way to work with files wich are not in workplace?

Thank you,
Andrey
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332658 is a reply to message #332656] Tue, 04 November 2008 07:58 Go to previous messageGo to next message
Eclipse UserFriend
File R/W should be handled by FileStoreEditorInput. I would suggest you
open editors using that instead of your own MyEditorInput. To reiterate,
what is special about your IEditorInput implementation that can't be
satisfied? If you need to open non-workspace resources, you should use
the FSEI class in my opinion. Please provide more context to your
application's setup.
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332667 is a reply to message #332658] Tue, 04 November 2008 13:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: andrey.int.com

> what is special about your IEditorInput implementation that can't be
> satisfied? If you need to open non-workspace resources, you should use the
> FSEI class in my opinion. Please provide more context to your
> application's setup.
Actually, nothing. But how to create FSEI? It requires IFileStore in
constructor. How to pass local file to FSEI?

Thnak tyou,
Andrey
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332668 is a reply to message #332667] Tue, 04 November 2008 13:43 Go to previous messageGo to next message
Eclipse UserFriend
ailinykh wrote:
> Actually, nothing. But how to create FSEI? It requires IFileStore in
> constructor. How to pass local file to FSEI?

http://wiki.eclipse.org/EFS
http://help.eclipse.org/stable/nftopic/org.eclipse.platform. doc.isv/reference/api/org/eclipse/core/filesystem/package-su mmary.html

Use EFS.getLocalFileSystem(). I think you can figure it out from there.
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332684 is a reply to message #332668] Wed, 05 November 2008 02:53 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for links. Actually there is a complication here.
The reason why I need my own EditorInput is:
When I create new editor, there is no any file in file system. So, I create
new Model (which provides content I will edit) and pass it to editor using
my EditorInput. It looks like:

EditorInput ei=new EditorInput( new Model());
window.getActivePage().openEditor(ei, Editor.ID);

So I need special EditorInput, which keeps my model. I don't see how I can
use standard EditorInput.What do I miss?

Thank you,
Andrey
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332711 is a reply to message #332684] Thu, 06 November 2008 14:59 Go to previous messageGo to next message
Eclipse UserFriend
Just so you know, it's extremely not recommended that you put model
objects in your IEditorInput itself. Read the javadoc for IEditorInput.
Think java.io.File, it's simply a key that would allow your editor to
load the content you need.

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332868 is a reply to message #332711] Tue, 11 November 2008 17:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: andrey.int.com

I agree. Having model in IEditorInput is not good idea. But what should I do
when I create new editor?
There is no any File at this moment. I don't see how I can tell editor to
create new model. I tried to pass null as IEditorInput. It doesn't work
null is not allowed.
Thank you,
Andrey


"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:gev161$23q$1@build.eclipse.org...
> Just so you know, it's extremely not recommended that you put model
> objects in your IEditorInput itself. Read the javadoc for IEditorInput.
> Think java.io.File, it's simply a key that would allow your editor to load
> the content you need.
>
> PW
>
>
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping
> http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332878 is a reply to message #332868] Wed, 12 November 2008 06:48 Go to previous messageGo to next message
Eclipse UserFriend
I tried opening an editor on a non-existing file. It works fine

IFileStore store = EFS.getLocalFileSystem().getStore(new
Path("C:\\NoSuchFile.txt"));
IDE.openEditor(activePage, new FileStoreEditorInput(store),
"org.eclipse.ui.DefaultTextEditor");

So probably the issue would be in your editor. Probably in the place
where you create your model from the file (setInput?), check whether the
file exists and if not, create an empty model.

- Prakash
--

http://blog.eclipse-tips.com
Re: cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332885 is a reply to message #332878] Wed, 12 November 2008 13:26 Go to previous message
Eclipse UserFriend
Originally posted by: andrey.int.com

Create a new file and open non existing file are different things. If you
open file which doesn't exixt (someone deleted it) this is an exceptional
situation and you have to notify user. Creating a new file is regular
procedure, you have to create new editor, that's it. What I found in eclipse
sources (Java editor probably) is creating special implementation of
IEditorInput which is not connected to any file. Is it a supposed way to
create new editor?

Thank you,
Andrey

"Prakash G.R." <grprakash@gmail.com> wrote in message
news:gfdu71$e2d$1@build.eclipse.org...
>I tried opening an editor on a non-existing file. It works fine
>
> IFileStore store = EFS.getLocalFileSystem().getStore(new
> Path("C:\\NoSuchFile.txt"));
> IDE.openEditor(activePage, new FileStoreEditorInput(store),
> "org.eclipse.ui.DefaultTextEditor");
>
> So probably the issue would be in your editor. Probably in the place
> where you create your model from the file (setInput?), check whether the
> file exists and if not, create an empty model.
>
> - Prakash
> --
>
> http://blog.eclipse-tips.com
>
>
Previous Topic:view and multiple viewers
Next Topic:How to list features of local update site?
Goto Forum:
  


Current Time: Sun Feb 16 16:22:18 GMT 2025

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

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

Back to the top