Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Add new node on a diagram
Add new node on a diagram [message #1596213] Sun, 01 February 2015 13:50 Go to next message
Elvis Dowson is currently offline Elvis DowsonFriend
Messages: 65
Registered: December 2011
Member
Hi,

I've created a Sirius workbench based on the following library ecore model, which models a library containing authors and books. An author can author multiple books.

index.php/fa/20688/0/

I've create two diagrams, one for the library and another for an author to show the list of books written by the author.

I tried implement an "Add New Book" tool to add a new book to an existing author diagram, but it doesn't seem to work.

index.php/fa/20689/0/

Im having some difficultly figuring out the correct way to instantiate a new Book element from within an Author diagram, when the books are contained by the library element.

I've attached the model, sample and design sources with this post.

If I could get some pointers as to how to correctly add a new book node to an Authors diagram, it would be much appreciated.

Regards,

Elvis Dowson

Re: Add new node on a diagram [message #1603614 is a reply to message #1596213] Fri, 06 February 2015 09:20 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Le 01/02/2015 14:50, Elvis Dowson a écrit :
> Hi,
>
> I've created a Sirius workbench based on the following library ecore model, which models a library containing authors and books. An author can author multiple books.
>
>
>
> I've create two diagrams, one for the library and another for an author to show the list of books written by the author.
>
> I tried implement an "Add New Book" tool to add a new book to an existing author diagram, but it doesn't seem to work.
>
>
>
> Im having some difficultly figuring out the correct way to instantiate a new Book element from within an Author diagram, when the books are contained by the library element.

Inside the definition of a tool, the "Create Instance" operation will
attach the newly created model element inside the current context of the
tool, so before creating the new Book, you must use "Change Context" to
navigate from the initial context of the tool (the element on which it
is applied, say an Author) to the Library into which the newly created
Book must be attached.


--
Pierre-Charles David - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Add new node on a diagram [message #1609835 is a reply to message #1603614] Tue, 10 February 2015 11:16 Go to previous messageGo to next message
Elvis Dowson is currently offline Elvis DowsonFriend
Messages: 65
Registered: December 2011
Member
Hi Pierre,

How can I go about writing the Change Context Browse Expression?

I do not know how to navigate to the library.Library instance in the model.

Regards,

Elvis Dowson
Re: Add new node on a diagram [message #1614419 is a reply to message #1609835] Fri, 13 February 2015 08:29 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Le 10/02/2015 12:16, Elvis Dowson a écrit :
> Hi Pierre,
>
> How can I go about writing the Change Context Browse Expression?
>
> I do not know how to navigate to the library.Library instance in the model.

It really depends on the structure of your own metamodel, and on which
element the tool is applied on (which determines the starting point).
Assuming the structure of the metamodel shown in your previous message,
and that the tool is applied directly in the background of a diagram
which represents an author, the expression could be

feature:eContainer

which simply navigates to the model element that contains the Author,
i.e. the Library.

--
Pierre-Charles David - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Add new node on a diagram [message #1615690 is a reply to message #1614419] Sat, 14 February 2015 03:32 Go to previous messageGo to next message
Elvis Dowson is currently offline Elvis DowsonFriend
Messages: 65
Registered: December 2011
Member
Hi Pierre,

Thank you for the reply.

I tried changing the current context for the create new book tool for an author diagram, to that of the containing library, using feature:eContainer.

When I tried to create a new book on the author diagram, nothing happened. However, a new book with no name was created on the Library diagram.

Could you please let me know the full sequence of steps required to create a new book on the author diagram, associate the current author with the newly created book and name the book?

Are there any other resources to learn how to do these common steps, apart from downloading the obeo example repositories. The problem with looking at existing examples is that there are no accompanying textual descriptions.

A project like Sirius really needs a book to go along with it, like the EMF book (2nd Edition).

Regards,

Elvis Dowson
Re: Add new node on a diagram [message #1631123 is a reply to message #1615690] Mon, 23 February 2015 15:55 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Le 14/02/2015 04:32, Elvis Dowson a écrit :
> Hi Pierre,

Hi.

> Thank you for the reply.
>
> I tried changing the current context for the create new book tool for an
> author diagram, to that of the containing library, using
> feature:eContainer.
>
> When I tried to create a new book on the author diagram, nothing
> happened. However, a new book with no name was created on the Library
> diagram.

Did you set the author of the new book? I suppose your author diagram
only shows books from the library whose author is the current one, so if
the new instance you created inside the library is not attached to the
author it's normal it does not show in your author diagram.

> Could you please let me know the full sequence of steps required to
> create a new book on the author diagram, associate the current author
> with the newly created book and name the book?

The structure of your tool should probably look something like this
(untested, you may need to make some adjustments):

a. Change Context: var:self
b. Change Context: feature:eContainer
c. Create Instance: TypeName=Book ReferenceName=books
d. Set FeatureName=name ValueExpression=Untitled
e. Set FeatureName=books ValueExpression=var:instance

Some explanantions:
a: this is a no-op but allows multiple chilren inside a "Begin" element,
which normally contains only one.
b: we navigate to the library, because that is where Book instances are
contained/stored, and thus where the new instance we will create must be
attached.
c: we create the new instance and add it to the "books" containment
reference of the Library
d: we set a default title for the new instance
e: now we're back in the context of the Author, and we add the new book
to the author's "books" reference. When the "Create Instance" operation
was executed earlier it created a new variable (by default named
"instance" but that can be changed) so that we can reference the new
object here, simply by var:instance.

> Are there any other resources to learn how to do these common steps,
> apart from downloading the obeo example repositories. The problem with
> looking at existing examples is that there are no accompanying textual
> descriptions.

There is the short tutorial at
https://wiki.eclipse.org/Sirius/Tutorials/4MinTutorial, but it only
covers the basics.

> A project like Sirius really needs a book to go along with it, like the
> EMF book (2nd Edition).

Given the resources this would take (to create and to keep up to date),
I think I'd rather spend them in making Sirius easier to use and more
discoverable. :-)

Regards,
Pierre-Charles

--
Pierre-Charles David - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Add new node on a diagram [message #1643636 is a reply to message #1631123] Sun, 01 March 2015 17:40 Go to previous messageGo to next message
Elvis Dowson is currently offline Elvis DowsonFriend
Messages: 65
Registered: December 2011
Member
Hi Pierre,

Thank you for the suggestion. It worked. I was able to add a new book to the Library, and update the Author diagram.

On a similar note, would it be possible to additionally describe the sequence of steps for achieving the following operations for the Author diagram?

a. How to Delete a book from an author diagram.
- How to implement a Delete from view option
- How to implement a Delete from model option.

b. How to Double-click to rename a book.

c. How to Right-click on a book, so that a pop up context menu gets populated with an option to rename the current book.

d. How to implement a tool to Disassociate a book from the current author.

Regards,

Elvis Dowson

[Updated on: Sun, 01 March 2015 17:40]

Report message to a moderator

Re: Add new node on a diagram [message #1645318 is a reply to message #1615690] Mon, 02 March 2015 12:52 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Le 14/02/2015 04:32, Elvis Dowson a écrit :
> A project like Sirius really needs a book to go along with it, like the
> EMF book (2nd Edition).

There's no plan for this right now, but Obeo provides training if you're
interested (including in English): see
http://www.obeo.fr/en/services/training for details.

--
Pierre-Charles David - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Add new node on a diagram [message #1652050 is a reply to message #1645318] Thu, 05 March 2015 17:11 Go to previous message
Elvis Dowson is currently offline Elvis DowsonFriend
Messages: 65
Registered: December 2011
Member
Hi Pierre,

Would it be possible for you to describe the sequence of steps to implement the tools to perform the following actions:
a. Delete a book from an author diagram.
- Delete from view option
- Delete from model option.

b. Double-click to rename a book.

c. Right-click on a book, so that a pop up context menu gets populated with an option to rename the current book.

d. Disassociate a book from the current author.

Thanks!

Regards,

Elvis Dowson
Previous Topic:Element-Based Edges
Next Topic:Create new representation that is unsynchronized by default
Goto Forum:
  


Current Time: Thu Apr 18 16:27:47 GMT 2024

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

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

Back to the top