DetailsPart and registered pages [message #327329] |
Tue, 15 April 2008 11:41  |
Eclipse User |
|
|
|
I have a master/details page. I have objects in the master page. Some of
the items in the master like are like staff, manager, president... that all
extend Person. I want the selection to bring up the same page for all of
these selections.
detailsPart.registerPage(Person.class, new PersonDetailsPage());
but this doesn't work. I need to implement this for each class. Is that
correct?
|
|
|
|
|
Re: DetailsPart and registered pages [message #327369 is a reply to message #327341] |
Wed, 16 April 2008 12:38  |
Eclipse User |
|
|
|
To use the same page for all the children regardless of type and with
unknown classes the DetailsPageProvider approach is your friend.
in the MasterDetailsBlock declare something like
private IDetailsPageProvider myDetailsPageProvider;
then create the DetailsPageProvider in the M/D block constructor
myDetailsPageProvider=new DetailsPageProvider(...);
so that your registerPages method can say something like
void registerPages(DetailsPart detailsPart) {
detailsPart.setPageProvider(myDetailsPageProvider);
}
Now, DetailsPageProvider looks something like
public class DetailsPageProvider
implements IDetailsPageProvider {
public DetailsPageProvider(...) {
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see
org.eclipse.ui.forms.IDetailsPageProvider#getPageKey(java.la ng.Object)
*/
public Object getPageKey(Object object) {
return object;
}
/* (non-Javadoc)
* @see org.eclipse.ui.forms.IDetailsPageProvider#getPage(java.lang. Object)
*/
public IDetailsPage getPage(Object key) {
return new ObjectDetailsPage(key);
}
}
And from there it is all about whatever you want ObjectDetailsPage to
put on the form -
public class ObjectDetailsPage
implements IDetailsPage {
...
public ObjectDetailsPage(Object key) {
...
}
/* (non-Javadoc)
* @see org.eclipse.ui.forms.
* IDetailsPage#createContents(org.eclipse.swt.widgets.Composit e)
*/
public void createContents(Composite parent) {
// here you get to create whatever form you
// want for the input object
...
// or you can use the same page for every object
}
HTH,
Steve
Jay Simpson wrote:
> Is this a bug or the way its supposed to work by design? Is there a way to
> have all the children use the same page without listing all the classes? We
> would like to be able to extend this to unknown classes.
>
>
> "Steve Blass" <sblass@acm.org> wrote in message
> news:fu31ar$i75$1@build.eclipse.org...
>> Jay Simpson wrote:
>>> I have a master/details page. I have objects in the master page. Some
>>> of the items in the master like are like staff, manager, president...
>>> that all extend Person. I want the selection to bring up the same page
>>> for all of these selections.
>>>
>>> detailsPart.registerPage(Person.class, new PersonDetailsPage());
>>>
>>> but this doesn't work. I need to implement this for each class. Is that
>>> correct?
>> To use registered pages the answer is yes. It is also possible to use a
>> DetailsPageProvider and build pages that depend on the input class without
>> registering the pages ahead of time.
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03123 seconds