From dcd506c6482e7476941a6d4c14b6dd5eb51c85f9 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Tue, 29 May 2012 17:02:24 -0700 Subject: 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 --- .../internal/editors/layout/LayoutEditorMatchingStrategy.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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()); } -- cgit v1.1