Copy and Paste in JMatter
Posted by Eitan Suez Tue, 28 Nov 2006 11:52:00 GMT
Every Swing application gets for free the ability to use the underlying platform's copy and paste capabilities when working with JTextFields and JTextAreas.
In JMatter you might have noticed that instances also sport their own Copy/Paste commands. You'll find this feature to be a little more powerful and interesting compared to the basic clipboard copy/paste feature.
The main difference is that unlike the clipboard, where you get one temporary area to copy to, JMatter provides a temporary "buffer" area for every distinct type.
So, for example in the Contact Manager demo application, I can go about and copy an Address here, a Contact object there, or an entire Person instance and all three copies exist in memory simultaneously, each in its own buffer. I can then, say, create a new Person instance and right-click "Paste" on the title view for the new instance. All of the information is copied over. This use case may not be very interesting or real.
But there are other situations. Take for example how a Person has a Contact property modeled using composition (or aggregation). Each instance has its own copy. Yet it's very possible for two persons to have the same contact information, or perhaps the same address, with the very real possibility that the two copies will change/diverge over time.
The copy/paste commands on instances are automatically placed by JMatter in a number of context menus for a number of views. You'll find these commands in the title view's context menu, as shown below.

You'll also find it on aggregate objects' nodes as shown below.

Finally, you'll find it on the context menus for individual tab title views, as shown here:

This is a minor, though useful feature that comes in handy and can save repetitive data entry tasks, where one might otherwise have to invoke copy/paste individually on atomic fields.

