Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 134755 Details for
Bug 97228
[navigation] NLSKeyHyperlink to reveal/goto the key in the properties file editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
New patch using FileBuffers
NLSKeyHyperlink_nonTextEditors_2.patch (text/plain), 5.96 KB, created by
Florian Albrecht
on 2009-05-07 04:30:27 EDT
(
hide
)
Description:
New patch using FileBuffers
Filename:
MIME Type:
Creator:
Florian Albrecht
Created:
2009-05-07 04:30:27 EDT
Size:
5.96 KB
patch
obsolete
>Index: ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java,v >retrieving revision 1.23 >diff -u -r1.23 NLSKeyHyperlink.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java 6 May 2008 09:43:45 -0000 1.23 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java 7 May 2009 08:27:08 -0000 >@@ -12,6 +12,10 @@ > > import org.eclipse.core.runtime.Assert; > >+import org.eclipse.core.filebuffers.FileBuffers; >+import org.eclipse.core.filebuffers.ITextFileBuffer; >+import org.eclipse.core.filebuffers.LocationKind; >+ > import org.eclipse.core.resources.IStorage; > > import org.eclipse.swt.widgets.Display; >@@ -27,9 +31,9 @@ > > import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IFileEditorInput; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.texteditor.IEditorStatusLine; >-import org.eclipse.ui.texteditor.ITextEditor; > > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.dom.ITypeBinding; >@@ -109,58 +113,60 @@ > return; > } > >- // Reveal the key in the properties file >- if (editor instanceof ITextEditor) { >- IRegion region= null; >- boolean found= false; >- >- // Find key in document >- IEditorInput editorInput= editor.getEditorInput(); >- IDocument document= ((ITextEditor)editor).getDocumentProvider().getDocument(editorInput); >- if (document != null) { >- FindReplaceDocumentAdapter finder= new FindReplaceDocumentAdapter(document); >- PropertyKeyHyperlinkDetector detector= new PropertyKeyHyperlinkDetector(); >- detector.setContext(editor); >- String key= PropertyFileDocumentModel.unwindEscapeChars(fKeyName); >- int offset= document.getLength() - 1; >- try { >- while (!found && offset >= 0) { >- region= finder.find(offset, key, false, true, false, false); >- if (region == null) >- offset= -1; >- else { >- // test whether it's the key >- IHyperlink[] hyperlinks= detector.detectHyperlinks(null, region, false); >- if (hyperlinks != null) { >- for (int i= 0; i < hyperlinks.length; i++) { >- IRegion hyperlinkRegion= hyperlinks[i].getHyperlinkRegion(); >- found= key.equals(document.get(hyperlinkRegion.getOffset(), hyperlinkRegion.getLength())); >+ IEditorInput input= editor.getEditorInput(); >+ if (input instanceof IFileEditorInput) { >+ ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer( >+ ((IFileEditorInput)input).getFile().getFullPath(), LocationKind.IFILE); >+ if (buffer != null) { >+ // Find key in document >+ IDocument document= buffer.getDocument(); >+ boolean found= false; >+ IRegion region= null; >+ if (document != null) { >+ FindReplaceDocumentAdapter finder= new FindReplaceDocumentAdapter(document); >+ PropertyKeyHyperlinkDetector detector= new PropertyKeyHyperlinkDetector(); >+ detector.setContext(editor); >+ String key= PropertyFileDocumentModel.unwindEscapeChars(fKeyName); >+ int offset= document.getLength() - 1; >+ try { >+ while (!found && offset >= 0) { >+ region= finder.find(offset, key, false, true, false, false); >+ if (region == null) >+ offset= -1; >+ else { >+ // test whether it's the key >+ IHyperlink[] hyperlinks= detector.detectHyperlinks(null, region, false); >+ if (hyperlinks != null) { >+ for (int i= 0; i < hyperlinks.length; i++) { >+ IRegion hyperlinkRegion= hyperlinks[i].getHyperlinkRegion(); >+ found= key.equals(document.get(hyperlinkRegion.getOffset(), hyperlinkRegion.getLength())); >+ } >+ } else if (document instanceof IDocumentExtension3) { >+ // Fall back: test using properties file partitioning >+ ITypedRegion partition= null; >+ partition= ((IDocumentExtension3)document).getPartition(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, region.getOffset(), false); >+ found= IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) >+ && key.equals(document.get(partition.getOffset(), partition.getLength()).trim()); > } >- } else if (document instanceof IDocumentExtension3) { >- // Fall back: test using properties file partitioning >- ITypedRegion partition= null; >- partition= ((IDocumentExtension3)document).getPartition(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, region.getOffset(), false); >- found= IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) >- && key.equals(document.get(partition.getOffset(), partition.getLength()).trim()); >+ // Prevent endless loop (panic code, shouldn't be needed) >+ if (offset == region.getOffset()) >+ offset= -1; >+ else >+ offset= region.getOffset(); > } >- // Prevent endless loop (panic code, shouldn't be needed) >- if (offset == region.getOffset()) >- offset= -1; >- else >- offset= region.getOffset(); > } >+ } catch (BadLocationException ex) { >+ found= false; >+ } catch (BadPartitioningException e1) { >+ found= false; > } >- } catch (BadLocationException ex) { >- found= false; >- } catch (BadPartitioningException e1) { >- found= false; > } >- } >- if (found) >- EditorUtility.revealInEditor(editor, region); >- else { >- EditorUtility.revealInEditor(editor, 0, 0); >- showErrorInStatusLine(editor, Messages.format(JavaEditorMessages.Editor_OpenPropertiesFile_error_keyNotFound, fKeyName)); >+ if (found) >+ EditorUtility.revealInEditor(editor, region); >+ else { >+ EditorUtility.revealInEditor(editor, 0, 0); >+ showErrorInStatusLine(editor, Messages.format(JavaEditorMessages.Editor_OpenPropertiesFile_error_keyNotFound, fKeyName)); >+ } > } > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 97228
:
134625
|
134755
|
134757
|
134766
|
134937