Bug 508690 - Unable to apply quick fixes in a row
Summary: Unable to apply quick fixes in a row
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 4.1.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2016-12-05 13:22 EST by Thomas Muller CLA
Modified: 2016-12-09 05:56 EST (History)
2 users (show)

See Also:


Attachments
Plugins with demo viewpoint, rule and quickfix (134.09 KB, application/zip)
2016-12-05 13:22 EST, Thomas Muller CLA
no flags Details
A demo project which allows to reproduce the bug (2.23 KB, application/zip)
2016-12-05 13:23 EST, Thomas Muller CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Muller CLA 2016-12-05 13:22:23 EST
Created attachment 265722 [details]
Plugins with demo viewpoint, rule and quickfix

Hi all, 
here is a bug I found:
When having multiple error markers for a given resource, applying a quick fix for it from Sirius doesn't let the possibility to further apply other fixes for other items.

In attachment, plugins to reproduce the bug (with a validation rule which states that the attribute of contained objects shall not be 0), and a demo project.

Steps to reproduce the bug from the demo project:
- Open the existing representation,
- Launch the validation,
- Select one of the two objects with "aproperty" equal to O,
- Apply the quick fix on it,
- Attempt to apply the quick fix on the second object.

The bug occurs there, as the fix seems to be launched without effect.

Note : by launching the validation again one can apply a fix. From outside, it looks like error markers are regenerated when applying the first fixes and somehow they got disconnected from those handled by Sirius...
Comment 1 Thomas Muller CLA 2016-12-05 13:23:23 EST
Created attachment 265723 [details]
A demo project which allows to reproduce the bug
Comment 2 Thomas Muller CLA 2016-12-06 05:50:26 EST
Debugging the second fix attempt, I found that in org.eclipse.sirius.diagram.ui.internal.quickfix.ValidationFixResolution.tryToOpenEditorAndApplyFix() at line 127, "markedView" is null, so no fix is executed and no re-validation is done :

            View markedView = getMarkedView(currentSession, marker); // is null on the second attempt
            if (markedView != null) {
                EObject fixTarget = getFixTarget(markedView);
                if (fixTarget != null) {
                    Diagram diagram = markedView.getDiagram();
                    executeFix(editor, (DDiagram) diagram.getElement(), fixTarget, currentSession.getTransactionalEditingDomain(), offscreenValidation);
                    revalidate(editor, diagram, offscreenValidation);
                }
            }
Comment 3 Thomas Muller CLA 2016-12-06 06:00:33 EST
getMarkedView() mentionned above returns null, as "diagramURI" is null in :
String diagramURI = marker.getAttribute(NavigationMarkerConstants.DIAGRAM_URI, null);
Comment 4 Thomas Muller CLA 2016-12-06 08:53:58 EST
DiagramUri is not set as in ValidateAction.createValidationRuleMarker(...) {
[...]
       // Search diagram URI
        Object object = viewer.getFocusEditPart().getModel();
        String diagramUri = null;
        if (object instanceof Diagram) {
            final URI uri = EcoreUtil.getURI((Diagram) object);
            diagramUri = uri.toString();
        }
The object which has the focus denotes the object which is fixed, and this is not necessarily the diagram.

As the uri is mandatory for further process, the code above should be improved to handle the case where a DNode or such has the focus (i.e. is fixed).
Comment 5 Maxime Porhel CLA 2016-12-09 05:56:42 EST
Hi Thomas, 

Thank you for your detailed bug report and analysis. 
It seems that in some cases, we do not have a Diagram but an other kind of GMF View, we might just need to get the corresponding parentDiagram to be able to put the diagramUri in the marker. We already have the diagramEditPart in the calling method so we could also directly get the diagram with diagramEditPart.getDiagramView();

Note that it's not yet in the scope of a future release.

Regards

Maxime