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
Member
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 06:45 Go to previous message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 118
Registered: July 2009
Location: Bangalore, India
Senior Member

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
Previous Topic:Checkboxcelleditor in treeviewercolumn
Next Topic:Check box with text in the tool bar
Goto Forum:
  


Current Time: Sun Nov 23 07:34:49 GMT 2014

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

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