Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348468 - XMLMultiPageEditorPart should implement INavigationLocationProvider for proper back button support
Summary: XMLMultiPageEditorPart should implement INavigationLocationProvider for prope...
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.3.1   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-06 16:06 EDT by Peter Hendriks CLA
Modified: 2011-06-09 11:42 EDT (History)
0 users

See Also:


Attachments
patch (14.98 KB, patch)
2011-06-07 17:26 EDT, Nick Sandonato CLA
no flags Details | Diff
patch (15.04 KB, patch)
2011-06-08 10:54 EDT, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Hendriks CLA 2011-06-06 16:06:05 EDT
Build Identifier: Eclipse 3.6.2

The default XML editor in Web Tools: org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart does not implement org.eclipse.ui.INavigationLocationProvider. This means that no detailed location information is recorded when org.eclipse.ui.INavigationHistory.markLocation(IEditorPart part) is called, or can be retrieved when the navigation history is navigated (The NavigationHistoryEntry.restoreLocation() method needs the provider interface as well).

The effect of not implementing this interface is that text position is not preserved when recording history in XML editors. This is annoying and breaks the fluid Alt+Left navigation at seemingly odd moments, especially within files. Users expect this to work similarly to e.g. Java editors.

The solution would be to implement the interface on the multipageditorpart and delegate to the text editor for the implementation. The org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor would serve as an example, as this does contain this solution already.

Reproducible: Always

Steps to Reproduce:
1. Be sure that the "Java element" in "XML Editors" is enabled in the "General > Editors> Text Editors > Hyperlinks" workspace preferences.
2. Type some xml in foo.xml file that contains a Java reference, e.g. <element foo="java.lang.String" />
3. Hover and hold Ctrl to activate the hyperlink and navigate to the Java definition.
4. Select the foo.xml editor and change the selection.
5. Select the String editor and press Alt+Left to trigger navigating the history.
6. Observe that history selection is not correctly restored and the caret stays on the modified position, instead of moving to the historic location when navigating away to String.
7. Observe that while performing similar operations on two Java files, the caret is moved to the correct position.

Especially in larger files, this is problematic. I am currently adding my own hyperlink detector that navigates to nodes in the same XML document, and then this becomes even more apparent (Alt+Left does not do anything anymore).
Comment 1 Nick Sandonato CLA 2011-06-07 17:26:30 EDT
Created attachment 197545 [details]
patch
Comment 2 Nitin Dahyabhai CLA 2011-06-07 18:42:18 EDT
> Object first = ((StructuredSelection) selection).getFirstElement();
(Almost) Never do this; use IStructuredSelection instead.
Comment 3 Nick Sandonato CLA 2011-06-08 10:54:16 EDT
Created attachment 197609 [details]
patch

Nice catch, Nitin.
Comment 4 Nick Sandonato CLA 2011-06-09 11:42:27 EDT
Changes checked in.