// master details page try { ScrolledPropertiesPage masterDetailsPage= new ScrolledPropertiesPage(this); pageIndex=addPage(masterDetailsPage); setPageText(pageIndex, "Model"); } catch (PartInitException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }
where ScrolledPropertiesPage is borrowed from the Eclipse Forms Tutorial examples as is the ScrolledPropertiesBlock class called on by the ScrolledPropertiesPage.
In the ScrolledPropertiesBlock called by the Master part of our ScrolledPropertiesPage lies the opportunity to define our details page parts. Rather than registering pages for types as shown in the Eclipse Forms Tutorial example we use a call to detailsPart.setPageProvider(myDetailsPageProvider); to handle the detailsPart creation for our model objects. This gives us a chance to ask the object what it is and display the results as we learn what our viewer selections call themselves as we develop detail pages. For simplicity's sake the details part sections are contained in the ObjectDetailsPage as private classes that build input forms for our objects. Connecting the widget contents back to the model uses PropertyDescriptors and modifyListeners
... we get the PropertyDescriptors list from the selection input ...
final List l = new AdapterFactoryItemDelegator( ourEditor.getAdapterFactory()).getPropertyDescriptors(input);... after that when we create a text some control named Title and fill it with blah.getTitle(), then, to deal with editor changes to the value we add a ModifyListener when we setLayoutData ... ...
Title.setLayoutData(gd); Title.addModifyListener(new ModifyListener(){ public void modifyText(ModifyEvent e) { for (Iterator i=l.iterator();i.hasNext();) { IItemPropertyDescriptor desc = (IItemPropertyDescriptor)i.next(); if (desc.getId(input).equals( "Title" ) ) { desc.setPropertyValue(input,((Text)e.widget).getText()); } } }});
... now changing the field in our form updates the contents of the properties view and the model. Changes made in the properties view will show up in our details form the next time the details form is refreshed.