Custom IContentOutlinePage [message #284420] |
Sat, 23 April 2005 05:00  |
Eclipse User |
|
|
|
Originally posted by: Wolflgang_Horn.onlinehome.de
Hi,
I'm trying to create a custom IContentOutlinePage implementation for my
ImageEditor plugin.
The code compiles fine but when I run the application, the outline view
shows the default message: "An outline is not available.".
Debugging the ImageEditor.getAdapter code shows two problems:
public Object getAdapter(Class adapter)
{
if(org.eclipse.ui.views.contentoutline.IContentOutlinePage.c lass ==
adapter)
{
return outlinePage;
}
return super.getAdapter(adapter);
}
1.) I create the outline page object in the editors constructor. When the
getAdapter method is called,
the comparison of the required adapter class and IContentOutlinePage.class
always fails. I tried the
following versions:
if(adapter == IContentOutlinePage.class)
if(IContentOutlinePage.class == adapter)
if(IContentOutlinePage.class.equals(adapter))
if(org.eclipse.ui.views.contentoutline.IContentOutlinePage.c lass ==
adapter)
and some similar. The debugger shows that the adapter parameter in fact
refers to the IContentOutlinePage class.
I get this fixed when I do a compare of class names:
if(IContentOutlinePage.class.getName() == adapter.getName())
Anyway, I think that's not the correct way to do this.
2.) When I return the page, the outline view doesn't recognize it as an
instance of IContentOutlinePage. I debugged
the method ContentOutline.doCreatePage and found that the return value of
getAdapter is exactly the object I created.
The class is ImageOutlinePage which implements IContentOutlinePage.
Nevertheless the condition below never
evaluates to true:
Object obj = part.getAdapter(IContentOutlinePage.class);
if (obj instanceof IContentOutlinePage) {
...
}
Is it possible that this is somehow related to the classpath settings?
In order to get the code compile at all, I had to add
org.eclipse.ui.views_3.1.0.jar explicitly to the Java Build Path in
project options. Does anybody know why the contentoutline package is
different from others in that respect? All
other platform packages are automatically added to the PlugIn-Dependencies
list - I didn't have to customize
anything.
Thanks,
Joggerwolf
|
|
|
|
Re: Custom IContentOutlinePage [message #284455 is a reply to message #284442] |
Mon, 25 April 2005 14:26  |
Eclipse User |
|
|
|
Originally posted by: Wolflgang_Horn.onlinehome.de
Adding the plugin to the manifest solves the problem.
Thanks!
Joggerwolf
"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> schrieb im Newsbeitrag
news:d4is7v$avi$1@news.eclipse.org...
> If you are building plugins, you should not need to explicitly add jars.
> The plugin.xml is sufficient. You're plugin.xml (or MANIFEST if using the
> new form) must have the oeg.eclipse.ui.views plugin as a required plugin.
> Explicitly providing the jars could cause a problem because now the jar is
> seen in two different plugins, so you will you get two different instances
> of the class depending on which plugin referenced it.
>
>
> --
> Thanks,
> Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.03761 seconds