Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 532244

Summary: Dot Editor: Double clicking on an element in a DOT attribute value selects the entire value
Product: [Tools] GEF Reporter: Zoey Gerrit Prigge <eclipse>
Component: GEF DOTAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: miklossy
Version: unspecified   
Target Milestone: 5.0.100 (Photon) RC1   
Hardware: PC   
OS: Windows 10   
See Also: https://github.com/eclipse/gef/pull/15
https://github.com/eclipse/gef/pull/16
https://github.com/eclipse/gef/pull/17
Whiteboard:

Description Zoey Gerrit Prigge CLA 2018-03-09 09:54:49 EST
If one double clicks on Element, Tag, ... within an HTML-like label in the Dot-Editor, the entire label is selected. From my pov it seems more logical to the user that only the smallest surrounding entity is selected.

As an example:
somenodesname [label=<<table><tr><td align="center">Category</td></tr></table>>, fontname="Helvetica", fontcolor="black", fontsize=10.0];

Double clicking on "center" should only select this.
Comment 1 Tamas Miklossy CLA 2018-03-10 03:45:28 EST
Xtext determines the selected text based on the lexer tokens: https://www.eclipse.org/forums/index.php/t/373244/

From the DOT host grammar point of view, the entire text belonging to the HTML-Like Label is one lexer token. 

The problem could be addressed by customizing the org.eclipse.xtext.ui.editor.doubleClicking.LexerTokenAndCharacterPairAwareStrategy
to delegate the double click calculation to the DOT HTML-Like Label sub-grammar.
Comment 2 Tamas Miklossy CLA 2018-04-14 09:07:30 EDT
The double click calcutor should be improved by providing a general solution for all dot attribute values following a sub-grammar (html-like labels, record-based labels, style...).
Comment 3 Tamas Miklossy CLA 2018-04-14 09:20:43 EDT
I pushed the following changes to origin/master:

[532244] Implement DotEditorDoubleClickingTests test cases.

- Ensure the correct behaviour of element selection when the user double
clicks on an element in the DOT Editor.
- Some of these test cases are ignored, they should be activated as soon
as the DOT Editor double click calculation has been improved.
Comment 4 Zoey Gerrit Prigge CLA 2018-04-27 05:38:13 EDT
Hi Tamás,

Thank you for the help regarding this issue.

I have noticed that not all double click events are handled by the LexerTokenAndCharacterPairAwareStrategy, but that some are handled by FixedCharCountPartitionDoubleClickSelector. The selection of the IDoubleClickStrategy happens in org.eclipse.xtext.ui.editor.doubleClicking.DoubleClickStrategyProvider.

This seems to be problematic because the selections provided by FixedCharCountPartitionDoubleClickSelector are not as they would be expected

We should hence provide a custom implementation of DoubleClickStrategyProvider, I believe.

I will prepare a pull request in due course.
Comment 5 Tamas Miklossy CLA 2018-04-29 06:41:28 EDT
Hello Zoey,

Thanks for the info!

I analyzed the problem and found a bug by mapping the DOT grammar token types to the DOT Editor partitions: the wrong editor partition was assigned to the STRING and QUOTED_STRING token types, that's why the not the proper ITextDoubleclickStrategy was executed and that's why the double clicking text selection cut off elements where it should not and did not cut off the elements where it should. I fixed that mapping in the master branch with the following commit:

[532244] Improve Dot Editor text double clicking behaviour.

- Add a custom ITokenTypeToPartitionTypeMapper implementation with the
corresponding binding in the DotUiModule to ensure that the right
ITextDoubleClickStrategy is selected by the DoubleClickStrategyProvider.
- Implement corresponding DotEditorDoubleClickingTests,
DotTokenTypeToPartitionMapperTests and
DotHtmlLabelTokenTypeToPartitionMapperTests test cases.

Now the double click selection should work properly everywhere except the HTML-like label texts. That use case still needs to be adjusted.
Comment 6 Eclipse Genie CLA 2018-05-04 05:51:16 EDT
GitHub Pull Request 15 created by [prggz]
https://github.com/eclipse/gef/pull/15
Comment 7 Zoey Gerrit Prigge CLA 2018-05-04 05:54:41 EDT
Hi Tamás, 
Thanks for the help with finding the bug. 
I provided a push request (#15) implementing further test cases.

I removed the HTML like label test cases which will still need to be looked into.
Comment 8 Tamas Miklossy CLA 2018-05-04 06:03:32 EDT
Thanks for your contribution, Zoey! I merged your Pull Request into GEF master.
Comment 9 Eclipse Genie CLA 2018-05-17 09:49:51 EDT
GitHub Pull Request 16 created by [prggz]
https://github.com/eclipse/gef/pull/16
Comment 10 Zoey Gerrit Prigge CLA 2018-05-17 09:54:10 EDT
I have provided a pull request (#16) dealing with double clicking support for HTML labels.

The corresponding test cases are reintegrated and expanded to a comprehensive covering.

Imho, once the request is merged, this bug can be closed.
Comment 11 Eclipse Genie CLA 2018-05-18 03:41:03 EDT
GitHub Pull Request 17 created by [prggz]
https://github.com/eclipse/gef/pull/17
Comment 12 Tamas Miklossy CLA 2018-05-18 04:23:26 EDT
Thanks for your contribution, Zoey! I merged all your Pull Requests into GEF master.

Resolving as fixed in 5.0.100 (Photon) RC1.