Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 304768 - Contribution of Master-Detail Support
Summary: Contribution of Master-Detail Support
Status: CLOSED WONTFIX
Alias: None
Product: EEF
Classification: Modeling
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement
Target Milestone: ---   Edit
Assignee: EEF Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 303845 304624
Blocks:
  Show dependency tree
 
Reported: 2010-03-04 20:37 EST by Miles Parker CLA
Modified: 2016-05-30 10:37 EDT (History)
2 users (show)

See Also:


Attachments
Patch for Master Detail support. (20.92 KB, text/plain)
2010-03-04 20:37 EST, Miles Parker CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miles Parker CLA 2010-03-04 20:37:12 EST
Created attachment 161056 [details]
Patch for Master Detail support.

Hi guys,

As threatened :) here is the support for Master Detail within EEF forms. It's pretty slick I have to say, and I can say that because the overall abstraction of EMF and EEF made some cool things possible. You can drill down into arbitrary (depending on screen real estate) levels of detail for any EMF relations. You can add and remove objects using the existing buttons. It remembers the expanded state of sub-forms, etc.. I've only tried it with forms, but I assume it should work with other parts as well. There is a fair amount of subtlety involved in getting the events to the right place and so on and I think that is working pretty well at this point. Undo isn't working well right now, but I think that's due to bug 304624 I reported today. Except for one place where we don't have a user code block, full auto-regeneration currently works as well!

So, Goulwen asked how we could model this..he sounded a bit skeptical. :) The idea is to have a ViewReference that includes the information for the referring reference, etc.. In other words, all we need is what is in the constructor for GenericDetailPropertiesEditionPart, and that should all be available or easily added to the .components EEF model. For obvious reasons, I haven't gone mucking around with the Acelo generation or models. Should I have a separate bug for the generation and model support, or could we just keep it here?

Below is a use case, which should also serve as guidance for integrating with model. I don't have this example tested because I just ensued my own code, and I'm not sure that the eef example models are working..plus I'm way over the time I planned to spend on this! There are as always lot's of improvements that could be made.

See my blog entry for background and setup steps 1-3. http://milesparker.blogspot.com/2010/02/pimping-eef-master-detail.html

You don't need to register anything or do anything else complicated -- you can use all of the existing forms and providers as is. You just need to change LibraryPropertiesEditionPartForm in these places:

    // Start of user code for attributeDetail widgets declarations
    private AbstractDetailPropertiesEditionPart bookDetail;
    // End of user code


	protected void addToBooks() {
		// Start of user code addToBooks() method body
        bookDetail.addDetailObject();
        // End of user code

	}

	protected void createBooksGroup(FormToolkit widgetFactory, final Composite view) {
...
// Start of user code for booksDetail widgets implementation
        bookDetail = new SimpleDetailPropertiesEditionPart("Book", propertiesEditionComponent, books, LibrariesViewsRepository.SContext.books,
            LibrariesViewsRepository.class, "label", LibrariesViewsRepository.FORM_KIND,
            LibrariesPackage.eINSTANCE.getBook(), LibrariesViewsRepository.Book.class);
        bookDetail.createControls(widgetFactory, booksGroup);

        // End of user code
		booksSection.setClient(booksGroup);
	}


	public void initBooks(EObject current, EReference containingFeature, EReference feature) {
		if (current.eResource() != null && current.eResource().getResourceSet() != null)
			this.resourceSet = current.eResource().getResourceSet();
		if (containingFeature != null)
			booksEditUtil = new EMFListEditUtil(current, containingFeature, feature);
		else
			booksEditUtil = new EMFListEditUtil(current, feature);
        bookDetail.init(current, booksEditUtil);
	}

OK, that's it!

As you can see, we need a user code block in initBooks. I couldn't think of a better place to put this.

That's the simple example. That's for use when there is only one instantiable class for a given reference. In the case where there is more, you just need to specialize GenericDetailPropertiesEditionPart like this:

public class BookDetailPart extends GenericDetailPropertiesEditionPart {

    public BookDetailPart(IPropertiesEditionComponent masterComponent, ReferencesTable<? extends EObject> table,
            String masterReference) {
            super("Book", masterComponent, table, masterReference, LibrariesViewsRepository.class, "label",
                    LibrariesViewsRepository.FORM_KIND, MetaABMPackage.eINSTANCE.getBook());
        }


    public Class getDetailView(Object object) {
//you want to have the least specialized classes appear last here..
        if (object instanceof org.example.LargeFormatBook) {
            return LibrariesViewsRepository.LargeFormatBook.class;
        } else if (object instanceof org.example.AudioBook) {
            return LibrariesViewsRepository.SContinuousSpace.class;
        } else if (object instanceof org.example.Book) {
            return LibrariesViewsRepository.Book.class;
        }
...
        return null;
    }
}

Note that the subclass is only necessary because I wasn't able to find a way to get the analogous default view from a given EClass. It should be possible to generate that, right?

OK, enough for now. Hope you have a chance to try it out. I'll try to get a simple screencast or something together on it.

cheers,

Miles
Comment 1 Miles Parker CLA 2010-03-04 20:39:47 EST
Oh, I obviously missed some text replaces in my examples form the original usage, but I think the usage should still be clear. Let me know if you have a hard time replicating.
Comment 2 Miles Parker CLA 2010-03-04 21:14:11 EST
I forget to mention that 303845 also breaks this and until that's fixed you need one more change to "LibraryPropertiesEditionComponent"...

	protected void runUpdateRunnable(final Notification msg) {
        if (msg.getNotifier() == library) {
...
        }
        }
Comment 3 Miles Parker CLA 2010-03-12 15:24:18 EST
Just to note that I have "improved" this a lot already. So if you decide to incorporate please let me know and I can send an update patch. Or you could just make me a committer. ;)

BTW, I think we could safely roll all of the table edit util from Advanced Widget Table Composition into a helper class as well. Would make the code quit a bit cleaner and I can't see anyone wanting to change these behaviors directly and they don't have protected regions anyway..
Comment 4 Stephane Begaudeau CLA 2016-05-30 10:37:22 EDT
The Eclipse EEF team has worked over the past few months on a brand new runtime using a reflective approach which can be used more easily with Eclipse Sirius. Since we do not plan to continue to work on the old runtime and its code generation approach, I will close this issue for now.

If you want to contribute, you can reopen this issue and submit a contribution to the project thanks to our Gerrit: https://git.eclipse.org/r/#/admin/projects/eef/org.eclipse.eef