Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » [CommonNavigator] initial input
[CommonNavigator] initial input [message #464065] Fri, 23 February 2007 07:13 Go to next message
Eclipse UserFriend
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 #464192 is a reply to message #464065] Tue, 27 February 2007 04:02 Go to previous messageGo to next message
Eclipse UserFriend
hi peter,

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.
to give a honest, but confusing one:
getAdapter(Class adapter) could be called from every code point at any
time for any class argument.

probably you are looking for something else:

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

sebastian



Peter Maas schrieb:
> 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.
>
Re: [CommonNavigator] initial input [message #464435 is a reply to message #464192] Mon, 05 March 2007 12:15 Go to previous message
Eclipse UserFriend
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")
Previous Topic:3rd party class not found
Next Topic:Refresh, New Project, within Ant?
Goto Forum:
  


Current Time: Wed Mar 26 10:11:21 EDT 2025

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

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

Back to the top