|
Re: How I can add graphical elements to my file [message #218908 is a reply to message #218881] |
Mon, 16 February 2009 10:27 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Hi Brice,
I think you should use MindMapFactory.eINSTANCE.createTopic();
And then you need a AbstractTransactionalCommand to add the Topic
persistent to the Map. At the place where I put <thisMap> you have to
find the Map, which contains all Topics, Relations etc. This depends on
where you create the Topic.
Topic newTopic = (Topic)MindMapFactory.eINSTANCE.createTopic();
TransactionalEditingDomain editingDomain =
((MindmapDiagramEditor)getPart()).getEditingDomain();
AbstractTransactionalCommand cmd = new
AbstractTransactionalCommand(editingDomain, "create topic", null, null)
{
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException
{
<thisMap>.getRootTopics().add(newTopic);
return CommandResult.newOKCommandResult();
}
};
try
{
OperationHistoryFactory.getOperationHistory().execute(cmd, new
NullProgressMonitor(), null);
}
catch (Throwable t)
{
System.err.println(t.toString());
}
I think this should work.
Best wishes
Julia
Brice Laurel schrieb:
> Hi list,
>
> I read and do this tutorial
> http://wiki.eclipse.org/index.php/GMF_Tutorial. I have the figure with 3
> topics :
> - a topic ;
> - a subtopic ;
> - another subtopic.
> Now, I want to add another topic in my figure programmatically.
> I create a plugin's project that allow me to add a figure to file
> "default.mindmap_diagram" programmatically. I think I can use the code
> MindMapFactory.eINSTANCE.create(Topic); am I wrong?
> I don't see when the link between this instruction with file
> "default.mindmap_diagram"?
>
> Thanks in advance for your help.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03123 seconds