[CommonNavigator] initial input [message #464065] |
Fri, 23 February 2007 07:13  |
Eclipse User |
|
|
|
CommonNavigator gets the initial tree via getInitialInput().
This method is supposed to return an IAdaptable. An IAdaptable
has the method public Object getAdapter(Class adapter). I
wonder when and under wich circumstances getAdapter() is
ever called? Which kind of Object is it supposed to return?
Thanks for your advice.
--
Gruesse/Regards,
Peter Maas, Aachen
E-mail "cC5tYWFzQG1hZ21hc29mdC5kZQ==\n".decode("base64")
|
|
|
|
Re: [CommonNavigator] initial input [message #464435 is a reply to message #464192] |
Mon, 05 March 2007 12:15  |
Eclipse User |
|
|
|
Sebastian Fuchs schrieb:
> adapters are another way for defining associations.
> for explanations of the adapter pattern, have a look at
> GAMMA, E. et al.: "Design Patterns", Addison-Wesley
>
> that's why there is no common answer for your question.
Sebastian,
thanks for your advice. I think I know how the adapter pattern works
but couldn't get it to work with getInitialInput(). I tried to feed
a tree of nodes into the CommonViewer by using getInitialInput().
My Implementation was:
class MyNavigator extends CommonNavigator {
// tree to be displayed in CommonViewer
ArrayList<Nodes> tree = ...;
protected IAdaptable getInitialInput() {
return new IAdaptable() {
public Object getAdapter(Class adapter) {
return tree;
}
};
}
}
I know that this is looking silly but I had no idea how to tell
the CommonViewer instance "please show this tree". A natural place
for this would probably be init() but CommonViewer doesn't yet exist
at init() call time.
> for explanations of replacing the navigator root follow this thread:
> http://www.eclipsezone.com/eclipse/forums/t79254.html?start= 0
> or have a look at the extract at
> http://www.cpuidle.de/blog/?p=48
I know these pages but found it irritating to provide a default input to
a Viewer via WorkbenchAdvisor#getDefaultPageInput(). How to handle several
views needing different input? And why must I clear the run-time workspace
to ram a tree down CommonViewer's throat? :)
Why is it hard to let CommonNavigator pull the tree from another object?
I came up with this workaround:
public void setFocus() {
super.setFocus();
if (root == null) {
CommonViewer viewer = getCommonViewer();
if (viewer != null) {
root = TreeProvider.initializeTree();
viewer.setInput(root);
}
}
}
I know that this is silly, too, but - being a workaround - it works. :)
Thanks again for your advice.
--
Gruesse/Regards,
Peter Maas, Aachen
E-mail "cC5tYWFzQG1hZ21hc29mdC5kZQ==\n".decode("base64")
|
|
|
Powered by
FUDForum. Page generated in 0.24586 seconds