diff options
author | Tor Norbye <tnorbye@google.com> | 2012-05-29 17:02:24 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-05-29 17:02:24 -0700 |
commit | dcd506c6482e7476941a6d4c14b6dd5eb51c85f9 (patch) | |
tree | 7266523839a2a3b4521d1c1ae7e8d839f56b6935 | |
parent | 245b95e899777b68ab280d9600571d74ebd7de3f (diff) | |
download | sdk-dcd506c6482e7476941a6d4c14b6dd5eb51c85f9.zip sdk-dcd506c6482e7476941a6d4c14b6dd5eb51c85f9.tar.gz sdk-dcd506c6482e7476941a6d4c14b6dd5eb51c85f9.tar.bz2 |
Fix LayoutEditorMatchingStrategy to handle non-layout files
If you have both res/menu/main.xml and res/layout/main.xml, and the
menu file is open, then double clicking on the layout file would *not*
open up the layout. There was a bug in LayoutEditorMatchingStrategy
which meant that it only considered the project and base names of the
files, not whether the existing editor represented a layout file.
Change-Id: Idaf7c1b145b60510f4913896d7d0b2162744a399
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorMatchingStrategy.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorMatchingStrategy.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorMatchingStrategy.java index 6a6b99c..4ea49f9 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorMatchingStrategy.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/LayoutEditorMatchingStrategy.java @@ -42,7 +42,8 @@ public class LayoutEditorMatchingStrategy implements IEditorMatchingStrategy { // get the IFile object and check it's in one of the layout folders. IFile iFile = fileInput.getFile(); - ResourceFolder resFolder = ResourceManager.getInstance().getResourceFolder(iFile); + ResourceManager manager = ResourceManager.getInstance(); + ResourceFolder resFolder = manager.getResourceFolder(iFile); // Per the IEditorMatchingStrategy documentation, editorRef.getEditorInput() // is expensive so try exclude files that definitely don't match, such @@ -61,6 +62,12 @@ public class LayoutEditorMatchingStrategy implements IEditorMatchingStrategy { FileEditorInput editorFileInput = (FileEditorInput)editorInput; IFile editorIFile = editorFileInput.getFile(); + ResourceFolder editorFolder = manager.getResourceFolder(editorIFile); + if (editorFolder == null + || editorFolder.getType() != ResourceFolderType.LAYOUT) { + return false; + } + return editorIFile.getProject().equals(iFile.getProject()) && editorIFile.getName().equals(iFile.getName()); } |