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

Bug 97228

Summary: [navigation] NLSKeyHyperlink to reveal/goto the key in the properties file editor
Product: [Eclipse Project] JDT Reporter: Michael Seele <mseele>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P5 CC: cw.florian.albrecht, daniel_megert, markus.kell.r
Version: 3.1Keywords: helpwanted
Target Milestone: 3.5 RC1Flags: markus.kell.r: review+
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch for using IFindReplaceTarget for non Text Editors
daniel_megert: review-
New patch using FileBuffers
none
Replaces the last patch - copied wrong patch
none
Patch against HEAD and Workspace
none
Patch including HyperlinkDetector again daniel_megert: iplog+

Description Michael Seele CLA 2005-05-30 08:32:05 EDT
if you go to the key in the properties file editor in NLSKeyHyperlink, when the
user klicks on a key in the java editor, you work with "hard coded" code! this
is very bad because plugins like Jinto(which support a own properties file
editor) have no chance to goto the right line in its editor! 
please go over IAdaptable(IGoToMarker???) and let make the editor do its job!!!
Comment 1 Dani Megert CLA 2005-05-30 08:40:47 EDT
There are two thing involved:
- detecting the key in the Java editor
- navigating to it

Can you provide an example of how the key in the Java editor looks like for
Jinto and an example of the properties file.

See also:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-text-home/development/bug-incomplete.htm
Comment 2 Michael Seele CLA 2005-05-30 09:46:02 EDT
Jinto is a plugin for java
internationalization(www.guh-software.de/jinto_en.html) an it's properties
editor is a big table which displays a column for all keys and several columns
for every language.
It's ok that you are detecting the key in the java editor and open the
referenced editor for it. but the navigating to the key in the referenced editor
should be done over a dynamic interface like IAdaptable that i can implement
something into Jinto to step to the matching row in the Jinto editor!
I need the key that i know where i must step to.
Comment 3 Dani Megert CLA 2005-05-30 10:32:47 EDT
It opens whatever editor the user has defined to open the Java properties file.
I guess your editor does not implement ITextEditor? In that case it will not
jump to the right location. This can be changed on our side by:
1. getting the document from the file buffer
2. search the key(s) ==> offset, length
3. use EditorUtility.reveal which will use IGotoMarker or if not implemented,
sends a selection changed event to the editor
Comment 4 Michael Seele CLA 2005-05-31 03:20:54 EDT
yes, i don't implement ITextEditor. but i don't understand you description how i
can do it without implementing ITextEditor!
1) i don't know in which document the user has been clicked on a key
2) i don't know when the user has been clicked on a key
3) the EditorUtility class is a internal class which i dosn't use

can you describe more detailed what you mean!?

where's the problem to implement the "hard coded" code as it should be(dynamic
for every editor)?
Comment 5 Dani Megert CLA 2005-05-31 03:49:28 EDT
You're right, please read comment 3 again ;-) I wrote: "This can be changed on
our side by:..." i.e. *we* have to change our code so that your scenario works.

On your side to support the scenario better you can (if you don't do already)
implement IGotoMarker or offer an adapter:

	public Object getAdapter(Class adapter) {
		if (IGotoMarker.class.equals(adapter))
			return fGotoMarkerAdapter;
		...
	}


If you don't your editor will get a selection changed event.
Comment 6 Michael Seele CLA 2005-05-31 04:22:48 EDT
ah, i see! your seuggestion will be only an workaround until you've changed the
code.
sorry for my wrong reply!
Comment 7 Dani Megert CLA 2005-05-31 04:29:15 EDT
>your seuggestion will be only an workaround
Nope. There's nothing you can do for now except wait.

However, the IGotoMarker tip is a good one anyway since this supports scenarios
where others call IDE.gotoMarker(yourEditor, marker).
Comment 8 Michael Seele CLA 2007-08-09 03:51:14 EDT
do you have any plan's for this bug?
Comment 9 Dani Megert CLA 2007-08-09 03:55:32 EDT
No plans to work on this.
Comment 10 Florian Albrecht CLA 2009-05-06 08:14:52 EDT
We have the same problem: A custom .properties editor which is not text based. Ctrl+Click works (opens the editor), but does not mark the key as the editor does not implement ITextEditor. The suggested solution above would be great and does not seem to be that hard to implement. Do you have an idea when this bug will be fixed?
Comment 11 Dani Megert CLA 2009-05-06 08:17:07 EDT
>Do you have an idea when this bug will be fixed?
When we get a good quality patch.
Comment 12 Florian Albrecht CLA 2009-05-06 10:50:01 EDT
Created attachment 134625 [details]
Patch for using IFindReplaceTarget for non Text Editors

Well, you could do it this way: Using IFindReplaceTarget and IFindReplaceTargetExtension3 to find the key in the editor. The editor would be responsible for providing this extension and has to map a match in the .properties file to its UI. With this patch, it works for us.
Comment 13 Dani Megert CLA 2009-05-06 11:27:51 EDT
Comment on attachment 134625 [details]
Patch for using IFindReplaceTarget for non Text Editors

The patch introduces a requirement i.e. to have a find replace adapter being present.

The fix needs to be crafted along comment 3.
Comment 14 Florian Albrecht CLA 2009-05-07 04:30:27 EDT
Created attachment 134755 [details]
New patch using FileBuffers

OK, now I got the point with the file buffers... I think it could work this way (for us, it does).
Comment 15 Florian Albrecht CLA 2009-05-07 04:38:44 EDT
Comment on attachment 134755 [details]
New patch using FileBuffers

Copy / Paste bug, do not use!
Comment 16 Florian Albrecht CLA 2009-05-07 04:42:52 EDT
Created attachment 134757 [details]
Replaces the last patch - copied wrong patch

Sorry, copied a wrong patch. This one should do it.
Comment 17 Dani Megert CLA 2009-05-07 05:14:01 EDT
I cannot apply the patch (too many conflicts). Please make sure to make the patch against HEAD and select 'Workspace' as patch root (second page of patch wizard).
Comment 18 Florian Albrecht CLA 2009-05-07 06:54:06 EDT
Created attachment 134766 [details]
Patch against HEAD and Workspace
Comment 19 Dani Megert CLA 2009-05-07 11:53:12 EDT
Thanks for the patch Florian. It's almost good. Two issues:

1) please don't remove the code that uses PropertyKeyHyperlinkDetector to check
   the key. Leaving it in shouldn't hurt your sceario.

2) please add your credentials to the copyright notice of each file in the
following form:
name <e-mail> - bugzilla summary - bugzilla URL
e.g.
Dani Megert <dani@eclipse.org> - this is a bug - https://bugs.eclipse.org...
Comment 20 Florian Albrecht CLA 2009-05-08 03:50:00 EDT
Created attachment 134937 [details]
Patch including HyperlinkDetector again

I hope the copyright notice is OK... Haven't done this before ;-)
Comment 21 Dani Megert CLA 2009-05-08 05:30:42 EDT
Committed the patch to head and then made some minor modifications:
1. make sure we connect and disconnect the file buffer
2. use document provider if it is a text editor
3. use adapter to get the IFile (is more generic)
4. refactored the code
Comment 22 Markus Keller CLA 2009-05-08 08:18:51 EDT
Looks good. Filed bug 275447 for API improvement in IFileBufferManager.
Comment 23 Markus Keller CLA 2009-05-15 06:06:20 EDT
Verified in I20090514-2000.