Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 357250 - [General] Application reacts different ways when trying to modify a read-only resource
Summary: [General] Application reacts different ways when trying to modify a read-only...
Status: RESOLVED FIXED
Alias: None
Product: Papyrus
Classification: Modeling
Component: Core (show other bugs)
Version: 0.10.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 350910
Blocks: 323802 357254
  Show dependency tree
 
Reported: 2011-09-09 11:23 EDT by Vincent Hémery CLA
Modified: 2014-03-28 05:25 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Hémery CLA 2011-09-09 11:23:20 EDT
When a resource is read-only, it can be opened by Papyrus or loaded in a model as additional resource (like in the cases of Profiles and Sub-models).

When a user tries to modify such a resource, the issue should always be the same.
For the moment, different cases may happen :

- command's execution is tried from the diagram stack, ex : rename from figure :
 A GEF-inherited dialog proposes the user to make the resource writable, or to take the SVN Lock if this case is applicable. In such a case, problem is that the lock is taken on one file only, and not all registered models (notation, di, uml).

- command's execution is tried from the workspace stack, obtained from the transactional editing domain :
 The modification is not performed, but the user receives no warning message.

- command is executed, ex : rename a model element in outline view :
 The modification is temporarily performed on the resource, though the resource itself is read-only. This modification will most probably be lost at file closure.


All these cases should look the same way for the end user.
Modifications must be forbidden if there is no lock, and at least print an understandable warning message, and eventually propose to take the lock on all directly impacted resources.
Comment 1 Vincent Hémery CLA 2011-09-20 11:42:53 EDT
The solution we preconize is to always run operations on the same command stack (instance of org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl).

To achieve this, we should create a DiagramCommandStack which acts like a proxy to the WorkspaceCommandStack.

Then, this proxy command stack would be installed on editors' graphical edit domains thanks to the org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.configureDiagramEditDomain() method.
(overriding method in org.eclipse.papyrus.diagram.common.part.UmlGmfDiagramEditor and in org.eclipse.papyrus.sysml.diagram.parametric.part.SysmlDiagramEditor)

This way, the default diagram command stack is bypassed and all executions are redirected to the WorkspaceCommandStackImpl, which itself delegates it to the operation history.

Hence, users can still execute a command with any command stack or edit(ing) domain they currently use, but behavior and necessary checks are done in every case.



About the lock checks which were performed by the DiagramCommandStack :
They will now be performed by a proxy history, which is installed on the workspace command stack.

The proxy history provides a way to contribute OperationApprover as the default history, but you can manage the order of the approvers using priorities.

Hence, this proxy history performs all necessary checks regarding read-only resources (that all 3 needed resources are writable, that read-only mode is not active...), then either :
- rises an understandable error message and forbides the modification
- execute the correct modification on default history.

With such an extensible mechanism, we will then be able to fully control when a modification is authorized and what the user is told.



For the developper, all these mechanisms are compatible with all way of using a command stack or editing domain. Hence, no further code modification is needed on these usage.


The only forbidden usage will be the direct execution on default history (not to bypass checks performed by proxy history) :
OperationHistoryFactory.getOperationHistory() should no longer be used.
Comment 2 Mathieu Velten CLA 2011-09-29 12:50:45 EDT
work commited on branch, will be ported to trunk tomorrow.

some public documentation is missing (schema and interface), this will be added tomorrow too.
Comment 3 Mathieu Velten CLA 2011-10-12 11:19:08 EDT
the proxy causes problems : post-commit actions needed to create the edit part after a modification of the notation model are called only at the end of the execute of a composite command instead of at each execution of command.
This causes problem with commands that rely on the fact that the edit part are already created when reaching the end of the composite command (CommonDeferredCreateConnectionViewCommand for example).

To fix that I removed the proxy and simply override getOperationHistory of DiagramCommandStack instead :
CheckedOperationHistory is hence used.

I also plug a correct CommandStack which use the OperationHistory on the abstract nat table editor.

Still not backported on trunk, will be done in a few days.
Comment 4 Christian Damus CLA 2014-02-13 08:36:39 EST
What is the status of this bug?  The last comment indicating activity was in 2011 and I see that the CheckedDiagramCommandStack is long since in use on the master branch.  Is it complete?
Comment 5 Christian Damus CLA 2014-02-13 09:02:57 EST
It turns out that the ReadOnlyOneFileApprover, which I am working on in a branch for the dependent bug 323802, has been dormant ever since the org.eclipse.papyrus.commands plug-in was renamed as org.eclipse.papyrus.infra.gmfdiag.commands because the CheckedOperationHistory was still trying to load operation approvers from its extension point using the org.eclipse.papyrus.commands namespace.  Therefore, no approvers are ever found.

I have fixed this in commit b0b8ee5.
Comment 6 Toni Siljamäki CLA 2014-03-06 04:13:14 EST
Has this one been fixed = can be closed?
Comment 7 Camille Letavernier CLA 2014-03-06 04:19:38 EST
> Has this one been fixed = can be closed?

No. The read-only mode implementation is not fully complete yet.
Comment 8 Camille Letavernier CLA 2014-03-28 05:25:33 EDT
Fixed (See Bug 323802)