Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Re: Input for generated editor
Re: Input for generated editor [message #118896] Thu, 17 April 2008 17:35 Go to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Barbara,

Martin Taal has invested a fair bit of time in ensuring that Teneo hooks
up well with the GMF editor. Maybe it might solve your problems
directly. I've added the EMFT newsgroup to the "to" list of the reply.

I imagine you should be able to use EMF's URIEditorInput as the editor
input and that all your code to communicate with the data base would be
done either at the URI converter level or ResourceImpl side of things.
With the URIConverter changes in EMF 2.4, this should be even easier to
accomplish, if something like XML data columns are your target.

Maybe you could explain a bit more what you're trying to do?


Barbara Rosi-Schwartz wrote:
> Hello all.
>
> I have generated a graphical editor from my domain model. Since my
> application is database, not file system, driven, I knew I would have
> to rewire the generated editor to accept my "virtual" object as
> retrieved from the database and I was hoping this could be done in a
> relatively straightforward manner, through localised changes in one or
> two classes.
>
> However a perusal of the generated code leads me to believe that the
> dependency on the editable object being on the file system (or a URI
> resource) is deeply ingrained and that it is going to take quite a lot
> of surgery to switch to a database driven paradigm.
>
> Is this accurate or am I missing something?
>
> If so, I do wonder why so many of the Eclipse APIs and facilities
> continue to assume that the whole world is in a file system! :-)
>
> TIA,
> B.
>
Re: Input for generated editor [message #118909 is a reply to message #118896] Thu, 17 April 2008 18:20 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Barbara,
This tutorial here:
http://www.elver.org/hibernate/gmftutorial/tutorial1.html

describes how to change the generated gmf editor to retrieve its data from the database. In the
tutorial also the diagram itself is stored in the db. It is also possible to store the diagram in a
local file and get the data from the database. This is however not described in the tutorial but I
am sure that the tutorial leads you in the right direction.

gr. Martin

Ed Merks wrote:
> Barbara,
>
> Martin Taal has invested a fair bit of time in ensuring that Teneo hooks
> up well with the GMF editor. Maybe it might solve your problems
> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>
> I imagine you should be able to use EMF's URIEditorInput as the editor
> input and that all your code to communicate with the data base would be
> done either at the URI converter level or ResourceImpl side of things.
> With the URIConverter changes in EMF 2.4, this should be even easier to
> accomplish, if something like XML data columns are your target.
>
> Maybe you could explain a bit more what you're trying to do?
>
>
> Barbara Rosi-Schwartz wrote:
>> Hello all.
>>
>> I have generated a graphical editor from my domain model. Since my
>> application is database, not file system, driven, I knew I would have
>> to rewire the generated editor to accept my "virtual" object as
>> retrieved from the database and I was hoping this could be done in a
>> relatively straightforward manner, through localised changes in one or
>> two classes.
>>
>> However a perusal of the generated code leads me to believe that the
>> dependency on the editable object being on the file system (or a URI
>> resource) is deeply ingrained and that it is going to take quite a lot
>> of surgery to switch to a database driven paradigm.
>>
>> Is this accurate or am I missing something?
>>
>> If so, I do wonder why so many of the Eclipse APIs and facilities
>> continue to assume that the whole world is in a file system! :-)
>>
>> TIA,
>> B.
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #118936 is a reply to message #118896] Thu, 17 April 2008 20:24 Go to previous messageGo to next message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
Hi Ed,

Ah, if only I was able to find the link to where your webcam is
available we could avoid all this cross chatter in the newsgroup taking
up needless bandwidth :-)

This is *really* *truly* exiting stuff, the Teneo hooks stuff, that you
have pointed us to. Many thanks. When B. spoke to me about I imagined
the solution as a URI handler, say "db://", that new how to resolve to
the database. Never actually thought that someone has already tackled
the space. Wow, I feel like an 20 odd year old again, and that is
knocking a very big hunk off of it.

I will take a look at this in the morning with great pleasure.

While, I have THE Ed Merks' attention I really just have to say how
much I appreciate the courage of you blog. Few have the will to stand
up for their true core ideals. Kudos to you ;-)

Thanks (seriously) for the pointer,
Joel

On 2008-04-17 18:35:07 +0100, Ed Merks <merks@ca.ibm.com> said:

> Barbara,
>
> Martin Taal has invested a fair bit of time in ensuring that Teneo
> hooks up well with the GMF editor. Maybe it might solve your problems
> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>
> I imagine you should be able to use EMF's URIEditorInput as the editor
> input and that all your code to communicate with the data base would be
> done either at the URI converter level or ResourceImpl side of things.
> With the URIConverter changes in EMF 2.4, this should be even easier to
> accomplish, if something like XML data columns are your target.
>
> Maybe you could explain a bit more what you're trying to do?
>
>
> Barbara Rosi-Schwartz wrote:
>> Hello all.
>>
>> I have generated a graphical editor from my domain model. Since my
>> application is database, not file system, driven, I knew I would have
>> to rewire the generated editor to accept my "virtual" object as
>> retrieved from the database and I was hoping this could be done in a
>> relatively straightforward manner, through localised changes in one or
>> two classes.
>>
>> However a perusal of the generated code leads me to believe that the
>> dependency on the editable object being on the file system (or a URI
>> resource) is deeply ingrained and that it is going to take quite a lot
>> of surgery to switch to a database driven paradigm.
>>
>> Is this accurate or am I missing something?
>>
>> If so, I do wonder why so many of the Eclipse APIs and facilities
>> continue to assume that the whole world is in a file system! :-)
>>
>> TIA,
>> B.


--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Tool
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: Input for generated editor [message #118949 is a reply to message #118909] Thu, 17 April 2008 20:30 Go to previous messageGo to next message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
Hi Martin,

I am butting in on my wife's post and I do not think she is happy with
me at the moment :-) Just warning you in case you are concerned of
getting involved in the middle of a family thing :-)

From what Ed described and you say below I am very intrigued. I will
take a look at all of the tomorrow. My thanks for the info and for
taking the lead in what I feel is a very needed extension to the
Eclipse Resource paradigm. I brought all of this stuff up in the
Eclipse newsgroup four years back but I have never had the bandwidth to
actually tackle it in a generic way. Thanks for tackling the space.

Btw, have you ever thought about how to turn SOA services into URI.
That would be extremely useful as well.

All the best,
Joel

On 2008-04-17 19:20:35 +0100, Martin Taal <mtaal@elver.org> said:

> Hi Barbara,
> This tutorial here:
> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>
> describes how to change the generated gmf editor to retrieve its data
> from the database. In the tutorial also the diagram itself is stored in
> the db. It is also possible to store the diagram in a local file and
> get the data from the database. This is however not described in the
> tutorial but I am sure that the tutorial leads you in the right
> direction.
>
> gr. Martin
>
> Ed Merks wrote:
>> Barbara,
>>
>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>> hooks up well with the GMF editor. Maybe it might solve your problems
>> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>>
>> I imagine you should be able to use EMF's URIEditorInput as the editor
>> input and that all your code to communicate with the data base would be
>> done either at the URI converter level or ResourceImpl side of things.
>> With the URIConverter changes in EMF 2.4, this should be even easier to
>> accomplish, if something like XML data columns are your target.
>>
>> Maybe you could explain a bit more what you're trying to do?
>>
>>
>> Barbara Rosi-Schwartz wrote:
>>> Hello all.
>>>
>>> I have generated a graphical editor from my domain model. Since my
>>> application is database, not file system, driven, I knew I would have
>>> to rewire the generated editor to accept my "virtual" object as
>>> retrieved from the database and I was hoping this could be done in a
>>> relatively straightforward manner, through localised changes in one or
>>> two classes.
>>>
>>> However a perusal of the generated code leads me to believe that the
>>> dependency on the editable object being on the file system (or a URI
>>> resource) is deeply ingrained and that it is going to take quite a lot
>>> of surgery to switch to a database driven paradigm.
>>>
>>> Is this accurate or am I missing something?
>>>
>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>> continue to assume that the whole world is in a file system! :-)
>>>
>>> TIA,
>>> B.


--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Tool
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: Input for generated editor [message #119003 is a reply to message #118936] Fri, 18 April 2008 11:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Joel,

Thanks for the kind words. I'm glad my blog is a source of
entertainment as well as food for thought. It's nice to make light
things heavy and also to make heavy things light...

Last year I worked with some folks at IBM research on prototyping
support for serializing using a database that supports native XML. The
idea was to use a URI of the form
database:<JDBC-URL-of-the-connection>!/<table-name>/<column-name >?key='value'.
You can imagine a URI converter that would create an input stream by
invoking a query to read the XML from the named table, accessing the
named column for the row with the given key and similarly do an update
upon closing the output stream. The database would effectively be
access as a big archive (zip) file and with EMF 2.4's support for
URIHandlers, it would be easy to just add a URI handler to an existing
resource set to support this type of thing.

Of course what Teneo is doing is far more sophisticated in that it
decomposes the objects themselves into tables and all that good
relational stuff. The use of native XML columns will perhaps become
more interesting in the future...


Joel Rosi-Schwartz wrote:
> Hi Ed,
>
> Ah, if only I was able to find the link to where your webcam is
> available we could avoid all this cross chatter in the newsgroup
> taking up needless bandwidth :-)
>
> This is *really* *truly* exiting stuff, the Teneo hooks stuff, that
> you have pointed us to. Many thanks. When B. spoke to me about I
> imagined the solution as a URI handler, say "db://", that new how to
> resolve to the database. Never actually thought that someone has
> already tackled the space. Wow, I feel like an 20 odd year old again,
> and that is knocking a very big hunk off of it.
>
> I will take a look at this in the morning with great pleasure.
>
> While, I have THE Ed Merks' attention I really just have to say how
> much I appreciate the courage of you blog. Few have the will to stand
> up for their true core ideals. Kudos to you ;-)
>
> Thanks (seriously) for the pointer,
> Joel
>
> On 2008-04-17 18:35:07 +0100, Ed Merks <merks@ca.ibm.com> said:
>
>> Barbara,
>>
>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>> hooks up well with the GMF editor. Maybe it might solve your
>> problems directly. I've added the EMFT newsgroup to the "to" list of
>> the reply.
>>
>> I imagine you should be able to use EMF's URIEditorInput as the
>> editor input and that all your code to communicate with the data base
>> would be done either at the URI converter level or ResourceImpl side
>> of things. With the URIConverter changes in EMF 2.4, this should be
>> even easier to accomplish, if something like XML data columns are
>> your target.
>>
>> Maybe you could explain a bit more what you're trying to do?
>>
>>
>> Barbara Rosi-Schwartz wrote:
>>> Hello all.
>>>
>>> I have generated a graphical editor from my domain model. Since my
>>> application is database, not file system, driven, I knew I would
>>> have to rewire the generated editor to accept my "virtual" object as
>>> retrieved from the database and I was hoping this could be done in a
>>> relatively straightforward manner, through localised changes in one
>>> or two classes.
>>>
>>> However a perusal of the generated code leads me to believe that the
>>> dependency on the editable object being on the file system (or a URI
>>> resource) is deeply ingrained and that it is going to take quite a
>>> lot of surgery to switch to a database driven paradigm.
>>>
>>> Is this accurate or am I missing something?
>>>
>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>> continue to assume that the whole world is in a file system! :-)
>>>
>>> TIA,
>>> B.
>
>
Re: Input for generated editor [message #119128 is a reply to message #118949] Sat, 19 April 2008 06:41 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Joel,
Yes I hope it is usefull for you. Regarding soa/uri, I have not had time to look in detail at the
Eclipse URI/resource loading part. Teneo builds upon the EMF resource and the EMF resource factory
which takes care of opening the correct HibernateResource (which is an EMF resource).

gr. Martin

Joel Rosi-Schwartz wrote:
> Hi Martin,
>
> I am butting in on my wife's post and I do not think she is happy with
> me at the moment :-) Just warning you in case you are concerned of
> getting involved in the middle of a family thing :-)
>
> From what Ed described and you say below I am very intrigued. I will
> take a look at all of the tomorrow. My thanks for the info and for
> taking the lead in what I feel is a very needed extension to the Eclipse
> Resource paradigm. I brought all of this stuff up in the Eclipse
> newsgroup four years back but I have never had the bandwidth to actually
> tackle it in a generic way. Thanks for tackling the space.
>
> Btw, have you ever thought about how to turn SOA services into URI. That
> would be extremely useful as well.
>
> All the best,
> Joel
>
> On 2008-04-17 19:20:35 +0100, Martin Taal <mtaal@elver.org> said:
>
>> Hi Barbara,
>> This tutorial here:
>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>
>> describes how to change the generated gmf editor to retrieve its data
>> from the database. In the tutorial also the diagram itself is stored
>> in the db. It is also possible to store the diagram in a local file
>> and get the data from the database. This is however not described in
>> the tutorial but I am sure that the tutorial leads you in the right
>> direction.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Barbara,
>>>
>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>> hooks up well with the GMF editor. Maybe it might solve your
>>> problems directly. I've added the EMFT newsgroup to the "to" list of
>>> the reply.
>>>
>>> I imagine you should be able to use EMF's URIEditorInput as the
>>> editor input and that all your code to communicate with the data base
>>> would be done either at the URI converter level or ResourceImpl side
>>> of things. With the URIConverter changes in EMF 2.4, this should be
>>> even easier to accomplish, if something like XML data columns are
>>> your target.
>>>
>>> Maybe you could explain a bit more what you're trying to do?
>>>
>>>
>>> Barbara Rosi-Schwartz wrote:
>>>> Hello all.
>>>>
>>>> I have generated a graphical editor from my domain model. Since my
>>>> application is database, not file system, driven, I knew I would
>>>> have to rewire the generated editor to accept my "virtual" object as
>>>> retrieved from the database and I was hoping this could be done in a
>>>> relatively straightforward manner, through localised changes in one
>>>> or two classes.
>>>>
>>>> However a perusal of the generated code leads me to believe that the
>>>> dependency on the editable object being on the file system (or a URI
>>>> resource) is deeply ingrained and that it is going to take quite a
>>>> lot of surgery to switch to a database driven paradigm.
>>>>
>>>> Is this accurate or am I missing something?
>>>>
>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>> continue to assume that the whole world is in a file system! :-)
>>>>
>>>> TIA,
>>>> B.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #122758 is a reply to message #118909] Wed, 21 May 2008 13:58 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Martin,
Thanks for your tutorial, it was a good entry point for me.
I am currently trying to implement a custom resource which doesnt get
the model eobjects and the diagram from a file or a database, but
forwards to a abstract source. The abstract source contains several
diagrams and all model elements. (see
news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
BTW and off topic: the source is then syncronized with a server which
saves it using Teneo :-)

As I want to use gmf to create diagram editors, i try to use a custom
resource which wraps my source and only returns the model elements of
one diagram. I tried to open the DiagramEditor with my CustomResource,
similar as you did with your DatabaseResource. But it seems that there
are several places where the generated Editor requires a file (e.g.
private long computeModificationStamp(ResourceSetInfo info)) or a
XMLResource (e.g. public static String getIdStr(View view) in
ViewUtil). So I really wonder how you did your adaptation :-)
Also you mentioned that it is possible to use different Resources for
the data and he diagram. Till now I couldnt find the resource for the
model elements contained on a diagram. Could you give me a hint where it
is loaded?
Thanks...

Jonas


> Hi Barbara,
> This tutorial here:
> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>
> describes how to change the generated gmf editor to retrieve its data
> from the database. In the tutorial also the diagram itself is stored in
> the db. It is also possible to store the diagram in a local file and get
> the data from the database. This is however not described in the
> tutorial but I am sure that the tutorial leads you in the right direction.
>
> gr. Martin
>
> Ed Merks wrote:
>> Barbara,
>>
>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>> hooks up well with the GMF editor. Maybe it might solve your problems
>> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>>
>> I imagine you should be able to use EMF's URIEditorInput as the editor
>> input and that all your code to communicate with the data base would
>> be done either at the URI converter level or ResourceImpl side of
>> things. With the URIConverter changes in EMF 2.4, this should be even
>> easier to accomplish, if something like XML data columns are your target.
>>
>> Maybe you could explain a bit more what you're trying to do?
>>
>>
>> Barbara Rosi-Schwartz wrote:
>>> Hello all.
>>>
>>> I have generated a graphical editor from my domain model. Since my
>>> application is database, not file system, driven, I knew I would have
>>> to rewire the generated editor to accept my "virtual" object as
>>> retrieved from the database and I was hoping this could be done in a
>>> relatively straightforward manner, through localised changes in one
>>> or two classes.
>>>
>>> However a perusal of the generated code leads me to believe that the
>>> dependency on the editable object being on the file system (or a URI
>>> resource) is deeply ingrained and that it is going to take quite a
>>> lot of surgery to switch to a database driven paradigm.
>>>
>>> Is this accurate or am I missing something?
>>>
>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>> continue to assume that the whole world is in a file system! :-)
>>>
>>> TIA,
>>> B.
>>>
>
>
Re: Input for generated editor [message #122847 is a reply to message #122758] Thu, 22 May 2008 11:21 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
I need some time to answer your post because I have to go deep into the code again. I will come back
to you on this (hopefully today).

Regarding the XMLResource, see the header Hibernate XML resource on this page:
http://www.elver.org/hibernate/gmftutorial/tutorial4.html

Afaik your resource should implement the XMLResource interface.

gr. Martin

Jonas wrote:
> Hi Martin,
> Thanks for your tutorial, it was a good entry point for me.
> I am currently trying to implement a custom resource which doesnt get
> the model eobjects and the diagram from a file or a database, but
> forwards to a abstract source. The abstract source contains several
> diagrams and all model elements. (see
> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
> BTW and off topic: the source is then syncronized with a server which
> saves it using Teneo :-)
>
> As I want to use gmf to create diagram editors, i try to use a custom
> resource which wraps my source and only returns the model elements of
> one diagram. I tried to open the DiagramEditor with my CustomResource,
> similar as you did with your DatabaseResource. But it seems that there
> are several places where the generated Editor requires a file (e.g.
> private long computeModificationStamp(ResourceSetInfo info)) or a
> XMLResource (e.g. public static String getIdStr(View view) in
> ViewUtil). So I really wonder how you did your adaptation :-)
> Also you mentioned that it is possible to use different Resources for
> the data and he diagram. Till now I couldnt find the resource for the
> model elements contained on a diagram. Could you give me a hint where it
> is loaded?
> Thanks...
>
> Jonas
>
>
>> Hi Barbara,
>> This tutorial here:
>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>
>> describes how to change the generated gmf editor to retrieve its data
>> from the database. In the tutorial also the diagram itself is stored
>> in the db. It is also possible to store the diagram in a local file
>> and get the data from the database. This is however not described in
>> the tutorial but I am sure that the tutorial leads you in the right
>> direction.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Barbara,
>>>
>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>> hooks up well with the GMF editor. Maybe it might solve your
>>> problems directly. I've added the EMFT newsgroup to the "to" list of
>>> the reply.
>>>
>>> I imagine you should be able to use EMF's URIEditorInput as the
>>> editor input and that all your code to communicate with the data base
>>> would be done either at the URI converter level or ResourceImpl side
>>> of things. With the URIConverter changes in EMF 2.4, this should be
>>> even easier to accomplish, if something like XML data columns are
>>> your target.
>>>
>>> Maybe you could explain a bit more what you're trying to do?
>>>
>>>
>>> Barbara Rosi-Schwartz wrote:
>>>> Hello all.
>>>>
>>>> I have generated a graphical editor from my domain model. Since my
>>>> application is database, not file system, driven, I knew I would
>>>> have to rewire the generated editor to accept my "virtual" object as
>>>> retrieved from the database and I was hoping this could be done in a
>>>> relatively straightforward manner, through localised changes in one
>>>> or two classes.
>>>>
>>>> However a perusal of the generated code leads me to believe that the
>>>> dependency on the editable object being on the file system (or a URI
>>>> resource) is deeply ingrained and that it is going to take quite a
>>>> lot of surgery to switch to a database driven paradigm.
>>>>
>>>> Is this accurate or am I missing something?
>>>>
>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>> continue to assume that the whole world is in a file system! :-)
>>>>
>>>> TIA,
>>>> B.
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #122969 is a reply to message #122758] Tue, 27 May 2008 08:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
Sorry for my late reply.

Here are some additional pointers. I hope it is helpfull.

I open the editor like this:
page.openEditor(new URIEditorInput(StoreController.DATABASE_URI),
MindmapDiagramEditor.ID);

Afaics using the URIEditorInput solves some of the issues related to the fact the generated editor
assumes that the resources are files. (you can search for the string URIEditorInput in the generated
code and it is used on various locations).

For storing data and diagrams in different resources. You can take a look at the OpenMindmapDBEditor
and then the initializeData method. Currently it stores the diagram and the map in one resource. In
this method you can create two resources one for the Map and for the Diagram. The diagram contains a
reference to the root of the model (diagram.setElement(map)). When opening the diagram resource then
the model resource should open automatically. Note that you should search the EMFT newsgroup for
some related GMF-Teneo topics (about cross-resource containment references if I remember it
correctly...).

Afaics the diagram always requires at least one model root object. By storing this root object in a
separate resource (during initialization) model and diagram are stored separately.

Storing the diagram and the model separately only works if:
- both the diagram and the model are stored in the same database (both resources point to the same
database), or
- the diagram is stored in a xml/xmi resource and the model in the database.

XMI/XML resources support cross-resource references but database resources don't support references
to entities outside of the database.

gr. Martin

Jonas wrote:
> Hi Martin,
> Thanks for your tutorial, it was a good entry point for me.
> I am currently trying to implement a custom resource which doesnt get
> the model eobjects and the diagram from a file or a database, but
> forwards to a abstract source. The abstract source contains several
> diagrams and all model elements. (see
> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
> BTW and off topic: the source is then syncronized with a server which
> saves it using Teneo :-)
>
> As I want to use gmf to create diagram editors, i try to use a custom
> resource which wraps my source and only returns the model elements of
> one diagram. I tried to open the DiagramEditor with my CustomResource,
> similar as you did with your DatabaseResource. But it seems that there
> are several places where the generated Editor requires a file (e.g.
> private long computeModificationStamp(ResourceSetInfo info)) or a
> XMLResource (e.g. public static String getIdStr(View view) in
> ViewUtil). So I really wonder how you did your adaptation :-)
> Also you mentioned that it is possible to use different Resources for
> the data and he diagram. Till now I couldnt find the resource for the
> model elements contained on a diagram. Could you give me a hint where it
> is loaded?
> Thanks...
>
> Jonas
>
>
>> Hi Barbara,
>> This tutorial here:
>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>
>> describes how to change the generated gmf editor to retrieve its data
>> from the database. In the tutorial also the diagram itself is stored
>> in the db. It is also possible to store the diagram in a local file
>> and get the data from the database. This is however not described in
>> the tutorial but I am sure that the tutorial leads you in the right
>> direction.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Barbara,
>>>
>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>> hooks up well with the GMF editor. Maybe it might solve your
>>> problems directly. I've added the EMFT newsgroup to the "to" list of
>>> the reply.
>>>
>>> I imagine you should be able to use EMF's URIEditorInput as the
>>> editor input and that all your code to communicate with the data base
>>> would be done either at the URI converter level or ResourceImpl side
>>> of things. With the URIConverter changes in EMF 2.4, this should be
>>> even easier to accomplish, if something like XML data columns are
>>> your target.
>>>
>>> Maybe you could explain a bit more what you're trying to do?
>>>
>>>
>>> Barbara Rosi-Schwartz wrote:
>>>> Hello all.
>>>>
>>>> I have generated a graphical editor from my domain model. Since my
>>>> application is database, not file system, driven, I knew I would
>>>> have to rewire the generated editor to accept my "virtual" object as
>>>> retrieved from the database and I was hoping this could be done in a
>>>> relatively straightforward manner, through localised changes in one
>>>> or two classes.
>>>>
>>>> However a perusal of the generated code leads me to believe that the
>>>> dependency on the editable object being on the file system (or a URI
>>>> resource) is deeply ingrained and that it is going to take quite a
>>>> lot of surgery to switch to a database driven paradigm.
>>>>
>>>> Is this accurate or am I missing something?
>>>>
>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>> continue to assume that the whole world is in a file system! :-)
>>>>
>>>> TIA,
>>>> B.
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #125139 is a reply to message #122969] Wed, 04 June 2008 17:52 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Martin,
thanks for your reply and 5 days isn't late :-)
Your Hints were great I am now able to load my custom resource. I
additionally had to adapt "private long
computeModificationStamp(ResourceSetInfo info)" in ModelDocumentProvider
as it assumes a file even if you use URIEditor input.

Now the editor loads without any error, but I dont see the diagram
nodes. In the property view I can see that the root element is corretly
loaded and that it´s elements are in it, but they dont appear. It is
also not possible to add anything to the diagram (ExecutionException).
I implemented my own resource which is a subclass of
org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
connected to a file or a database and should just be a wrapper. For
testing i initialize my resource like this:

private void initialize() {
//Create Model root and one test Node
MEDiagram meDiagram = DiagramFactory.eINSTANCE.createMEDiagram();
TestForDiagram testForDiagram = ModelFactory.eINSTANCE
.createTestForDiagram();
meDiagram.getElements().add(testForDiagram);
//Create gmf diagram
Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
//Put the content in the resource
super.getContents().add(diagram);
super.getContents().add(meDiagram);
//Set root of the gmf diagram
diagram.setElement(meDiagram);
//Add Transactional domain. Otherwise: Nullpointer Exception
ResourceSet resourceSet = this.getResourceSet();
TransactionalEditingDomain.Factory.INSTANCE
.createEditingDomain(resourceSet);
}

I spent much time in debugging and it seams that only the root element
is loaded. I observed the getElements() method of MEDiagram. It is
called several time, but Afaics only for EditingPolicies and Property
views. Can sb. give me a Hint which method in the generated editor loads
the diagram nodes and would be a good hook for debugging?
Thanks for any help...

Jonas




Martin Taal schrieb:
> Hi Jonas,
> Sorry for my late reply.
>
> Here are some additional pointers. I hope it is helpfull.
>
> I open the editor like this:
> page.openEditor(new
> URIEditorInput(StoreController.DATABASE_URI),
> MindmapDiagramEditor.ID);
>
> Afaics using the URIEditorInput solves some of the issues related to the
> fact the generated editor assumes that the resources are files. (you can
> search for the string URIEditorInput in the generated code and it is
> used on various locations).
>
> For storing data and diagrams in different resources. You can take a
> look at the OpenMindmapDBEditor and then the initializeData method.
> Currently it stores the diagram and the map in one resource. In this
> method you can create two resources one for the Map and for the Diagram.
> The diagram contains a reference to the root of the model
> (diagram.setElement(map)). When opening the diagram resource then the
> model resource should open automatically. Note that you should search
> the EMFT newsgroup for some related GMF-Teneo topics (about
> cross-resource containment references if I remember it correctly...).
>
> Afaics the diagram always requires at least one model root object. By
> storing this root object in a separate resource (during initialization)
> model and diagram are stored separately.
>
> Storing the diagram and the model separately only works if:
> - both the diagram and the model are stored in the same database (both
> resources point to the same database), or
> - the diagram is stored in a xml/xmi resource and the model in the
> database.
>
> XMI/XML resources support cross-resource references but database
> resources don't support references to entities outside of the database.
>
> gr. Martin
>
> Jonas wrote:
>> Hi Martin,
>> Thanks for your tutorial, it was a good entry point for me.
>> I am currently trying to implement a custom resource which doesnt get
>> the model eobjects and the diagram from a file or a database, but
>> forwards to a abstract source. The abstract source contains several
>> diagrams and all model elements. (see
>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>> BTW and off topic: the source is then syncronized with a server which
>> saves it using Teneo :-)
>>
>> As I want to use gmf to create diagram editors, i try to use a custom
>> resource which wraps my source and only returns the model elements of
>> one diagram. I tried to open the DiagramEditor with my
>> CustomResource, similar as you did with your DatabaseResource. But it
>> seems that there are several places where the generated Editor
>> requires a file (e.g. private long
>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource (e.g.
>> public static String getIdStr(View view) in ViewUtil). So I really
>> wonder how you did your adaptation :-)
>> Also you mentioned that it is possible to use different Resources for
>> the data and he diagram. Till now I couldnt find the resource for the
>> model elements contained on a diagram. Could you give me a hint where
>> it is loaded?
>> Thanks...
>>
>> Jonas
>>
>>
>>> Hi Barbara,
>>> This tutorial here:
>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>
>>> describes how to change the generated gmf editor to retrieve its data
>>> from the database. In the tutorial also the diagram itself is stored
>>> in the db. It is also possible to store the diagram in a local file
>>> and get the data from the database. This is however not described in
>>> the tutorial but I am sure that the tutorial leads you in the right
>>> direction.
>>>
>>> gr. Martin
>>>
>>> Ed Merks wrote:
>>>> Barbara,
>>>>
>>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>>> hooks up well with the GMF editor. Maybe it might solve your
>>>> problems directly. I've added the EMFT newsgroup to the "to" list
>>>> of the reply.
>>>>
>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>> editor input and that all your code to communicate with the data
>>>> base would be done either at the URI converter level or ResourceImpl
>>>> side of things. With the URIConverter changes in EMF 2.4, this
>>>> should be even easier to accomplish, if something like XML data
>>>> columns are your target.
>>>>
>>>> Maybe you could explain a bit more what you're trying to do?
>>>>
>>>>
>>>> Barbara Rosi-Schwartz wrote:
>>>>> Hello all.
>>>>>
>>>>> I have generated a graphical editor from my domain model. Since my
>>>>> application is database, not file system, driven, I knew I would
>>>>> have to rewire the generated editor to accept my "virtual" object
>>>>> as retrieved from the database and I was hoping this could be done
>>>>> in a relatively straightforward manner, through localised changes
>>>>> in one or two classes.
>>>>>
>>>>> However a perusal of the generated code leads me to believe that
>>>>> the dependency on the editable object being on the file system (or
>>>>> a URI resource) is deeply ingrained and that it is going to take
>>>>> quite a lot of surgery to switch to a database driven paradigm.
>>>>>
>>>>> Is this accurate or am I missing something?
>>>>>
>>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>>> continue to assume that the whole world is in a file system! :-)
>>>>>
>>>>> TIA,
>>>>> B.
>>>>>
>>>
>>>
>
>
Re: Input for generated editor [message #125148 is a reply to message #125139] Wed, 04 June 2008 20:35 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
Hmm, after initialization the diagram is empty. Which elements do you see in the properties view?
And can you post the stacktrace of the executionexception?

Regarding were to look for how the diagram nodes are loaded I don't know the answer. I hope someone
on the gmft newsgroup will answer this one...

Other small (probably insignificant) differences with the tutorial is that I add the model
(meDiagram) to the resource before the diagram, in addition in your case the diagram name is not
set. But I would be surprised if this makes any difference....

gr. Martin

Jonas wrote:
> Hi Martin,
> thanks for your reply and 5 days isn't late :-)
> Your Hints were great I am now able to load my custom resource. I
> additionally had to adapt "private long
> computeModificationStamp(ResourceSetInfo info)" in ModelDocumentProvider
> as it assumes a file even if you use URIEditor input.
>
> Now the editor loads without any error, but I dont see the diagram
> nodes. In the property view I can see that the root element is corretly
> loaded and that it´s elements are in it, but they dont appear. It is
> also not possible to add anything to the diagram (ExecutionException).
> I implemented my own resource which is a subclass of
> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
> connected to a file or a database and should just be a wrapper. For
> testing i initialize my resource like this:
>
> private void initialize() {
> //Create Model root and one test Node
> MEDiagram meDiagram =
> DiagramFactory.eINSTANCE.createMEDiagram();
> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
> .createTestForDiagram();
> meDiagram.getElements().add(testForDiagram);
> //Create gmf diagram
> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
> //Put the content in the resource
> super.getContents().add(diagram);
> super.getContents().add(meDiagram);
> //Set root of the gmf diagram
> diagram.setElement(meDiagram);
> //Add Transactional domain. Otherwise: Nullpointer Exception
> ResourceSet resourceSet = this.getResourceSet();
> TransactionalEditingDomain.Factory.INSTANCE
> .createEditingDomain(resourceSet);
> }
>
> I spent much time in debugging and it seams that only the root element
> is loaded. I observed the getElements() method of MEDiagram. It is
> called several time, but Afaics only for EditingPolicies and Property
> views. Can sb. give me a Hint which method in the generated editor loads
> the diagram nodes and would be a good hook for debugging?
> Thanks for any help...
>
> Jonas
>
>
>
>
> Martin Taal schrieb:
>> Hi Jonas,
>> Sorry for my late reply.
>>
>> Here are some additional pointers. I hope it is helpfull.
>>
>> I open the editor like this:
>> page.openEditor(new
>> URIEditorInput(StoreController.DATABASE_URI),
>> MindmapDiagramEditor.ID);
>>
>> Afaics using the URIEditorInput solves some of the issues related to
>> the fact the generated editor assumes that the resources are files.
>> (you can search for the string URIEditorInput in the generated code
>> and it is used on various locations).
>>
>> For storing data and diagrams in different resources. You can take a
>> look at the OpenMindmapDBEditor and then the initializeData method.
>> Currently it stores the diagram and the map in one resource. In this
>> method you can create two resources one for the Map and for the
>> Diagram. The diagram contains a reference to the root of the model
>> (diagram.setElement(map)). When opening the diagram resource then the
>> model resource should open automatically. Note that you should search
>> the EMFT newsgroup for some related GMF-Teneo topics (about
>> cross-resource containment references if I remember it correctly...).
>>
>> Afaics the diagram always requires at least one model root object. By
>> storing this root object in a separate resource (during
>> initialization) model and diagram are stored separately.
>>
>> Storing the diagram and the model separately only works if:
>> - both the diagram and the model are stored in the same database (both
>> resources point to the same database), or
>> - the diagram is stored in a xml/xmi resource and the model in the
>> database.
>>
>> XMI/XML resources support cross-resource references but database
>> resources don't support references to entities outside of the database.
>>
>> gr. Martin
>>
>> Jonas wrote:
>>> Hi Martin,
>>> Thanks for your tutorial, it was a good entry point for me.
>>> I am currently trying to implement a custom resource which doesnt get
>>> the model eobjects and the diagram from a file or a database, but
>>> forwards to a abstract source. The abstract source contains several
>>> diagrams and all model elements. (see
>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>> BTW and off topic: the source is then syncronized with a server which
>>> saves it using Teneo :-)
>>>
>>> As I want to use gmf to create diagram editors, i try to use a custom
>>> resource which wraps my source and only returns the model elements of
>>> one diagram. I tried to open the DiagramEditor with my
>>> CustomResource, similar as you did with your DatabaseResource. But it
>>> seems that there are several places where the generated Editor
>>> requires a file (e.g. private long
>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>> really wonder how you did your adaptation :-)
>>> Also you mentioned that it is possible to use different Resources for
>>> the data and he diagram. Till now I couldnt find the resource for the
>>> model elements contained on a diagram. Could you give me a hint where
>>> it is loaded?
>>> Thanks...
>>>
>>> Jonas
>>>
>>>
>>>> Hi Barbara,
>>>> This tutorial here:
>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>
>>>> describes how to change the generated gmf editor to retrieve its
>>>> data from the database. In the tutorial also the diagram itself is
>>>> stored in the db. It is also possible to store the diagram in a
>>>> local file and get the data from the database. This is however not
>>>> described in the tutorial but I am sure that the tutorial leads you
>>>> in the right direction.
>>>>
>>>> gr. Martin
>>>>
>>>> Ed Merks wrote:
>>>>> Barbara,
>>>>>
>>>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>>>> hooks up well with the GMF editor. Maybe it might solve your
>>>>> problems directly. I've added the EMFT newsgroup to the "to" list
>>>>> of the reply.
>>>>>
>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>> editor input and that all your code to communicate with the data
>>>>> base would be done either at the URI converter level or
>>>>> ResourceImpl side of things. With the URIConverter changes in EMF
>>>>> 2.4, this should be even easier to accomplish, if something like
>>>>> XML data columns are your target.
>>>>>
>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>
>>>>>
>>>>> Barbara Rosi-Schwartz wrote:
>>>>>> Hello all.
>>>>>>
>>>>>> I have generated a graphical editor from my domain model. Since my
>>>>>> application is database, not file system, driven, I knew I would
>>>>>> have to rewire the generated editor to accept my "virtual" object
>>>>>> as retrieved from the database and I was hoping this could be done
>>>>>> in a relatively straightforward manner, through localised changes
>>>>>> in one or two classes.
>>>>>>
>>>>>> However a perusal of the generated code leads me to believe that
>>>>>> the dependency on the editable object being on the file system (or
>>>>>> a URI resource) is deeply ingrained and that it is going to take
>>>>>> quite a lot of surgery to switch to a database driven paradigm.
>>>>>>
>>>>>> Is this accurate or am I missing something?
>>>>>>
>>>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>>>> continue to assume that the whole world is in a file system! :-)
>>>>>>
>>>>>> TIA,
>>>>>> B.
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #125151 is a reply to message #125148] Wed, 04 June 2008 22:56 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Thanks Martin,
I changed the order but it had no effect.

When I open the diagram i get:
java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
at
org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
at
org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
at
org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
at
org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
at
org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
at
org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
at
org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
at
org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
at
org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
at
org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
at
org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
at
org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
at
org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
at org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
at
org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
at
org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
at
org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
at
org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
at
org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
at
org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
at org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
at org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve Method)
at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive Method)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)




> Hi Jonas,
> Hmm, after initialization the diagram is empty. Which elements do you
> see in the properties view?
> And can you post the stacktrace of the executionexception?
>
> Regarding were to look for how the diagram nodes are loaded I don't know
> the answer. I hope someone on the gmft newsgroup will answer this one...
>
> Other small (probably insignificant) differences with the tutorial is
> that I add the model (meDiagram) to the resource before the diagram, in
> addition in your case the diagram name is not set. But I would be
> surprised if this makes any difference....
>
> gr. Martin
>
> Jonas wrote:
>> Hi Martin,
>> thanks for your reply and 5 days isn't late :-)
>> Your Hints were great I am now able to load my custom resource. I
>> additionally had to adapt "private long
>> computeModificationStamp(ResourceSetInfo info)" in
>> ModelDocumentProvider as it assumes a file even if you use URIEditor
>> input.
>>
>> Now the editor loads without any error, but I dont see the diagram
>> nodes. In the property view I can see that the root element is
>> corretly loaded and that it´s elements are in it, but they dont
>> appear. It is also not possible to add anything to the diagram
>> (ExecutionException).
>> I implemented my own resource which is a subclass of
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
>> connected to a file or a database and should just be a wrapper. For
>> testing i initialize my resource like this:
>>
>> private void initialize() {
>> //Create Model root and one test Node
>> MEDiagram meDiagram =
>> DiagramFactory.eINSTANCE.createMEDiagram();
>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>> .createTestForDiagram();
>> meDiagram.getElements().add(testForDiagram);
>> //Create gmf diagram
>> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>> //Put the content in the resource
>> super.getContents().add(diagram);
>> super.getContents().add(meDiagram);
>> //Set root of the gmf diagram
>> diagram.setElement(meDiagram);
>> //Add Transactional domain. Otherwise: Nullpointer Exception
>> ResourceSet resourceSet = this.getResourceSet();
>> TransactionalEditingDomain.Factory.INSTANCE
>> .createEditingDomain(resourceSet);
>> }
>>
>> I spent much time in debugging and it seams that only the root element
>> is loaded. I observed the getElements() method of MEDiagram. It is
>> called several time, but Afaics only for EditingPolicies and Property
>> views. Can sb. give me a Hint which method in the generated editor
>> loads the diagram nodes and would be a good hook for debugging?
>> Thanks for any help...
>>
>> Jonas
>>
>>
>>
>>
>> Martin Taal schrieb:
>>> Hi Jonas,
>>> Sorry for my late reply.
>>>
>>> Here are some additional pointers. I hope it is helpfull.
>>>
>>> I open the editor like this:
>>> page.openEditor(new
>>> URIEditorInput(StoreController.DATABASE_URI),
>>> MindmapDiagramEditor.ID);
>>>
>>> Afaics using the URIEditorInput solves some of the issues related to
>>> the fact the generated editor assumes that the resources are files.
>>> (you can search for the string URIEditorInput in the generated code
>>> and it is used on various locations).
>>>
>>> For storing data and diagrams in different resources. You can take a
>>> look at the OpenMindmapDBEditor and then the initializeData method.
>>> Currently it stores the diagram and the map in one resource. In this
>>> method you can create two resources one for the Map and for the
>>> Diagram. The diagram contains a reference to the root of the model
>>> (diagram.setElement(map)). When opening the diagram resource then the
>>> model resource should open automatically. Note that you should search
>>> the EMFT newsgroup for some related GMF-Teneo topics (about
>>> cross-resource containment references if I remember it correctly...).
>>>
>>> Afaics the diagram always requires at least one model root object. By
>>> storing this root object in a separate resource (during
>>> initialization) model and diagram are stored separately.
>>>
>>> Storing the diagram and the model separately only works if:
>>> - both the diagram and the model are stored in the same database
>>> (both resources point to the same database), or
>>> - the diagram is stored in a xml/xmi resource and the model in the
>>> database.
>>>
>>> XMI/XML resources support cross-resource references but database
>>> resources don't support references to entities outside of the database.
>>>
>>> gr. Martin
>>>
>>> Jonas wrote:
>>>> Hi Martin,
>>>> Thanks for your tutorial, it was a good entry point for me.
>>>> I am currently trying to implement a custom resource which doesnt
>>>> get the model eobjects and the diagram from a file or a database,
>>>> but forwards to a abstract source. The abstract source contains
>>>> several diagrams and all model elements. (see
>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>> BTW and off topic: the source is then syncronized with a server
>>>> which saves it using Teneo :-)
>>>>
>>>> As I want to use gmf to create diagram editors, i try to use a
>>>> custom resource which wraps my source and only returns the model
>>>> elements of one diagram. I tried to open the DiagramEditor with my
>>>> CustomResource, similar as you did with your DatabaseResource. But
>>>> it seems that there are several places where the generated Editor
>>>> requires a file (e.g. private long
>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>>> really wonder how you did your adaptation :-)
>>>> Also you mentioned that it is possible to use different Resources
>>>> for the data and he diagram. Till now I couldnt find the resource
>>>> for the model elements contained on a diagram. Could you give me a
>>>> hint where it is loaded?
>>>> Thanks...
>>>>
>>>> Jonas
>>>>
>>>>
>>>>> Hi Barbara,
>>>>> This tutorial here:
>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>
>>>>> describes how to change the generated gmf editor to retrieve its
>>>>> data from the database. In the tutorial also the diagram itself is
>>>>> stored in the db. It is also possible to store the diagram in a
>>>>> local file and get the data from the database. This is however not
>>>>> described in the tutorial but I am sure that the tutorial leads you
>>>>> in the right direction.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Ed Merks wrote:
>>>>>> Barbara,
>>>>>>
>>>>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>>>>> hooks up well with the GMF editor. Maybe it might solve your
>>>>>> problems directly. I've added the EMFT newsgroup to the "to" list
>>>>>> of the reply.
>>>>>>
>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>> editor input and that all your code to communicate with the data
>>>>>> base would be done either at the URI converter level or
>>>>>> ResourceImpl side of things. With the URIConverter changes in EMF
>>>>>> 2.4, this should be even easier to accomplish, if something like
>>>>>> XML data columns are your target.
>>>>>>
>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>
>>>>>>
>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>> Hello all.
>>>>>>>
>>>>>>> I have generated a graphical editor from my domain model. Since
>>>>>>> my application is database, not file system, driven, I knew I
>>>>>>> would have to rewire the generated editor to accept my "virtual"
>>>>>>> object as retrieved from the database and I was hoping this could
>>>>>>> be done in a relatively straightforward manner, through localised
>>>>>>> changes in one or two classes.
>>>>>>>
>>>>>>> However a perusal of the generated code leads me to believe that
>>>>>>> the dependency on the editable object being on the file system
>>>>>>> (or a URI resource) is deeply ingrained and that it is going to
>>>>>>> take quite a lot of surgery to switch to a database driven paradigm.
>>>>>>>
>>>>>>> Is this accurate or am I missing something?
>>>>>>>
>>>>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>>>>> continue to assume that the whole world is in a file system! :-)
>>>>>>>
>>>>>>> TIA,
>>>>>>> B.
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: Input for generated editor [message #125157 is a reply to message #125151] Thu, 05 June 2008 17:18 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
I am not sure if you should add the resourceset to a new transactional editing domain like you do.
What npe do you get when you remove that from the initialization?

How do you open the editor?

Also after initialization the diagram is empty. Which elements do you see in the properties view?

gr. Martin

Jonas wrote:
> Thanks Martin,
> I changed the order but it had no effect.
>
> When I open the diagram i get:
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>
> at
> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>
> at
> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>
> at
> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>
> at
> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>
> at
> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>
> at
> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>
> at
> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>
> at
> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>
> at
> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>
> at
> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>
> at
> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>
> at
> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>
> at
> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>
> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
> at
> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>
> at
> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>
> at
> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>
> at
> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>
> at
> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>
> at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
> at
> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>
> at
> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
> at
> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
> at
> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
> at
> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
> at
> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>
> at
> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>
> at
> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>
> at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
> at
> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
> at org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
> at
> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
> at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve
> Method)
> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
> at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive
> Method)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>
>
>
>
>> Hi Jonas,
>> Hmm, after initialization the diagram is empty. Which elements do you
>> see in the properties view?
>> And can you post the stacktrace of the executionexception?
>>
>> Regarding were to look for how the diagram nodes are loaded I don't
>> know the answer. I hope someone on the gmft newsgroup will answer this
>> one...
>>
>> Other small (probably insignificant) differences with the tutorial is
>> that I add the model (meDiagram) to the resource before the diagram,
>> in addition in your case the diagram name is not set. But I would be
>> surprised if this makes any difference....
>>
>> gr. Martin
>>
>> Jonas wrote:
>>> Hi Martin,
>>> thanks for your reply and 5 days isn't late :-)
>>> Your Hints were great I am now able to load my custom resource. I
>>> additionally had to adapt "private long
>>> computeModificationStamp(ResourceSetInfo info)" in
>>> ModelDocumentProvider as it assumes a file even if you use URIEditor
>>> input.
>>>
>>> Now the editor loads without any error, but I dont see the diagram
>>> nodes. In the property view I can see that the root element is
>>> corretly loaded and that it´s elements are in it, but they dont
>>> appear. It is also not possible to add anything to the diagram
>>> (ExecutionException).
>>> I implemented my own resource which is a subclass of
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
>>> connected to a file or a database and should just be a wrapper. For
>>> testing i initialize my resource like this:
>>>
>>> private void initialize() {
>>> //Create Model root and one test Node
>>> MEDiagram meDiagram =
>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>> .createTestForDiagram();
>>> meDiagram.getElements().add(testForDiagram);
>>> //Create gmf diagram
>>> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>> //Put the content in the resource
>>> super.getContents().add(diagram);
>>> super.getContents().add(meDiagram);
>>> //Set root of the gmf diagram
>>> diagram.setElement(meDiagram);
>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>> ResourceSet resourceSet = this.getResourceSet();
>>> TransactionalEditingDomain.Factory.INSTANCE
>>> .createEditingDomain(resourceSet);
>>> }
>>>
>>> I spent much time in debugging and it seams that only the root
>>> element is loaded. I observed the getElements() method of MEDiagram.
>>> It is called several time, but Afaics only for EditingPolicies and
>>> Property views. Can sb. give me a Hint which method in the generated
>>> editor loads the diagram nodes and would be a good hook for debugging?
>>> Thanks for any help...
>>>
>>> Jonas
>>>
>>>
>>>
>>>
>>> Martin Taal schrieb:
>>>> Hi Jonas,
>>>> Sorry for my late reply.
>>>>
>>>> Here are some additional pointers. I hope it is helpfull.
>>>>
>>>> I open the editor like this:
>>>> page.openEditor(new
>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>> MindmapDiagramEditor.ID);
>>>>
>>>> Afaics using the URIEditorInput solves some of the issues related to
>>>> the fact the generated editor assumes that the resources are files.
>>>> (you can search for the string URIEditorInput in the generated code
>>>> and it is used on various locations).
>>>>
>>>> For storing data and diagrams in different resources. You can take a
>>>> look at the OpenMindmapDBEditor and then the initializeData method.
>>>> Currently it stores the diagram and the map in one resource. In this
>>>> method you can create two resources one for the Map and for the
>>>> Diagram. The diagram contains a reference to the root of the model
>>>> (diagram.setElement(map)). When opening the diagram resource then
>>>> the model resource should open automatically. Note that you should
>>>> search the EMFT newsgroup for some related GMF-Teneo topics (about
>>>> cross-resource containment references if I remember it correctly...).
>>>>
>>>> Afaics the diagram always requires at least one model root object.
>>>> By storing this root object in a separate resource (during
>>>> initialization) model and diagram are stored separately.
>>>>
>>>> Storing the diagram and the model separately only works if:
>>>> - both the diagram and the model are stored in the same database
>>>> (both resources point to the same database), or
>>>> - the diagram is stored in a xml/xmi resource and the model in the
>>>> database.
>>>>
>>>> XMI/XML resources support cross-resource references but database
>>>> resources don't support references to entities outside of the database.
>>>>
>>>> gr. Martin
>>>>
>>>> Jonas wrote:
>>>>> Hi Martin,
>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>> I am currently trying to implement a custom resource which doesnt
>>>>> get the model eobjects and the diagram from a file or a database,
>>>>> but forwards to a abstract source. The abstract source contains
>>>>> several diagrams and all model elements. (see
>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>> BTW and off topic: the source is then syncronized with a server
>>>>> which saves it using Teneo :-)
>>>>>
>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>> custom resource which wraps my source and only returns the model
>>>>> elements of one diagram. I tried to open the DiagramEditor with my
>>>>> CustomResource, similar as you did with your DatabaseResource. But
>>>>> it seems that there are several places where the generated Editor
>>>>> requires a file (e.g. private long
>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>>>> really wonder how you did your adaptation :-)
>>>>> Also you mentioned that it is possible to use different Resources
>>>>> for the data and he diagram. Till now I couldnt find the resource
>>>>> for the model elements contained on a diagram. Could you give me a
>>>>> hint where it is loaded?
>>>>> Thanks...
>>>>>
>>>>> Jonas
>>>>>
>>>>>
>>>>>> Hi Barbara,
>>>>>> This tutorial here:
>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>
>>>>>> describes how to change the generated gmf editor to retrieve its
>>>>>> data from the database. In the tutorial also the diagram itself is
>>>>>> stored in the db. It is also possible to store the diagram in a
>>>>>> local file and get the data from the database. This is however not
>>>>>> described in the tutorial but I am sure that the tutorial leads
>>>>>> you in the right direction.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Ed Merks wrote:
>>>>>>> Barbara,
>>>>>>>
>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>> "to" list of the reply.
>>>>>>>
>>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>>> editor input and that all your code to communicate with the data
>>>>>>> base would be done either at the URI converter level or
>>>>>>> ResourceImpl side of things. With the URIConverter changes in
>>>>>>> EMF 2.4, this should be even easier to accomplish, if something
>>>>>>> like XML data columns are your target.
>>>>>>>
>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>
>>>>>>>
>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>> Hello all.
>>>>>>>>
>>>>>>>> I have generated a graphical editor from my domain model. Since
>>>>>>>> my application is database, not file system, driven, I knew I
>>>>>>>> would have to rewire the generated editor to accept my "virtual"
>>>>>>>> object as retrieved from the database and I was hoping this
>>>>>>>> could be done in a relatively straightforward manner, through
>>>>>>>> localised changes in one or two classes.
>>>>>>>>
>>>>>>>> However a perusal of the generated code leads me to believe that
>>>>>>>> the dependency on the editable object being on the file system
>>>>>>>> (or a URI resource) is deeply ingrained and that it is going to
>>>>>>>> take quite a lot of surgery to switch to a database driven
>>>>>>>> paradigm.
>>>>>>>>
>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>
>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>> facilities continue to assume that the whole world is in a file
>>>>>>>> system! :-)
>>>>>>>>
>>>>>>>> TIA,
>>>>>>>> B.
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #125162 is a reply to message #125157] Thu, 05 June 2008 18:44 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Martin,

- In the Properties view I see the element I added (Test for Diagram)

- I open the editor like this:
ModelElement modelElement = (ModelElement)object;
URIEditorInput input = new URIEditorInput(URI.createURI("myURI"));
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().openEditor(input,
"org.unicase.model.classDiagram.part.ModelDiagramEditorID", true);
} catch (PartInitException e)

I implemented a Resource Factory which creates my custom Resource for
testing:
public Resource createResource(URI uri) {
return new MyDiagramResource();
}
I registered it and changed the my DocumentProvider to use my Factory :
resource = domain.getResourceSet().createResource(
uri.trimFragment(),"MyDiagramResourceFactoryID");
}
Afaics this seams to work correctly.


- If i dont add a transactional domain the editor does not open and I
get a NullPointer. This is because the TransactionalEditing Domain is null:


java.lang.NullPointerException
at
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createEditPart(EditPartService.java:226)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:611)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
at
org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
at
org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
at
org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
at
org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
at org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
at
org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
at
org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
at
org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
at
org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
at
org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
at
org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3050)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)


Martin Taal schrieb:
> Hi Jonas,
> I am not sure if you should add the resourceset to a new transactional
> editing domain like you do. What npe do you get when you remove that
> from the initialization?
>
> How do you open the editor?
>
> Also after initialization the diagram is empty. Which elements do you
> see in the properties view?
>
> gr. Martin
>
> Jonas wrote:
>> Thanks Martin,
>> I changed the order but it had no effect.
>>
>> When I open the diagram i get:
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write transaction
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>
>> at
>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>
>> at
>> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>>
>> at
>> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>>
>> at
>> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>>
>> at
>> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>>
>> at
>> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>>
>> at
>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>>
>> at
>> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>>
>> at
>> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>>
>> at
>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>>
>> at
>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>
>> at
>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>
>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>> at
>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>
>> at
>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>
>> at
>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>> at
>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>> at
>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>> at
>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>> at
>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>> at
>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>
>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>> at
>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>
>> at
>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>
>> at
>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>> at
>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>> at
>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>> at org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
>> at
>> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
>> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
>> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
>> at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve
>> Method)
>> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
>> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
>> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
>> at
>> org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive Method)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
>> at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>> at
>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>
>> at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>> at
>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>
>> at
>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>
>>
>>
>>
>>> Hi Jonas,
>>> Hmm, after initialization the diagram is empty. Which elements do you
>>> see in the properties view?
>>> And can you post the stacktrace of the executionexception?
>>>
>>> Regarding were to look for how the diagram nodes are loaded I don't
>>> know the answer. I hope someone on the gmft newsgroup will answer
>>> this one...
>>>
>>> Other small (probably insignificant) differences with the tutorial is
>>> that I add the model (meDiagram) to the resource before the diagram,
>>> in addition in your case the diagram name is not set. But I would be
>>> surprised if this makes any difference....
>>>
>>> gr. Martin
>>>
>>> Jonas wrote:
>>>> Hi Martin,
>>>> thanks for your reply and 5 days isn't late :-)
>>>> Your Hints were great I am now able to load my custom resource. I
>>>> additionally had to adapt "private long
>>>> computeModificationStamp(ResourceSetInfo info)" in
>>>> ModelDocumentProvider as it assumes a file even if you use URIEditor
>>>> input.
>>>>
>>>> Now the editor loads without any error, but I dont see the diagram
>>>> nodes. In the property view I can see that the root element is
>>>> corretly loaded and that it´s elements are in it, but they dont
>>>> appear. It is also not possible to add anything to the diagram
>>>> (ExecutionException).
>>>> I implemented my own resource which is a subclass of
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is
>>>> not connected to a file or a database and should just be a wrapper.
>>>> For testing i initialize my resource like this:
>>>>
>>>> private void initialize() {
>>>> //Create Model root and one test Node
>>>> MEDiagram meDiagram =
>>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>>> .createTestForDiagram();
>>>> meDiagram.getElements().add(testForDiagram);
>>>> //Create gmf diagram
>>>> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
>>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>>> //Put the content in the resource
>>>> super.getContents().add(diagram);
>>>> super.getContents().add(meDiagram);
>>>> //Set root of the gmf diagram
>>>> diagram.setElement(meDiagram);
>>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>>> ResourceSet resourceSet = this.getResourceSet();
>>>> TransactionalEditingDomain.Factory.INSTANCE
>>>> .createEditingDomain(resourceSet);
>>>> }
>>>>
>>>> I spent much time in debugging and it seams that only the root
>>>> element is loaded. I observed the getElements() method of MEDiagram.
>>>> It is called several time, but Afaics only for EditingPolicies and
>>>> Property views. Can sb. give me a Hint which method in the generated
>>>> editor loads the diagram nodes and would be a good hook for debugging?
>>>> Thanks for any help...
>>>>
>>>> Jonas
>>>>
>>>>
>>>>
>>>>
>>>> Martin Taal schrieb:
>>>>> Hi Jonas,
>>>>> Sorry for my late reply.
>>>>>
>>>>> Here are some additional pointers. I hope it is helpfull.
>>>>>
>>>>> I open the editor like this:
>>>>> page.openEditor(new
>>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>>> MindmapDiagramEditor.ID);
>>>>>
>>>>> Afaics using the URIEditorInput solves some of the issues related
>>>>> to the fact the generated editor assumes that the resources are
>>>>> files. (you can search for the string URIEditorInput in the
>>>>> generated code and it is used on various locations).
>>>>>
>>>>> For storing data and diagrams in different resources. You can take
>>>>> a look at the OpenMindmapDBEditor and then the initializeData
>>>>> method. Currently it stores the diagram and the map in one
>>>>> resource. In this method you can create two resources one for the
>>>>> Map and for the Diagram. The diagram contains a reference to the
>>>>> root of the model (diagram.setElement(map)). When opening the
>>>>> diagram resource then the model resource should open automatically.
>>>>> Note that you should search the EMFT newsgroup for some related
>>>>> GMF-Teneo topics (about cross-resource containment references if I
>>>>> remember it correctly...).
>>>>>
>>>>> Afaics the diagram always requires at least one model root object.
>>>>> By storing this root object in a separate resource (during
>>>>> initialization) model and diagram are stored separately.
>>>>>
>>>>> Storing the diagram and the model separately only works if:
>>>>> - both the diagram and the model are stored in the same database
>>>>> (both resources point to the same database), or
>>>>> - the diagram is stored in a xml/xmi resource and the model in the
>>>>> database.
>>>>>
>>>>> XMI/XML resources support cross-resource references but database
>>>>> resources don't support references to entities outside of the
>>>>> database.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Jonas wrote:
>>>>>> Hi Martin,
>>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>>> I am currently trying to implement a custom resource which doesnt
>>>>>> get the model eobjects and the diagram from a file or a database,
>>>>>> but forwards to a abstract source. The abstract source contains
>>>>>> several diagrams and all model elements. (see
>>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>>> BTW and off topic: the source is then syncronized with a server
>>>>>> which saves it using Teneo :-)
>>>>>>
>>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>>> custom resource which wraps my source and only returns the model
>>>>>> elements of one diagram. I tried to open the DiagramEditor with
>>>>>> my CustomResource, similar as you did with your DatabaseResource.
>>>>>> But it seems that there are several places where the generated
>>>>>> Editor requires a file (e.g. private long
>>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>>>>> really wonder how you did your adaptation :-)
>>>>>> Also you mentioned that it is possible to use different Resources
>>>>>> for the data and he diagram. Till now I couldnt find the resource
>>>>>> for the model elements contained on a diagram. Could you give me a
>>>>>> hint where it is loaded?
>>>>>> Thanks...
>>>>>>
>>>>>> Jonas
>>>>>>
>>>>>>
>>>>>>> Hi Barbara,
>>>>>>> This tutorial here:
>>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>>
>>>>>>> describes how to change the generated gmf editor to retrieve its
>>>>>>> data from the database. In the tutorial also the diagram itself
>>>>>>> is stored in the db. It is also possible to store the diagram in
>>>>>>> a local file and get the data from the database. This is however
>>>>>>> not described in the tutorial but I am sure that the tutorial
>>>>>>> leads you in the right direction.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Ed Merks wrote:
>>>>>>>> Barbara,
>>>>>>>>
>>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>>> "to" list of the reply.
>>>>>>>>
>>>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>>>> editor input and that all your code to communicate with the data
>>>>>>>> base would be done either at the URI converter level or
>>>>>>>> ResourceImpl side of things. With the URIConverter changes in
>>>>>>>> EMF 2.4, this should be even easier to accomplish, if something
>>>>>>>> like XML data columns are your target.
>>>>>>>>
>>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>>
>>>>>>>>
>>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>>> Hello all.
>>>>>>>>>
>>>>>>>>> I have generated a graphical editor from my domain model. Since
>>>>>>>>> my application is database, not file system, driven, I knew I
>>>>>>>>> would have to rewire the generated editor to accept my
>>>>>>>>> "virtual" object as retrieved from the database and I was
>>>>>>>>> hoping this could be done in a relatively straightforward
>>>>>>>>> manner, through localised changes in one or two classes.
>>>>>>>>>
>>>>>>>>> However a perusal of the generated code leads me to believe
>>>>>>>>> that the dependency on the editable object being on the file
>>>>>>>>> system (or a URI resource) is deeply ingrained and that it is
>>>>>>>>> going to take quite a lot of surgery to switch to a database
>>>>>>>>> driven paradigm.
>>>>>>>>>
>>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>>
>>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>>> facilities continue to assume that the whole world is in a file
>>>>>>>>> system! :-)
>>>>>>>>>
>>>>>>>>> TIA,
>>>>>>>>> B.
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: Input for generated editor [message #125163 is a reply to message #125162] Thu, 05 June 2008 19:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
To be sure did you make the changes outlined here:
http://www.elver.org/hibernate/gmftutorial/tutorial3.html
in the 'Change MindmapDiagramEditor' section?

I don't know much about this but the editor has an editingdomain with a resourceset, I would expect
that the resource would be read in there and would get the editingdomain from the editor...

gr. Martin

Jonas wrote:
> Hi Martin,
>
> - In the Properties view I see the element I added (Test for Diagram)
>
> - I open the editor like this:
> ModelElement modelElement = (ModelElement)object;
> URIEditorInput input = new
> URIEditorInput(URI.createURI("myURI"));
> try {
> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
> .getActivePage().openEditor(input,
>
> "org.unicase.model.classDiagram.part.ModelDiagramEditorID", true);
> } catch (PartInitException e)
>
> I implemented a Resource Factory which creates my custom Resource for
> testing:
> public Resource createResource(URI uri) {
> return new MyDiagramResource();
> }
> I registered it and changed the my DocumentProvider to use my Factory :
> resource = domain.getResourceSet().createResource(
> uri.trimFragment(),"MyDiagramResourceFactoryID");
> }
> Afaics this seams to work correctly.
>
>
> - If i dont add a transactional domain the editor does not open and I
> get a NullPointer. This is because the TransactionalEditing Domain is null:
>
>
> java.lang.NullPointerException
> at
> org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createEditPart(EditPartService.java:226)
>
> at
> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:611)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>
> at
> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>
> at
> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>
> at
> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>
> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
> at
> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>
> at
> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>
> at
> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>
> at
> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>
> at
> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>
> at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
> at
> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>
> at
> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
> at
> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
> at
> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
> at
> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
> at
> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>
> at
> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>
> at
> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>
> at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
> at
> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3050)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>
>
> Martin Taal schrieb:
>> Hi Jonas,
>> I am not sure if you should add the resourceset to a new transactional
>> editing domain like you do. What npe do you get when you remove that
>> from the initialization?
>>
>> How do you open the editor?
>>
>> Also after initialization the diagram is empty. Which elements do you
>> see in the properties view?
>>
>> gr. Martin
>>
>> Jonas wrote:
>>> Thanks Martin,
>>> I changed the order but it had no effect.
>>>
>>> When I open the diagram i get:
>>> java.lang.IllegalStateException: Cannot modify resource set without a
>>> write transaction
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>>
>>> at
>>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>>
>>> at
>>> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>>>
>>> at
>>> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>>>
>>> at
>>> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>>>
>>> at
>>> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>>>
>>> at
>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>>>
>>> at
>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>>
>>> at
>>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>>
>>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>>> at
>>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>>
>>> at
>>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>>
>>> at
>>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>>
>>> at
>>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>>
>>> at
>>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>>
>>> at
>>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>>> at
>>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>>> at
>>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>>>
>>> at
>>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>>> at
>>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>>
>>> at
>>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>>
>>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>>> at
>>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>>
>>> at
>>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>>
>>> at
>>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>>
>>> at
>>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>>
>>> at
>>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>>
>>> at
>>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>>> at
>>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>>> at
>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>>> at
>>> org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
>>> at
>>> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
>>> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
>>> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
>>> at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve
>>> Method)
>>> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
>>> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
>>> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
>>> at
>>> org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive Method)
>>> at
>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
>>> at
>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>>> at
>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>
>>> at
>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>>
>>> at
>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>> at
>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>>
>>> at
>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>>
>>> at java.lang.reflect.Method.invoke(Method.java:585)
>>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>>
>>>
>>>
>>>
>>>> Hi Jonas,
>>>> Hmm, after initialization the diagram is empty. Which elements do
>>>> you see in the properties view?
>>>> And can you post the stacktrace of the executionexception?
>>>>
>>>> Regarding were to look for how the diagram nodes are loaded I don't
>>>> know the answer. I hope someone on the gmft newsgroup will answer
>>>> this one...
>>>>
>>>> Other small (probably insignificant) differences with the tutorial
>>>> is that I add the model (meDiagram) to the resource before the
>>>> diagram, in addition in your case the diagram name is not set. But I
>>>> would be surprised if this makes any difference....
>>>>
>>>> gr. Martin
>>>>
>>>> Jonas wrote:
>>>>> Hi Martin,
>>>>> thanks for your reply and 5 days isn't late :-)
>>>>> Your Hints were great I am now able to load my custom resource. I
>>>>> additionally had to adapt "private long
>>>>> computeModificationStamp(ResourceSetInfo info)" in
>>>>> ModelDocumentProvider as it assumes a file even if you use
>>>>> URIEditor input.
>>>>>
>>>>> Now the editor loads without any error, but I dont see the diagram
>>>>> nodes. In the property view I can see that the root element is
>>>>> corretly loaded and that it´s elements are in it, but they dont
>>>>> appear. It is also not possible to add anything to the diagram
>>>>> (ExecutionException).
>>>>> I implemented my own resource which is a subclass of
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is
>>>>> not connected to a file or a database and should just be a wrapper.
>>>>> For testing i initialize my resource like this:
>>>>>
>>>>> private void initialize() {
>>>>> //Create Model root and one test Node
>>>>> MEDiagram meDiagram =
>>>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>>>> .createTestForDiagram();
>>>>> meDiagram.getElements().add(testForDiagram);
>>>>> //Create gmf diagram
>>>>> Diagram diagram = ViewService.createDiagram(meDiagram,
>>>>> "Model",
>>>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>>>> //Put the content in the resource
>>>>> super.getContents().add(diagram);
>>>>> super.getContents().add(meDiagram);
>>>>> //Set root of the gmf diagram
>>>>> diagram.setElement(meDiagram);
>>>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>>>> ResourceSet resourceSet = this.getResourceSet();
>>>>> TransactionalEditingDomain.Factory.INSTANCE
>>>>> .createEditingDomain(resourceSet);
>>>>> }
>>>>>
>>>>> I spent much time in debugging and it seams that only the root
>>>>> element is loaded. I observed the getElements() method of
>>>>> MEDiagram. It is called several time, but Afaics only for
>>>>> EditingPolicies and Property views. Can sb. give me a Hint which
>>>>> method in the generated editor loads the diagram nodes and would be
>>>>> a good hook for debugging?
>>>>> Thanks for any help...
>>>>>
>>>>> Jonas
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Jonas,
>>>>>> Sorry for my late reply.
>>>>>>
>>>>>> Here are some additional pointers. I hope it is helpfull.
>>>>>>
>>>>>> I open the editor like this:
>>>>>> page.openEditor(new
>>>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>>>> MindmapDiagramEditor.ID);
>>>>>>
>>>>>> Afaics using the URIEditorInput solves some of the issues related
>>>>>> to the fact the generated editor assumes that the resources are
>>>>>> files. (you can search for the string URIEditorInput in the
>>>>>> generated code and it is used on various locations).
>>>>>>
>>>>>> For storing data and diagrams in different resources. You can take
>>>>>> a look at the OpenMindmapDBEditor and then the initializeData
>>>>>> method. Currently it stores the diagram and the map in one
>>>>>> resource. In this method you can create two resources one for the
>>>>>> Map and for the Diagram. The diagram contains a reference to the
>>>>>> root of the model (diagram.setElement(map)). When opening the
>>>>>> diagram resource then the model resource should open
>>>>>> automatically. Note that you should search the EMFT newsgroup for
>>>>>> some related GMF-Teneo topics (about cross-resource containment
>>>>>> references if I remember it correctly...).
>>>>>>
>>>>>> Afaics the diagram always requires at least one model root object.
>>>>>> By storing this root object in a separate resource (during
>>>>>> initialization) model and diagram are stored separately.
>>>>>>
>>>>>> Storing the diagram and the model separately only works if:
>>>>>> - both the diagram and the model are stored in the same database
>>>>>> (both resources point to the same database), or
>>>>>> - the diagram is stored in a xml/xmi resource and the model in the
>>>>>> database.
>>>>>>
>>>>>> XMI/XML resources support cross-resource references but database
>>>>>> resources don't support references to entities outside of the
>>>>>> database.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Jonas wrote:
>>>>>>> Hi Martin,
>>>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>>>> I am currently trying to implement a custom resource which doesnt
>>>>>>> get the model eobjects and the diagram from a file or a database,
>>>>>>> but forwards to a abstract source. The abstract source contains
>>>>>>> several diagrams and all model elements. (see
>>>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>>>> BTW and off topic: the source is then syncronized with a server
>>>>>>> which saves it using Teneo :-)
>>>>>>>
>>>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>>>> custom resource which wraps my source and only returns the model
>>>>>>> elements of one diagram. I tried to open the DiagramEditor with
>>>>>>> my CustomResource, similar as you did with your DatabaseResource.
>>>>>>> But it seems that there are several places where the generated
>>>>>>> Editor requires a file (e.g. private long
>>>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So
>>>>>>> I really wonder how you did your adaptation :-)
>>>>>>> Also you mentioned that it is possible to use different Resources
>>>>>>> for the data and he diagram. Till now I couldnt find the resource
>>>>>>> for the model elements contained on a diagram. Could you give me
>>>>>>> a hint where it is loaded?
>>>>>>> Thanks...
>>>>>>>
>>>>>>> Jonas
>>>>>>>
>>>>>>>
>>>>>>>> Hi Barbara,
>>>>>>>> This tutorial here:
>>>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>>>
>>>>>>>> describes how to change the generated gmf editor to retrieve its
>>>>>>>> data from the database. In the tutorial also the diagram itself
>>>>>>>> is stored in the db. It is also possible to store the diagram in
>>>>>>>> a local file and get the data from the database. This is however
>>>>>>>> not described in the tutorial but I am sure that the tutorial
>>>>>>>> leads you in the right direction.
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> Ed Merks wrote:
>>>>>>>>> Barbara,
>>>>>>>>>
>>>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>>>> "to" list of the reply.
>>>>>>>>>
>>>>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>>>>> editor input and that all your code to communicate with the
>>>>>>>>> data base would be done either at the URI converter level or
>>>>>>>>> ResourceImpl side of things. With the URIConverter changes in
>>>>>>>>> EMF 2.4, this should be even easier to accomplish, if something
>>>>>>>>> like XML data columns are your target.
>>>>>>>>>
>>>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>>>> Hello all.
>>>>>>>>>>
>>>>>>>>>> I have generated a graphical editor from my domain model.
>>>>>>>>>> Since my application is database, not file system, driven, I
>>>>>>>>>> knew I would have to rewire the generated editor to accept my
>>>>>>>>>> "virtual" object as retrieved from the database and I was
>>>>>>>>>> hoping this could be done in a relatively straightforward
>>>>>>>>>> manner, through localised changes in one or two classes.
>>>>>>>>>>
>>>>>>>>>> However a perusal of the generated code leads me to believe
>>>>>>>>>> that the dependency on the editable object being on the file
>>>>>>>>>> system (or a URI resource) is deeply ingrained and that it is
>>>>>>>>>> going to take quite a lot of surgery to switch to a database
>>>>>>>>>> driven paradigm.
>>>>>>>>>>
>>>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>>>
>>>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>>>> facilities continue to assume that the whole world is in a
>>>>>>>>>> file system! :-)
>>>>>>>>>>
>>>>>>>>>> TIA,
>>>>>>>>>> B.
>>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #125748 is a reply to message #125163] Wed, 11 June 2008 14:08 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Thanks Martin,
The second thing was a helpful hint. The problem was indeed that the
editor uses it´s own resource set and editing domain and does not care
if there is already one. I changed this behaviour as described in
http://www.eclipse.org/articles/Article-Integrating-EMF-GMF- Editors/index.html#extending_the_editor_input
BTW, congratulations for Teneo becoming gratuated :-)
Jonas


Martin Taal schrieb:
> Hi Jonas,
> To be sure did you make the changes outlined here:
> http://www.elver.org/hibernate/gmftutorial/tutorial3.html
> in the 'Change MindmapDiagramEditor' section?
>
> I don't know much about this but the editor has an editingdomain with a
> resourceset, I would expect that the resource would be read in there and
> would get the editingdomain from the editor...
>
> gr. Martin
>
> Jonas wrote:
>> Hi Martin,
>>
>> - In the Properties view I see the element I added (Test for Diagram)
>>
>> - I open the editor like this:
>> ModelElement modelElement = (ModelElement)object;
>> URIEditorInput input = new
>> URIEditorInput(URI.createURI("myURI"));
>> try {
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
>> .getActivePage().openEditor(input,
>>
>> "org.unicase.model.classDiagram.part.ModelDiagramEditorID", true);
>> } catch (PartInitException e)
>>
>> I implemented a Resource Factory which creates my custom Resource for
>> testing:
>> public Resource createResource(URI uri) {
>> return new MyDiagramResource();
>> }
>> I registered it and changed the my DocumentProvider to use my Factory
>> : resource = domain.getResourceSet().createResource(
>> uri.trimFragment(),"MyDiagramResourceFactoryID");
>> }
>> Afaics this seams to work correctly.
>>
>>
>> - If i dont add a transactional domain the editor does not open and I
>> get a NullPointer. This is because the TransactionalEditing Domain is
>> null:
>>
>>
>> java.lang.NullPointerException
>> at
>> org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createEditPart(EditPartService.java:226)
>>
>> at
>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:611)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>
>> at
>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>
>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>> at
>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>
>> at
>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>
>> at
>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>> at
>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>> at
>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>> at
>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>> at
>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>> at
>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>
>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>> at
>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>
>> at
>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>
>> at
>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>> at
>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>> at
>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3050)
>> at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>> at
>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>
>> at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>> at
>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>
>> at
>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>
>>
>> Martin Taal schrieb:
>>> Hi Jonas,
>>> I am not sure if you should add the resourceset to a new
>>> transactional editing domain like you do. What npe do you get when
>>> you remove that from the initialization?
>>>
>>> How do you open the editor?
>>>
>>> Also after initialization the diagram is empty. Which elements do you
>>> see in the properties view?
>>>
>>> gr. Martin
>>>
>>> Jonas wrote:
>>>> Thanks Martin,
>>>> I changed the order but it had no effect.
>>>>
>>>> When I open the diagram i get:
>>>> java.lang.IllegalStateException: Cannot modify resource set without
>>>> a write transaction
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>>>
>>>> at
>>>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>>>>
>>>> at
>>>> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>>>>
>>>> at
>>>> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>>>>
>>>> at
>>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>>>>
>>>> at
>>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>>>
>>>> at
>>>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>>>
>>>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>>>> at
>>>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>>>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>>>> at
>>>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>>>> at
>>>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>>>>
>>>> at
>>>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>>>> at
>>>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>>>
>>>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>>>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>>>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>>>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>>>
>>>> at
>>>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>>>
>>>> at
>>>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>>>
>>>> at
>>>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>>>> at
>>>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>>>>
>>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>>>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>>>> at
>>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>>>> at
>>>> org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
>>>> at
>>>> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
>>>> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
>>>> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
>>>> at
>>>> org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve Method)
>>>> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
>>>> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
>>>> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
>>>> at
>>>> org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive
>>>> Method)
>>>> at
>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
>>>> at
>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>>>> at
>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>>>
>>>> at
>>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>>> at
>>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>>>
>>>> at
>>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>>>
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>>>
>>>> at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>>>
>>>> at java.lang.reflect.Method.invoke(Method.java:585)
>>>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>>>
>>>>
>>>>
>>>>
>>>>> Hi Jonas,
>>>>> Hmm, after initialization the diagram is empty. Which elements do
>>>>> you see in the properties view?
>>>>> And can you post the stacktrace of the executionexception?
>>>>>
>>>>> Regarding were to look for how the diagram nodes are loaded I don't
>>>>> know the answer. I hope someone on the gmft newsgroup will answer
>>>>> this one...
>>>>>
>>>>> Other small (probably insignificant) differences with the tutorial
>>>>> is that I add the model (meDiagram) to the resource before the
>>>>> diagram, in addition in your case the diagram name is not set. But
>>>>> I would be surprised if this makes any difference....
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Jonas wrote:
>>>>>> Hi Martin,
>>>>>> thanks for your reply and 5 days isn't late :-)
>>>>>> Your Hints were great I am now able to load my custom resource. I
>>>>>> additionally had to adapt "private long
>>>>>> computeModificationStamp(ResourceSetInfo info)" in
>>>>>> ModelDocumentProvider as it assumes a file even if you use
>>>>>> URIEditor input.
>>>>>>
>>>>>> Now the editor loads without any error, but I dont see the diagram
>>>>>> nodes. In the property view I can see that the root element is
>>>>>> corretly loaded and that it´s elements are in it, but they dont
>>>>>> appear. It is also not possible to add anything to the diagram
>>>>>> (ExecutionException).
>>>>>> I implemented my own resource which is a subclass of
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is
>>>>>> not connected to a file or a database and should just be a
>>>>>> wrapper. For testing i initialize my resource like this:
>>>>>>
>>>>>> private void initialize() {
>>>>>> //Create Model root and one test Node
>>>>>> MEDiagram meDiagram =
>>>>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>>>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>>>>> .createTestForDiagram();
>>>>>> meDiagram.getElements().add(testForDiagram);
>>>>>> //Create gmf diagram
>>>>>> Diagram diagram = ViewService.createDiagram(meDiagram,
>>>>>> "Model",
>>>>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>>>>> //Put the content in the resource
>>>>>> super.getContents().add(diagram);
>>>>>> super.getContents().add(meDiagram);
>>>>>> //Set root of the gmf diagram
>>>>>> diagram.setElement(meDiagram);
>>>>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>>>>> ResourceSet resourceSet = this.getResourceSet();
>>>>>> TransactionalEditingDomain.Factory.INSTANCE
>>>>>> .createEditingDomain(resourceSet);
>>>>>> }
>>>>>>
>>>>>> I spent much time in debugging and it seams that only the root
>>>>>> element is loaded. I observed the getElements() method of
>>>>>> MEDiagram. It is called several time, but Afaics only for
>>>>>> EditingPolicies and Property views. Can sb. give me a Hint which
>>>>>> method in the generated editor loads the diagram nodes and would
>>>>>> be a good hook for debugging?
>>>>>> Thanks for any help...
>>>>>>
>>>>>> Jonas
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Martin Taal schrieb:
>>>>>>> Hi Jonas,
>>>>>>> Sorry for my late reply.
>>>>>>>
>>>>>>> Here are some additional pointers. I hope it is helpfull.
>>>>>>>
>>>>>>> I open the editor like this:
>>>>>>> page.openEditor(new
>>>>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>>>>> MindmapDiagramEditor.ID);
>>>>>>>
>>>>>>> Afaics using the URIEditorInput solves some of the issues related
>>>>>>> to the fact the generated editor assumes that the resources are
>>>>>>> files. (you can search for the string URIEditorInput in the
>>>>>>> generated code and it is used on various locations).
>>>>>>>
>>>>>>> For storing data and diagrams in different resources. You can
>>>>>>> take a look at the OpenMindmapDBEditor and then the
>>>>>>> initializeData method. Currently it stores the diagram and the
>>>>>>> map in one resource. In this method you can create two resources
>>>>>>> one for the Map and for the Diagram. The diagram contains a
>>>>>>> reference to the root of the model (diagram.setElement(map)).
>>>>>>> When opening the diagram resource then the model resource should
>>>>>>> open automatically. Note that you should search the EMFT
>>>>>>> newsgroup for some related GMF-Teneo topics (about cross-resource
>>>>>>> containment references if I remember it correctly...).
>>>>>>>
>>>>>>> Afaics the diagram always requires at least one model root
>>>>>>> object. By storing this root object in a separate resource
>>>>>>> (during initialization) model and diagram are stored separately.
>>>>>>>
>>>>>>> Storing the diagram and the model separately only works if:
>>>>>>> - both the diagram and the model are stored in the same database
>>>>>>> (both resources point to the same database), or
>>>>>>> - the diagram is stored in a xml/xmi resource and the model in
>>>>>>> the database.
>>>>>>>
>>>>>>> XMI/XML resources support cross-resource references but database
>>>>>>> resources don't support references to entities outside of the
>>>>>>> database.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Jonas wrote:
>>>>>>>> Hi Martin,
>>>>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>>>>> I am currently trying to implement a custom resource which
>>>>>>>> doesnt get the model eobjects and the diagram from a file or a
>>>>>>>> database, but forwards to a abstract source. The abstract source
>>>>>>>> contains several diagrams and all model elements. (see
>>>>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>>>>> BTW and off topic: the source is then syncronized with a server
>>>>>>>> which saves it using Teneo :-)
>>>>>>>>
>>>>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>>>>> custom resource which wraps my source and only returns the model
>>>>>>>> elements of one diagram. I tried to open the DiagramEditor with
>>>>>>>> my CustomResource, similar as you did with your
>>>>>>>> DatabaseResource. But it seems that there are several places
>>>>>>>> where the generated Editor requires a file (e.g. private long
>>>>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So
>>>>>>>> I really wonder how you did your adaptation :-)
>>>>>>>> Also you mentioned that it is possible to use different
>>>>>>>> Resources for the data and he diagram. Till now I couldnt find
>>>>>>>> the resource for the model elements contained on a diagram.
>>>>>>>> Could you give me a hint where it is loaded?
>>>>>>>> Thanks...
>>>>>>>>
>>>>>>>> Jonas
>>>>>>>>
>>>>>>>>
>>>>>>>>> Hi Barbara,
>>>>>>>>> This tutorial here:
>>>>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>>>>
>>>>>>>>> describes how to change the generated gmf editor to retrieve
>>>>>>>>> its data from the database. In the tutorial also the diagram
>>>>>>>>> itself is stored in the db. It is also possible to store the
>>>>>>>>> diagram in a local file and get the data from the database.
>>>>>>>>> This is however not described in the tutorial but I am sure
>>>>>>>>> that the tutorial leads you in the right direction.
>>>>>>>>>
>>>>>>>>> gr. Martin
>>>>>>>>>
>>>>>>>>> Ed Merks wrote:
>>>>>>>>>> Barbara,
>>>>>>>>>>
>>>>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>>>>> "to" list of the reply.
>>>>>>>>>>
>>>>>>>>>> I imagine you should be able to use EMF's URIEditorInput as
>>>>>>>>>> the editor input and that all your code to communicate with
>>>>>>>>>> the data base would be done either at the URI converter level
>>>>>>>>>> or ResourceImpl side of things. With the URIConverter changes
>>>>>>>>>> in EMF 2.4, this should be even easier to accomplish, if
>>>>>>>>>> something like XML data columns are your target.
>>>>>>>>>>
>>>>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>>>>> Hello all.
>>>>>>>>>>>
>>>>>>>>>>> I have generated a graphical editor from my domain model.
>>>>>>>>>>> Since my application is database, not file system, driven, I
>>>>>>>>>>> knew I would have to rewire the generated editor to accept my
>>>>>>>>>>> "virtual" object as retrieved from the database and I was
>>>>>>>>>>> hoping this could be done in a relatively straightforward
>>>>>>>>>>> manner, through localised changes in one or two classes.
>>>>>>>>>>>
>>>>>>>>>>> However a perusal of the generated code leads me to believe
>>>>>>>>>>> that the dependency on the editable object being on the file
>>>>>>>>>>> system (or a URI resource) is deeply ingrained and that it is
>>>>>>>>>>> going to take quite a lot of surgery to switch to a database
>>>>>>>>>>> driven paradigm.
>>>>>>>>>>>
>>>>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>>>>
>>>>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>>>>> facilities continue to assume that the whole world is in a
>>>>>>>>>>> file system! :-)
>>>>>>>>>>>
>>>>>>>>>>> TIA,
>>>>>>>>>>> B.
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: Input for generated editor [message #617827 is a reply to message #118896] Thu, 17 April 2008 18:20 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Barbara,
This tutorial here:
http://www.elver.org/hibernate/gmftutorial/tutorial1.html

describes how to change the generated gmf editor to retrieve its data from the database. In the
tutorial also the diagram itself is stored in the db. It is also possible to store the diagram in a
local file and get the data from the database. This is however not described in the tutorial but I
am sure that the tutorial leads you in the right direction.

gr. Martin

Ed Merks wrote:
> Barbara,
>
> Martin Taal has invested a fair bit of time in ensuring that Teneo hooks
> up well with the GMF editor. Maybe it might solve your problems
> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>
> I imagine you should be able to use EMF's URIEditorInput as the editor
> input and that all your code to communicate with the data base would be
> done either at the URI converter level or ResourceImpl side of things.
> With the URIConverter changes in EMF 2.4, this should be even easier to
> accomplish, if something like XML data columns are your target.
>
> Maybe you could explain a bit more what you're trying to do?
>
>
> Barbara Rosi-Schwartz wrote:
>> Hello all.
>>
>> I have generated a graphical editor from my domain model. Since my
>> application is database, not file system, driven, I knew I would have
>> to rewire the generated editor to accept my "virtual" object as
>> retrieved from the database and I was hoping this could be done in a
>> relatively straightforward manner, through localised changes in one or
>> two classes.
>>
>> However a perusal of the generated code leads me to believe that the
>> dependency on the editable object being on the file system (or a URI
>> resource) is deeply ingrained and that it is going to take quite a lot
>> of surgery to switch to a database driven paradigm.
>>
>> Is this accurate or am I missing something?
>>
>> If so, I do wonder why so many of the Eclipse APIs and facilities
>> continue to assume that the whole world is in a file system! :-)
>>
>> TIA,
>> B.
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #617829 is a reply to message #118896] Thu, 17 April 2008 20:24 Go to previous message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
Hi Ed,

Ah, if only I was able to find the link to where your webcam is
available we could avoid all this cross chatter in the newsgroup taking
up needless bandwidth :-)

This is *really* *truly* exiting stuff, the Teneo hooks stuff, that you
have pointed us to. Many thanks. When B. spoke to me about I imagined
the solution as a URI handler, say "db://", that new how to resolve to
the database. Never actually thought that someone has already tackled
the space. Wow, I feel like an 20 odd year old again, and that is
knocking a very big hunk off of it.

I will take a look at this in the morning with great pleasure.

While, I have THE Ed Merks' attention I really just have to say how
much I appreciate the courage of you blog. Few have the will to stand
up for their true core ideals. Kudos to you ;-)

Thanks (seriously) for the pointer,
Joel

On 2008-04-17 18:35:07 +0100, Ed Merks <merks@ca.ibm.com> said:

> Barbara,
>
> Martin Taal has invested a fair bit of time in ensuring that Teneo
> hooks up well with the GMF editor. Maybe it might solve your problems
> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>
> I imagine you should be able to use EMF's URIEditorInput as the editor
> input and that all your code to communicate with the data base would be
> done either at the URI converter level or ResourceImpl side of things.
> With the URIConverter changes in EMF 2.4, this should be even easier to
> accomplish, if something like XML data columns are your target.
>
> Maybe you could explain a bit more what you're trying to do?
>
>
> Barbara Rosi-Schwartz wrote:
>> Hello all.
>>
>> I have generated a graphical editor from my domain model. Since my
>> application is database, not file system, driven, I knew I would have
>> to rewire the generated editor to accept my "virtual" object as
>> retrieved from the database and I was hoping this could be done in a
>> relatively straightforward manner, through localised changes in one or
>> two classes.
>>
>> However a perusal of the generated code leads me to believe that the
>> dependency on the editable object being on the file system (or a URI
>> resource) is deeply ingrained and that it is going to take quite a lot
>> of surgery to switch to a database driven paradigm.
>>
>> Is this accurate or am I missing something?
>>
>> If so, I do wonder why so many of the Eclipse APIs and facilities
>> continue to assume that the whole world is in a file system! :-)
>>
>> TIA,
>> B.


--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Tool
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: Input for generated editor [message #617830 is a reply to message #118909] Thu, 17 April 2008 20:30 Go to previous message
Joel Rosi-Schwartz is currently offline Joel Rosi-SchwartzFriend
Messages: 624
Registered: July 2009
Location: London. England
Senior Member
Hi Martin,

I am butting in on my wife's post and I do not think she is happy with
me at the moment :-) Just warning you in case you are concerned of
getting involved in the middle of a family thing :-)

From what Ed described and you say below I am very intrigued. I will
take a look at all of the tomorrow. My thanks for the info and for
taking the lead in what I feel is a very needed extension to the
Eclipse Resource paradigm. I brought all of this stuff up in the
Eclipse newsgroup four years back but I have never had the bandwidth to
actually tackle it in a generic way. Thanks for tackling the space.

Btw, have you ever thought about how to turn SOA services into URI.
That would be extremely useful as well.

All the best,
Joel

On 2008-04-17 19:20:35 +0100, Martin Taal <mtaal@elver.org> said:

> Hi Barbara,
> This tutorial here:
> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>
> describes how to change the generated gmf editor to retrieve its data
> from the database. In the tutorial also the diagram itself is stored in
> the db. It is also possible to store the diagram in a local file and
> get the data from the database. This is however not described in the
> tutorial but I am sure that the tutorial leads you in the right
> direction.
>
> gr. Martin
>
> Ed Merks wrote:
>> Barbara,
>>
>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>> hooks up well with the GMF editor. Maybe it might solve your problems
>> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>>
>> I imagine you should be able to use EMF's URIEditorInput as the editor
>> input and that all your code to communicate with the data base would be
>> done either at the URI converter level or ResourceImpl side of things.
>> With the URIConverter changes in EMF 2.4, this should be even easier to
>> accomplish, if something like XML data columns are your target.
>>
>> Maybe you could explain a bit more what you're trying to do?
>>
>>
>> Barbara Rosi-Schwartz wrote:
>>> Hello all.
>>>
>>> I have generated a graphical editor from my domain model. Since my
>>> application is database, not file system, driven, I knew I would have
>>> to rewire the generated editor to accept my "virtual" object as
>>> retrieved from the database and I was hoping this could be done in a
>>> relatively straightforward manner, through localised changes in one or
>>> two classes.
>>>
>>> However a perusal of the generated code leads me to believe that the
>>> dependency on the editable object being on the file system (or a URI
>>> resource) is deeply ingrained and that it is going to take quite a lot
>>> of surgery to switch to a database driven paradigm.
>>>
>>> Is this accurate or am I missing something?
>>>
>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>> continue to assume that the whole world is in a file system! :-)
>>>
>>> TIA,
>>> B.


--
Joel Rosi-Schwartz
Etish Limited [http://www.etish.org]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^...^
/ o,o \ The proud parents of Useme
|) ::: (| The Open Requirements Management Tool
====w=w==== [https://useme.dev.java.net]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Re: Input for generated editor [message #617834 is a reply to message #118936] Fri, 18 April 2008 11:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Joel,

Thanks for the kind words. I'm glad my blog is a source of
entertainment as well as food for thought. It's nice to make light
things heavy and also to make heavy things light...

Last year I worked with some folks at IBM research on prototyping
support for serializing using a database that supports native XML. The
idea was to use a URI of the form
database:<JDBC-URL-of-the-connection>!/<table-name>/<column-name >?key='value'.
You can imagine a URI converter that would create an input stream by
invoking a query to read the XML from the named table, accessing the
named column for the row with the given key and similarly do an update
upon closing the output stream. The database would effectively be
access as a big archive (zip) file and with EMF 2.4's support for
URIHandlers, it would be easy to just add a URI handler to an existing
resource set to support this type of thing.

Of course what Teneo is doing is far more sophisticated in that it
decomposes the objects themselves into tables and all that good
relational stuff. The use of native XML columns will perhaps become
more interesting in the future...


Joel Rosi-Schwartz wrote:
> Hi Ed,
>
> Ah, if only I was able to find the link to where your webcam is
> available we could avoid all this cross chatter in the newsgroup
> taking up needless bandwidth :-)
>
> This is *really* *truly* exiting stuff, the Teneo hooks stuff, that
> you have pointed us to. Many thanks. When B. spoke to me about I
> imagined the solution as a URI handler, say "db://", that new how to
> resolve to the database. Never actually thought that someone has
> already tackled the space. Wow, I feel like an 20 odd year old again,
> and that is knocking a very big hunk off of it.
>
> I will take a look at this in the morning with great pleasure.
>
> While, I have THE Ed Merks' attention I really just have to say how
> much I appreciate the courage of you blog. Few have the will to stand
> up for their true core ideals. Kudos to you ;-)
>
> Thanks (seriously) for the pointer,
> Joel
>
> On 2008-04-17 18:35:07 +0100, Ed Merks <merks@ca.ibm.com> said:
>
>> Barbara,
>>
>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>> hooks up well with the GMF editor. Maybe it might solve your
>> problems directly. I've added the EMFT newsgroup to the "to" list of
>> the reply.
>>
>> I imagine you should be able to use EMF's URIEditorInput as the
>> editor input and that all your code to communicate with the data base
>> would be done either at the URI converter level or ResourceImpl side
>> of things. With the URIConverter changes in EMF 2.4, this should be
>> even easier to accomplish, if something like XML data columns are
>> your target.
>>
>> Maybe you could explain a bit more what you're trying to do?
>>
>>
>> Barbara Rosi-Schwartz wrote:
>>> Hello all.
>>>
>>> I have generated a graphical editor from my domain model. Since my
>>> application is database, not file system, driven, I knew I would
>>> have to rewire the generated editor to accept my "virtual" object as
>>> retrieved from the database and I was hoping this could be done in a
>>> relatively straightforward manner, through localised changes in one
>>> or two classes.
>>>
>>> However a perusal of the generated code leads me to believe that the
>>> dependency on the editable object being on the file system (or a URI
>>> resource) is deeply ingrained and that it is going to take quite a
>>> lot of surgery to switch to a database driven paradigm.
>>>
>>> Is this accurate or am I missing something?
>>>
>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>> continue to assume that the whole world is in a file system! :-)
>>>
>>> TIA,
>>> B.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Input for generated editor [message #617844 is a reply to message #118949] Sat, 19 April 2008 06:41 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Joel,
Yes I hope it is usefull for you. Regarding soa/uri, I have not had time to look in detail at the
Eclipse URI/resource loading part. Teneo builds upon the EMF resource and the EMF resource factory
which takes care of opening the correct HibernateResource (which is an EMF resource).

gr. Martin

Joel Rosi-Schwartz wrote:
> Hi Martin,
>
> I am butting in on my wife's post and I do not think she is happy with
> me at the moment :-) Just warning you in case you are concerned of
> getting involved in the middle of a family thing :-)
>
> From what Ed described and you say below I am very intrigued. I will
> take a look at all of the tomorrow. My thanks for the info and for
> taking the lead in what I feel is a very needed extension to the Eclipse
> Resource paradigm. I brought all of this stuff up in the Eclipse
> newsgroup four years back but I have never had the bandwidth to actually
> tackle it in a generic way. Thanks for tackling the space.
>
> Btw, have you ever thought about how to turn SOA services into URI. That
> would be extremely useful as well.
>
> All the best,
> Joel
>
> On 2008-04-17 19:20:35 +0100, Martin Taal <mtaal@elver.org> said:
>
>> Hi Barbara,
>> This tutorial here:
>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>
>> describes how to change the generated gmf editor to retrieve its data
>> from the database. In the tutorial also the diagram itself is stored
>> in the db. It is also possible to store the diagram in a local file
>> and get the data from the database. This is however not described in
>> the tutorial but I am sure that the tutorial leads you in the right
>> direction.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Barbara,
>>>
>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>> hooks up well with the GMF editor. Maybe it might solve your
>>> problems directly. I've added the EMFT newsgroup to the "to" list of
>>> the reply.
>>>
>>> I imagine you should be able to use EMF's URIEditorInput as the
>>> editor input and that all your code to communicate with the data base
>>> would be done either at the URI converter level or ResourceImpl side
>>> of things. With the URIConverter changes in EMF 2.4, this should be
>>> even easier to accomplish, if something like XML data columns are
>>> your target.
>>>
>>> Maybe you could explain a bit more what you're trying to do?
>>>
>>>
>>> Barbara Rosi-Schwartz wrote:
>>>> Hello all.
>>>>
>>>> I have generated a graphical editor from my domain model. Since my
>>>> application is database, not file system, driven, I knew I would
>>>> have to rewire the generated editor to accept my "virtual" object as
>>>> retrieved from the database and I was hoping this could be done in a
>>>> relatively straightforward manner, through localised changes in one
>>>> or two classes.
>>>>
>>>> However a perusal of the generated code leads me to believe that the
>>>> dependency on the editable object being on the file system (or a URI
>>>> resource) is deeply ingrained and that it is going to take quite a
>>>> lot of surgery to switch to a database driven paradigm.
>>>>
>>>> Is this accurate or am I missing something?
>>>>
>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>> continue to assume that the whole world is in a file system! :-)
>>>>
>>>> TIA,
>>>> B.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #618087 is a reply to message #118909] Wed, 21 May 2008 13:58 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Martin,
Thanks for your tutorial, it was a good entry point for me.
I am currently trying to implement a custom resource which doesnt get
the model eobjects and the diagram from a file or a database, but
forwards to a abstract source. The abstract source contains several
diagrams and all model elements. (see
news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
BTW and off topic: the source is then syncronized with a server which
saves it using Teneo :-)

As I want to use gmf to create diagram editors, i try to use a custom
resource which wraps my source and only returns the model elements of
one diagram. I tried to open the DiagramEditor with my CustomResource,
similar as you did with your DatabaseResource. But it seems that there
are several places where the generated Editor requires a file (e.g.
private long computeModificationStamp(ResourceSetInfo info)) or a
XMLResource (e.g. public static String getIdStr(View view) in
ViewUtil). So I really wonder how you did your adaptation :-)
Also you mentioned that it is possible to use different Resources for
the data and he diagram. Till now I couldnt find the resource for the
model elements contained on a diagram. Could you give me a hint where it
is loaded?
Thanks...

Jonas


> Hi Barbara,
> This tutorial here:
> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>
> describes how to change the generated gmf editor to retrieve its data
> from the database. In the tutorial also the diagram itself is stored in
> the db. It is also possible to store the diagram in a local file and get
> the data from the database. This is however not described in the
> tutorial but I am sure that the tutorial leads you in the right direction.
>
> gr. Martin
>
> Ed Merks wrote:
>> Barbara,
>>
>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>> hooks up well with the GMF editor. Maybe it might solve your problems
>> directly. I've added the EMFT newsgroup to the "to" list of the reply.
>>
>> I imagine you should be able to use EMF's URIEditorInput as the editor
>> input and that all your code to communicate with the data base would
>> be done either at the URI converter level or ResourceImpl side of
>> things. With the URIConverter changes in EMF 2.4, this should be even
>> easier to accomplish, if something like XML data columns are your target.
>>
>> Maybe you could explain a bit more what you're trying to do?
>>
>>
>> Barbara Rosi-Schwartz wrote:
>>> Hello all.
>>>
>>> I have generated a graphical editor from my domain model. Since my
>>> application is database, not file system, driven, I knew I would have
>>> to rewire the generated editor to accept my "virtual" object as
>>> retrieved from the database and I was hoping this could be done in a
>>> relatively straightforward manner, through localised changes in one
>>> or two classes.
>>>
>>> However a perusal of the generated code leads me to believe that the
>>> dependency on the editable object being on the file system (or a URI
>>> resource) is deeply ingrained and that it is going to take quite a
>>> lot of surgery to switch to a database driven paradigm.
>>>
>>> Is this accurate or am I missing something?
>>>
>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>> continue to assume that the whole world is in a file system! :-)
>>>
>>> TIA,
>>> B.
>>>
>
>
Re: Input for generated editor [message #618127 is a reply to message #122758] Thu, 22 May 2008 11:21 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
I need some time to answer your post because I have to go deep into the code again. I will come back
to you on this (hopefully today).

Regarding the XMLResource, see the header Hibernate XML resource on this page:
http://www.elver.org/hibernate/gmftutorial/tutorial4.html

Afaik your resource should implement the XMLResource interface.

gr. Martin

Jonas wrote:
> Hi Martin,
> Thanks for your tutorial, it was a good entry point for me.
> I am currently trying to implement a custom resource which doesnt get
> the model eobjects and the diagram from a file or a database, but
> forwards to a abstract source. The abstract source contains several
> diagrams and all model elements. (see
> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
> BTW and off topic: the source is then syncronized with a server which
> saves it using Teneo :-)
>
> As I want to use gmf to create diagram editors, i try to use a custom
> resource which wraps my source and only returns the model elements of
> one diagram. I tried to open the DiagramEditor with my CustomResource,
> similar as you did with your DatabaseResource. But it seems that there
> are several places where the generated Editor requires a file (e.g.
> private long computeModificationStamp(ResourceSetInfo info)) or a
> XMLResource (e.g. public static String getIdStr(View view) in
> ViewUtil). So I really wonder how you did your adaptation :-)
> Also you mentioned that it is possible to use different Resources for
> the data and he diagram. Till now I couldnt find the resource for the
> model elements contained on a diagram. Could you give me a hint where it
> is loaded?
> Thanks...
>
> Jonas
>
>
>> Hi Barbara,
>> This tutorial here:
>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>
>> describes how to change the generated gmf editor to retrieve its data
>> from the database. In the tutorial also the diagram itself is stored
>> in the db. It is also possible to store the diagram in a local file
>> and get the data from the database. This is however not described in
>> the tutorial but I am sure that the tutorial leads you in the right
>> direction.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Barbara,
>>>
>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>> hooks up well with the GMF editor. Maybe it might solve your
>>> problems directly. I've added the EMFT newsgroup to the "to" list of
>>> the reply.
>>>
>>> I imagine you should be able to use EMF's URIEditorInput as the
>>> editor input and that all your code to communicate with the data base
>>> would be done either at the URI converter level or ResourceImpl side
>>> of things. With the URIConverter changes in EMF 2.4, this should be
>>> even easier to accomplish, if something like XML data columns are
>>> your target.
>>>
>>> Maybe you could explain a bit more what you're trying to do?
>>>
>>>
>>> Barbara Rosi-Schwartz wrote:
>>>> Hello all.
>>>>
>>>> I have generated a graphical editor from my domain model. Since my
>>>> application is database, not file system, driven, I knew I would
>>>> have to rewire the generated editor to accept my "virtual" object as
>>>> retrieved from the database and I was hoping this could be done in a
>>>> relatively straightforward manner, through localised changes in one
>>>> or two classes.
>>>>
>>>> However a perusal of the generated code leads me to believe that the
>>>> dependency on the editable object being on the file system (or a URI
>>>> resource) is deeply ingrained and that it is going to take quite a
>>>> lot of surgery to switch to a database driven paradigm.
>>>>
>>>> Is this accurate or am I missing something?
>>>>
>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>> continue to assume that the whole world is in a file system! :-)
>>>>
>>>> TIA,
>>>> B.
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #618971 is a reply to message #122758] Tue, 27 May 2008 08:26 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
Sorry for my late reply.

Here are some additional pointers. I hope it is helpfull.

I open the editor like this:
page.openEditor(new URIEditorInput(StoreController.DATABASE_URI),
MindmapDiagramEditor.ID);

Afaics using the URIEditorInput solves some of the issues related to the fact the generated editor
assumes that the resources are files. (you can search for the string URIEditorInput in the generated
code and it is used on various locations).

For storing data and diagrams in different resources. You can take a look at the OpenMindmapDBEditor
and then the initializeData method. Currently it stores the diagram and the map in one resource. In
this method you can create two resources one for the Map and for the Diagram. The diagram contains a
reference to the root of the model (diagram.setElement(map)). When opening the diagram resource then
the model resource should open automatically. Note that you should search the EMFT newsgroup for
some related GMF-Teneo topics (about cross-resource containment references if I remember it
correctly...).

Afaics the diagram always requires at least one model root object. By storing this root object in a
separate resource (during initialization) model and diagram are stored separately.

Storing the diagram and the model separately only works if:
- both the diagram and the model are stored in the same database (both resources point to the same
database), or
- the diagram is stored in a xml/xmi resource and the model in the database.

XMI/XML resources support cross-resource references but database resources don't support references
to entities outside of the database.

gr. Martin

Jonas wrote:
> Hi Martin,
> Thanks for your tutorial, it was a good entry point for me.
> I am currently trying to implement a custom resource which doesnt get
> the model eobjects and the diagram from a file or a database, but
> forwards to a abstract source. The abstract source contains several
> diagrams and all model elements. (see
> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
> BTW and off topic: the source is then syncronized with a server which
> saves it using Teneo :-)
>
> As I want to use gmf to create diagram editors, i try to use a custom
> resource which wraps my source and only returns the model elements of
> one diagram. I tried to open the DiagramEditor with my CustomResource,
> similar as you did with your DatabaseResource. But it seems that there
> are several places where the generated Editor requires a file (e.g.
> private long computeModificationStamp(ResourceSetInfo info)) or a
> XMLResource (e.g. public static String getIdStr(View view) in
> ViewUtil). So I really wonder how you did your adaptation :-)
> Also you mentioned that it is possible to use different Resources for
> the data and he diagram. Till now I couldnt find the resource for the
> model elements contained on a diagram. Could you give me a hint where it
> is loaded?
> Thanks...
>
> Jonas
>
>
>> Hi Barbara,
>> This tutorial here:
>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>
>> describes how to change the generated gmf editor to retrieve its data
>> from the database. In the tutorial also the diagram itself is stored
>> in the db. It is also possible to store the diagram in a local file
>> and get the data from the database. This is however not described in
>> the tutorial but I am sure that the tutorial leads you in the right
>> direction.
>>
>> gr. Martin
>>
>> Ed Merks wrote:
>>> Barbara,
>>>
>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>> hooks up well with the GMF editor. Maybe it might solve your
>>> problems directly. I've added the EMFT newsgroup to the "to" list of
>>> the reply.
>>>
>>> I imagine you should be able to use EMF's URIEditorInput as the
>>> editor input and that all your code to communicate with the data base
>>> would be done either at the URI converter level or ResourceImpl side
>>> of things. With the URIConverter changes in EMF 2.4, this should be
>>> even easier to accomplish, if something like XML data columns are
>>> your target.
>>>
>>> Maybe you could explain a bit more what you're trying to do?
>>>
>>>
>>> Barbara Rosi-Schwartz wrote:
>>>> Hello all.
>>>>
>>>> I have generated a graphical editor from my domain model. Since my
>>>> application is database, not file system, driven, I knew I would
>>>> have to rewire the generated editor to accept my "virtual" object as
>>>> retrieved from the database and I was hoping this could be done in a
>>>> relatively straightforward manner, through localised changes in one
>>>> or two classes.
>>>>
>>>> However a perusal of the generated code leads me to believe that the
>>>> dependency on the editable object being on the file system (or a URI
>>>> resource) is deeply ingrained and that it is going to take quite a
>>>> lot of surgery to switch to a database driven paradigm.
>>>>
>>>> Is this accurate or am I missing something?
>>>>
>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>> continue to assume that the whole world is in a file system! :-)
>>>>
>>>> TIA,
>>>> B.
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #619170 is a reply to message #122969] Wed, 04 June 2008 17:52 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Martin,
thanks for your reply and 5 days isn't late :-)
Your Hints were great I am now able to load my custom resource. I
additionally had to adapt "private long
computeModificationStamp(ResourceSetInfo info)" in ModelDocumentProvider
as it assumes a file even if you use URIEditor input.

Now the editor loads without any error, but I dont see the diagram
nodes. In the property view I can see that the root element is corretly
loaded and that it´s elements are in it, but they dont appear. It is
also not possible to add anything to the diagram (ExecutionException).
I implemented my own resource which is a subclass of
org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
connected to a file or a database and should just be a wrapper. For
testing i initialize my resource like this:

private void initialize() {
//Create Model root and one test Node
MEDiagram meDiagram = DiagramFactory.eINSTANCE.createMEDiagram();
TestForDiagram testForDiagram = ModelFactory.eINSTANCE
.createTestForDiagram();
meDiagram.getElements().add(testForDiagram);
//Create gmf diagram
Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
//Put the content in the resource
super.getContents().add(diagram);
super.getContents().add(meDiagram);
//Set root of the gmf diagram
diagram.setElement(meDiagram);
//Add Transactional domain. Otherwise: Nullpointer Exception
ResourceSet resourceSet = this.getResourceSet();
TransactionalEditingDomain.Factory.INSTANCE
.createEditingDomain(resourceSet);
}

I spent much time in debugging and it seams that only the root element
is loaded. I observed the getElements() method of MEDiagram. It is
called several time, but Afaics only for EditingPolicies and Property
views. Can sb. give me a Hint which method in the generated editor loads
the diagram nodes and would be a good hook for debugging?
Thanks for any help...

Jonas




Martin Taal schrieb:
> Hi Jonas,
> Sorry for my late reply.
>
> Here are some additional pointers. I hope it is helpfull.
>
> I open the editor like this:
> page.openEditor(new
> URIEditorInput(StoreController.DATABASE_URI),
> MindmapDiagramEditor.ID);
>
> Afaics using the URIEditorInput solves some of the issues related to the
> fact the generated editor assumes that the resources are files. (you can
> search for the string URIEditorInput in the generated code and it is
> used on various locations).
>
> For storing data and diagrams in different resources. You can take a
> look at the OpenMindmapDBEditor and then the initializeData method.
> Currently it stores the diagram and the map in one resource. In this
> method you can create two resources one for the Map and for the Diagram.
> The diagram contains a reference to the root of the model
> (diagram.setElement(map)). When opening the diagram resource then the
> model resource should open automatically. Note that you should search
> the EMFT newsgroup for some related GMF-Teneo topics (about
> cross-resource containment references if I remember it correctly...).
>
> Afaics the diagram always requires at least one model root object. By
> storing this root object in a separate resource (during initialization)
> model and diagram are stored separately.
>
> Storing the diagram and the model separately only works if:
> - both the diagram and the model are stored in the same database (both
> resources point to the same database), or
> - the diagram is stored in a xml/xmi resource and the model in the
> database.
>
> XMI/XML resources support cross-resource references but database
> resources don't support references to entities outside of the database.
>
> gr. Martin
>
> Jonas wrote:
>> Hi Martin,
>> Thanks for your tutorial, it was a good entry point for me.
>> I am currently trying to implement a custom resource which doesnt get
>> the model eobjects and the diagram from a file or a database, but
>> forwards to a abstract source. The abstract source contains several
>> diagrams and all model elements. (see
>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>> BTW and off topic: the source is then syncronized with a server which
>> saves it using Teneo :-)
>>
>> As I want to use gmf to create diagram editors, i try to use a custom
>> resource which wraps my source and only returns the model elements of
>> one diagram. I tried to open the DiagramEditor with my
>> CustomResource, similar as you did with your DatabaseResource. But it
>> seems that there are several places where the generated Editor
>> requires a file (e.g. private long
>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource (e.g.
>> public static String getIdStr(View view) in ViewUtil). So I really
>> wonder how you did your adaptation :-)
>> Also you mentioned that it is possible to use different Resources for
>> the data and he diagram. Till now I couldnt find the resource for the
>> model elements contained on a diagram. Could you give me a hint where
>> it is loaded?
>> Thanks...
>>
>> Jonas
>>
>>
>>> Hi Barbara,
>>> This tutorial here:
>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>
>>> describes how to change the generated gmf editor to retrieve its data
>>> from the database. In the tutorial also the diagram itself is stored
>>> in the db. It is also possible to store the diagram in a local file
>>> and get the data from the database. This is however not described in
>>> the tutorial but I am sure that the tutorial leads you in the right
>>> direction.
>>>
>>> gr. Martin
>>>
>>> Ed Merks wrote:
>>>> Barbara,
>>>>
>>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>>> hooks up well with the GMF editor. Maybe it might solve your
>>>> problems directly. I've added the EMFT newsgroup to the "to" list
>>>> of the reply.
>>>>
>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>> editor input and that all your code to communicate with the data
>>>> base would be done either at the URI converter level or ResourceImpl
>>>> side of things. With the URIConverter changes in EMF 2.4, this
>>>> should be even easier to accomplish, if something like XML data
>>>> columns are your target.
>>>>
>>>> Maybe you could explain a bit more what you're trying to do?
>>>>
>>>>
>>>> Barbara Rosi-Schwartz wrote:
>>>>> Hello all.
>>>>>
>>>>> I have generated a graphical editor from my domain model. Since my
>>>>> application is database, not file system, driven, I knew I would
>>>>> have to rewire the generated editor to accept my "virtual" object
>>>>> as retrieved from the database and I was hoping this could be done
>>>>> in a relatively straightforward manner, through localised changes
>>>>> in one or two classes.
>>>>>
>>>>> However a perusal of the generated code leads me to believe that
>>>>> the dependency on the editable object being on the file system (or
>>>>> a URI resource) is deeply ingrained and that it is going to take
>>>>> quite a lot of surgery to switch to a database driven paradigm.
>>>>>
>>>>> Is this accurate or am I missing something?
>>>>>
>>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>>> continue to assume that the whole world is in a file system! :-)
>>>>>
>>>>> TIA,
>>>>> B.
>>>>>
>>>
>>>
>
>
Re: Input for generated editor [message #619175 is a reply to message #125139] Wed, 04 June 2008 20:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
Hmm, after initialization the diagram is empty. Which elements do you see in the properties view?
And can you post the stacktrace of the executionexception?

Regarding were to look for how the diagram nodes are loaded I don't know the answer. I hope someone
on the gmft newsgroup will answer this one...

Other small (probably insignificant) differences with the tutorial is that I add the model
(meDiagram) to the resource before the diagram, in addition in your case the diagram name is not
set. But I would be surprised if this makes any difference....

gr. Martin

Jonas wrote:
> Hi Martin,
> thanks for your reply and 5 days isn't late :-)
> Your Hints were great I am now able to load my custom resource. I
> additionally had to adapt "private long
> computeModificationStamp(ResourceSetInfo info)" in ModelDocumentProvider
> as it assumes a file even if you use URIEditor input.
>
> Now the editor loads without any error, but I dont see the diagram
> nodes. In the property view I can see that the root element is corretly
> loaded and that it´s elements are in it, but they dont appear. It is
> also not possible to add anything to the diagram (ExecutionException).
> I implemented my own resource which is a subclass of
> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
> connected to a file or a database and should just be a wrapper. For
> testing i initialize my resource like this:
>
> private void initialize() {
> //Create Model root and one test Node
> MEDiagram meDiagram =
> DiagramFactory.eINSTANCE.createMEDiagram();
> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
> .createTestForDiagram();
> meDiagram.getElements().add(testForDiagram);
> //Create gmf diagram
> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
> //Put the content in the resource
> super.getContents().add(diagram);
> super.getContents().add(meDiagram);
> //Set root of the gmf diagram
> diagram.setElement(meDiagram);
> //Add Transactional domain. Otherwise: Nullpointer Exception
> ResourceSet resourceSet = this.getResourceSet();
> TransactionalEditingDomain.Factory.INSTANCE
> .createEditingDomain(resourceSet);
> }
>
> I spent much time in debugging and it seams that only the root element
> is loaded. I observed the getElements() method of MEDiagram. It is
> called several time, but Afaics only for EditingPolicies and Property
> views. Can sb. give me a Hint which method in the generated editor loads
> the diagram nodes and would be a good hook for debugging?
> Thanks for any help...
>
> Jonas
>
>
>
>
> Martin Taal schrieb:
>> Hi Jonas,
>> Sorry for my late reply.
>>
>> Here are some additional pointers. I hope it is helpfull.
>>
>> I open the editor like this:
>> page.openEditor(new
>> URIEditorInput(StoreController.DATABASE_URI),
>> MindmapDiagramEditor.ID);
>>
>> Afaics using the URIEditorInput solves some of the issues related to
>> the fact the generated editor assumes that the resources are files.
>> (you can search for the string URIEditorInput in the generated code
>> and it is used on various locations).
>>
>> For storing data and diagrams in different resources. You can take a
>> look at the OpenMindmapDBEditor and then the initializeData method.
>> Currently it stores the diagram and the map in one resource. In this
>> method you can create two resources one for the Map and for the
>> Diagram. The diagram contains a reference to the root of the model
>> (diagram.setElement(map)). When opening the diagram resource then the
>> model resource should open automatically. Note that you should search
>> the EMFT newsgroup for some related GMF-Teneo topics (about
>> cross-resource containment references if I remember it correctly...).
>>
>> Afaics the diagram always requires at least one model root object. By
>> storing this root object in a separate resource (during
>> initialization) model and diagram are stored separately.
>>
>> Storing the diagram and the model separately only works if:
>> - both the diagram and the model are stored in the same database (both
>> resources point to the same database), or
>> - the diagram is stored in a xml/xmi resource and the model in the
>> database.
>>
>> XMI/XML resources support cross-resource references but database
>> resources don't support references to entities outside of the database.
>>
>> gr. Martin
>>
>> Jonas wrote:
>>> Hi Martin,
>>> Thanks for your tutorial, it was a good entry point for me.
>>> I am currently trying to implement a custom resource which doesnt get
>>> the model eobjects and the diagram from a file or a database, but
>>> forwards to a abstract source. The abstract source contains several
>>> diagrams and all model elements. (see
>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>> BTW and off topic: the source is then syncronized with a server which
>>> saves it using Teneo :-)
>>>
>>> As I want to use gmf to create diagram editors, i try to use a custom
>>> resource which wraps my source and only returns the model elements of
>>> one diagram. I tried to open the DiagramEditor with my
>>> CustomResource, similar as you did with your DatabaseResource. But it
>>> seems that there are several places where the generated Editor
>>> requires a file (e.g. private long
>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>> really wonder how you did your adaptation :-)
>>> Also you mentioned that it is possible to use different Resources for
>>> the data and he diagram. Till now I couldnt find the resource for the
>>> model elements contained on a diagram. Could you give me a hint where
>>> it is loaded?
>>> Thanks...
>>>
>>> Jonas
>>>
>>>
>>>> Hi Barbara,
>>>> This tutorial here:
>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>
>>>> describes how to change the generated gmf editor to retrieve its
>>>> data from the database. In the tutorial also the diagram itself is
>>>> stored in the db. It is also possible to store the diagram in a
>>>> local file and get the data from the database. This is however not
>>>> described in the tutorial but I am sure that the tutorial leads you
>>>> in the right direction.
>>>>
>>>> gr. Martin
>>>>
>>>> Ed Merks wrote:
>>>>> Barbara,
>>>>>
>>>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>>>> hooks up well with the GMF editor. Maybe it might solve your
>>>>> problems directly. I've added the EMFT newsgroup to the "to" list
>>>>> of the reply.
>>>>>
>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>> editor input and that all your code to communicate with the data
>>>>> base would be done either at the URI converter level or
>>>>> ResourceImpl side of things. With the URIConverter changes in EMF
>>>>> 2.4, this should be even easier to accomplish, if something like
>>>>> XML data columns are your target.
>>>>>
>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>
>>>>>
>>>>> Barbara Rosi-Schwartz wrote:
>>>>>> Hello all.
>>>>>>
>>>>>> I have generated a graphical editor from my domain model. Since my
>>>>>> application is database, not file system, driven, I knew I would
>>>>>> have to rewire the generated editor to accept my "virtual" object
>>>>>> as retrieved from the database and I was hoping this could be done
>>>>>> in a relatively straightforward manner, through localised changes
>>>>>> in one or two classes.
>>>>>>
>>>>>> However a perusal of the generated code leads me to believe that
>>>>>> the dependency on the editable object being on the file system (or
>>>>>> a URI resource) is deeply ingrained and that it is going to take
>>>>>> quite a lot of surgery to switch to a database driven paradigm.
>>>>>>
>>>>>> Is this accurate or am I missing something?
>>>>>>
>>>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>>>> continue to assume that the whole world is in a file system! :-)
>>>>>>
>>>>>> TIA,
>>>>>> B.
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #619176 is a reply to message #125148] Wed, 04 June 2008 22:56 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Thanks Martin,
I changed the order but it had no effect.

When I open the diagram i get:
java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
at
org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
at
org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
at
org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
at
org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
at
org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
at
org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
at
org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
at
org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
at
org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
at
org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
at
org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
at
org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
at
org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
at org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
at
org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
at
org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
at
org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
at
org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
at
org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
at
org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
at org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
at org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve Method)
at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive Method)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)




> Hi Jonas,
> Hmm, after initialization the diagram is empty. Which elements do you
> see in the properties view?
> And can you post the stacktrace of the executionexception?
>
> Regarding were to look for how the diagram nodes are loaded I don't know
> the answer. I hope someone on the gmft newsgroup will answer this one...
>
> Other small (probably insignificant) differences with the tutorial is
> that I add the model (meDiagram) to the resource before the diagram, in
> addition in your case the diagram name is not set. But I would be
> surprised if this makes any difference....
>
> gr. Martin
>
> Jonas wrote:
>> Hi Martin,
>> thanks for your reply and 5 days isn't late :-)
>> Your Hints were great I am now able to load my custom resource. I
>> additionally had to adapt "private long
>> computeModificationStamp(ResourceSetInfo info)" in
>> ModelDocumentProvider as it assumes a file even if you use URIEditor
>> input.
>>
>> Now the editor loads without any error, but I dont see the diagram
>> nodes. In the property view I can see that the root element is
>> corretly loaded and that it´s elements are in it, but they dont
>> appear. It is also not possible to add anything to the diagram
>> (ExecutionException).
>> I implemented my own resource which is a subclass of
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
>> connected to a file or a database and should just be a wrapper. For
>> testing i initialize my resource like this:
>>
>> private void initialize() {
>> //Create Model root and one test Node
>> MEDiagram meDiagram =
>> DiagramFactory.eINSTANCE.createMEDiagram();
>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>> .createTestForDiagram();
>> meDiagram.getElements().add(testForDiagram);
>> //Create gmf diagram
>> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>> //Put the content in the resource
>> super.getContents().add(diagram);
>> super.getContents().add(meDiagram);
>> //Set root of the gmf diagram
>> diagram.setElement(meDiagram);
>> //Add Transactional domain. Otherwise: Nullpointer Exception
>> ResourceSet resourceSet = this.getResourceSet();
>> TransactionalEditingDomain.Factory.INSTANCE
>> .createEditingDomain(resourceSet);
>> }
>>
>> I spent much time in debugging and it seams that only the root element
>> is loaded. I observed the getElements() method of MEDiagram. It is
>> called several time, but Afaics only for EditingPolicies and Property
>> views. Can sb. give me a Hint which method in the generated editor
>> loads the diagram nodes and would be a good hook for debugging?
>> Thanks for any help...
>>
>> Jonas
>>
>>
>>
>>
>> Martin Taal schrieb:
>>> Hi Jonas,
>>> Sorry for my late reply.
>>>
>>> Here are some additional pointers. I hope it is helpfull.
>>>
>>> I open the editor like this:
>>> page.openEditor(new
>>> URIEditorInput(StoreController.DATABASE_URI),
>>> MindmapDiagramEditor.ID);
>>>
>>> Afaics using the URIEditorInput solves some of the issues related to
>>> the fact the generated editor assumes that the resources are files.
>>> (you can search for the string URIEditorInput in the generated code
>>> and it is used on various locations).
>>>
>>> For storing data and diagrams in different resources. You can take a
>>> look at the OpenMindmapDBEditor and then the initializeData method.
>>> Currently it stores the diagram and the map in one resource. In this
>>> method you can create two resources one for the Map and for the
>>> Diagram. The diagram contains a reference to the root of the model
>>> (diagram.setElement(map)). When opening the diagram resource then the
>>> model resource should open automatically. Note that you should search
>>> the EMFT newsgroup for some related GMF-Teneo topics (about
>>> cross-resource containment references if I remember it correctly...).
>>>
>>> Afaics the diagram always requires at least one model root object. By
>>> storing this root object in a separate resource (during
>>> initialization) model and diagram are stored separately.
>>>
>>> Storing the diagram and the model separately only works if:
>>> - both the diagram and the model are stored in the same database
>>> (both resources point to the same database), or
>>> - the diagram is stored in a xml/xmi resource and the model in the
>>> database.
>>>
>>> XMI/XML resources support cross-resource references but database
>>> resources don't support references to entities outside of the database.
>>>
>>> gr. Martin
>>>
>>> Jonas wrote:
>>>> Hi Martin,
>>>> Thanks for your tutorial, it was a good entry point for me.
>>>> I am currently trying to implement a custom resource which doesnt
>>>> get the model eobjects and the diagram from a file or a database,
>>>> but forwards to a abstract source. The abstract source contains
>>>> several diagrams and all model elements. (see
>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>> BTW and off topic: the source is then syncronized with a server
>>>> which saves it using Teneo :-)
>>>>
>>>> As I want to use gmf to create diagram editors, i try to use a
>>>> custom resource which wraps my source and only returns the model
>>>> elements of one diagram. I tried to open the DiagramEditor with my
>>>> CustomResource, similar as you did with your DatabaseResource. But
>>>> it seems that there are several places where the generated Editor
>>>> requires a file (e.g. private long
>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>>> really wonder how you did your adaptation :-)
>>>> Also you mentioned that it is possible to use different Resources
>>>> for the data and he diagram. Till now I couldnt find the resource
>>>> for the model elements contained on a diagram. Could you give me a
>>>> hint where it is loaded?
>>>> Thanks...
>>>>
>>>> Jonas
>>>>
>>>>
>>>>> Hi Barbara,
>>>>> This tutorial here:
>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>
>>>>> describes how to change the generated gmf editor to retrieve its
>>>>> data from the database. In the tutorial also the diagram itself is
>>>>> stored in the db. It is also possible to store the diagram in a
>>>>> local file and get the data from the database. This is however not
>>>>> described in the tutorial but I am sure that the tutorial leads you
>>>>> in the right direction.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Ed Merks wrote:
>>>>>> Barbara,
>>>>>>
>>>>>> Martin Taal has invested a fair bit of time in ensuring that Teneo
>>>>>> hooks up well with the GMF editor. Maybe it might solve your
>>>>>> problems directly. I've added the EMFT newsgroup to the "to" list
>>>>>> of the reply.
>>>>>>
>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>> editor input and that all your code to communicate with the data
>>>>>> base would be done either at the URI converter level or
>>>>>> ResourceImpl side of things. With the URIConverter changes in EMF
>>>>>> 2.4, this should be even easier to accomplish, if something like
>>>>>> XML data columns are your target.
>>>>>>
>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>
>>>>>>
>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>> Hello all.
>>>>>>>
>>>>>>> I have generated a graphical editor from my domain model. Since
>>>>>>> my application is database, not file system, driven, I knew I
>>>>>>> would have to rewire the generated editor to accept my "virtual"
>>>>>>> object as retrieved from the database and I was hoping this could
>>>>>>> be done in a relatively straightforward manner, through localised
>>>>>>> changes in one or two classes.
>>>>>>>
>>>>>>> However a perusal of the generated code leads me to believe that
>>>>>>> the dependency on the editable object being on the file system
>>>>>>> (or a URI resource) is deeply ingrained and that it is going to
>>>>>>> take quite a lot of surgery to switch to a database driven paradigm.
>>>>>>>
>>>>>>> Is this accurate or am I missing something?
>>>>>>>
>>>>>>> If so, I do wonder why so many of the Eclipse APIs and facilities
>>>>>>> continue to assume that the whole world is in a file system! :-)
>>>>>>>
>>>>>>> TIA,
>>>>>>> B.
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: Input for generated editor [message #619178 is a reply to message #125151] Thu, 05 June 2008 17:18 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
I am not sure if you should add the resourceset to a new transactional editing domain like you do.
What npe do you get when you remove that from the initialization?

How do you open the editor?

Also after initialization the diagram is empty. Which elements do you see in the properties view?

gr. Martin

Jonas wrote:
> Thanks Martin,
> I changed the order but it had no effect.
>
> When I open the diagram i get:
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>
> at
> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>
> at
> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>
> at
> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>
> at
> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>
> at
> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>
> at
> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>
> at
> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>
> at
> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>
> at
> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>
> at
> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>
> at
> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>
> at
> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>
> at
> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>
> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
> at
> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>
> at
> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>
> at
> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>
> at
> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>
> at
> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>
> at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
> at
> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>
> at
> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
> at
> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
> at
> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
> at
> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
> at
> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>
> at
> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>
> at
> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>
> at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
> at
> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
> at org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
> at
> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
> at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve
> Method)
> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
> at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive
> Method)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>
>
>
>
>> Hi Jonas,
>> Hmm, after initialization the diagram is empty. Which elements do you
>> see in the properties view?
>> And can you post the stacktrace of the executionexception?
>>
>> Regarding were to look for how the diagram nodes are loaded I don't
>> know the answer. I hope someone on the gmft newsgroup will answer this
>> one...
>>
>> Other small (probably insignificant) differences with the tutorial is
>> that I add the model (meDiagram) to the resource before the diagram,
>> in addition in your case the diagram name is not set. But I would be
>> surprised if this makes any difference....
>>
>> gr. Martin
>>
>> Jonas wrote:
>>> Hi Martin,
>>> thanks for your reply and 5 days isn't late :-)
>>> Your Hints were great I am now able to load my custom resource. I
>>> additionally had to adapt "private long
>>> computeModificationStamp(ResourceSetInfo info)" in
>>> ModelDocumentProvider as it assumes a file even if you use URIEditor
>>> input.
>>>
>>> Now the editor loads without any error, but I dont see the diagram
>>> nodes. In the property view I can see that the root element is
>>> corretly loaded and that it´s elements are in it, but they dont
>>> appear. It is also not possible to add anything to the diagram
>>> (ExecutionException).
>>> I implemented my own resource which is a subclass of
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is not
>>> connected to a file or a database and should just be a wrapper. For
>>> testing i initialize my resource like this:
>>>
>>> private void initialize() {
>>> //Create Model root and one test Node
>>> MEDiagram meDiagram =
>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>> .createTestForDiagram();
>>> meDiagram.getElements().add(testForDiagram);
>>> //Create gmf diagram
>>> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>> //Put the content in the resource
>>> super.getContents().add(diagram);
>>> super.getContents().add(meDiagram);
>>> //Set root of the gmf diagram
>>> diagram.setElement(meDiagram);
>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>> ResourceSet resourceSet = this.getResourceSet();
>>> TransactionalEditingDomain.Factory.INSTANCE
>>> .createEditingDomain(resourceSet);
>>> }
>>>
>>> I spent much time in debugging and it seams that only the root
>>> element is loaded. I observed the getElements() method of MEDiagram.
>>> It is called several time, but Afaics only for EditingPolicies and
>>> Property views. Can sb. give me a Hint which method in the generated
>>> editor loads the diagram nodes and would be a good hook for debugging?
>>> Thanks for any help...
>>>
>>> Jonas
>>>
>>>
>>>
>>>
>>> Martin Taal schrieb:
>>>> Hi Jonas,
>>>> Sorry for my late reply.
>>>>
>>>> Here are some additional pointers. I hope it is helpfull.
>>>>
>>>> I open the editor like this:
>>>> page.openEditor(new
>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>> MindmapDiagramEditor.ID);
>>>>
>>>> Afaics using the URIEditorInput solves some of the issues related to
>>>> the fact the generated editor assumes that the resources are files.
>>>> (you can search for the string URIEditorInput in the generated code
>>>> and it is used on various locations).
>>>>
>>>> For storing data and diagrams in different resources. You can take a
>>>> look at the OpenMindmapDBEditor and then the initializeData method.
>>>> Currently it stores the diagram and the map in one resource. In this
>>>> method you can create two resources one for the Map and for the
>>>> Diagram. The diagram contains a reference to the root of the model
>>>> (diagram.setElement(map)). When opening the diagram resource then
>>>> the model resource should open automatically. Note that you should
>>>> search the EMFT newsgroup for some related GMF-Teneo topics (about
>>>> cross-resource containment references if I remember it correctly...).
>>>>
>>>> Afaics the diagram always requires at least one model root object.
>>>> By storing this root object in a separate resource (during
>>>> initialization) model and diagram are stored separately.
>>>>
>>>> Storing the diagram and the model separately only works if:
>>>> - both the diagram and the model are stored in the same database
>>>> (both resources point to the same database), or
>>>> - the diagram is stored in a xml/xmi resource and the model in the
>>>> database.
>>>>
>>>> XMI/XML resources support cross-resource references but database
>>>> resources don't support references to entities outside of the database.
>>>>
>>>> gr. Martin
>>>>
>>>> Jonas wrote:
>>>>> Hi Martin,
>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>> I am currently trying to implement a custom resource which doesnt
>>>>> get the model eobjects and the diagram from a file or a database,
>>>>> but forwards to a abstract source. The abstract source contains
>>>>> several diagrams and all model elements. (see
>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>> BTW and off topic: the source is then syncronized with a server
>>>>> which saves it using Teneo :-)
>>>>>
>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>> custom resource which wraps my source and only returns the model
>>>>> elements of one diagram. I tried to open the DiagramEditor with my
>>>>> CustomResource, similar as you did with your DatabaseResource. But
>>>>> it seems that there are several places where the generated Editor
>>>>> requires a file (e.g. private long
>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>>>> really wonder how you did your adaptation :-)
>>>>> Also you mentioned that it is possible to use different Resources
>>>>> for the data and he diagram. Till now I couldnt find the resource
>>>>> for the model elements contained on a diagram. Could you give me a
>>>>> hint where it is loaded?
>>>>> Thanks...
>>>>>
>>>>> Jonas
>>>>>
>>>>>
>>>>>> Hi Barbara,
>>>>>> This tutorial here:
>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>
>>>>>> describes how to change the generated gmf editor to retrieve its
>>>>>> data from the database. In the tutorial also the diagram itself is
>>>>>> stored in the db. It is also possible to store the diagram in a
>>>>>> local file and get the data from the database. This is however not
>>>>>> described in the tutorial but I am sure that the tutorial leads
>>>>>> you in the right direction.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Ed Merks wrote:
>>>>>>> Barbara,
>>>>>>>
>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>> "to" list of the reply.
>>>>>>>
>>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>>> editor input and that all your code to communicate with the data
>>>>>>> base would be done either at the URI converter level or
>>>>>>> ResourceImpl side of things. With the URIConverter changes in
>>>>>>> EMF 2.4, this should be even easier to accomplish, if something
>>>>>>> like XML data columns are your target.
>>>>>>>
>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>
>>>>>>>
>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>> Hello all.
>>>>>>>>
>>>>>>>> I have generated a graphical editor from my domain model. Since
>>>>>>>> my application is database, not file system, driven, I knew I
>>>>>>>> would have to rewire the generated editor to accept my "virtual"
>>>>>>>> object as retrieved from the database and I was hoping this
>>>>>>>> could be done in a relatively straightforward manner, through
>>>>>>>> localised changes in one or two classes.
>>>>>>>>
>>>>>>>> However a perusal of the generated code leads me to believe that
>>>>>>>> the dependency on the editable object being on the file system
>>>>>>>> (or a URI resource) is deeply ingrained and that it is going to
>>>>>>>> take quite a lot of surgery to switch to a database driven
>>>>>>>> paradigm.
>>>>>>>>
>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>
>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>> facilities continue to assume that the whole world is in a file
>>>>>>>> system! :-)
>>>>>>>>
>>>>>>>> TIA,
>>>>>>>> B.
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #619180 is a reply to message #125157] Thu, 05 June 2008 18:44 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Hi Martin,

- In the Properties view I see the element I added (Test for Diagram)

- I open the editor like this:
ModelElement modelElement = (ModelElement)object;
URIEditorInput input = new URIEditorInput(URI.createURI("myURI"));
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().openEditor(input,
"org.unicase.model.classDiagram.part.ModelDiagramEditorID", true);
} catch (PartInitException e)

I implemented a Resource Factory which creates my custom Resource for
testing:
public Resource createResource(URI uri) {
return new MyDiagramResource();
}
I registered it and changed the my DocumentProvider to use my Factory :
resource = domain.getResourceSet().createResource(
uri.trimFragment(),"MyDiagramResourceFactoryID");
}
Afaics this seams to work correctly.


- If i dont add a transactional domain the editor does not open and I
get a NullPointer. This is because the TransactionalEditing Domain is null:


java.lang.NullPointerException
at
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createEditPart(EditPartService.java:226)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:611)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
at
org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
at
org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
at
org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
at
org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
at
org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at
org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
at
org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
at
org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
at
org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
at
org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
at
org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
at
org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
at org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
at
org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
at
org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:880)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
at
org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
at
org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
at
org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
at
org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
at
org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3050)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)


Martin Taal schrieb:
> Hi Jonas,
> I am not sure if you should add the resourceset to a new transactional
> editing domain like you do. What npe do you get when you remove that
> from the initialization?
>
> How do you open the editor?
>
> Also after initialization the diagram is empty. Which elements do you
> see in the properties view?
>
> gr. Martin
>
> Jonas wrote:
>> Thanks Martin,
>> I changed the order but it had no effect.
>>
>> When I open the diagram i get:
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write transaction
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>
>> at
>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>
>> at
>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>
>> at
>> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>>
>> at
>> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>>
>> at
>> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>>
>> at
>> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>>
>> at
>> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>>
>> at
>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>>
>> at
>> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>>
>> at
>> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>>
>> at
>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>>
>> at
>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>
>> at
>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>
>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>> at
>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>
>> at
>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>
>> at
>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>> at
>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>> at
>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>> at
>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>> at
>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>> at
>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>
>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>> at
>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>
>> at
>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>
>> at
>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>> at
>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>> at
>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>> at org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
>> at
>> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
>> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
>> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
>> at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve
>> Method)
>> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
>> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
>> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
>> at
>> org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive Method)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
>> at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>> at
>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>
>> at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>> at
>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>
>> at
>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>
>>
>>
>>
>>> Hi Jonas,
>>> Hmm, after initialization the diagram is empty. Which elements do you
>>> see in the properties view?
>>> And can you post the stacktrace of the executionexception?
>>>
>>> Regarding were to look for how the diagram nodes are loaded I don't
>>> know the answer. I hope someone on the gmft newsgroup will answer
>>> this one...
>>>
>>> Other small (probably insignificant) differences with the tutorial is
>>> that I add the model (meDiagram) to the resource before the diagram,
>>> in addition in your case the diagram name is not set. But I would be
>>> surprised if this makes any difference....
>>>
>>> gr. Martin
>>>
>>> Jonas wrote:
>>>> Hi Martin,
>>>> thanks for your reply and 5 days isn't late :-)
>>>> Your Hints were great I am now able to load my custom resource. I
>>>> additionally had to adapt "private long
>>>> computeModificationStamp(ResourceSetInfo info)" in
>>>> ModelDocumentProvider as it assumes a file even if you use URIEditor
>>>> input.
>>>>
>>>> Now the editor loads without any error, but I dont see the diagram
>>>> nodes. In the property view I can see that the root element is
>>>> corretly loaded and that it´s elements are in it, but they dont
>>>> appear. It is also not possible to add anything to the diagram
>>>> (ExecutionException).
>>>> I implemented my own resource which is a subclass of
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is
>>>> not connected to a file or a database and should just be a wrapper.
>>>> For testing i initialize my resource like this:
>>>>
>>>> private void initialize() {
>>>> //Create Model root and one test Node
>>>> MEDiagram meDiagram =
>>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>>> .createTestForDiagram();
>>>> meDiagram.getElements().add(testForDiagram);
>>>> //Create gmf diagram
>>>> Diagram diagram = ViewService.createDiagram(meDiagram, "Model",
>>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>>> //Put the content in the resource
>>>> super.getContents().add(diagram);
>>>> super.getContents().add(meDiagram);
>>>> //Set root of the gmf diagram
>>>> diagram.setElement(meDiagram);
>>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>>> ResourceSet resourceSet = this.getResourceSet();
>>>> TransactionalEditingDomain.Factory.INSTANCE
>>>> .createEditingDomain(resourceSet);
>>>> }
>>>>
>>>> I spent much time in debugging and it seams that only the root
>>>> element is loaded. I observed the getElements() method of MEDiagram.
>>>> It is called several time, but Afaics only for EditingPolicies and
>>>> Property views. Can sb. give me a Hint which method in the generated
>>>> editor loads the diagram nodes and would be a good hook for debugging?
>>>> Thanks for any help...
>>>>
>>>> Jonas
>>>>
>>>>
>>>>
>>>>
>>>> Martin Taal schrieb:
>>>>> Hi Jonas,
>>>>> Sorry for my late reply.
>>>>>
>>>>> Here are some additional pointers. I hope it is helpfull.
>>>>>
>>>>> I open the editor like this:
>>>>> page.openEditor(new
>>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>>> MindmapDiagramEditor.ID);
>>>>>
>>>>> Afaics using the URIEditorInput solves some of the issues related
>>>>> to the fact the generated editor assumes that the resources are
>>>>> files. (you can search for the string URIEditorInput in the
>>>>> generated code and it is used on various locations).
>>>>>
>>>>> For storing data and diagrams in different resources. You can take
>>>>> a look at the OpenMindmapDBEditor and then the initializeData
>>>>> method. Currently it stores the diagram and the map in one
>>>>> resource. In this method you can create two resources one for the
>>>>> Map and for the Diagram. The diagram contains a reference to the
>>>>> root of the model (diagram.setElement(map)). When opening the
>>>>> diagram resource then the model resource should open automatically.
>>>>> Note that you should search the EMFT newsgroup for some related
>>>>> GMF-Teneo topics (about cross-resource containment references if I
>>>>> remember it correctly...).
>>>>>
>>>>> Afaics the diagram always requires at least one model root object.
>>>>> By storing this root object in a separate resource (during
>>>>> initialization) model and diagram are stored separately.
>>>>>
>>>>> Storing the diagram and the model separately only works if:
>>>>> - both the diagram and the model are stored in the same database
>>>>> (both resources point to the same database), or
>>>>> - the diagram is stored in a xml/xmi resource and the model in the
>>>>> database.
>>>>>
>>>>> XMI/XML resources support cross-resource references but database
>>>>> resources don't support references to entities outside of the
>>>>> database.
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Jonas wrote:
>>>>>> Hi Martin,
>>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>>> I am currently trying to implement a custom resource which doesnt
>>>>>> get the model eobjects and the diagram from a file or a database,
>>>>>> but forwards to a abstract source. The abstract source contains
>>>>>> several diagrams and all model elements. (see
>>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>>> BTW and off topic: the source is then syncronized with a server
>>>>>> which saves it using Teneo :-)
>>>>>>
>>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>>> custom resource which wraps my source and only returns the model
>>>>>> elements of one diagram. I tried to open the DiagramEditor with
>>>>>> my CustomResource, similar as you did with your DatabaseResource.
>>>>>> But it seems that there are several places where the generated
>>>>>> Editor requires a file (e.g. private long
>>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So I
>>>>>> really wonder how you did your adaptation :-)
>>>>>> Also you mentioned that it is possible to use different Resources
>>>>>> for the data and he diagram. Till now I couldnt find the resource
>>>>>> for the model elements contained on a diagram. Could you give me a
>>>>>> hint where it is loaded?
>>>>>> Thanks...
>>>>>>
>>>>>> Jonas
>>>>>>
>>>>>>
>>>>>>> Hi Barbara,
>>>>>>> This tutorial here:
>>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>>
>>>>>>> describes how to change the generated gmf editor to retrieve its
>>>>>>> data from the database. In the tutorial also the diagram itself
>>>>>>> is stored in the db. It is also possible to store the diagram in
>>>>>>> a local file and get the data from the database. This is however
>>>>>>> not described in the tutorial but I am sure that the tutorial
>>>>>>> leads you in the right direction.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Ed Merks wrote:
>>>>>>>> Barbara,
>>>>>>>>
>>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>>> "to" list of the reply.
>>>>>>>>
>>>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>>>> editor input and that all your code to communicate with the data
>>>>>>>> base would be done either at the URI converter level or
>>>>>>>> ResourceImpl side of things. With the URIConverter changes in
>>>>>>>> EMF 2.4, this should be even easier to accomplish, if something
>>>>>>>> like XML data columns are your target.
>>>>>>>>
>>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>>
>>>>>>>>
>>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>>> Hello all.
>>>>>>>>>
>>>>>>>>> I have generated a graphical editor from my domain model. Since
>>>>>>>>> my application is database, not file system, driven, I knew I
>>>>>>>>> would have to rewire the generated editor to accept my
>>>>>>>>> "virtual" object as retrieved from the database and I was
>>>>>>>>> hoping this could be done in a relatively straightforward
>>>>>>>>> manner, through localised changes in one or two classes.
>>>>>>>>>
>>>>>>>>> However a perusal of the generated code leads me to believe
>>>>>>>>> that the dependency on the editable object being on the file
>>>>>>>>> system (or a URI resource) is deeply ingrained and that it is
>>>>>>>>> going to take quite a lot of surgery to switch to a database
>>>>>>>>> driven paradigm.
>>>>>>>>>
>>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>>
>>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>>> facilities continue to assume that the whole world is in a file
>>>>>>>>> system! :-)
>>>>>>>>>
>>>>>>>>> TIA,
>>>>>>>>> B.
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Re: Input for generated editor [message #619181 is a reply to message #125162] Thu, 05 June 2008 19:36 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jonas,
To be sure did you make the changes outlined here:
http://www.elver.org/hibernate/gmftutorial/tutorial3.html
in the 'Change MindmapDiagramEditor' section?

I don't know much about this but the editor has an editingdomain with a resourceset, I would expect
that the resource would be read in there and would get the editingdomain from the editor...

gr. Martin

Jonas wrote:
> Hi Martin,
>
> - In the Properties view I see the element I added (Test for Diagram)
>
> - I open the editor like this:
> ModelElement modelElement = (ModelElement)object;
> URIEditorInput input = new
> URIEditorInput(URI.createURI("myURI"));
> try {
> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
> .getActivePage().openEditor(input,
>
> "org.unicase.model.classDiagram.part.ModelDiagramEditorID", true);
> } catch (PartInitException e)
>
> I implemented a Resource Factory which creates my custom Resource for
> testing:
> public Resource createResource(URI uri) {
> return new MyDiagramResource();
> }
> I registered it and changed the my DocumentProvider to use my Factory :
> resource = domain.getResourceSet().createResource(
> uri.trimFragment(),"MyDiagramResourceFactoryID");
> }
> Afaics this seams to work correctly.
>
>
> - If i dont add a transactional domain the editor does not open and I
> get a NullPointer. This is because the TransactionalEditing Domain is null:
>
>
> java.lang.NullPointerException
> at
> org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createEditPart(EditPartService.java:226)
>
> at
> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:611)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>
> at
> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>
> at
> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>
> at
> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>
> at
> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>
> at
> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>
> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
> at
> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>
> at
> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>
> at
> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>
> at
> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>
> at
> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>
> at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
> at
> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>
> at
> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>
> at
> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>
> at
> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>
> at
> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
> at
> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
> at
> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
> at
> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
> at
> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
> at
> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
> at
> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>
> at
> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>
> at
> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>
> at
> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>
> at
> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>
> at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
> at
> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3050)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>
>
> Martin Taal schrieb:
>> Hi Jonas,
>> I am not sure if you should add the resourceset to a new transactional
>> editing domain like you do. What npe do you get when you remove that
>> from the initialization?
>>
>> How do you open the editor?
>>
>> Also after initialization the diagram is empty. Which elements do you
>> see in the properties view?
>>
>> gr. Martin
>>
>> Jonas wrote:
>>> Thanks Martin,
>>> I changed the order but it had no effect.
>>>
>>> When I open the diagram i get:
>>> java.lang.IllegalStateException: Cannot modify resource set without a
>>> write transaction
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>>
>>> at
>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>>
>>> at
>>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>>
>>> at
>>> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>>>
>>> at
>>> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>>>
>>> at
>>> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>>>
>>> at
>>> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>>>
>>> at
>>> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>>>
>>> at
>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>>>
>>> at
>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>>
>>> at
>>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>>
>>> at
>>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>>
>>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>>> at
>>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>>
>>> at
>>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>>
>>> at
>>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>>
>>> at
>>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>>
>>> at
>>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>>
>>> at
>>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>>> at
>>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>>
>>> at
>>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>>> at
>>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>>>
>>> at
>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>>>
>>> at
>>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>>> at
>>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>>
>>> at
>>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>>
>>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>>> at
>>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>>
>>> at
>>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>>
>>> at
>>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>>
>>> at
>>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>>
>>> at
>>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>>
>>> at
>>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>>> at
>>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>>> at
>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>>> at
>>> org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
>>> at
>>> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
>>> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
>>> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
>>> at org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve
>>> Method)
>>> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
>>> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
>>> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
>>> at
>>> org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive Method)
>>> at
>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
>>> at
>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>>> at
>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>
>>> at
>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>>
>>> at
>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>> at
>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>>
>>> at
>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>>
>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>> at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>>
>>> at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>>
>>> at java.lang.reflect.Method.invoke(Method.java:585)
>>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>>
>>>
>>>
>>>
>>>> Hi Jonas,
>>>> Hmm, after initialization the diagram is empty. Which elements do
>>>> you see in the properties view?
>>>> And can you post the stacktrace of the executionexception?
>>>>
>>>> Regarding were to look for how the diagram nodes are loaded I don't
>>>> know the answer. I hope someone on the gmft newsgroup will answer
>>>> this one...
>>>>
>>>> Other small (probably insignificant) differences with the tutorial
>>>> is that I add the model (meDiagram) to the resource before the
>>>> diagram, in addition in your case the diagram name is not set. But I
>>>> would be surprised if this makes any difference....
>>>>
>>>> gr. Martin
>>>>
>>>> Jonas wrote:
>>>>> Hi Martin,
>>>>> thanks for your reply and 5 days isn't late :-)
>>>>> Your Hints were great I am now able to load my custom resource. I
>>>>> additionally had to adapt "private long
>>>>> computeModificationStamp(ResourceSetInfo info)" in
>>>>> ModelDocumentProvider as it assumes a file even if you use
>>>>> URIEditor input.
>>>>>
>>>>> Now the editor loads without any error, but I dont see the diagram
>>>>> nodes. In the property view I can see that the root element is
>>>>> corretly loaded and that it´s elements are in it, but they dont
>>>>> appear. It is also not possible to add anything to the diagram
>>>>> (ExecutionException).
>>>>> I implemented my own resource which is a subclass of
>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is
>>>>> not connected to a file or a database and should just be a wrapper.
>>>>> For testing i initialize my resource like this:
>>>>>
>>>>> private void initialize() {
>>>>> //Create Model root and one test Node
>>>>> MEDiagram meDiagram =
>>>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>>>> .createTestForDiagram();
>>>>> meDiagram.getElements().add(testForDiagram);
>>>>> //Create gmf diagram
>>>>> Diagram diagram = ViewService.createDiagram(meDiagram,
>>>>> "Model",
>>>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>>>> //Put the content in the resource
>>>>> super.getContents().add(diagram);
>>>>> super.getContents().add(meDiagram);
>>>>> //Set root of the gmf diagram
>>>>> diagram.setElement(meDiagram);
>>>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>>>> ResourceSet resourceSet = this.getResourceSet();
>>>>> TransactionalEditingDomain.Factory.INSTANCE
>>>>> .createEditingDomain(resourceSet);
>>>>> }
>>>>>
>>>>> I spent much time in debugging and it seams that only the root
>>>>> element is loaded. I observed the getElements() method of
>>>>> MEDiagram. It is called several time, but Afaics only for
>>>>> EditingPolicies and Property views. Can sb. give me a Hint which
>>>>> method in the generated editor loads the diagram nodes and would be
>>>>> a good hook for debugging?
>>>>> Thanks for any help...
>>>>>
>>>>> Jonas
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Martin Taal schrieb:
>>>>>> Hi Jonas,
>>>>>> Sorry for my late reply.
>>>>>>
>>>>>> Here are some additional pointers. I hope it is helpfull.
>>>>>>
>>>>>> I open the editor like this:
>>>>>> page.openEditor(new
>>>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>>>> MindmapDiagramEditor.ID);
>>>>>>
>>>>>> Afaics using the URIEditorInput solves some of the issues related
>>>>>> to the fact the generated editor assumes that the resources are
>>>>>> files. (you can search for the string URIEditorInput in the
>>>>>> generated code and it is used on various locations).
>>>>>>
>>>>>> For storing data and diagrams in different resources. You can take
>>>>>> a look at the OpenMindmapDBEditor and then the initializeData
>>>>>> method. Currently it stores the diagram and the map in one
>>>>>> resource. In this method you can create two resources one for the
>>>>>> Map and for the Diagram. The diagram contains a reference to the
>>>>>> root of the model (diagram.setElement(map)). When opening the
>>>>>> diagram resource then the model resource should open
>>>>>> automatically. Note that you should search the EMFT newsgroup for
>>>>>> some related GMF-Teneo topics (about cross-resource containment
>>>>>> references if I remember it correctly...).
>>>>>>
>>>>>> Afaics the diagram always requires at least one model root object.
>>>>>> By storing this root object in a separate resource (during
>>>>>> initialization) model and diagram are stored separately.
>>>>>>
>>>>>> Storing the diagram and the model separately only works if:
>>>>>> - both the diagram and the model are stored in the same database
>>>>>> (both resources point to the same database), or
>>>>>> - the diagram is stored in a xml/xmi resource and the model in the
>>>>>> database.
>>>>>>
>>>>>> XMI/XML resources support cross-resource references but database
>>>>>> resources don't support references to entities outside of the
>>>>>> database.
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Jonas wrote:
>>>>>>> Hi Martin,
>>>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>>>> I am currently trying to implement a custom resource which doesnt
>>>>>>> get the model eobjects and the diagram from a file or a database,
>>>>>>> but forwards to a abstract source. The abstract source contains
>>>>>>> several diagrams and all model elements. (see
>>>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>>>> BTW and off topic: the source is then syncronized with a server
>>>>>>> which saves it using Teneo :-)
>>>>>>>
>>>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>>>> custom resource which wraps my source and only returns the model
>>>>>>> elements of one diagram. I tried to open the DiagramEditor with
>>>>>>> my CustomResource, similar as you did with your DatabaseResource.
>>>>>>> But it seems that there are several places where the generated
>>>>>>> Editor requires a file (e.g. private long
>>>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So
>>>>>>> I really wonder how you did your adaptation :-)
>>>>>>> Also you mentioned that it is possible to use different Resources
>>>>>>> for the data and he diagram. Till now I couldnt find the resource
>>>>>>> for the model elements contained on a diagram. Could you give me
>>>>>>> a hint where it is loaded?
>>>>>>> Thanks...
>>>>>>>
>>>>>>> Jonas
>>>>>>>
>>>>>>>
>>>>>>>> Hi Barbara,
>>>>>>>> This tutorial here:
>>>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>>>
>>>>>>>> describes how to change the generated gmf editor to retrieve its
>>>>>>>> data from the database. In the tutorial also the diagram itself
>>>>>>>> is stored in the db. It is also possible to store the diagram in
>>>>>>>> a local file and get the data from the database. This is however
>>>>>>>> not described in the tutorial but I am sure that the tutorial
>>>>>>>> leads you in the right direction.
>>>>>>>>
>>>>>>>> gr. Martin
>>>>>>>>
>>>>>>>> Ed Merks wrote:
>>>>>>>>> Barbara,
>>>>>>>>>
>>>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>>>> "to" list of the reply.
>>>>>>>>>
>>>>>>>>> I imagine you should be able to use EMF's URIEditorInput as the
>>>>>>>>> editor input and that all your code to communicate with the
>>>>>>>>> data base would be done either at the URI converter level or
>>>>>>>>> ResourceImpl side of things. With the URIConverter changes in
>>>>>>>>> EMF 2.4, this should be even easier to accomplish, if something
>>>>>>>>> like XML data columns are your target.
>>>>>>>>>
>>>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>>>> Hello all.
>>>>>>>>>>
>>>>>>>>>> I have generated a graphical editor from my domain model.
>>>>>>>>>> Since my application is database, not file system, driven, I
>>>>>>>>>> knew I would have to rewire the generated editor to accept my
>>>>>>>>>> "virtual" object as retrieved from the database and I was
>>>>>>>>>> hoping this could be done in a relatively straightforward
>>>>>>>>>> manner, through localised changes in one or two classes.
>>>>>>>>>>
>>>>>>>>>> However a perusal of the generated code leads me to believe
>>>>>>>>>> that the dependency on the editable object being on the file
>>>>>>>>>> system (or a URI resource) is deeply ingrained and that it is
>>>>>>>>>> going to take quite a lot of surgery to switch to a database
>>>>>>>>>> driven paradigm.
>>>>>>>>>>
>>>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>>>
>>>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>>>> facilities continue to assume that the whole world is in a
>>>>>>>>>> file system! :-)
>>>>>>>>>>
>>>>>>>>>> TIA,
>>>>>>>>>> B.
>>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: Input for generated editor [message #619237 is a reply to message #125163] Wed, 11 June 2008 14:08 Go to previous message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
Thanks Martin,
The second thing was a helpful hint. The problem was indeed that the
editor uses it´s own resource set and editing domain and does not care
if there is already one. I changed this behaviour as described in
http://www.eclipse.org/articles/Article-Integrating-EMF-GMF- Editors/index.html#extending_the_editor_input
BTW, congratulations for Teneo becoming gratuated :-)
Jonas


Martin Taal schrieb:
> Hi Jonas,
> To be sure did you make the changes outlined here:
> http://www.elver.org/hibernate/gmftutorial/tutorial3.html
> in the 'Change MindmapDiagramEditor' section?
>
> I don't know much about this but the editor has an editingdomain with a
> resourceset, I would expect that the resource would be read in there and
> would get the editingdomain from the editor...
>
> gr. Martin
>
> Jonas wrote:
>> Hi Martin,
>>
>> - In the Properties view I see the element I added (Test for Diagram)
>>
>> - I open the editor like this:
>> ModelElement modelElement = (ModelElement)object;
>> URIEditorInput input = new
>> URIEditorInput(URI.createURI("myURI"));
>> try {
>> PlatformUI.getWorkbench().getActiveWorkbenchWindow()
>> .getActivePage().openEditor(input,
>>
>> "org.unicase.model.classDiagram.part.ModelDiagramEditorID", true);
>> } catch (PartInitException e)
>>
>> I implemented a Resource Factory which creates my custom Resource for
>> testing:
>> public Resource createResource(URI uri) {
>> return new MyDiagramResource();
>> }
>> I registered it and changed the my DocumentProvider to use my Factory
>> : resource = domain.getResourceSet().createResource(
>> uri.trimFragment(),"MyDiagramResourceFactoryID");
>> }
>> Afaics this seams to work correctly.
>>
>>
>> - If i dont add a transactional domain the editor does not open and I
>> get a NullPointer. This is because the TransactionalEditing Domain is
>> null:
>>
>>
>> java.lang.NullPointerException
>> at
>> org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createEditPart(EditPartService.java:226)
>>
>> at
>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:611)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>
>> at
>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>
>> at
>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>
>> at
>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>
>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>> at
>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>
>> at
>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>
>> at
>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>
>> at
>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>> at
>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>
>> at
>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>
>> at
>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>
>> at
>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>> at
>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>> at
>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>> at
>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>> at
>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>> at
>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>
>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>> at
>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>
>> at
>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>
>> at
>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>
>> at
>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>
>> at
>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>> at
>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>> at
>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3050)
>> at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>> at
>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>
>> at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>> at
>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>
>> at
>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:585)
>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>
>>
>> Martin Taal schrieb:
>>> Hi Jonas,
>>> I am not sure if you should add the resourceset to a new
>>> transactional editing domain like you do. What npe do you get when
>>> you remove that from the initialization?
>>>
>>> How do you open the editor?
>>>
>>> Also after initialization the diagram is empty. Which elements do you
>>> see in the properties view?
>>>
>>> gr. Martin
>>>
>>> Jonas wrote:
>>>> Thanks Martin,
>>>> I changed the order but it had no effect.
>>>>
>>>> When I open the diagram i get:
>>>> java.lang.IllegalStateException: Cannot modify resource set without
>>>> a write transaction
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:338)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:300)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:282)
>>>>
>>>> at
>>>> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:238)
>>>>
>>>> at
>>>> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:247)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.notation.impl.ViewImpl.setMutable(Vi ewImpl.java:269)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand$1.doExecute(SetViewMutabilityCommand.java:154)
>>>>
>>>> at
>>>> org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:157)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.setMutability(SetViewMutabilityCommand.java:161)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.commands.SetViewMutabilit yCommand.execute(SetViewMutabilityCommand.java:128)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.createViews(CanonicalEditPolicy.java:469)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:112 5)
>>>>
>>>> at
>>>> org.unicase.model.classDiagram.edit.policies.MEDiagramCanoni calEditPolicy.refreshSemantic(MEDiagramCanonicalEditPolicy.j ava:124)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:985)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalCon nectionEditPolicy.refreshOnActivate(CanonicalConnectionEditP olicy.java:107)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.activate(CanonicalEditPolicy.java:653)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractEditPart.activateEditPolic ies(AbstractEditPart.java:165)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractEditPart.activate(Abstract EditPart.java:148)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.activate (AbstractGraphicalEditPart.java:193)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$0(GraphicalEditPart.java:1)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.activate(GraphicalEditPart.java:189)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart .activate(DiagramEditPart.java:349)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:201)
>>>>
>>>> at
>>>> org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
>>>>
>>>> at
>>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
>>>>
>>>> at
>>>> org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
>>>>
>>>> at
>>>> org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
>>>>
>>>> at
>>>> org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
>>>>
>>>> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:30 0)
>>>> at
>>>> org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1256)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1209)
>>>> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 08)
>>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
>>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
>>>> at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
>>>> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
>>>> at
>>>> org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:217)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:207)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:779)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:678)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:639)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2781)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2693)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2685)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2637)
>>>> at
>>>> org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2632)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2616)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2607)
>>>>
>>>> at
>>>> org.unicase.ui.navigator.TreeView.handleDoubleClick(TreeView .java:78)
>>>> at
>>>> org.eclipse.ui.navigator.CommonNavigator$3.doubleClick(Commo nNavigator.java:428)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredV iewer.java:799)
>>>>
>>>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>>>> at org.eclipse.core.runtime.Platform.run(Platform.java:880)
>>>> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
>>>> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(S tructuredViewer.java:797)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSel ect(AbstractTreeViewer.java:1419)
>>>>
>>>> at
>>>> org.eclipse.ui.navigator.CommonViewer.handleDoubleSelect(Com monViewer.java:340)
>>>>
>>>> at
>>>> org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSe lected(StructuredViewer.java:1173)
>>>>
>>>> at
>>>> org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEven t(OpenStrategy.java:237)
>>>>
>>>> at
>>>> org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.ja va:234)
>>>> at
>>>> org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:295)
>>>>
>>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1557)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1581)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1566)
>>>> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 357)
>>>> at
>>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3459)
>>>> at
>>>> org.eclipse.swt.widgets.Control.sendTrackEvents(Control.java :2923)
>>>> at
>>>> org.eclipse.swt.widgets.Control.kEventControlTrack(Control.j ava:2061)
>>>> at org.eclipse.swt.widgets.Widget.controlProc(Widget.java:373)
>>>> at org.eclipse.swt.widgets.Display.controlProc(Display.java:858 )
>>>> at
>>>> org.eclipse.swt.internal.carbon.OS.CallNextEventHandler(Nati ve Method)
>>>> at org.eclipse.swt.widgets.Tree.kEventMouseDown(Tree.java:2562)
>>>> at org.eclipse.swt.widgets.Widget.mouseProc(Widget.java:1324)
>>>> at org.eclipse.swt.widgets.Display.mouseProc(Display.java:2911)
>>>> at
>>>> org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Na tive
>>>> Method)
>>>> at
>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3033)
>>>> at
>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2394)
>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2358)
>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
>>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
>>>> at
>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
>>>>
>>>> at
>>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>>> at
>>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
>>>>
>>>> at
>>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:379)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>>>>
>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>> at
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
>>>>
>>>> at
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
>>>>
>>>> at java.lang.reflect.Method.invoke(Method.java:585)
>>>> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
>>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
>>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>>>>
>>>>
>>>>
>>>>
>>>>> Hi Jonas,
>>>>> Hmm, after initialization the diagram is empty. Which elements do
>>>>> you see in the properties view?
>>>>> And can you post the stacktrace of the executionexception?
>>>>>
>>>>> Regarding were to look for how the diagram nodes are loaded I don't
>>>>> know the answer. I hope someone on the gmft newsgroup will answer
>>>>> this one...
>>>>>
>>>>> Other small (probably insignificant) differences with the tutorial
>>>>> is that I add the model (meDiagram) to the resource before the
>>>>> diagram, in addition in your case the diagram name is not set. But
>>>>> I would be surprised if this makes any difference....
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Jonas wrote:
>>>>>> Hi Martin,
>>>>>> thanks for your reply and 5 days isn't late :-)
>>>>>> Your Hints were great I am now able to load my custom resource. I
>>>>>> additionally had to adapt "private long
>>>>>> computeModificationStamp(ResourceSetInfo info)" in
>>>>>> ModelDocumentProvider as it assumes a file even if you use
>>>>>> URIEditor input.
>>>>>>
>>>>>> Now the editor loads without any error, but I dont see the diagram
>>>>>> nodes. In the property view I can see that the root element is
>>>>>> corretly loaded and that it´s elements are in it, but they dont
>>>>>> appear. It is also not possible to add anything to the diagram
>>>>>> (ExecutionException).
>>>>>> I implemented my own resource which is a subclass of
>>>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl. The resource is
>>>>>> not connected to a file or a database and should just be a
>>>>>> wrapper. For testing i initialize my resource like this:
>>>>>>
>>>>>> private void initialize() {
>>>>>> //Create Model root and one test Node
>>>>>> MEDiagram meDiagram =
>>>>>> DiagramFactory.eINSTANCE.createMEDiagram();
>>>>>> TestForDiagram testForDiagram = ModelFactory.eINSTANCE
>>>>>> .createTestForDiagram();
>>>>>> meDiagram.getElements().add(testForDiagram);
>>>>>> //Create gmf diagram
>>>>>> Diagram diagram = ViewService.createDiagram(meDiagram,
>>>>>> "Model",
>>>>>> ModelDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
>>>>>> //Put the content in the resource
>>>>>> super.getContents().add(diagram);
>>>>>> super.getContents().add(meDiagram);
>>>>>> //Set root of the gmf diagram
>>>>>> diagram.setElement(meDiagram);
>>>>>> //Add Transactional domain. Otherwise: Nullpointer Exception
>>>>>> ResourceSet resourceSet = this.getResourceSet();
>>>>>> TransactionalEditingDomain.Factory.INSTANCE
>>>>>> .createEditingDomain(resourceSet);
>>>>>> }
>>>>>>
>>>>>> I spent much time in debugging and it seams that only the root
>>>>>> element is loaded. I observed the getElements() method of
>>>>>> MEDiagram. It is called several time, but Afaics only for
>>>>>> EditingPolicies and Property views. Can sb. give me a Hint which
>>>>>> method in the generated editor loads the diagram nodes and would
>>>>>> be a good hook for debugging?
>>>>>> Thanks for any help...
>>>>>>
>>>>>> Jonas
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Martin Taal schrieb:
>>>>>>> Hi Jonas,
>>>>>>> Sorry for my late reply.
>>>>>>>
>>>>>>> Here are some additional pointers. I hope it is helpfull.
>>>>>>>
>>>>>>> I open the editor like this:
>>>>>>> page.openEditor(new
>>>>>>> URIEditorInput(StoreController.DATABASE_URI),
>>>>>>> MindmapDiagramEditor.ID);
>>>>>>>
>>>>>>> Afaics using the URIEditorInput solves some of the issues related
>>>>>>> to the fact the generated editor assumes that the resources are
>>>>>>> files. (you can search for the string URIEditorInput in the
>>>>>>> generated code and it is used on various locations).
>>>>>>>
>>>>>>> For storing data and diagrams in different resources. You can
>>>>>>> take a look at the OpenMindmapDBEditor and then the
>>>>>>> initializeData method. Currently it stores the diagram and the
>>>>>>> map in one resource. In this method you can create two resources
>>>>>>> one for the Map and for the Diagram. The diagram contains a
>>>>>>> reference to the root of the model (diagram.setElement(map)).
>>>>>>> When opening the diagram resource then the model resource should
>>>>>>> open automatically. Note that you should search the EMFT
>>>>>>> newsgroup for some related GMF-Teneo topics (about cross-resource
>>>>>>> containment references if I remember it correctly...).
>>>>>>>
>>>>>>> Afaics the diagram always requires at least one model root
>>>>>>> object. By storing this root object in a separate resource
>>>>>>> (during initialization) model and diagram are stored separately.
>>>>>>>
>>>>>>> Storing the diagram and the model separately only works if:
>>>>>>> - both the diagram and the model are stored in the same database
>>>>>>> (both resources point to the same database), or
>>>>>>> - the diagram is stored in a xml/xmi resource and the model in
>>>>>>> the database.
>>>>>>>
>>>>>>> XMI/XML resources support cross-resource references but database
>>>>>>> resources don't support references to entities outside of the
>>>>>>> database.
>>>>>>>
>>>>>>> gr. Martin
>>>>>>>
>>>>>>> Jonas wrote:
>>>>>>>> Hi Martin,
>>>>>>>> Thanks for your tutorial, it was a good entry point for me.
>>>>>>>> I am currently trying to implement a custom resource which
>>>>>>>> doesnt get the model eobjects and the diagram from a file or a
>>>>>>>> database, but forwards to a abstract source. The abstract source
>>>>>>>> contains several diagrams and all model elements. (see
>>>>>>>> news://news.eclipse.org:119/fukmcg$pi5$1@build.eclipse.org)
>>>>>>>> BTW and off topic: the source is then syncronized with a server
>>>>>>>> which saves it using Teneo :-)
>>>>>>>>
>>>>>>>> As I want to use gmf to create diagram editors, i try to use a
>>>>>>>> custom resource which wraps my source and only returns the model
>>>>>>>> elements of one diagram. I tried to open the DiagramEditor with
>>>>>>>> my CustomResource, similar as you did with your
>>>>>>>> DatabaseResource. But it seems that there are several places
>>>>>>>> where the generated Editor requires a file (e.g. private long
>>>>>>>> computeModificationStamp(ResourceSetInfo info)) or a XMLResource
>>>>>>>> (e.g. public static String getIdStr(View view) in ViewUtil). So
>>>>>>>> I really wonder how you did your adaptation :-)
>>>>>>>> Also you mentioned that it is possible to use different
>>>>>>>> Resources for the data and he diagram. Till now I couldnt find
>>>>>>>> the resource for the model elements contained on a diagram.
>>>>>>>> Could you give me a hint where it is loaded?
>>>>>>>> Thanks...
>>>>>>>>
>>>>>>>> Jonas
>>>>>>>>
>>>>>>>>
>>>>>>>>> Hi Barbara,
>>>>>>>>> This tutorial here:
>>>>>>>>> http://www.elver.org/hibernate/gmftutorial/tutorial1.html
>>>>>>>>>
>>>>>>>>> describes how to change the generated gmf editor to retrieve
>>>>>>>>> its data from the database. In the tutorial also the diagram
>>>>>>>>> itself is stored in the db. It is also possible to store the
>>>>>>>>> diagram in a local file and get the data from the database.
>>>>>>>>> This is however not described in the tutorial but I am sure
>>>>>>>>> that the tutorial leads you in the right direction.
>>>>>>>>>
>>>>>>>>> gr. Martin
>>>>>>>>>
>>>>>>>>> Ed Merks wrote:
>>>>>>>>>> Barbara,
>>>>>>>>>>
>>>>>>>>>> Martin Taal has invested a fair bit of time in ensuring that
>>>>>>>>>> Teneo hooks up well with the GMF editor. Maybe it might solve
>>>>>>>>>> your problems directly. I've added the EMFT newsgroup to the
>>>>>>>>>> "to" list of the reply.
>>>>>>>>>>
>>>>>>>>>> I imagine you should be able to use EMF's URIEditorInput as
>>>>>>>>>> the editor input and that all your code to communicate with
>>>>>>>>>> the data base would be done either at the URI converter level
>>>>>>>>>> or ResourceImpl side of things. With the URIConverter changes
>>>>>>>>>> in EMF 2.4, this should be even easier to accomplish, if
>>>>>>>>>> something like XML data columns are your target.
>>>>>>>>>>
>>>>>>>>>> Maybe you could explain a bit more what you're trying to do?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Barbara Rosi-Schwartz wrote:
>>>>>>>>>>> Hello all.
>>>>>>>>>>>
>>>>>>>>>>> I have generated a graphical editor from my domain model.
>>>>>>>>>>> Since my application is database, not file system, driven, I
>>>>>>>>>>> knew I would have to rewire the generated editor to accept my
>>>>>>>>>>> "virtual" object as retrieved from the database and I was
>>>>>>>>>>> hoping this could be done in a relatively straightforward
>>>>>>>>>>> manner, through localised changes in one or two classes.
>>>>>>>>>>>
>>>>>>>>>>> However a perusal of the generated code leads me to believe
>>>>>>>>>>> that the dependency on the editable object being on the file
>>>>>>>>>>> system (or a URI resource) is deeply ingrained and that it is
>>>>>>>>>>> going to take quite a lot of surgery to switch to a database
>>>>>>>>>>> driven paradigm.
>>>>>>>>>>>
>>>>>>>>>>> Is this accurate or am I missing something?
>>>>>>>>>>>
>>>>>>>>>>> If so, I do wonder why so many of the Eclipse APIs and
>>>>>>>>>>> facilities continue to assume that the whole world is in a
>>>>>>>>>>> file system! :-)
>>>>>>>>>>>
>>>>>>>>>>> TIA,
>>>>>>>>>>> B.
>>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>>
>>>
>
>
Previous Topic:[EMF Search] Problem in wizard
Next Topic:[Teneo] prevent table creation for a specific EClass
Goto Forum:
  


Current Time: Thu Apr 25 11:59:16 GMT 2024

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

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

Back to the top