Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Copy-paste Association as a side-effect when pasting a Class
Copy-paste Association as a side-effect when pasting a Class [message #477381] Wed, 14 May 2008 16:40 Go to next message
Tim Myer is currently offline Tim MyerFriend
Messages: 81
Registered: July 2009
Member
Question about a custom UML Editor. Currently, I display Associations
as "children" underneath the Classes that are the source ends of the
Associations. This containment relationship is not in the model itself
(I am using the EMF-generated UML model from the org.eclipse.uml2.uml
plug-in). When I copy-and-paste a Class that is the source of an
Association, I would also like to copy the Association and to set the
source of the new Association to be the copy of the Class. I have tried
overriding ClassItemProvider#createCopyCommand,
ClassItemProvider#createCreatCopyCommand and even the PasteAction
contributed by the UMLActionBarContributor to have this side-effect for
the copy-paste operation, but without much luck. What would be the
recommended way to have this kind of side effect, and how would the
command that performs this side-effect get a reference to both the
original Class and the new Class?
-------Tim--------
Re: Copy-paste Association as a side-effect when pasting a Class [message #477386 is a reply to message #477381] Wed, 14 May 2008 18:44 Go to previous messageGo to next message
Tim Myer is currently offline Tim MyerFriend
Messages: 81
Registered: July 2009
Member
I figured out a way to do this by overriding CopyAction#createCommand.
I just find all the Associations that use the selected Class as a source
and add those Associations to the Collection<?> selection parameter.
That seems to give me the desired behavior but I am not sure how ideal
this solution is.
-----Tim------

Tim Myer wrote:
> Question about a custom UML Editor. Currently, I display Associations
> as "children" underneath the Classes that are the source ends of the
> Associations. This containment relationship is not in the model itself
> (I am using the EMF-generated UML model from the org.eclipse.uml2.uml
> plug-in). When I copy-and-paste a Class that is the source of an
> Association, I would also like to copy the Association and to set the
> source of the new Association to be the copy of the Class. I have tried
> overriding ClassItemProvider#createCopyCommand,
> ClassItemProvider#createCreatCopyCommand and even the PasteAction
> contributed by the UMLActionBarContributor to have this side-effect for
> the copy-paste operation, but without much luck. What would be the
> recommended way to have this kind of side effect, and how would the
> command that performs this side-effect get a reference to both the
> original Class and the new Class?
> -------Tim--------
Re: Copy-paste Association as a side-effect when pasting a Class [message #477406 is a reply to message #477386] Tue, 20 May 2008 15:43 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Tim,

Yes, to achieve a "deep" copy like this, you need to include all the desired
elements in the list of things being copied...

Kenn

"Tim Myer" <timezra@gmail.com> wrote in message
news:g0fbue$kc8$1@build.eclipse.org...
>I figured out a way to do this by overriding CopyAction#createCommand. I
>just find all the Associations that use the selected Class as a source and
>add those Associations to the Collection<?> selection parameter. That seems
>to give me the desired behavior but I am not sure how ideal this solution
>is.
> -----Tim------
>
> Tim Myer wrote:
>> Question about a custom UML Editor. Currently, I display Associations as
>> "children" underneath the Classes that are the source ends of the
>> Associations. This containment relationship is not in the model itself
>> (I am using the EMF-generated UML model from the org.eclipse.uml2.uml
>> plug-in). When I copy-and-paste a Class that is the source of an
>> Association, I would also like to copy the Association and to set the
>> source of the new Association to be the copy of the Class. I have tried
>> overriding ClassItemProvider#createCopyCommand,
>> ClassItemProvider#createCreatCopyCommand and even the PasteAction
>> contributed by the UMLActionBarContributor to have this side-effect for
>> the copy-paste operation, but without much luck. What would be the
>> recommended way to have this kind of side effect, and how would the
>> command that performs this side-effect get a reference to both the
>> original Class and the new Class?
>> -------Tim--------
Re: Copy-paste Association as a side-effect when pasting a Class [message #626565 is a reply to message #477381] Wed, 14 May 2008 18:44 Go to previous message
Tim Myer is currently offline Tim MyerFriend
Messages: 81
Registered: July 2009
Member
I figured out a way to do this by overriding CopyAction#createCommand.
I just find all the Associations that use the selected Class as a source
and add those Associations to the Collection<?> selection parameter.
That seems to give me the desired behavior but I am not sure how ideal
this solution is.
-----Tim------

Tim Myer wrote:
> Question about a custom UML Editor. Currently, I display Associations
> as "children" underneath the Classes that are the source ends of the
> Associations. This containment relationship is not in the model itself
> (I am using the EMF-generated UML model from the org.eclipse.uml2.uml
> plug-in). When I copy-and-paste a Class that is the source of an
> Association, I would also like to copy the Association and to set the
> source of the new Association to be the copy of the Class. I have tried
> overriding ClassItemProvider#createCopyCommand,
> ClassItemProvider#createCreatCopyCommand and even the PasteAction
> contributed by the UMLActionBarContributor to have this side-effect for
> the copy-paste operation, but without much luck. What would be the
> recommended way to have this kind of side effect, and how would the
> command that performs this side-effect get a reference to both the
> original Class and the new Class?
> -------Tim--------
Re: Copy-paste Association as a side-effect when pasting a Class [message #626588 is a reply to message #477386] Tue, 20 May 2008 15:43 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
Tim,

Yes, to achieve a "deep" copy like this, you need to include all the desired
elements in the list of things being copied...

Kenn

"Tim Myer" <timezra@gmail.com> wrote in message
news:g0fbue$kc8$1@build.eclipse.org...
>I figured out a way to do this by overriding CopyAction#createCommand. I
>just find all the Associations that use the selected Class as a source and
>add those Associations to the Collection<?> selection parameter. That seems
>to give me the desired behavior but I am not sure how ideal this solution
>is.
> -----Tim------
>
> Tim Myer wrote:
>> Question about a custom UML Editor. Currently, I display Associations as
>> "children" underneath the Classes that are the source ends of the
>> Associations. This containment relationship is not in the model itself
>> (I am using the EMF-generated UML model from the org.eclipse.uml2.uml
>> plug-in). When I copy-and-paste a Class that is the source of an
>> Association, I would also like to copy the Association and to set the
>> source of the new Association to be the copy of the Class. I have tried
>> overriding ClassItemProvider#createCopyCommand,
>> ClassItemProvider#createCreatCopyCommand and even the PasteAction
>> contributed by the UMLActionBarContributor to have this side-effect for
>> the copy-paste operation, but without much luck. What would be the
>> recommended way to have this kind of side effect, and how would the
>> command that performs this side-effect get a reference to both the
>> original Class and the new Class?
>> -------Tim--------
Previous Topic:Re: Programmatically moving Packages within an UML model
Next Topic:Editor shows api generated import twice
Goto Forum:
  


Current Time: Thu Nov 20 21:10:52 GMT 2014

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

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