get access to Diagram from DiagramEditor [message #875502] |
Tue, 22 May 2012 21:33 |
Johnny Qin Messages: 40 Registered: April 2012 |
Member |
|
|
Hello everyone,
I am trying to create a simulation view from Graphiti. No change is necessary or allowed during the simulation. Therefore, I decide to create a simple dedicated editor to handle simulation, which will never be dirty and I want all changes stay in the diagram object in memory (without persist to model).
In eclipse launcher delegate class, launch() uses something like PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() to get the diagram editor object, from Graphiti doc I can see a getDiagram() defined for DiagramEditorInput class, which seems perfect, because I can get access to diagram object by DiagramEditor.getEditorInput().getDiagram().
However, I don't find getDiagram() method in DiagramEditorInput source code. Is it removed? I am using version 0.9
Without this approach, how do I get access to Diagram object from DiagramEditor (without using resource)?
Thanks,
Johnny
|
|
|
|
Re: get access to Diagram from DiagramEditor [message #876047 is a reply to message #875706] |
Wed, 23 May 2012 20:05 |
Johnny Qin Messages: 40 Registered: April 2012 |
Member |
|
|
Thanks a lot, Michael. getDiagram method on diagram editor gave me the Diagram object.
In simulation, what I need is to change color of different shapes programmatically. Therefore, I dig into the Diagram object, find the shapes that I want to change, change it in diagram editor's editing domain.
TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
text.setForeground(highlightColor);
}
});
When I run it, changes are reflected visually. However, I get the following error popup in Eclipse because of java.util.ConcurrentModificationException
(I cannot use link until have posted more than 25 messages, so here's the link of error screenshot, please put http by yourself:)
//dl.dropbox.com/u/6621367/Screen%20Shot%202012-05-23%20at%203.44.36%20PM.png)
Maybe I am not supposed to do this?
Initially I tried to load pictogram model from resource file, updated color in the model, then use unload method to update editor. This way, when it runs, editor keeps reminding dirty status, which destroys the simulation because user is not supposed to hit save button after every graphical change during simulation.
Any idea or recommendations are highly appreciated!
Thanks,
Johnny
[Updated on: Wed, 23 May 2012 20:08] Report message to a moderator
|
|
|
Re: get access to Diagram from DiagramEditor [message #876304 is a reply to message #876047] |
Thu, 24 May 2012 10:46 |
Michael Wenz Messages: 1931 Registered: July 2009 Location: Walldorf, Germany |
Senior Member |
|
|
That should basically be correct. Maybe there's something else. Can you post
the stacktrace of the ConcurrentModificationException?
Another option you have to execute a feature on the editor's command stack
ist the method executeFeature(feature, context) on the DiagramEditor. You
would only need to wrap your functionality into a (Custom-) feature.
Michael
"Johnny Qin" schrieb im Newsbeitrag news:jpjfuk$i4a$1@xxxxxxxxe.org...
Thanks a lot, Michael. getDiagram method on diagram editor gave me the
Diagram object.
In simulation, what I need is to change color of different shapes
programmatically. Therefore, I dig into the Diagram object, find the shapes
that I want to change, change it in diagram editor's editing domain.
TransactionalEditingDomain editingDomain = diagramEditor.getEditingDomain();
editingDomain.getCommandStack().execute(new
RecordingCommand(editingDomain) {
@Override
protected void doExecute() {
text.setForeground(highlightColor);
}
});
When I run it, changes are reflected visually. However, I get the following
error popup in Eclipse because of java.util.ConcurrentModificationException
Maybe I am not supposed to do this?
Initially I tried to load pictogram model from resource file, updated color
in the model, then use unload method to update editor. This way, when it
runs, editor keeps reminding dirty status, which destroys the simulation
because user is not supposed to hit save button after every graphical change
during simulation.
Any idea or recommendations are highly appreciated!
Thanks,
Johnny
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03327 seconds