Edit: problems with copy and paste containment [message #1759492] |
Wed, 12 April 2017 05:43  |
Eclipse User |
|
|
|
Hi,
I am having trouble to copy and paste an containment of type ClassB into the container of type ClassA using the standard Edit Commands.
The class structure is like this:
ClassA:
ClassB containmentOne;
ClassB containmentTwo;
When I copy containmentTwo from one object of type ClassA to another object of type ClassA it gets inserted at containmentOne. But it should get inserted at containmentTwo because there it comes from.
Is there any standard solution to solve the issue?
I could of course create two new classes derived from ClassB, e.g. ClassBOne and ClassBTwo and all should work well but may be there is a best practice to overcome the above described issue.
Any hints are appreciated, Martin
|
|
|
|
Re: Edit: problems with copy and paste containment [message #1759503 is a reply to message #1759492] |
Wed, 12 April 2017 08:04   |
Eclipse User |
|
|
|
Hi Ed,
thanks for your answer.
Its just a Tree like this
ClassA
-- ClassB containmentOne
-- ClassB containmentTwo
The Item provider of ClassA handles the displayed text
public String getCreateChildText(Object owner, Object feature, Object child, Collection<?> selection) {
Object childFeature = feature;
Object childObject = child;
boolean qualify =
childFeature == XyzPackage.Literals.CLASS_A__CONATINMENT_ONE ||
childFeature == XyzPackage.Literals.CLASS_A__CONATINMENT_TWO ;
if (qualify) {
return getString
("_UI_CreateChild_text2",
new Object[] { getTypeText(childObject), getFeatureText(childFeature), getTypeText(owner) });
}
return super.getCreateChildText(owner, feature, child, selection);
}
in plugin.properties I modified the value of _UI_CreateChild_text2={1} to display the feature text only.
I thought the copied object may know where it comes from and tries to be copied to the same feature at the new container.
|
|
|
|
Powered by
FUDForum. Page generated in 0.24074 seconds