Copy-paste Association as a side-effect when pasting a Class [message #477381] |
Wed, 14 May 2008 12:40  |
Eclipse User |
|
|
|
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 11:43  |
Eclipse User |
|
|
|
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 14:44  |
Eclipse User |
|
|
|
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 11:43  |
Eclipse User |
|
|
|
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--------
|
|
|
Powered by
FUDForum. Page generated in 0.04323 seconds