cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput [message #332624] |
Sun, 02 November 2008 21:41  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #332644 is a reply to message #332626] |
Mon, 03 November 2008 13:18   |
Eclipse User |
|
|
|
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 #332656 is a reply to message #332644] |
Tue, 04 November 2008 04:21   |
Eclipse User |
|
|
|
> 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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #332684 is a reply to message #332668] |
Wed, 05 November 2008 02:53   |
Eclipse User |
|
|
|
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 #332878 is a reply to message #332868] |
Wed, 12 November 2008 06:48   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.07455 seconds