aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml53
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java49
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/binaryxml/BinaryXMLDescriber.java31
3 files changed, 97 insertions, 36 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
index 62db218..168c54c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml
@@ -484,6 +484,9 @@
icon="icons/android_file.png"
id="com.android.ide.eclipse.editors.manifest.ManifestEditor"
name="Android Manifest Editor">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.core.runtime.xml">
+ </contentTypeBinding>
</editor>
<editor
class="com.android.ide.eclipse.adt.internal.editors.export.ExportEditor"
@@ -492,6 +495,9 @@
icon="icons/android_file.png"
id="com.android.ide.eclipse.editors.export.ExportEditor"
name="Android Export Editor">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.core.runtime.xml">
+ </contentTypeBinding>
</editor>
<editor
class="com.android.ide.eclipse.adt.internal.editors.resources.ResourcesEditor"
@@ -500,6 +506,9 @@
icon="icons/android_file.png"
id="com.android.ide.eclipse.editors.resources.ResourcesEditor"
name="Android Resource Editor">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.core.runtime.xml">
+ </contentTypeBinding>
</editor>
<editor
class="com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor"
@@ -510,6 +519,9 @@
id="com.android.ide.eclipse.editors.layout.LayoutEditor"
matchingStrategy="com.android.ide.eclipse.adt.internal.editors.layout.MatchingStrategy"
name="Android Layout Editor">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.core.runtime.xml">
+ </contentTypeBinding>
</editor>
<editor
class="com.android.ide.eclipse.adt.internal.editors.menu.MenuEditor"
@@ -518,6 +530,9 @@
icon="icons/android_file.png"
id="com.android.ide.eclipse.editors.menu.MenuEditor"
name="Android Menu Editor">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.core.runtime.xml">
+ </contentTypeBinding>
</editor>
<editor
class="com.android.ide.eclipse.adt.internal.editors.xml.XmlEditor"
@@ -526,6 +541,20 @@
icon="icons/android_file.png"
id="com.android.ide.eclipse.editors.xml.XmlEditor"
name="Android Xml Resources Editor">
+ <contentTypeBinding
+ contentTypeId="org.eclipse.core.runtime.xml">
+ </contentTypeBinding>
+ </editor>
+ <editor
+ class="com.android.ide.eclipse.adt.internal.editors.binaryxml.BinaryXMLMultiPageEditorPart"
+ contributorClass="org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorActionBarContributor"
+ icon="$nl$/icons/android_file.png"
+ id="com.android.ide.eclipse.adt.binedit.BinaryXMLMultiPageEditorPart"
+ name="Android Binary XML editor"
+ symbolicFontName="org.eclipse.wst.sse.ui.textfont">
+ <contentTypeBinding
+ contentTypeId="com.android.ide.eclipse.adt.binaryXml">
+ </contentTypeBinding>
</editor>
</extension>
<extension
@@ -987,24 +1016,12 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
</extension>
<extension point="org.eclipse.core.contenttype.contentTypes">
- <content-type id="com.android.ide.eclipse.adt.binaryXml" name="Android Binary XML"
- priority="high"
- file-extensions="xml">
- <describer
- class="com.android.ide.eclipse.adt.internal.editors.binaryxml.BinaryXMLDescriber">
- </describer>
+ <content-type
+ describer="com.android.ide.eclipse.adt.internal.editors.binaryxml.BinaryXMLDescriber"
+ file-extensions="xml"
+ id="com.android.ide.eclipse.adt.binaryXml"
+ name="Android Binary XML"
+ priority="high">
</content-type>
</extension>
- <extension point="org.eclipse.ui.editors">
- <editor
- name="Android Binary XML editor"
- icon="$nl$/icons/android_file.png"
- contributorClass="org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorActionBarContributor"
- class="com.android.ide.eclipse.adt.internal.editors.binaryxml.BinaryXMLMultiPageEditorPart"
- symbolicFontName="org.eclipse.wst.sse.ui.textfont"
- id="com.android.ide.eclipse.adt.binedit.BinaryXMLMultiPageEditorPart">
- <contentTypeBinding
- contentTypeId="com.android.ide.eclipse.adt.binaryXml" />
- </editor>
- </extension>
</plugin>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
index 87a59d9..4ceacfa 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlEditor.java
@@ -604,6 +604,38 @@ public abstract class AndroidXmlEditor extends FormEditor implements IResourceCh
*/
private void createTextEditor() {
try {
+ if (AdtPlugin.DEBUG_XML_FILE_INIT) {
+ AdtPlugin.log(
+ IStatus.ERROR,
+ "%s.createTextEditor: input=%s %s",
+ this.getClass(),
+ getEditorInput() == null ? "null" : getEditorInput().getClass(),
+ getEditorInput() == null ? "null" : getEditorInput().toString()
+ );
+
+ org.eclipse.core.runtime.IAdaptable adaptable= (org.eclipse.core.runtime.IAdaptable) getEditorInput();
+ IFile file1 = (IFile)adaptable.getAdapter(IFile.class);
+ org.eclipse.core.runtime.IPath location= file1.getFullPath();
+ org.eclipse.core.resources.IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
+ IFile file2 = workspaceRoot.getFile(location);
+
+ try {
+ org.eclipse.core.runtime.content.IContentDescription desc = file2.getContentDescription();
+ org.eclipse.core.runtime.content.IContentType type = desc.getContentType();
+
+ AdtPlugin.log(IStatus.ERROR,
+ "file %s description %s %s; contentType %s %s",
+ file2,
+ desc == null ? "null" : desc.getClass(),
+ desc == null ? "null" : desc.toString(),
+ type == null ? "null" : type.getClass(),
+ type == null ? "null" : type.toString());
+
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
mTextEditor = new StructuredTextEditor();
int index = addPage(mTextEditor, getEditorInput());
mTextPageIndex = index;
@@ -611,15 +643,16 @@ public abstract class AndroidXmlEditor extends FormEditor implements IResourceCh
setPageImage(index,
IconFactory.getInstance().getIcon("editor_page_source")); //$NON-NLS-1$
+ if (AdtPlugin.DEBUG_XML_FILE_INIT) {
+ AdtPlugin.log(IStatus.ERROR, "Found document class: %1$s, file=%2$s",
+ mTextEditor.getTextViewer().getDocument() != null ?
+ mTextEditor.getTextViewer().getDocument().getClass() :
+ "null",
+ getEditorInput()
+ );
+ }
+
if (!(mTextEditor.getTextViewer().getDocument() instanceof IStructuredDocument)) {
- if (AdtPlugin.DEBUG_XML_FILE_INIT) {
- AdtPlugin.log(IStatus.ERROR, "Unexpected document class: %1$s, file=%2$s",
- mTextEditor.getTextViewer().getDocument() != null ?
- mTextEditor.getTextViewer().getDocument().getClass() :
- "null",
- getEditorInput()
- );
- }
Status status = new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
"Error opening the Android XML editor. Is the document an XML file?");
throw new RuntimeException("Android XML Editor Error", new CoreException(status));
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/binaryxml/BinaryXMLDescriber.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/binaryxml/BinaryXMLDescriber.java
index 846eb44..ba78565 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/binaryxml/BinaryXMLDescriber.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/binaryxml/BinaryXMLDescriber.java
@@ -16,6 +16,9 @@
package com.android.ide.eclipse.adt.internal.editors.binaryxml;
+import com.android.ide.eclipse.adt.AdtPlugin;
+
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.content.IContentDescriber;
import org.eclipse.core.runtime.content.IContentDescription;
@@ -50,20 +53,28 @@ public class BinaryXMLDescriber implements IContentDescriber {
* InputStream, org.eclipse.core.runtime.content.IContentDescription)
*/
public int describe(InputStream contents, IContentDescription description) throws IOException {
+ int status = INVALID;
int length = 8;
byte[] bytes = new byte[length];
- if (contents.read(bytes, 0, length) != length) {
- return INVALID;
+ if (contents.read(bytes, 0, length) == length) {
+ ByteBuffer buf = ByteBuffer.wrap(bytes);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+ short type = buf.getShort();
+ short headerSize = buf.getShort();
+ int size = buf.getInt(); // chunk size
+ if (AdtPlugin.DEBUG_XML_FILE_INIT) {
+ AdtPlugin.log(IStatus.ERROR, "BinaryXML: type 0x%04x, headerSize 0x%04x, size 0x%08x", type, headerSize, size);
+ }
+ if (type == RES_XML_TYPE && headerSize == RES_XML_HEADER_SIZE) {
+ status = VALID;
+ }
}
- ByteBuffer buf = ByteBuffer.wrap(bytes);
- buf.order(ByteOrder.LITTLE_ENDIAN);
- short type = buf.getShort();
- short headerSize = buf.getShort();
- buf.getInt(); // chunk size
- if (type == RES_XML_TYPE && headerSize == RES_XML_HEADER_SIZE) {
- return VALID;
+ if (AdtPlugin.DEBUG_XML_FILE_INIT) {
+ AdtPlugin.log(IStatus.ERROR, "BinaryXML status: %d (%s)",
+ status,
+ status == VALID ? "VALID" : "INVALID");
}
- return INVALID;
+ return status;
}
/*