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 134766 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]
Patch against HEAD and Workspace
NLSKeyHyperlink_nonTextEditor_3.patch (text/plain), 6.27 KB, created by
Florian Albrecht
on 2009-05-07 06:54:06 EDT
(
hide
)
Description:
Patch against HEAD and Workspace
Filename:
MIME Type:
Creator:
Florian Albrecht
Created:
2009-05-07 06:54:06 EDT
Size:
6.27 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >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.26 >diff -u -r1.26 NLSKeyHyperlink.java >--- ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java 13 Mar 2009 18:26:39 -0000 1.26 >+++ ui/org/eclipse/jdt/internal/ui/javaeditor/NLSKeyHyperlink.java 7 May 2009 10:53:34 -0000 >@@ -10,12 +10,17 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.ui.javaeditor; > >-import org.eclipse.swt.widgets.Display; >- > import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IPath; >+ >+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; >+ > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.BadPartitioningException; > import org.eclipse.jface.text.FindReplaceDocumentAdapter; >@@ -27,10 +32,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; >@@ -42,7 +46,6 @@ > import org.eclipse.jdt.internal.corext.util.Messages; > > import org.eclipse.jdt.internal.ui.propertiesfileeditor.IPropertiesFilePartitions; >-import org.eclipse.jdt.internal.ui.propertiesfileeditor.PropertyKeyHyperlinkDetector; > import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; > > >@@ -121,58 +124,54 @@ > 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(keyName); >- 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())); >+ // Reveal the key in the editor >+ IEditorInput input = editor.getEditorInput(); >+ if (input instanceof IFileEditorInput) { >+ IPath path= ((IFileEditorInput)input).getFile().getFullPath(); >+ ITextFileBuffer buffer= FileBuffers.getTextFileBufferManager().getTextFileBuffer( >+ path, 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); >+ String key= PropertyFileDocumentModel.unwindEscapeChars(keyName); >+ 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 >+ if (document instanceof IDocumentExtension3) { >+ // 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, keyName)); >+ if (found) >+ EditorUtility.revealInEditor(editor, region); >+ else { >+ EditorUtility.revealInEditor(editor, 0, 0); >+ showErrorInStatusLine(editor, Messages.format(JavaEditorMessages.Editor_OpenPropertiesFile_error_keyNotFound, keyName)); >+ } > } > } > }
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