|Modify palette tool to copy existing resource [message #207425]
||Tue, 30 September 2008 07:38
| Daniel Taylor
Registered: July 2009
Here's a short explanation of what I'm trying to do:
In my EMF domain, the top level diagram is a Component, which has an
EReference that is a list of components, so you can have components inside
components, etc. They also have other attributes, but that's not
important for now.
What I would like is for all top level Components in the project to be
available to the user in the palette, so they can drop in a component
they've already created in a different diagram into the current one. For
example, a user can make a new diagram and define component A, another new
diagram and define component B, then they can make a new diagram called
component C, and components A and B will be available in the palette to
create as subcomponents. I want it to be a deep copy, and have no
references to the object it was copied from, but just to copy it's
structure and attributes and deep copy the references exactly.
Here's what I've done so far:
I have modified my generated diagram and palette factory so that the
palette factory gets a map of all top level components in the project
(name, IPath to the resource). I know how to access the EMF model with
The strategy I tried to use (which didn't work) is to make a custom
creation tool (I made a copy of
org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool) and I send it the
type I'm creating (Component) and the IPath to the resource I want to
copy. Then, in performCreation(), I attempted to add a method that goes
through the result of the compound creation command (I don't understand
exactly what that does, and that's part of my problem) and modify the
editPart's model element directly.
This didn't work, and I figure it's pretty obvious this isn't the right
way to do it. So what approach should I use to essentially make a copy of
the resource at the given IPath into the current diagram?
Please let me know if any part of my description is not clear. I
appreciate your advice.
Powered by FUDForum
. Page generated in 0.02141 seconds