Bug 6823 - [Edit] Add Goto Line (CTRL-L) to Compare Editor
Summary: [Edit] Add Goto Line (CTRL-L) to Compare Editor
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.3   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 3.5 M3   Edit
Assignee: Tomasz Zarna CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
: 2057 13870 248350 (view as bug list)
Depends on:
Blocks: 169386
  Show dependency tree
 
Reported: 2001-12-11 16:42 EST by Carolyn MacLeod CLA
Modified: 2008-10-14 04:30 EDT (History)
10 users (show)

See Also:


Attachments
Patch v01 (13.67 KB, patch)
2008-10-07 11:31 EDT, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (18.98 KB, application/octet-stream)
2008-10-07 11:31 EDT, Tomasz Zarna CLA
no flags Details
Patch v02 (24.16 KB, patch)
2008-10-08 06:55 EDT, Tomasz Zarna CLA
no flags Details | Diff
Patch v03 (14.66 KB, patch)
2008-10-09 09:59 EDT, Tomasz Zarna CLA
no flags Details | Diff
Patch v04 (16.79 KB, patch)
2008-10-13 06:05 EDT, Tomasz Zarna CLA
no flags Details | Diff
mylyn/context/zip (78.14 KB, application/octet-stream)
2008-10-13 06:05 EDT, Tomasz Zarna CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carolyn MacLeod CLA 2001-12-11 16:42:39 EST
Because patches are line-number based, it would really help if you could tell 
what line number you were looking at in the compare patch browser. If the patch 
can't be lined up properly, the natural thing is to assume that the line 
numbers have changed significantly, and so the first thing you try to do 
is "Find" the .reg file strings in the left (workspace) pane, and figure out 
what line number the patch should really be referring to. (I usually use Goto 
Line... in any text editor to determine what line I am on).

The problem is that the patch compare browser does not have Find... or Goto 
Line...
Comment 1 James Moody CLA 2001-12-11 16:53:11 EST
Moving to Compare.
Comment 2 Andre Weinand CLA 2002-01-23 10:15:21 EST
*** Bug 2057 has been marked as a duplicate of this bug. ***
Comment 3 Andre Weinand CLA 2002-01-23 10:16:40 EST
Every Compare editor should have Find and Goto Line.
Comment 4 Andre Weinand CLA 2002-05-31 05:11:41 EDT
Not for 2.0
Comment 5 Benjamin Pasero CLA 2004-11-29 04:12:37 EST
What about having this in Eclipse 3.1?
Comment 6 Andre Weinand CLA 2004-11-29 04:45:01 EST
Would be cool!
The problem is: we don't want to duplicate gazillion features of the underlying text editors.
So we are reluctant to port anything that exists there over to Compare.
Instead we are working on making editors (or parts in general) better composable.
This would make it possible to compose Compare editors and dialogs/patch dialogs from "real editors" 
and not from low-level widgets as it is done today.
Comment 7 Michael Valenta CLA 2007-04-03 13:09:01 EDT
Find and Line numbers have been added in 3.3 M7. We didn;t add CTRL-L so I'll leave this bug open.
Comment 8 Michael Valenta CLA 2007-04-03 13:10:41 EDT
*** Bug 13870 has been marked as a duplicate of this bug. ***
Comment 9 Tomasz Zarna CLA 2007-07-03 14:02:05 EDT
Michael, I need to kindly ask you for some clues on how to ship Goto Line to Compare Editor. First, I added a keybinding for the compare editor scope context. That was the easiest part.

Due to the fact that CompareEditor is not an instance of ITextEditor I couldn't simply delegate the call to the GotoLineAction (which was my first idea). The second was to rewrite, at least the crucial part, the GotoLineAction so it can be used in Compare project. What made me totally confused was the fact that I have no idea how to get an IDocument of the CompareEditorInput. The IDocument object is need for obtaining the line numbers of the file and for selecting the given line. And I'm not talking only about the fact that the input is made out of two... resources.

The other lead was to figure out how are the line number calculated for the compare editor. This is the connection I found: To make the LineNumberRuler works we need to use a ITextViewer with it. SourceViewer implements ISourceViewer which extends ITextViewer. The MergeSourceViewer class used in CompareEditorInput is a subclass of the SourceViewer class. After discovering that my first thought was that I somehow need to get the MergeSourceViewer object from the CompareEditorInput and then probably I will be able to get the IDocument I've been looking for.

I'm sorry if the above doesn't make any sense to you. The amount of code I've seen trying to figure out how to "bite" the bug overwhelmed me :)
Comment 10 Michael Valenta CLA 2007-07-04 14:33:14 EDT
Dani, is there any chance in getting the GotoLineAction in Workbench/TextEditor pushed down or should we just write our own?

Tomek, the easiest solution would be to add the action in the MergeSoureViewer itself so you would have access to the document. Perhaps you could add it in the MergeSourceViewer#menuaboutToShow method.
Comment 11 Dani Megert CLA 2007-07-05 03:59:39 EDT
>Dani, is there any chance in getting the GotoLineAction in Workbench/TextEditor
>pushed down or should we just write our own?
Do you mean to provide a GotoLineAction for an ITextViewer? All our actions are targeted towards ITextEditor. There are just some very few exceptions like the FindReplaceAction which can also work on an IFindReplaceTarget. I have no lans to do this for Goto Line.

As a workaround you could create an ITextEditor adapter for your source viewer. But that needs some glue code. 

However, that seems to be too much unless you could use that to exploit other text editor actions.

BTW: You might want to look at: 
org.eclipse.ui.console.actions.TextViewerGotoLineAction
Comment 12 Michael Valenta CLA 2007-08-01 10:18:44 EDT
Given that we need to write the action from scratch, we won't have time to get to this in M1.
Comment 13 Szymon Brandys CLA 2008-04-16 08:35:07 EDT
Postponing to 3.5.
Comment 14 Tomasz Zarna CLA 2008-09-24 04:14:00 EDT
*** Bug 248350 has been marked as a duplicate of this bug. ***
Comment 15 Tomasz Zarna CLA 2008-10-07 11:31:19 EDT
Created attachment 114438 [details]
Patch v01

Patch that adds "Go to Line" action to context menu in Compare Editor, the entered line is selected properly despite the fact that it looks like selected lines are decorated differently in TextEditors. The other remaining issue is missing key binding.
Comment 16 Tomasz Zarna CLA 2008-10-07 11:31:35 EDT
Created attachment 114439 [details]
mylyn/context/zip
Comment 17 Dani Megert CLA 2008-10-07 12:50:18 EDT
Did you try the
>As a workaround you could create an ITextEditor adapter for your source viewer.
>But that needs some glue code. 
approach? Given that we might want to add more editor features this might be better i.e. less copied code.
Comment 18 Tomasz Zarna CLA 2008-10-08 06:55:44 EDT
Created attachment 114533 [details]
Patch v02

This is how such adapter could look like. I'm not sure whether implementing ITextEditor is enough here or should I try to use AbstractTextEditor as a base class. Next thing I would like to get rid of are changes in *.properties file. If I could somehow reach EditorMessages and its bundle it would safe us from copy-pasting more code.

The patch still has commented out markInNavigationHistory method, so there is no sign of skiping lines in the navigation history.

The other thing is that if we have in mind adding more Java features to Compare Editor I guess TextEditorAdapter shouldn't be bounded to a single SourceViewer. Instead the adapter should be available from CompareEditor and it should handle multiple SourceViewers.

How does it sound?
Comment 19 Tomasz Zarna CLA 2008-10-08 07:32:37 EDT
(In reply to comment #15)
> Created an attachment (id=114438) [details]
> Patch v01
> 
> (...) The other remaining issue is missing key binding.

Paul, could you give me a helping hand here?

Comment 20 Dani Megert CLA 2008-10-08 08:07:37 EDT
>I'm not sure whether implementing
>ITextEditor is enough here or should I try to use AbstractTextEditor
I wouldn't do this. You have better control if you implement those methods that are needed in the context of the compare viewers.

>Next thing I would like to get rid of are changes in *.properties file.
>If I could somehow reach EditorMessages and its bundle
This won't happen. Message bundles are internal. However, what I could do is offer you a GotoLineAction(ITextEditor editor) that has the strings set.
Comment 21 Tomasz Zarna CLA 2008-10-08 09:52:40 EDT
(In reply to comment #20)
> >Next thing I would like to get rid of are changes in *.properties file.
> >If I could somehow reach EditorMessages and its bundle
> This won't happen. Message bundles are internal. However, what I could do is
> offer you a GotoLineAction(ITextEditor editor) that has the strings set.

This would be great, do you want me to open a bug for it?
Comment 22 Dani Megert CLA 2008-10-08 10:01:40 EDT
>This would be great, do you want me to open a bug for it?
I've already done it for you (it's in HEAD).
Comment 23 Tomasz Zarna CLA 2008-10-09 09:59:13 EDT
Created attachment 114680 [details]
Patch v03

Updated version of the previous patch, uses the new GotoLineAction constructor provided by Dani.
Comment 24 Tomasz Zarna CLA 2008-10-13 06:05:15 EDT
Created attachment 114934 [details]
Patch v04

Finally a working patch! As Paul suggested I activated the Text Editing scope for the Compare Editor to enable Ctrl+L key binding. This works for the Compare Editor only, so I'll open a bug to add Go to Line action for other context as well.
Comment 25 Tomasz Zarna CLA 2008-10-13 06:05:23 EDT
Created attachment 114935 [details]
mylyn/context/zip
Comment 26 Tomasz Zarna CLA 2008-10-13 08:38:56 EDT
On second thought, I'm not so sure if activating "Editing Text" for Compare Editor is the best solution. Compare Editor can be opened not only for text comparisons. This fact makes bug 250624 to rise in importance. The fix for it would probably activate the context for TextMergeViewer not CompareEditor
Comment 27 Tomasz Zarna CLA 2008-10-14 04:30:59 EDT
Latest patch released to HEAD, bug logged bug 250624 (see comment above).