aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2012-03-07 19:45:14 -0800
committerRaphael <raphael@google.com>2012-03-07 19:45:14 -0800
commit8894233bc9e334d4fcaa129e65170d0ef7d919da (patch)
tree548ac06b596dd7a2efd184b7319c668b351270be /eclipse
parent8fca561846794680e582b2c1416ebda030a90f1a (diff)
downloadsdk-8894233bc9e334d4fcaa129e65170d0ef7d919da.zip
sdk-8894233bc9e334d4fcaa129e65170d0ef7d919da.tar.gz
sdk-8894233bc9e334d4fcaa129e65170d0ef7d919da.tar.bz2
ADT: Use file path to find which editor to use.
In case we don't have any ResourceFolder information when opening a file using the CommonXmlEditor, we can fallback on the foldername to find which delegate to use. Change-Id: Id83f0c70ddfdc81de867cd8489135eaec45aa2c3
Diffstat (limited to 'eclipse')
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java
index 5481456..96ce82b 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/common/CommonXmlEditor.java
@@ -136,10 +136,19 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
ResourceFolder resFolder = ResourceManager.getInstance().getResourceFolder(file);
ResourceFolderType type = resFolder == null ? null : resFolder.getType();
- for (IDelegateCreator creator : DELEGATES) {
- mDelegate = creator.createForFile(this, type);
- if (mDelegate != null) {
- break;
+ if (type == null) {
+ // We lack any real resource information about that file.
+ // Let's take a guess using the actual path.
+ String folderName = AdtUtils.getParentFolderName(editorInput);
+ type = ResourceFolderType.getFolderType(folderName);
+ }
+
+ if (type != null) {
+ for (IDelegateCreator creator : DELEGATES) {
+ mDelegate = creator.createForFile(this, type);
+ if (mDelegate != null) {
+ break;
+ }
}
}
@@ -161,7 +170,7 @@ public class CommonXmlEditor extends AndroidXmlEditor implements IShowEditorInpu
// and IProjects so for now just use a plain XML editor for project-less layout
// files
mDelegate = new OtherXmlEditorDelegate(this);
- } else {
+ } else if (type != null) {
for (IDelegateCreator creator : DELEGATES) {
mDelegate = creator.createForFile(this, type);
if (mDelegate != null) {