Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [newbie] editor and data relation
[newbie] editor and data relation [message #418502] Thu, 17 April 2008 11:38 Go to next message
Eclipse UserFriend
Originally posted by: luca_picello.mentor.com

Hello folks,
in the library example I can find (LibraryEditor.java):
---------------
[...]
public void createModel() {
URI resourceURI = EditUIUtil.getURI(getEditorInput());

Exception exception = null;
Resource resource = null;
try {
// Load the resource through the editing domain.
//
resource = editingDomain.getResourceSet().getResource(resourceURI, true);
}
[...]
---------------
[...]
selectionViewer.setInput(editingDomain.getResourceSet());
[...]
---------------

I would like to understand if in several editors (with different domains) we
can share the same data.
From the code above it seems to me that here we load the data (an xml file)
into the memory which refers to the local editingDomain so a modification in
another editor is not reflected.
Any comment?

thanks

Luca
Re: [newbie] editor and data relation [message #418505 is a reply to message #418502] Thu, 17 April 2008 11:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33146
Registered: July 2009
Senior Member
Luca,

Comments below.

Luca Picello wrote:
> Hello folks,
> in the library example I can find (LibraryEditor.java):
> ---------------
> [...]
> public void createModel() {
> URI resourceURI = EditUIUtil.getURI(getEditorInput());
>
> Exception exception = null;
> Resource resource = null;
> try {
> // Load the resource through the editing domain.
> //
> resource = editingDomain.getResourceSet().getResource(resourceURI,
> true);
> }
> [...]
> ---------------
> [...]
> selectionViewer.setInput(editingDomain.getResourceSet());
> [...]
> ---------------
>
> I would like to understand if in several editors (with different
> domains) we can share the same data.
You'll find this question was asked recently in this newsgroup and in
the GMF newsgroup.
> From the code above it seems to me that here we load the data (an xml
> file) into the memory which refers to the local editingDomain so a
> modification in another editor is not reflected.
Yes, there is no coordination among different editors.
> Any comment?
In the previous recent thread on this topic, Christian pointed at the
extended library model editor example as one that was hand tailored to
share an editing domain across editors. It's available in our examples
download zip file.
>
> thanks
>
> Luca
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [newbie] editor and data relation [message #418514 is a reply to message #418505] Thu, 17 April 2008 13:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: luca_picello.mentor.com

Hello Ed,
sharing the domain was not my target. At least not of my boss. ;-)
I want to share only EMF objects through different editors.
And I did it successfully referencing in every editor to a global
ResourceSet.
the ResourceSet comes from the editorDomain (of the first editor I start)
and I would like to understand what is bad in sharing ResourceSet but
different editorDomain.
In my opinion the bad thing is that on the same data we can't share the
command-stack... but do you think are there other special reasons to not to
it that way?

Luca




"Ed Merks" <merks@ca.ibm.com> wrote in message
news:fu7de9$jl9$2@build.eclipse.org...
> Luca,
>
> Comments below.
>
> Luca Picello wrote:
>> Hello folks,
>> in the library example I can find (LibraryEditor.java):
>> ---------------
>> [...]
>> public void createModel() {
>> URI resourceURI = EditUIUtil.getURI(getEditorInput());
>>
>> Exception exception = null;
>> Resource resource = null;
>> try {
>> // Load the resource through the editing domain.
>> //
>> resource = editingDomain.getResourceSet().getResource(resourceURI,
>> true);
>> }
>> [...]
>> ---------------
>> [...]
>> selectionViewer.setInput(editingDomain.getResourceSet());
>> [...]
>> ---------------
>>
>> I would like to understand if in several editors (with different domains)
>> we can share the same data.
> You'll find this question was asked recently in this newsgroup and in the
> GMF newsgroup.
>> From the code above it seems to me that here we load the data (an xml
>> file) into the memory which refers to the local editingDomain so a
>> modification in another editor is not reflected.
> Yes, there is no coordination among different editors.
>> Any comment?
> In the previous recent thread on this topic, Christian pointed at the
> extended library model editor example as one that was hand tailored to
> share an editing domain across editors. It's available in our examples
> download zip file.
>>
>> thanks
>>
>> Luca
>>
Re: [newbie] editor and data relation [message #418516 is a reply to message #418514] Thu, 17 April 2008 13:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33146
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030903010707000001090702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Luca,

Comments below.

Luca Picello wrote:
> Hello Ed,
> sharing the domain was not my target. At least not of my boss. ;-)
Tell your boss, you can't always get what you want. :-P
> I want to share only EMF objects through different editors.
If different editors change the same objects, they need to coordinate
their undo stack, don't they?
> And I did it successfully referencing in every editor to a global
> ResourceSet.
And does Undo work properly?
> the ResourceSet comes from the editorDomain (of the first editor I
> start) and I would like to understand what is bad in sharing
> ResourceSet but different editorDomain.
Because objects determine their editing domain from the resource set
using methods like this in AdapterFactoryEditingDomain and that can only
return one answer...

static public EditingDomain getEditingDomainFor(EObject object)
{
Resource resource = object.eResource();
if (resource != null)
{
IEditingDomainProvider editingDomainProvider =
(IEditingDomainProvider)EcoreUtil.getExistingAdapter(resourc e,
IEditingDomainProvider.class);
if (editingDomainProvider != null)
{
return editingDomainProvider.getEditingDomain();
}
else
{
ResourceSet resourceSet = resource.getResourceSet();
if (resourceSet instanceof IEditingDomainProvider)
{
EditingDomain editingDomain =
((IEditingDomainProvider)resourceSet).getEditingDomain();
return editingDomain;
}
else if (resourceSet != null)
{
editingDomainProvider =
(IEditingDomainProvider)EcoreUtil.getExistingAdapter(resourc eSet,
IEditingDomainProvider.class);
if (editingDomainProvider != null)
{
return editingDomainProvider.getEditingDomain();
}
}
}
}

return null;
}


> In my opinion the bad thing is that on the same data we can't share
> the command-stack... but do you think are there other special reasons
> to not to it that way?
That seems very bad. What exactly is the point about avoiding sharing
the editing domain which is precisely what will ensure that the command
stack stays coherent?
>
> Luca
>
>
>
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:fu7de9$jl9$2@build.eclipse.org...
>> Luca,
>>
>> Comments below.
>>
>> Luca Picello wrote:
>>> Hello folks,
>>> in the library example I can find (LibraryEditor.java):
>>> ---------------
>>> [...]
>>> public void createModel() {
>>> URI resourceURI = EditUIUtil.getURI(getEditorInput());
>>>
>>> Exception exception = null;
>>> Resource resource = null;
>>> try {
>>> // Load the resource through the editing domain.
>>> //
>>> resource = editingDomain.getResourceSet().getResource(resourceURI,
>>> true);
>>> }
>>> [...]
>>> ---------------
>>> [...]
>>> selectionViewer.setInput(editingDomain.getResourceSet());
>>> [...]
>>> ---------------
>>>
>>> I would like to understand if in several editors (with different
>>> domains) we can share the same data.
>> You'll find this question was asked recently in this newsgroup and in
>> the GMF newsgroup.
>>> From the code above it seems to me that here we load the data (an
>>> xml file) into the memory which refers to the local editingDomain so
>>> a modification in another editor is not reflected.
>> Yes, there is no coordination among different editors.
>>> Any comment?
>> In the previous recent thread on this topic, Christian pointed at the
>> extended library model editor example as one that was hand tailored
>> to share an editing domain across editors. It's available in our
>> examples download zip file.
>>>
>>> thanks
>>>
>>> Luca
>>>
>


--------------030903010707000001090702
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Luca,<br>
<br>
Comments below.<br>
<br>
Luca Picello wrote:
<blockquote cite="mid:fu7jtp$l02$1@build.eclipse.org" type="cite">Hello
Ed,
<br>
sharing the domain was not my target. At least not of my boss. ;-)
<br>
</blockquote>
Tell your boss, you can't always get what you want. :-P<br>
<blockquote cite="mid:fu7jtp$l02$1@build.eclipse.org" type="cite">I
want to share only EMF objects through different editors.
<br>
</blockquote>
If different editors change the same objects, they need to coordinate
their undo stack, don't they?<br>
<blockquote cite="mid:fu7jtp$l02$1@build.eclipse.org" type="cite">And I
did it successfully referencing in every editor to a global
ResourceSet.
<br>
</blockquote>
And does Undo work properly?&nbsp; <br>
<blockquote cite="mid:fu7jtp$l02$1@build.eclipse.org" type="cite">the
ResourceSet comes from the editorDomain (of the first editor I start)
and I would like to understand what is bad in sharing ResourceSet but
different editorDomain.
<br>
</blockquote>
Because objects determine their editing domain from the resource set
using methods like this in AdapterFactoryEditingDomain and that can
only return one answer...<br>
<br>
<small>&nbsp; static public EditingDomain getEditingDomainFor(EObject object)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; Resource resource = object.eResource();<br>
&nbsp;&nbsp;&nbsp; if (resource != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IEditingDomainProvider editingDomainProvider =<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; (IEditingDomainProvider)EcoreUtil.getExistingAdapter(resourc e,
IEditingDomainProvider.class);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (editingDomainProvider != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return editingDomainProvider.getEditingDomain();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ResourceSet resourceSet = resource.getResourceSet();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; if (resourceSet instanceof IEditingDomainProvider)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; EditingDomain editingDomain =
((IEditingDomainProvider)resourceSet).getEditingDomain();<br >
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return editingDomain;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; else if (resourceSet != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; editingDomainProvider =
(IEditingDomainProvider)EcoreUtil.getExistingAdapter(resourc eSet,
IEditingDomainProvider.class);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (editingDomainProvider != null)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return editingDomainProvider.getEditingDomain();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; }<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp; return null;<br>
&nbsp; }</small><br>
<br>
<br>
<blockquote cite="mid:fu7jtp$l02$1@build.eclipse.org" type="cite">In my
opinion the bad thing is that on the same data we can't share the
command-stack... but do you think are there other special reasons to
not to it that way?
<br>
</blockquote>
That seems very bad.&nbsp; What exactly is the point about avoiding sharing
the editing domain which is precisely what will ensure that the command
stack stays coherent?<br>
<blockquote cite="mid:fu7jtp$l02$1@build.eclipse.org" type="cite"><br>
Luca
<br>
<br>
<br>
<br>
<br>
"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:fu7de9$jl9$2@build.eclipse.org">news:fu7de9$jl9$2@build.eclipse.org</a>...
<br>
<blockquote type="cite">Luca,
<br>
<br>
Comments below.
<br>
<br>
Luca Picello wrote:
<br>
<blockquote type="cite">Hello folks,
<br>
in the library example I can find (LibraryEditor.java):
<br>
---------------
<br>
[...]
<br>
public void createModel() {
<br>
&nbsp;URI resourceURI = EditUIUtil.getURI(getEditorInput());
<br>
<br>
&nbsp;Exception exception = null;
<br>
&nbsp;Resource resource = null;
<br>
&nbsp;try {
<br>
&nbsp; // Load the resource through the editing domain.
<br>
&nbsp; //
<br>
&nbsp; resource = editingDomain.getResourceSet().getResource(resourceURI,
true);
<br>
&nbsp;}
<br>
[...]
<br>
---------------
<br>
[...]
<br>
selectionViewer.setInput(editingDomain.getResourceSet());
<br>
[...]
<br>
---------------
<br>
<br>
I would like to understand if in several editors (with different
domains) we can share the same data.
<br>
</blockquote>
You'll find this question was asked recently in this newsgroup and in
the GMF newsgroup.
<br>
<blockquote type="cite">From the code above it seems to me that
here we load the data (an xml file) into the memory which refers to the
local editingDomain so a modification in another editor is not
reflected.
<br>
</blockquote>
Yes, there is no coordination among different editors.
<br>
<blockquote type="cite">Any comment?
<br>
</blockquote>
In the previous recent thread on this topic, Christian pointed at the
extended library model editor example as one that was hand tailored to
share an editing domain across editors.&nbsp; It's available in our examples
download zip file.
<br>
<blockquote type="cite"><br>
thanks
<br>
<br>
Luca
<br>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>

--------------030903010707000001090702--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [newbie] editor and data relation [message #418517 is a reply to message #418516] Thu, 17 April 2008 14:11 Go to previous message
Eclipse UserFriend
Originally posted by: luca_picello.mentor.com

Hallo Ed!
I've got your answer before seeing my question in the newsgroup !! :-o
I dont know the real reason why they dont want to share the domain... but
I've heared rumors about GEF objects...
Because I am new to everything and the boss is always right I think I'll
shift this issue in another moment...
And because the boss now makes another requests on those shared ResourceSet
I think I have to fullfit it first... But let's see what happen!
Thank you again for your help. Really appreciated

Luca
Previous Topic:Primitive types
Next Topic:Serializing with schema metadata (but no schema)
Goto Forum:
  


Current Time: Sat May 11 13:54:56 GMT 2024

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

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

Back to the top