Incorrect behaviour of DiagramEditorBehavior when two instances of editor share same editing domain [message #689991] |
Tue, 28 June 2011 13:43  |
Eclipse User |
|
|
|
Hello, I would like to ask you for help with this problem:
My custom editor use Graphiti to edit data. If multiple instances of editor edit data from same file, they share editing domain where is file Resource.
I open two instances of graphiti editor (for example E1 and E2), both of them share same editing domain and edit EObjects from same Resource.
Problem occurs when org.eclipse.graphiti.ui.internal.editor.DiagramEditorBehavior.handleChangedResources() is called. It can be because one of the editors saved data or external change on resource was detected. Until here, it's fine.
After that every time I switch focus from E1 editor to E2, focused editor always refreshes whole content as it thinks its resource has changed. But while refreshing, it set second editor resource changed flag to true. So every time focus is switched between those 2 editors, newly focused editor calls "handleChangedResources()" and refreshes.
This is not good, and even worse it's when I make some changes to data in editor, because after that editor asks to discard those changes and reloads resource.
I found out that this behaviour is caused by this code in
org.eclipse.graphiti.ui.internal.editor.DiagramEditorBehavior
Every time resource change is detected, resources are unloaded.
from line 376:
private void handleChangedResources() {
if (!isDirty() || handleDirtyConflict()) {
getOperationHistory().dispose(getUndoContext(), true, true, true);
updateProblemIndication = false;
//Disable adapter temporarily.
setAdapterActive(false);
try {
// We unload our resources such that refreshEditorContent does a complete diagram refresh.
EList<Resource> resources = getEditingDomain().getResourceSet().getResources();
for (Resource resource : resources) {
resource.unload();
}
Every time resource unload is detected, resource change flag is set to true.
from line 268:
if (msg.getFeatureID(Resource.class) == Resource.RESOURCE__IS_LOADED) {
if (msg.getNewBooleanValue() == Boolean.FALSE) {
final Resource resource = (Resource) msg.getNotifier();
final URI uri = resource.getURI();
if (editingDomain.getResourceSet().getURIConverter().exists(uri, null)) {
// file content has changes
setResourceChanged(true);
----------
This all is fine until only one editor is active because "setAdapterActive(false);" handles it for one editor.
But when multiple instances of editor are running over same data, adapter for another editor is not disabled, so unloading and seting resourceChangedFlag continues in infinite loop.
E1:handleChangedResources() calls unload on Resource, it leads to calling E2:setResourceChanged(true). After focusing to E2,
E2:handleChangedResources() and so on.
I thought about using own implementation of DiagramEditorBehavior, but it's not possible because DiagramEditorBehavior is hardcoded to Graphiti internals.
Is there anyone who can help with solving this issue?
Is it bug in graphiti or am I doing something wrong?
I use Graphiti 0.8.0, final version.
|
|
|
|
|
|
|
|
|
Re: Incorrect behaviour of DiagramEditorBehavior when two instances of editor share same editing dom [message #690941 is a reply to message #690769] |
Thu, 30 June 2011 08:52  |
Eclipse User |
|
|
|
You might open an enhancement request in bugzilla for supporting shared
editing domains.
Since the shared editing domain setup is currently not really supported by
Graphiti,
my idea for a workaround would be to save the model file after a feature
modifies the model.
So if you just modify the visuals, e.g. MoveFeature (which you would not
want to be reflected in the sibling diagram, i guess?) you would
do as before. If you execute a feature which modifies existing model
elements you might do a save of your model file as post-op.
Does this work for you?
|
|
|
Powered by
FUDForum. Page generated in 0.04982 seconds