Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Access Notational style from
Access Notational style from [message #421052] Wed, 23 July 2008 00:34 Go to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello folks,

I need to access from ???ItemProvider an attribute that belongs to a
different editing domain. This editing domain is a notational style for
GMF (I use it to store sole attributes not directly related with my model)
and is stored inside the GMF diagram (I create it using
styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in the
class WorkflowTypeViewFactory).
Do you have any suggestion? Thank in advance.
Cheers

Nicola
Re: Access Notational style from [message #421055 is a reply to message #421052] Wed, 23 July 2008 01:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-aHzijTVF1iVTOhl54RjG
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Nicola,

My first recommendation would be to put the notation style information
in the same editing domain as your other object. Consider an editing
domain as a closed universe; maintaining dependencies between objects in
different editing domains is usually more trouble than it's worth.

Do you have some way of linking from the object in your first editing
domain to the notation style in the other? I don't know what you mean
by "need to access." You won't have an EReference of any kind that you
can follow, so you will probably need the URI of the style object and
also some way to know the editing domain in which resource-set you need
to search for it.

Perhaps you can explain the situation a bit more so that we can
understand how best to help.

Cheers,

Christian


On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:

> Hello folks,
>
> I need to access from ???ItemProvider an attribute that belongs to a
> different editing domain. This editing domain is a notational style for
> GMF (I use it to store sole attributes not directly related with my model)
> and is stored inside the GMF diagram (I create it using
> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in the
> class WorkflowTypeViewFactory).
> Do you have any suggestion? Thank in advance.
> Cheers
>
> Nicola
>
>

--=-aHzijTVF1iVTOhl54RjG
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Nicola,<BR>
<BR>
My first recommendation would be to put the notation style information in the same editing domain as your other object.&nbsp; Consider an editing domain as a closed universe; maintaining dependencies between objects in different editing domains is usually more trouble than it's worth.<BR>
<BR>
Do you have some way of linking from the object in your first editing domain to the notation style in the other?&nbsp; I don't know what you mean by &quot;need to access.&quot;&nbsp; You won't have an EReference of any kind that you can follow, so you will probably need the URI of the style object and also some way to know the editing domain in which resource-set you need to search for it.<BR>
<BR>
Perhaps you can explain the situation a bit more so that we can understand how best to help.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hello folks,</FONT>

<FONT COLOR="#000000">I need to access from ???ItemProvider an attribute that belongs to a </FONT>
<FONT COLOR="#000000">different editing domain. This editing domain is a notational style for </FONT>
<FONT COLOR="#000000">GMF (I use it to store sole attributes not directly related with my model) </FONT>
<FONT COLOR="#000000">and is stored inside the GMF diagram (I create it using </FONT>
<FONT COLOR="#000000"> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in the </FONT>
<FONT COLOR="#000000">class WorkflowTypeViewFactory).</FONT>
<FONT COLOR="#000000">Do you have any suggestion? Thank in advance.</FONT>
<FONT COLOR="#000000">Cheers</FONT>

<FONT COLOR="#000000">Nicola</FONT>


</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-aHzijTVF1iVTOhl54RjG--
Re: Access Notational style from [message #421074 is a reply to message #421055] Wed, 23 July 2008 09:36 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello Christian,

probably my message was not clear, I still don't use the proper
EMF/Modeling terms.
I try to explain a bit better what I have to do. I modeled an xsd file
that defines a workflow, and I need to deploy the model in a remote
server. For this reason I cannot add any attribute, reference to the EMF.
I need to store other information (server url, authentication info,etc.)
thus I defined another EMF model, with a class deriving Style, and I store
the information in the diagram file. I'm able to access the attributes
while using the GMF code, but I need to access to the server url also from
the EMF.Editor (some workflow attributes are queried from the serer)
that's why I need to mix to different world.
I hope I explained it a bitter better.
Thank you for yur help,
Cheers

Nicola

Christian W. Damus wrote

> Hi, Nicola,

> My first recommendation would be to put the notation style information
> in the same editing domain as your other object. Consider an editing
> domain as a closed universe; maintaining dependencies between objects in
> different editing domains is usually more trouble than it's worth.

> Do you have some way of linking from the object in your first editing
> domain to the notation style in the other? I don't know what you mean
> by "need to access." You won't have an EReference of any kind that you
> can follow, so you will probably need the URI of the style object and
> also some way to know the editing domain in which resource-set you need
> to search for it.

> Perhaps you can explain the situation a bit more so that we can
> understand how best to help.

> Cheers,

> Christian


> On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:

>> Hello folks,
>>
>> I need to access from ???ItemProvider an attribute that belongs to a
>> different editing domain. This editing domain is a notational style for
>> GMF (I use it to store sole attributes not directly related with my model)
>> and is stored inside the GMF diagram (I create it using
>> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in the
>> class WorkflowTypeViewFactory).
>> Do you have any suggestion? Thank in advance.
>> Cheers
>>
>> Nicola
>>
>>
Re: Access Notational style from [message #421114 is a reply to message #421074] Thu, 24 July 2008 21:16 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Sorry,

I've been looking a bit to the problem I showed and I still don't know how
to do it. Any idea?Please any help would be welcome.
Cheers

Nicola
Nicola Salvo wrote:

> Hello Christian,

> probably my message was not clear, I still don't use the proper
> EMF/Modeling terms.
> I try to explain a bit better what I have to do. I modeled an xsd file
> that defines a workflow, and I need to deploy the model in a remote
> server. For this reason I cannot add any attribute, reference to the EMF.
> I need to store other information (server url, authentication info,etc.)
> thus I defined another EMF model, with a class deriving Style, and I store
> the information in the diagram file. I'm able to access the attributes
> while using the GMF code, but I need to access to the server url also from
> the EMF.Editor (some workflow attributes are queried from the serer)
> that's why I need to mix to different world.
> I hope I explained it a bitter better.
> Thank you for yur help,
> Cheers

> Nicola

> Christian W. Damus wrote

>> Hi, Nicola,

>> My first recommendation would be to put the notation style information
>> in the same editing domain as your other object. Consider an editing
>> domain as a closed universe; maintaining dependencies between objects in
>> different editing domains is usually more trouble than it's worth.

>> Do you have some way of linking from the object in your first editing
>> domain to the notation style in the other? I don't know what you mean
>> by "need to access." You won't have an EReference of any kind that you
>> can follow, so you will probably need the URI of the style object and
>> also some way to know the editing domain in which resource-set you need
>> to search for it.

>> Perhaps you can explain the situation a bit more so that we can
>> understand how best to help.

>> Cheers,

>> Christian


>> On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:

>>> Hello folks,
>>>
>>> I need to access from ???ItemProvider an attribute that belongs to a
>>> different editing domain. This editing domain is a notational style for
>>> GMF (I use it to store sole attributes not directly related with my model)
>>> and is stored inside the GMF diagram (I create it using
>>> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in the
>>> class WorkflowTypeViewFactory).
>>> Do you have any suggestion? Thank in advance.
>>> Cheers
>>>
>>> Nicola
>>>
>>>
Re: Access Notational style from [message #421129 is a reply to message #421074] Sun, 27 July 2008 23:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Nicola,

You can use the AnyURI EDataType from EMF's XMLType package to define an
EAttribute in your Style (or whatever else) that stores the URI of your
remote object. Then, when you need to retrieve the object, simply
create a URI on the attribute value and use
EcoreUtil::getEObject(ResourceSet, URI) to load the object in the
appropriate resource set.

See XMLTypePackage.Literals.ANY_URI.

HTH,

Christian



Nicola Salvo wrote:
> Hello Christian,
>
> probably my message was not clear, I still don't use the proper
> EMF/Modeling terms.
> I try to explain a bit better what I have to do. I modeled an xsd file
> that defines a workflow, and I need to deploy the model in a remote
> server. For this reason I cannot add any attribute, reference to the
> EMF. I need to store other information (server url, authentication
> info,etc.) thus I defined another EMF model, with a class deriving
> Style, and I store the information in the diagram file. I'm able to
> access the attributes while using the GMF code, but I need to access to
> the server url also from the EMF.Editor (some workflow attributes are
> queried from the serer) that's why I need to mix to different world.
> I hope I explained it a bitter better.
> Thank you for yur help,
> Cheers
>
> Nicola
> Christian W. Damus wrote
>
>> Hi, Nicola,
>
>> My first recommendation would be to put the notation style information
>> in the same editing domain as your other object. Consider an editing
>> domain as a closed universe; maintaining dependencies between objects in
>> different editing domains is usually more trouble than it's worth.
>
>> Do you have some way of linking from the object in your first editing
>> domain to the notation style in the other? I don't know what you mean
>> by "need to access." You won't have an EReference of any kind that you
>> can follow, so you will probably need the URI of the style object and
>> also some way to know the editing domain in which resource-set you need
>> to search for it.
>
>> Perhaps you can explain the situation a bit more so that we can
>> understand how best to help.
>
>> Cheers,
>
>> Christian
>
>
>> On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:
>
>>> Hello folks,
>>>
>>> I need to access from ???ItemProvider an attribute that belongs to a
>>> different editing domain. This editing domain is a notational style
>>> for GMF (I use it to store sole attributes not directly related with
>>> my model) and is stored inside the GMF diagram (I create it using
>>>
>>> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in
>>> the class WorkflowTypeViewFactory).
>>> Do you have any suggestion? Thank in advance.
>>> Cheers
>>>
>>> Nicola
>>>
>>>
>
>
Re: Access Notational style from [message #421136 is a reply to message #421129] Mon, 28 July 2008 10:45 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello Christian,

thank you for your answer. I think that my problem is bit different. I
cannot modify my EMF model, I have to stick with an XML Schema definition,
thus I cannot add the AnyUri attribute. Moreover I think that I don't need
it. What I have to do is to fetch from the server some values to populate
a drop-down list in a getChoiceOfValues of an edit ???ItemProvider.
I thought that just to obtain an object stored in a different domain, the
transaction framework might be used. What I did is:

In the GMF diagram plugin:
<extension
point="org.eclipse.emf.transaction.editingDomains">
<editingDomain
factory="org.eclipse.emf.workspace.WorkspaceEditingDomainFactory "
id="EditingDomain">
</editingDomain>
</extension>

in the RequestDocumentProvider:

private TransactionalEditingDomain createEditingDomain() {
TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory
getInstance().createEditingDomain();

editingDomain.setID("EditingDomain"); //$NON-NLS-1$

and in my emf ActivityTypeItemProvider:

TransactionalEditingDomain editingDomain =
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "EditingDomain");
List resources = editingDomain.getResourceSet().getResources();

the editing domain returned is not null, but the resource list is empty,
thus I don't know how to retrieve the PropertiesStyle object. Please help.
I'm running short of time (and energies)
Thank you in advance

Nicola

Christian W. Damus wrote:

> Hi, Nicola,

> You can use the AnyURI EDataType from EMF's XMLType package to define an
> EAttribute in your Style (or whatever else) that stores the URI of your
> remote object. Then, when you need to retrieve the object, simply
> create a URI on the attribute value and use
> EcoreUtil::getEObject(ResourceSet, URI) to load the object in the
> appropriate resource set.

> See XMLTypePackage.Literals.ANY_URI.

> HTH,

> Christian



> Nicola Salvo wrote:
>> Hello Christian,
>>
>> probably my message was not clear, I still don't use the proper
>> EMF/Modeling terms.
>> I try to explain a bit better what I have to do. I modeled an xsd file
>> that defines a workflow, and I need to deploy the model in a remote
>> server. For this reason I cannot add any attribute, reference to the
>> EMF. I need to store other information (server url, authentication
>> info,etc.) thus I defined another EMF model, with a class deriving
>> Style, and I store the information in the diagram file. I'm able to
>> access the attributes while using the GMF code, but I need to access to
>> the server url also from the EMF.Editor (some workflow attributes are
>> queried from the serer) that's why I need to mix to different world.
>> I hope I explained it a bitter better.
>> Thank you for yur help,
>> Cheers
>>
>> Nicola
>> Christian W. Damus wrote
>>
>>> Hi, Nicola,
>>
>>> My first recommendation would be to put the notation style information
>>> in the same editing domain as your other object. Consider an editing
>>> domain as a closed universe; maintaining dependencies between objects in
>>> different editing domains is usually more trouble than it's worth.
>>
>>> Do you have some way of linking from the object in your first editing
>>> domain to the notation style in the other? I don't know what you mean
>>> by "need to access." You won't have an EReference of any kind that you
>>> can follow, so you will probably need the URI of the style object and
>>> also some way to know the editing domain in which resource-set you need
>>> to search for it.
>>
>>> Perhaps you can explain the situation a bit more so that we can
>>> understand how best to help.
>>
>>> Cheers,
>>
>>> Christian
>>
>>
>>> On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:
>>
>>>> Hello folks,
>>>>
>>>> I need to access from ???ItemProvider an attribute that belongs to a
>>>> different editing domain. This editing domain is a notational style
>>>> for GMF (I use it to store sole attributes not directly related with
>>>> my model) and is stored inside the GMF diagram (I create it using
>>>>
>>>> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in
>>>> the class WorkflowTypeViewFactory).
>>>> Do you have any suggestion? Thank in advance.
>>>> Cheers
>>>>
>>>> Nicola
>>>>
>>>>
>>
>>
Re: Access Notational style from [message #421176 is a reply to message #421136] Tue, 29 July 2008 17:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Nicola,

I'm not sure that I'm understanding the difficulty.

In order to load an object in a resource set in which the object is not
currently loaded (such as when there are no resources loaded at all),
EMF needs the object's URI.

Once you have the URI, the ResourceSet::getEObject(URI) API will give
you the object, if necessary loading the resource that contains it.

How you get the URI is up to you. I thought you needed, from
information in the PropertiesStyle object, to load an object in a
different resource set. That is why I thought you could add an AnyURI
attribute to the PropertiesStyle.

If that doesn't work, then you will need somehow to get:

- the URI of the resource that contains your object
- the fragment within that resource of the object

Then, appending the fragment to the resource URI gives you the EObject
URI required by the resource set.

It may help to know that EcoreUtil::getURI(EObject) will give you the
URI of a loaded object, which you can use to load the same object in a
different resource set.

HTH,

Christian


Nicola Salvo wrote:
> Hello Christian,
>
> thank you for your answer. I think that my problem is bit different. I
> cannot modify my EMF model, I have to stick with an XML Schema
> definition, thus I cannot add the AnyUri attribute. Moreover I think
> that I don't need it. What I have to do is to fetch from the server some
> values to populate a drop-down list in a getChoiceOfValues of an edit
> ???ItemProvider.
> I thought that just to obtain an object stored in a different domain,
> the transaction framework might be used. What I did is:
>
> In the GMF diagram plugin:
> <extension
> point="org.eclipse.emf.transaction.editingDomains">
> <editingDomain
> factory="org.eclipse.emf.workspace.WorkspaceEditingDomainFactory "
> id="EditingDomain">
> </editingDomain>
> </extension>
>
> in the RequestDocumentProvider:
>
> private TransactionalEditingDomain createEditingDomain() {
> TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory
> getInstance().createEditingDomain();
>
> editingDomain.setID("EditingDomain"); //$NON-NLS-1$
>
> and in my emf ActivityTypeItemProvider:
>
> TransactionalEditingDomain editingDomain =
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "EditingDomain");
>
> List resources = editingDomain.getResourceSet().getResources();
>
> the editing domain returned is not null, but the resource list is empty,
> thus I don't know how to retrieve the PropertiesStyle object. Please
> help. I'm running short of time (and energies)
> Thank you in advance
>
> Nicola
>
> Christian W. Damus wrote:
>
>> Hi, Nicola,
>
>> You can use the AnyURI EDataType from EMF's XMLType package to define
>> an EAttribute in your Style (or whatever else) that stores the URI of
>> your remote object. Then, when you need to retrieve the object,
>> simply create a URI on the attribute value and use
>> EcoreUtil::getEObject(ResourceSet, URI) to load the object in the
>> appropriate resource set.
>
>> See XMLTypePackage.Literals.ANY_URI.
>
>> HTH,
>
>> Christian
>
>
>
>> Nicola Salvo wrote:
>>> Hello Christian,
>>>
>>> probably my message was not clear, I still don't use the proper
>>> EMF/Modeling terms.
>>> I try to explain a bit better what I have to do. I modeled an xsd
>>> file that defines a workflow, and I need to deploy the model in a
>>> remote server. For this reason I cannot add any attribute, reference
>>> to the EMF. I need to store other information (server url,
>>> authentication info,etc.) thus I defined another EMF model, with a
>>> class deriving Style, and I store the information in the diagram
>>> file. I'm able to access the attributes while using the GMF code, but
>>> I need to access to the server url also from the EMF.Editor (some
>>> workflow attributes are queried from the serer) that's why I need to
>>> mix to different world.
>>> I hope I explained it a bitter better.
>>> Thank you for yur help,
>>> Cheers
>>>
>>> Nicola
>>> Christian W. Damus wrote
>>>
>>>> Hi, Nicola,
>>>
>>>> My first recommendation would be to put the notation style information
>>>> in the same editing domain as your other object. Consider an editing
>>>> domain as a closed universe; maintaining dependencies between
>>>> objects in
>>>> different editing domains is usually more trouble than it's worth.
>>>
>>>> Do you have some way of linking from the object in your first editing
>>>> domain to the notation style in the other? I don't know what you mean
>>>> by "need to access." You won't have an EReference of any kind that you
>>>> can follow, so you will probably need the URI of the style object and
>>>> also some way to know the editing domain in which resource-set you need
>>>> to search for it.
>>>
>>>> Perhaps you can explain the situation a bit more so that we can
>>>> understand how best to help.
>>>
>>>> Cheers,
>>>
>>>> Christian
>>>
>>>
>>>> On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:
>>>
>>>>> Hello folks,
>>>>>
>>>>> I need to access from ???ItemProvider an attribute that belongs to
>>>>> a different editing domain. This editing domain is a notational
>>>>> style for GMF (I use it to store sole attributes not directly
>>>>> related with my model) and is stored inside the GMF diagram (I
>>>>> create it using
>>>>> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in
>>>>> the class WorkflowTypeViewFactory).
>>>>> Do you have any suggestion? Thank in advance.
>>>>> Cheers
>>>>>
>>>>> Nicola
>>>>>
>>>>>
>>>
>>>
>
>
Re: Access Notational style from [message #421231 is a reply to message #421176] Fri, 01 August 2008 10:18 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hi Christian,

thank you for the answer!

> I'm not sure that I'm understanding the difficulty.
Now that you pointed out how to do it no difficulty... almost:) I have
still a problem.
So this is what I did:

1) Added an attibute

* @see gsoc.ogsadai.model.ModelPackage#getRequestType_StyleURI()
* @model dataType="org.eclipse.emf.ecore.xml.type.AnyURI" volatile="true"
transient="true"
* extendedMetaData="kind='attribute' name='styleURI'"
* @generated NOT
*/
String getStyleURI();
in which I save the URI of the notational style that is in the GMF model.
It's volatile and transient because I can't serialize it.

2) In the method where I need to access the attribute in the other class i
did:

TransactionalEditingDomain editingDomain =
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "gsoc.ogsadai.diagram.editingDomain");
String styleURI = (((RequestType)((WorkflowType)((PipelineType)
((ActivityType)object).eContainer()).eContainer()).eContaine r())).getStyleURI();
URI uri = URI.createURI(styleURI);
EObject obj = editingDomain.getResourceSet().getEObject(uri, true);

My problems are:

1) the way I get syleURI is quite orrible. Is there a more elegant way?
2) As you said in the previous post is my duty to save the URI. I added an

protected void handleNotificationEvent(Notification event)

in the editPart, but this is called only when the element is modified, and
moreover I will need just once to save the URI (not every time that the
element is modified). Where can I put my code to initialize the styleURI?

Sorry for the (stupid?) questions, and thank you for your time.
Cheers

Nicola

> Nicola Salvo wrote:
>> Hello Christian,
>>
>> thank you for your answer. I think that my problem is bit different. I
>> cannot modify my EMF model, I have to stick with an XML Schema
>> definition, thus I cannot add the AnyUri attribute. Moreover I think
>> that I don't need it. What I have to do is to fetch from the server some
>> values to populate a drop-down list in a getChoiceOfValues of an edit
>> ???ItemProvider.
>> I thought that just to obtain an object stored in a different domain,
>> the transaction framework might be used. What I did is:
>>
>> In the GMF diagram plugin:
>> <extension
>> point="org.eclipse.emf.transaction.editingDomains">
>> <editingDomain
>> factory="org.eclipse.emf.workspace.WorkspaceEditingDomainFactory "
>> id="EditingDomain">
>> </editingDomain>
>> </extension>
>>
>> in the RequestDocumentProvider:
>>
>> private TransactionalEditingDomain createEditingDomain() {
>> TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory
>> getInstance().createEditingDomain();
>>
>> editingDomain.setID("EditingDomain"); //$NON-NLS-1$
>>
>> and in my emf ActivityTypeItemProvider:
>>
>> TransactionalEditingDomain editingDomain =
>>
TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "EditingDomain");
>>
>> List resources = editingDomain.getResourceSet().getResources();
>>
>> the editing domain returned is not null, but the resource list is empty,
>> thus I don't know how to retrieve the PropertiesStyle object. Please
>> help. I'm running short of time (and energies)
>> Thank you in advance
>>
>> Nicola
>>
>> Christian W. Damus wrote:
>>
>>> Hi, Nicola,
>>
>>> You can use the AnyURI EDataType from EMF's XMLType package to define
>>> an EAttribute in your Style (or whatever else) that stores the URI of
>>> your remote object. Then, when you need to retrieve the object,
>>> simply create a URI on the attribute value and use
>>> EcoreUtil::getEObject(ResourceSet, URI) to load the object in the
>>> appropriate resource set.
>>
>>> See XMLTypePackage.Literals.ANY_URI.
>>
>>> HTH,
>>
>>> Christian
>>
>>
>>
>>> Nicola Salvo wrote:
>>>> Hello Christian,
>>>>
>>>> probably my message was not clear, I still don't use the proper
>>>> EMF/Modeling terms.
>>>> I try to explain a bit better what I have to do. I modeled an xsd
>>>> file that defines a workflow, and I need to deploy the model in a
>>>> remote server. For this reason I cannot add any attribute, reference
>>>> to the EMF. I need to store other information (server url,
>>>> authentication info,etc.) thus I defined another EMF model, with a
>>>> class deriving Style, and I store the information in the diagram
>>>> file. I'm able to access the attributes while using the GMF code, but
>>>> I need to access to the server url also from the EMF.Editor (some
>>>> workflow attributes are queried from the serer) that's why I need to
>>>> mix to different world.
>>>> I hope I explained it a bitter better.
>>>> Thank you for yur help,
>>>> Cheers
>>>>
>>>> Nicola
>>>> Christian W. Damus wrote
>>>>
>>>>> Hi, Nicola,
>>>>
>>>>> My first recommendation would be to put the notation style information
>>>>> in the same editing domain as your other object. Consider an editing
>>>>> domain as a closed universe; maintaining dependencies between
>>>>> objects in
>>>>> different editing domains is usually more trouble than it's worth.
>>>>
>>>>> Do you have some way of linking from the object in your first editing
>>>>> domain to the notation style in the other? I don't know what you mean
>>>>> by "need to access." You won't have an EReference of any kind that you
>>>>> can follow, so you will probably need the URI of the style object and
>>>>> also some way to know the editing domain in which resource-set you need
>>>>> to search for it.
>>>>
>>>>> Perhaps you can explain the situation a bit more so that we can
>>>>> understand how best to help.
>>>>
>>>>> Cheers,
>>>>
>>>>> Christian
>>>>
>>>>
>>>>> On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:
>>>>
>>>>>> Hello folks,
>>>>>>
>>>>>> I need to access from ???ItemProvider an attribute that belongs to
>>>>>> a different editing domain. This editing domain is a notational
>>>>>> style for GMF (I use it to store sole attributes not directly
>>>>>> related with my model) and is stored inside the GMF diagram (I
>>>>>> create it using
>>>>>> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ()); in
>>>>>> the class WorkflowTypeViewFactory).
>>>>>> Do you have any suggestion? Thank in advance.
>>>>>> Cheers
>>>>>>
>>>>>> Nicola
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
Re: Access Notational style from [message #421233 is a reply to message #421231] Fri, 01 August 2008 13:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Nicola,

Comments below.


Nicola Salvo wrote:
> Hi Christian,
>
> thank you for the answer!
>
>> I'm not sure that I'm understanding the difficulty.
> Now that you pointed out how to do it no difficulty... almost:) I have
> still a problem.
> So this is what I did:
>
> 1) Added an attibute
> * @see gsoc.ogsadai.model.ModelPackage#getRequestType_StyleURI()
> * @model dataType="org.eclipse.emf.ecore.xml.type.AnyURI"
> volatile="true" transient="true"
> * extendedMetaData="kind='attribute' name='styleURI'"
> * @generated NOT
> */
> String getStyleURI();
> in which I save the URI of the notational style that is in the GMF
> model. It's volatile and transient because I can't serialize it.
>
> 2) In the method where I need to access the attribute in the other
> class i did:
>
> TransactionalEditingDomain editingDomain =
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "gsoc.ogsadai.diagram.editingDomain");
>
> String styleURI = (((RequestType)((WorkflowType)((PipelineType)
> ((ActivityType)object).eContainer()).eContainer()).eContaine r())).getStyleURI();
>
What's "object"? Where is this code? Given that eContainer returns and
EObject which has an eContainer method, I don't think all these casts
are necessary.
> URI uri = URI.createURI(styleURI);
> EObject obj = editingDomain.getResourceSet().getEObject(uri, true);
I imagine you should be able to use object.eResource().getResourceSet()
to avoid any dependencies on the editing domain.
>
> My problems are:
>
> 1) the way I get syleURI is quite orrible. Is there a more elegant way?
I think so. It's just not clear the context of the code above. Is that
the body of getStyleURI()?
> 2) As you said in the previous post is my duty to save the URI. I
> added an
> protected void handleNotificationEvent(Notification event)
Didn't you say you weren't saving it; you did make the feature transient...
>
> in the editPart, but this is called only when the element is modified,
> and moreover I will need just once to save the URI (not every time
> that the element is modified). Where can I put my code to initialize
> the styleURI?
Unfortunately even carefully reading the whole thread I'm having a very
hard time understand the problem you're trying to solve. :-(
>
> Sorry for the (stupid?) questions, and thank you for your time.
> Cheers
>
> Nicola
>
>> Nicola Salvo wrote:
>>> Hello Christian,
>>>
>>> thank you for your answer. I think that my problem is bit different.
>>> I cannot modify my EMF model, I have to stick with an XML Schema
>>> definition, thus I cannot add the AnyUri attribute. Moreover I think
>>> that I don't need it. What I have to do is to fetch from the server
>>> some values to populate a drop-down list in a getChoiceOfValues of
>>> an edit ???ItemProvider.
>>> I thought that just to obtain an object stored in a different
>>> domain, the transaction framework might be used. What I did is:
>>>
>>> In the GMF diagram plugin:
>>> <extension
>>> point="org.eclipse.emf.transaction.editingDomains">
>>> <editingDomain
>>>
>>> factory="org.eclipse.emf.workspace.WorkspaceEditingDomainFactory "
>>> id="EditingDomain">
>>> </editingDomain>
>>> </extension>
>>>
>>> in the RequestDocumentProvider:
>>>
>>> private TransactionalEditingDomain createEditingDomain() {
>>> TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory
>>> getInstance().createEditingDomain();
>>>
>>> editingDomain.setID("EditingDomain"); //$NON-NLS-1$
>>>
>>> and in my emf ActivityTypeItemProvider:
>>>
>>> TransactionalEditingDomain editingDomain =
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomai n( "EditingDomain");
>
>>>
>>> List resources = editingDomain.getResourceSet().getResources();
>>>
>>> the editing domain returned is not null, but the resource list is
>>> empty, thus I don't know how to retrieve the PropertiesStyle object.
>>> Please help. I'm running short of time (and energies)
>>> Thank you in advance
>>>
>>> Nicola
>>>
>>> Christian W. Damus wrote:
>>>
>>>> Hi, Nicola,
>>>
>>>> You can use the AnyURI EDataType from EMF's XMLType package to
>>>> define an EAttribute in your Style (or whatever else) that stores
>>>> the URI of your remote object. Then, when you need to retrieve the
>>>> object, simply create a URI on the attribute value and use
>>>> EcoreUtil::getEObject(ResourceSet, URI) to load the object in the
>>>> appropriate resource set.
>>>
>>>> See XMLTypePackage.Literals.ANY_URI.
>>>
>>>> HTH,
>>>
>>>> Christian
>>>
>>>
>>>
>>>> Nicola Salvo wrote:
>>>>> Hello Christian,
>>>>>
>>>>> probably my message was not clear, I still don't use the proper
>>>>> EMF/Modeling terms.
>>>>> I try to explain a bit better what I have to do. I modeled an xsd
>>>>> file that defines a workflow, and I need to deploy the model in a
>>>>> remote server. For this reason I cannot add any attribute,
>>>>> reference to the EMF. I need to store other information (server
>>>>> url, authentication info,etc.) thus I defined another EMF model,
>>>>> with a class deriving Style, and I store the information in the
>>>>> diagram file. I'm able to access the attributes while using the
>>>>> GMF code, but I need to access to the server url also from the
>>>>> EMF.Editor (some workflow attributes are queried from the serer)
>>>>> that's why I need to mix to different world.
>>>>> I hope I explained it a bitter better.
>>>>> Thank you for yur help,
>>>>> Cheers
>>>>>
>>>>> Nicola
>>>>> Christian W. Damus wrote
>>>>>
>>>>>> Hi, Nicola,
>>>>>
>>>>>> My first recommendation would be to put the notation style
>>>>>> information
>>>>>> in the same editing domain as your other object. Consider an
>>>>>> editing
>>>>>> domain as a closed universe; maintaining dependencies between
>>>>>> objects in
>>>>>> different editing domains is usually more trouble than it's worth.
>>>>>
>>>>>> Do you have some way of linking from the object in your first
>>>>>> editing
>>>>>> domain to the notation style in the other? I don't know what you
>>>>>> mean
>>>>>> by "need to access." You won't have an EReference of any kind
>>>>>> that you
>>>>>> can follow, so you will probably need the URI of the style object
>>>>>> and
>>>>>> also some way to know the editing domain in which resource-set
>>>>>> you need
>>>>>> to search for it.
>>>>>
>>>>>> Perhaps you can explain the situation a bit more so that we can
>>>>>> understand how best to help.
>>>>>
>>>>>> Cheers,
>>>>>
>>>>>> Christian
>>>>>
>>>>>
>>>>>> On Wed, 2008-07-23 at 00:34 +0000, Nicola Salvo wrote:
>>>>>
>>>>>>> Hello folks,
>>>>>>>
>>>>>>> I need to access from ???ItemProvider an attribute that belongs
>>>>>>> to a different editing domain. This editing domain is a
>>>>>>> notational style for GMF (I use it to store sole attributes not
>>>>>>> directly related with my model) and is stored inside the GMF
>>>>>>> diagram (I create it using
>>>>>>> styles.add(PropertiesFactory.eINSTANCE.createPropertiesStyle ());
>>>>>>> in the class WorkflowTypeViewFactory).
>>>>>>> Do you have any suggestion? Thank in advance.
>>>>>>> Cheers
>>>>>>>
>>>>>>> Nicola
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Access Notational style from [message #421238 is a reply to message #421233] Fri, 01 August 2008 15:08 Go to previous messageGo to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello,

first of all welcome back :D I'll try to sum the previous posts.
I have a model (request.ecore) that is modeled following an XML Schema,
that I can't change. I'm using it with GMF, and in order to save some
properties (server url, user credentials..) I defined a notational style
(properties.ecore) with a class PropertiesStyle, serialized in the with
the GMF diagram. From the GMF code I'm able to access to this properties,
because I'm in the same editing domain, but unfortunately access to this
information also from the EMF in order to query a server and populate a
dropdown list in the EMF.Edit.

> I imagine you should be able to use object.eResource().getResourceSet()
> to avoid any dependencies on the editing domain.
You are right! This code:

ResourceSet rs = ((EObject)object).eResource().getResourceSet();
Resource r = rs.getResources().get(0); //GMF
PropertiesStyle style = null;
for(TreeIterator<EObject> l = r.getAllContents();l.hasNext();){
EObject eobj = l.next();
if(eobj instanceof PropertiesStyle){
style = (PropertiesStyle) eobj;
System.out.println(style.getServerURL());
}
}

is enough to get get the PropertiesStyle from the GMF resourceImpl. I
don't know why, in my previous attempt the GMF domain was always empty. I
pretty help that everything works without the needs to use the uri. Have
you got any magical power during holidays? :) Seriously, is this behavior
normal? I though that I needed to use hte TransactionalDomain framework to
access to GMF from EMF.

> Unfortunately even carefully reading the whole thread I'm having a very
> hard time understand the problem you're trying to solve. :-(
Well, it seems that it was impossible to understand the problem, because I
made it up :) You can't imagine for how long I've been stuck on it. when
I'll finish this project I will win the award for "insistent problem
inventor".
Thanks again

Nicola
Re: Access Notational style from [message #421240 is a reply to message #421238] Fri, 01 August 2008 15:31 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Nicola,

Comments below.

Nicola Salvo wrote:
> Hello,
>
> first of all welcome back :D
You saw my pretty pictures. :-)
> I'll try to sum the previous posts.
> I have a model (request.ecore) that is modeled following an XML
> Schema, that I can't change. I'm using it with GMF, and in order to
> save some properties (server url, user credentials..) I defined a
> notational style (properties.ecore) with a class PropertiesStyle,
> serialized in the with the GMF diagram. From the GMF code I'm able to
> access to this properties, because I'm in the same editing domain, but
> unfortunately access to this information also from the EMF in order to
> query a server and populate a dropdown list in the EMF.Edit.
>> I imagine you should be able to use
>> object.eResource().getResourceSet() to avoid any dependencies on the
>> editing domain.
> You are right! This code:
>
> ResourceSet rs = ((EObject)object).eResource().getResourceSet();
> Resource r = rs.getResources().get(0); //GMF
> PropertiesStyle style = null;
> for(TreeIterator<EObject> l = r.getAllContents();l.hasNext();){
> EObject eobj = l.next();
> if(eobj instanceof PropertiesStyle){
> style = (PropertiesStyle) eobj;
> System.out.println(style.getServerURL());
So the right style will be the first PropertiesStyle instance in the
first resource in the resource set...
> }
> }
>
> is enough to get get the PropertiesStyle from the GMF resourceImpl. I
> don't know why, in my previous attempt the GMF domain was always
> empty. I pretty help that everything works without the needs to use
> the uri. Have you got any magical power during holidays? :)
I seem to be blessed with an uncanny knack for reading between the
lines. Some refer to it as my psychic debugging skills.
> Seriously, is this behavior normal? I though that I needed to use hte
> TransactionalDomain framework to access to GMF from EMF.
I imagine the diagram is loaded first, and it causes the domain model's
resource to be demand loaded so this would be a normal thing.
>
>> Unfortunately even carefully reading the whole thread I'm having a
>> very hard time understand the problem you're trying to solve. :-(
> Well, it seems that it was impossible to understand the problem,
> because I made it up :) You can't imagine for how long I've been stuck
> on it. when I'll finish this project I will win the award for
> "insistent problem inventor".
Oh there have been some good runners up in the past, let me assure you. :-P
> Thanks again
>
> Nicola
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Undo/Redo in different editors with one TransactionalEditingDomain
Next Topic:Unexpected Behavior in Generated Code
Goto Forum:
  


Current Time: Thu Apr 25 23:44:49 GMT 2024

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

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

Back to the top