Home » Eclipse Projects » Sirius » Add new node on a diagram
|
Re: Add new node on a diagram [message #1603614 is a reply to message #1596213] |
Fri, 06 February 2015 04:20   |
Eclipse User |
|
|
|
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
|
|
| | |
Re: Add new node on a diagram [message #1615690 is a reply to message #1614419] |
Fri, 13 February 2015 22:32   |
Eclipse User |
|
|
|
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 10:55   |
Eclipse User |
|
|
|
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
|
|
| | |
Re: Add new node on a diagram [message #1652050 is a reply to message #1645318] |
Thu, 05 March 2015 12:11  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Sun May 18 02:53:48 EDT 2025
Powered by FUDForum. Page generated in 0.02186 seconds
|