Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 09:43 Go to next message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
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] Wed, 12 April 2017 03:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
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?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Edit: problems with copy and paste containment [message #1759503 is a reply to message #1759492] Wed, 12 April 2017 12:04 Go to previous messageGo to next message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
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 09:05 Go to previous message
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
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: Fri Apr 19 19:35:44 GMT 2024

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

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

Back to the top