[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[gmf-dev] Creating copy of an existing diagram and model file
|
Dear gmf community,
please help me solving a little problem.
I try to open a pre-defined GMF-Diagram and to save this as a copy of it to
another diagram file.
My application under development is RCP-based.
*The unsolved problem*: the xyz.model_diagram contains "href"s to the
xyz.model file. And the copy of xyz still contains hrefs to the original,
template diagram.
Questions:
How do i reorganize all cross references within my gmf resource files ???
How is the model data copied from diagram X to diagram Y when copying the
content of X.model_diagram to Y.model_diagram?
Thx for any help!
Alex
-----------------------------------------------------------------------------------------------------------------------
Here the code snippet:
final Diagram diagramCopy = (Diagram)
EcoreUtil.copy(activeEditor.getDiagram());
final EObject modelCopy = EcoreUtil.copy()
ArrayList<IFile> affectedFiles = new ArrayList<IFile>();
AbstractTransactionalCommand copyCommand = new
AbstractTransactionalCommand(editingDomain, "CopyContent", affectedFiles) {
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info)throws ExecutionException {
diagramCopy.setName(diagramUri.lastSegment());
/* copy the content from the template to new editingDomain */
newDiagramResource.getContents().add(diagramCopy);
/* seems the model data is not copied from the diagram */
/*PseudoCode*/
openDiagram(newDiagramResource);
// results in graphical copy of template but has reference to original
template model. New model is empty.