openEditor in junit test refuses to open my editor, returns TextEditor [message #725475] |
Wed, 14 September 2011 17:25  |
Eclipse User |
|
|
|
I have an editor set up to open Makefile.am and Makefile.in files. I have specified a contenttype extension with "am" file extension and "Makefile.am,Makefile.in" files specified. I also have the same specified in my Automake editor and I refer to the content type id there as well (perhaps overkill).
In the Linux Tools EPP, it works fine. If one clicks on a Makefile.am or Makefile.in file, it opens using the editor.
In my junit test, I use Display.syncExec and create a Makefile.am file and then try and use:
EditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(
workbench.getActiveWorkbenchWindow().getActivePage(),
makefileAmFile,
true);
I then cast this to an AutomakeEditor to test various aspects of the editor.
When I run this test, I keep getting a ClassCastException because openEditor keeps giving me back a TextEditor and not an AutomakeEditor.
Any ideas why this works in normal Eclipse (i.e. double-clicking on a Makefile.am file brings up the right editor) but not under the junit test framework?
|
|
|
Re: openEditor in junit test refuses to open my editor, returns TextEditor [message #725555 is a reply to message #725475] |
Thu, 15 September 2011 03:09   |
Eclipse User |
|
|
|
On 14.09.2011 23:25, Jeff Johnston wrote:
> I have an editor set up to open Makefile.am and Makefile.in files. I
> have specified a contenttype extension with "am" file extension and
> "Makefile.am,Makefile.in" files specified. I also have the same
> specified in my Automake editor and I refer to the content type id
> there as well (perhaps overkill).
>
> In the Linux Tools EPP, it works fine. If one clicks on a Makefile.am
> or Makefile.in file, it opens using the editor.
>
> In my junit test, I use Display.syncExec and create a Makefile.am file
> and then try and use:
>
>
> EditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(
> workbench.getActiveWorkbenchWindow().getActivePage(),
> makefileAmFile,
> true);
>
> I then cast this to an AutomakeEditor to test various aspects of the
> editor.
>
> When I run this test, I keep getting a ClassCastException because
> openEditor keeps giving me back a TextEditor and not an AutomakeEditor.
>
> Any ideas why this works in normal Eclipse (i.e. double-clicking on a
> Makefile.am file brings up the right editor) but not under the junit
> test framework?
I see two possible reasons:
1) You manually defined the content type or default editor in your
normal Eclipse and hence it is missing when running the test
2) The bundle which defines the content type is not part of the required
bundles.
Dani
|
|
|
|
|
|
|
Re: openEditor in junit test refuses to open my editor, returns TextEditor [message #726906 is a reply to message #726674] |
Mon, 19 September 2011 17:39  |
Eclipse User |
|
|
|
Quote:Maybe some activities are defined in your test setup which filter your
editor? Look for 'org.eclipse.ui.activities' and
'org.eclipse.ui.activitySupport' extensions.
Dani
Thanks Dani. That appeared to be the problem. There was a plug-in that had activity ids and patterns set up in it. It used a pattern that matched Autotool stuff to map it to a general id, but it did not set default enablement for that id. Adding a default enablement statement seemed to have fixed the problem.
Not sure as to why this problem didn't show up using the editor via double-clicking on a file, but I am happy to have gotten to this work finally.
|
|
|
Powered by
FUDForum. Page generated in 0.08882 seconds