Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] ECPCellEditor Instantiate(When is instantiate called)
[EMF Forms] ECPCellEditor Instantiate [message #1728068] Wed, 30 March 2016 17:47 Go to next message
Robert Onslow is currently offline Robert OnslowFriend
Messages: 27
Registered: March 2016
Junior Member
I am customizing the Table in EMForms by registering an ECPCellEditor and ECPCellEditorTestor, following https://www.eclipse.org/forums/index.php/t/1067605/

My ECPCellEditor needs access to the Domain Model to populate a drop down with some elements in the model.

I note that ECPCellEditor.instantiate delivers a ViewModelContext, which I can then store to get the model using ViewModelContext.getDomainModel()

@Override
	public void instantiate(EStructuralFeature feature, ViewModelContext viewModelContext) {
		this.viewModelContext = viewModelContext;
}


However I'm finding that, although the ECPCellEditor is being installed, instantiate is not being called.

So my questions are: (a) when is instantiate called; (b) is this the correct way of accessing the domain mode from within the ECPCellEditorl?

Thanks

Robert
Re: [EMF Forms] ECPCellEditor Instantiate [message #1728098 is a reply to message #1728068] Thu, 31 March 2016 02:51 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

instantiate should be called once the Table is initialized.
Do you want to access the root element (the one which contains the
elements shown in the tree) or the element of a particular row? The cell
editor is reused over all rows so it will currently get the root element
from the view model context.

Best regards

Jonas



Am 30.03.2016 um 20:01 schrieb Robert Onslow:
> I am customizing the Table in EMForms by registering an ECPCellEditor
> and ECPCellEditorTestor, following
> https://www.eclipse.org/forums/index.php/t/1067605/
>
> My ECPCellEditor needs access to the Domain Model to populate a drop
> down with some elements in the model.
>
> I note that ECPCellEditor.instantiate delivers a ViewModelContext, which
> I can then store to get the model using ViewModelContext.getDomainModel()
>
> @Override
> public void instantiate(EStructuralFeature feature, ViewModelContext
> viewModelContext) {
> this.viewModelContext = viewModelContext;
> }
>
> However I'm finding that, although the ECPCellEditor is being installed,
> instantiate is not being called.
>
> So my questions are: (a) when is instantiate called; (b) is this the
> correct way of accessing the domain mode from within the ECPCellEditorl?
>
> Thanks
>
> Robert


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] ECPCellEditor Instantiate [message #1728129 is a reply to message #1728098] Thu, 31 March 2016 09:39 Go to previous messageGo to next message
Robert Onslow is currently offline Robert OnslowFriend
Messages: 27
Registered: March 2016
Junior Member
Thanks Jonas

Yes, I see that instantiate is called after createControl, so I needed to create the drop down in createControl, and populate the drop down in instantiate. Great.

I now need to search the contents of the EMF Project for particular elements to populate the drop down.

EObject root = viewModelContext.getModel()


gets me the root element of the table I think.

Then
EObject project = root.eContainer()
gets me the Project element which contains this root element, yes?.

What is the correct way to get specific elements within the project - I need all elements of type Author?

I thought that
project.eContents().stream().filter(o -> o.getClass().isAssignableFrom(Author.class)).collect(Collectors.toList());

would be the way but I find that project.eContents() is empty.

What's the correct way to do this using the EObject API?

Thanks

Robert
Re: [EMF Forms] ECPCellEditor Instantiate [message #1728304 is a reply to message #1728129] Fri, 01 April 2016 18:07 Go to previous messageGo to next message
Robert Onslow is currently offline Robert OnslowFriend
Messages: 27
Registered: March 2016
Junior Member
Project proj = (Project) root.eContainer();
Set<Author> = proj.getAllModelElementsByClass(Author.class);


That's the answer (where Author is the class of the instances which I want to get)

[Updated on: Sun, 03 April 2016 20:50]

Report message to a moderator

Re: [EMF Forms] ECPCellEditor Instantiate [message #1728337 is a reply to message #1728304] Sat, 02 April 2016 08:45 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

is that the solution to your problem? It is a little hard to understand
your examples, as the refer to a custom molde, though.

Best regards

Jonas



Am 01.04.2016 um 20:07 schrieb Robert Onslow:
> Project proj = (Project) root.eContainer();
> Set<Author> = proj.getAllModelElementsByClass(Author.class);
>
>
>


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] ECPCellEditor Instantiate [message #1728369 is a reply to message #1728337] Sun, 03 April 2016 20:50 Go to previous message
Robert Onslow is currently offline Robert OnslowFriend
Messages: 27
Registered: March 2016
Junior Member
Edited my post to make it clearer, Jonas.
Thanks
Robert
Previous Topic:[DefaultDataProvider] Default file provider - Browse workspace problem
Next Topic:[EMFStore] Creating a Workspace causes certificate path issues
Goto Forum:
  


Current Time: Sun Sep 24 23:11:07 GMT 2017

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

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