Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] save changes?
[EMF Forms] save changes? [message #1719678] Mon, 11 January 2016 12:35 Go to next message
Eclipse Friend is currently offline Eclipse FriendFriend
Messages: 2
Registered: January 2016
Junior Member
Hi there,

I embedded an emf forms generated view in my Editor (type: org.eclipse.ui.part.EditorPart).

This is my createPartControl how integrate the generated view.

@Override
	public void createPartControl(Composite parent)
	{

		try {
			final Composite content = new Composite(parent, SWT.NONE);
			content.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
			content.setLayout(GridLayoutFactory.fillDefaults().margins(10, 10).create());
			content.setLayoutData(GridDataFactory.fillDefaults().create());

			final ViewModelContext vmc = ViewModelContextFactory.INSTANCE.createViewModelContext(
				ViewProviderHelper.getView(object, null), object, new DefaultReferenceService());

			ecpView = ECPSWTViewRenderer.INSTANCE.render(content, vmc);
			content.layout();
		} catch (final ECPRendererException e) {
			e.printStackTrace();
		}
		parent.layout();

	}



How can i implement now the doSave method?
Is there an example how to implement the setDirty() mechanism and a doSave() in a correct way.

Thanks for your help!

[Updated on: Tue, 12 January 2016 08:42]

Report message to a moderator

Re: [EMF Forms] save changes? [message #1719756 is a reply to message #1719678] Mon, 11 January 2016 19:58 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

yes in the new release stream, EMF Forms contains a ready to use Editor.
It is fully generic, so it works with any kind of emf model. You need to
install it from the latest milestone build, though (1.8.x)
https://www.eclipse.org/ecp/emfforms/download.html

You can either have a look at it to see how it is implemented:

https://git.eclipse.org/c/emfclient/org.eclipse.emf.ecp.core.git/tree/bundles/org.eclipse.emfforms.editor/src/org/eclipse/emfforms/spi/editor/GenericEditor.java?h=develop

Or you can just use it, by registering it for you file extension:

<?xml version="1.0" encoding="UTF8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.emfforms.spi.editor.GenericEditor"
default="true"
extensions="myModel"
id="org.eclipse.emf.ecp.makeithappen.model.editor.myEditor"
name="My Model Editor">
</editor>
</extension>
</plugin>

With this registration, all files with the *.myModel extension will be
opened using the generic EMFForms Editor

Best regards

Jonas



Am 11.01.2016 um 17:40 schrieb Eclipse Friend:
> Hi there,
>
> I embedded an emf forms generated view in my Editor (type:
> org.eclipse.ui.part.EditorPart).
>
> This is my createPartControl how integrate the generated view.
>
> @Override
> public void createPartControl(Composite parent)
> {
>
> try {
> final Composite content = new Composite(parent, SWT.NONE);
>
> content.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
>
> content.setLayout(GridLayoutFactory.fillDefaults().margins(10,
> 10).create());
> content.setLayoutData(GridDataFactory.fillDefaults().create());
>
> final ViewModelContext vmc =
> ViewModelContextFactory.INSTANCE.createViewModelContext(
> ViewProviderHelper.getView(textModule, null),
> textModule, new DefaultReferenceService());
>
> ecpView = ECPSWTViewRenderer.INSTANCE.render(content, vmc);
> content.layout();
> } catch (final ECPRendererException e) {
> e.printStackTrace();
> }
> parent.layout();
>
> }
>
>
> How can i implement now the doSave method? Is there an example how to
> implement the setDirty() mechanism and a doSave() in a correct way.
>
> Thanks for your help!


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] save changes? [message #1719809 is a reply to message #1719756] Tue, 12 January 2016 09:05 Go to previous messageGo to next message
Eclipse Friend is currently offline Eclipse FriendFriend
Messages: 2
Registered: January 2016
Junior Member
Ok thank you.

I'll try your suggestion right away.

But if I don't want the to use the GenericEditor, how do i implement my doSave() method correctly?

The renderer returns an ECPSWTView and i have the possibility to get an swt control. How can i access every single control to create something like:

object.setA(textFieldA.getText())

Re: [EMF Forms] save changes? [message #1720070 is a reply to message #1719809] Thu, 14 January 2016 08:58 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

the save is handled by the resource, which contains the EObjects you
render with EMF Forms. EMF Forms does not even have to know about this.

Best regards

Jonas



Am 12.01.2016 um 10:05 schrieb Eclipse Friend:
> Ok thank you.
>
> I'll try your suggestion right away.
>
> But if I don't want the to use the GenericEditor, how do i implement my
> doSave() method correctly?
>
> The renderer returns an ECPSWTView and i have the possibility to get an
> swt control. How can i access every single control to create something
> like:
>
> object.setA(textFieldA.getText())
>
>


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] save changes? [message #1722960 is a reply to message #1720070] Wed, 10 February 2016 14:23 Go to previous messageGo to next message
Jim Boone is currently offline Jim BooneFriend
Messages: 15
Registered: August 2015
Location: North Carolina
Junior Member
Did you ever figure out how to save changes with your custom editor?

EMF Forms looks awesome but I haven't quite figured out how to integrate it with the EMF edit domain and make sure that the two-way binding plugs into the the command stack. If anyone could point me to an example, I would be grateful. In the meantime, I will study the generic editor. Thanks.

--Jim
Re: [EMF Forms] save changes? [message #1723096 is a reply to message #1719756] Thu, 11 February 2016 15:14 Go to previous messageGo to next message
Jim Boone is currently offline Jim BooneFriend
Messages: 15
Registered: August 2015
Location: North Carolina
Junior Member
Hi Jonas,

I upgraded from EMF Forms 1.7.x that comes with Mars to 1,8.x as suggested and added the editor extension as suggested (org.eclipse.emfforms.spi.editor.GenericEditor) but the class is not found. I show ECP SDK 3.x and EMF Forms SDK 1.8.0.20160208-2127 installed. Any idea what I did wrong? Is the editor in another plugin that I need to install? Thanks!

--Jim

Re: [EMF Forms] save changes? [message #1723116 is a reply to message #1723096] Thu, 11 February 2016 18:42 Go to previous messageGo to next message
Jim Boone is currently offline Jim BooneFriend
Messages: 15
Registered: August 2015
Location: North Carolina
Junior Member
Finally a success! I found the class org.eclipse.emfforms.internal.editor.ecore.EcoreEditor that extends org.eclipse.emfforms.spi.editor.GenericEditor, but GenericEditor doesn't show up in my classpath. Regardless, I now can see and use the generic ecore editor. Very nice! This is exactly what I was looking for. Thanks you all so much.
Re: [EMF Forms] save changes? [message #1723150 is a reply to message #1723116] Fri, 12 February 2016 07:57 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi,

please have a look at
http://eclipsesource.com/blogs/tutorials/emf-forms-editors/
how to install the generic editor.

Best regards

Jonas

Am 11.02.2016 um 19:42 schrieb Jim Boone:
> Finally a success! I found the class
> org.eclipse.emfforms.internal.editor.ecore.EcoreEditor that extends
> org.eclipse.emfforms.spi.editor.GenericEditor, but GenericEditor doesn't
> show up in my classpath. Regardless, I now can see and use the generic
> ecore editor. Very nice! This is exactly what I was looking for.
> Thanks you all so much.


--
--

Jonas Helming

Get professional Eclipse developer support:

http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] save changes? [message #1723258 is a reply to message #1723150] Fri, 12 February 2016 19:04 Go to previous message
Jim Boone is currently offline Jim BooneFriend
Messages: 15
Registered: August 2015
Location: North Carolina
Junior Member
Wow Jonas! That blog posting is hot off the press. Thank you so much. It describes exactly what I was looking for. I am more than happy to provide feedback as we start using the editor. BTW, the genmodel editor is nice too!
Previous Topic:[EMF Forms] Custom control get parent of an eStructuralFeature
Next Topic:[EMFStore] cleaning up deleted projects
Goto Forum:
  


Current Time: Tue Nov 24 20:35:28 GMT 2020

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

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

Back to the top