Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How I can add graphical elements to my file
How I can add graphical elements to my file [message #218881] Sun, 15 February 2009 21:50 Go to next message
Brice Laurel is currently offline Brice LaurelFriend
Messages: 72
Registered: July 2009
Member
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.
Re: How I can add graphical elements to my file [message #218908 is a reply to message #218881] Mon, 16 February 2009 10:27 Go to previous message
Eclipse UserFriend
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.
>
Previous Topic:Node provisionning
Next Topic:Inserting nodes in a compartment
Goto Forum:
  


Current Time: Sat Mar 06 06:05:16 GMT 2021

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

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

Back to the top