aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse/plugins
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2011-04-18 16:16:07 -0700
committerXavier Ducrohet <xav@android.com>2011-04-20 14:34:17 -0700
commit762f91d9f7f49b6e3dba4d47243f641967f934a9 (patch)
tree399fa03b24ddef0c930df6815ef8eb2716326ba6 /eclipse/plugins
parent43f3d9d16316fdf510425a67c26c15d681c3c400 (diff)
downloadsdk-762f91d9f7f49b6e3dba4d47243f641967f934a9.zip
sdk-762f91d9f7f49b6e3dba4d47243f641967f934a9.tar.gz
sdk-762f91d9f7f49b6e3dba4d47243f641967f934a9.tar.bz2
Move getParser(name) into IProjectCallback.
Change-Id: I316f03a9903e90eac0cb8059469c1de5b679dac5
Diffstat (limited to 'eclipse/plugins')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ContextPullParser.java21
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java18
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java4
4 files changed, 38 insertions, 12 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ContextPullParser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ContextPullParser.java
index d8911e4..7c40097 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ContextPullParser.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ContextPullParser.java
@@ -22,6 +22,8 @@ import static com.android.ide.common.layout.LayoutConstants.VALUE_FILL_PARENT;
import static com.android.ide.common.layout.LayoutConstants.VALUE_MATCH_PARENT;
import com.android.ide.common.rendering.api.ILayoutPullParser;
+import com.android.ide.common.rendering.api.IProjectCallback;
+import com.android.layoutlib.api.IXmlPullParser;
import com.android.sdklib.SdkConstants;
import org.kxml2.io.KXmlParser;
@@ -35,23 +37,22 @@ import org.kxml2.io.KXmlParser;
*/
public class ContextPullParser extends KXmlParser implements ILayoutPullParser {
- private final String mName;
- private final ILayoutPullParser mEmbeddedParser;
+ private final IProjectCallback mProjectCallback;
- public ContextPullParser(String name, ILayoutPullParser embeddedParser) {
+ public ContextPullParser(IProjectCallback projectCallback) {
super();
- mName = name;
- mEmbeddedParser = embeddedParser;
+ mProjectCallback = projectCallback;
}
// --- Layout lib API methods
+ /**
+ * this is deprecated but must still be implemented for older layout libraries.
+ * @deprecated use {@link IProjectCallback#getParser(String)}.
+ */
+ @Deprecated
public ILayoutPullParser getParser(String layoutName) {
- if (mName.equals(layoutName)) {
- return mEmbeddedParser;
- }
-
- return null;
+ return mProjectCallback.getParser(layoutName);
}
public Object getViewCookie() {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java
index 1a924a9..8d3eaf9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java
@@ -24,6 +24,7 @@ import static com.android.ide.common.layout.LayoutConstants.LIST_VIEW;
import com.android.ide.common.rendering.LayoutLibrary;
import com.android.ide.common.rendering.api.AdapterBinding;
import com.android.ide.common.rendering.api.DataBindingItem;
+import com.android.ide.common.rendering.api.ILayoutPullParser;
import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.ResourceReference;
@@ -66,6 +67,10 @@ public final class ProjectCallback extends LegacyCallback {
private LayoutLog mLogger;
private LayoutLibrary mLayoutLib;
+ private String mLayoutName;
+ private ILayoutPullParser mLayoutEmbeddedParser;
+
+
/**
* Creates a new {@link ProjectCallback} to be used with the layout lib.
*
@@ -350,6 +355,19 @@ public final class ProjectCallback extends LegacyCallback {
return constructor.newInstance(constructorParameters);
}
+ public void setLayoutParser(String layoutName, ILayoutPullParser layoutParser) {
+ mLayoutName = layoutName;
+ mLayoutEmbeddedParser = layoutParser;
+ }
+
+ public ILayoutPullParser getParser(String layoutName) {
+ if (layoutName.equals(mLayoutName)) {
+ return mLayoutEmbeddedParser;
+ }
+
+ return null;
+ }
+
public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
ResourceReference itemRef,
int fullPosition, int typePosition, int fullChildPosition, int typeChildPosition,
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
index 6592fa2..337ad5c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
@@ -1433,9 +1433,11 @@ public class GraphicalEditorPart extends EditorPart
ILayoutPullParser topParser = modelParser;
// Code to support editing included layout
+ // first reset the layout parser just in case.
+ mProjectCallback.setLayoutParser(null, null);
- // Outer layout name:
if (includeWithin != null) {
+ // Outer layout name:
String contextLayoutName = includeWithin.getName();
// Find the layout file.
@@ -1448,7 +1450,8 @@ public class GraphicalEditorPart extends EditorPart
// Get the name of the layout actually being edited, without the extension
// as it's what IXmlPullParser.getParser(String) will receive.
String queryLayoutName = getLayoutResourceName();
- topParser = new ContextPullParser(queryLayoutName, modelParser);
+ mProjectCallback.setLayoutParser(queryLayoutName, modelParser);
+ topParser = new ContextPullParser(mProjectCallback);
topParser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
topParser.setInput(new FileReader(layoutFile));
} catch (XmlPullParserException e) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
index a043e6d..8b71c5a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
@@ -129,6 +129,10 @@ public class ApiDemosRenderingTest extends SdkTestCase {
return null;
}
+ public ILayoutPullParser getParser(String layoutName) {
+ return null;
+ }
+
public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
ResourceReference itemRef, int fullPosition, int typePosition,
int fullChildPosition, int typeChildPosition,