MasterDetails and inital master selection [message #710639] |
Fri, 05 August 2011 04:49  |
Eclipse User |
|
|
|
Hello all !
I am extensively using th master details pattern of the forms UI. I need one little thing : I would like the master to auto-select its first item when not empty so that details are shown for this element.
It seems harder than expected : if I set the selection during master creation, the item is properly selected in the master, but details are not shown. Afterwards, I don't have the apropriate information to set the selection.
It seems to be done in PDE editors (for example the "extensions" tab), what is the best practice to implement this ?
Thank you very much!
Christophe
http://www.nextep-softwares.com
|
|
|
Re: MasterDetails and inital master selection [message #713826 is a reply to message #710639] |
Tue, 09 August 2011 02:45  |
Eclipse User |
|
|
|
Hi,
You need to set the selection after the details parts are registered to master.
In the typical code where master and details are registered add code like following:
protected void createFormContent(final IManagedForm managedForm) {
super.createFormContent(managedForm);
this.managedForm = managedForm;
this.form = managedForm.getForm();
this.toolkit = managedForm.getToolkit();
form.setText("Heading");
form.setImage("Some image");
toolkit.decorateFormHeading(form.getForm());
dtMasterDetailBlock = new EditorMasterDetailBlock(this, file, populateForDTEnumConstant, model, rootDataType, callback, domain);
Composite formBody = form.getBody();
formBody.setLayout(new GridLayout(1, false));
SashForm sashForm = new SashForm(formBody, SWT.NULL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(sashForm);
toolkit.adapt(sashForm, false, false);
dtMasterDetailBlock.createMasterPart(managedForm, sashForm);
DetailsPart detailsPart = new DetailsPart(managedForm, sashForm, SWT.NULL);
managedForm.addPart(detailsPart);
dtMasterDetailBlock.registerPages(detailsPart);
dtMasterDetailBlock.createToolBarActions(managedForm);
dtMasterDetailBlock.setInitialSelection();
}
Check location of : dtMasterDetailBlock.setInitialSelection();
Regards,
Ashwani Kr Sharma
|
|
|
Powered by
FUDForum. Page generated in 0.06062 seconds