Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » MasterDetails and inital master selection
MasterDetails and inital master selection [message #710639] Fri, 05 August 2011 08:49 Go to next message
Christophe Fondacci is currently offline Christophe FondacciFriend
Messages: 95
Registered: July 2009
Location: Paris
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!
Re: MasterDetails and inital master selection [message #713826 is a reply to message #710639] Tue, 09 August 2011 06:45 Go to previous message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member


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) {
		this.managedForm = managedForm;
		this.form = managedForm.getForm();
		this.toolkit = managedForm.getToolkit();

		form.setImage("Some image");
		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);


Check location of : dtMasterDetailBlock.setInitialSelection();

Ashwani Kr Sharma
Previous Topic:Validation Order
Next Topic:Unable to retrieve the modified cell value in the Table Viewer
Goto Forum:

Current Time: Mon Jun 25 04:34:08 GMT 2018

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

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

Back to the top