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--------

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--------

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--------

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--------

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--------