Skip to main content



      Home
Home » Modeling » EMF » Edit: problems with copy and paste containment(problems with copy and paste containment of container having multiple containments of same type)
Edit: problems with copy and paste containment [message #1759492] Wed, 12 April 2017 05:43 Go to next message
Eclipse UserFriend
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 #1759502 is a reply to message #1759492] Tue, 11 April 2017 23:29 Go to previous messageGo to next message
Eclipse UserFriend
No, there's no standard solution. Of course the copy is just a copy without a container so it doesn't know what the container was and hence what the preferred place it should be contained might be, given there is more than one choice where it can be contained.

I wonder how the user can tell visually which of the two features of A contain the B?
Re: Edit: problems with copy and paste containment [message #1759503 is a reply to message #1759492] Wed, 12 April 2017 08:04 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Edit: problems with copy and paste containment [message #1759568 is a reply to message #1759503] Thu, 13 April 2017 05:05 Go to previous message
Eclipse UserFriend
Solution:

Create two new classes derived from ClassB, e.g. ClassBOne and ClassBTwo and copy and paste works well.

Previous Topic:NPE while eSetting eContainingClass
Next Topic:[Teneo] Teneo 2.1, Hibernate 4, Tomcat 8
Goto Forum:
  


Current Time: Wed Jul 23 15:14:49 EDT 2025

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

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

Back to the top